gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Fix various rename bugs
0 3 0
default
3 files changed with 9 insertions and 11 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -1379,98 +1379,98 @@
1379 1379
      void erase(const Arc&) {}
1380 1380

	
1381 1381
      template <typename _Digraph>
1382 1382
      struct Constraints {
1383 1383
	void constraints() {
1384 1384
          checkConcept<Base, _Digraph>();
1385 1385
	  typename _Digraph::Node node;
1386 1386
	  digraph.erase(node);
1387 1387
	  typename _Digraph::Arc arc;
1388 1388
	  digraph.erase(arc);
1389 1389
	}
1390 1390

	
1391 1391
	_Digraph& digraph;
1392 1392
      };
1393 1393
    };
1394 1394

	
1395 1395
    /// \brief An empty erasable base undirected graph class.
1396 1396
    ///  
1397 1397
    /// This class provides beside the core undirected graph features
1398 1398
    /// core erase functions for the undirceted graph structure. The
1399 1399
    /// main difference between the base and this interface is that
1400 1400
    /// the graph alterations should handled already on this level.
1401 1401
    template <typename _Base = BaseGraphComponent>
1402 1402
    class ErasableGraphComponent : public _Base {
1403 1403
    public:
1404 1404

	
1405 1405
      typedef _Base Base;
1406 1406
      typedef typename Base::Node Node;
1407 1407
      typedef typename Base::Edge Edge;
1408 1408

	
1409 1409
      /// \brief Erase a node from the graph.
1410 1410
      ///
1411 1411
      /// Erase a node from the graph. This function should erase
1412 1412
      /// arcs connecting to the node.
1413 1413
      void erase(const Node&) {}    
1414 1414

	
1415 1415
      /// \brief Erase an arc from the graph.
1416 1416
      ///
1417 1417
      /// Erase an arc from the graph.
1418 1418
      ///
1419 1419
      void erase(const Edge&) {}
1420 1420

	
1421 1421
      template <typename _Graph>
1422 1422
      struct Constraints {
1423 1423
	void constraints() {
1424 1424
          checkConcept<Base, _Graph>();
1425 1425
	  typename _Graph::Node node;
1426 1426
	  graph.erase(node);
1427
	  typename _Graph::Arc arc;
1428
	  graph.erase(arc);
1427
	  typename _Graph::Edge edge;
1428
	  graph.erase(edge);
1429 1429
	}
1430 1430

	
1431 1431
	_Graph& graph;
1432 1432
      };
1433 1433
    };
1434 1434

	
1435 1435
    /// \brief An empty clearable base digraph class.
1436 1436
    ///
1437 1437
    /// This class provides beside the core digraph features core clear
1438 1438
    /// functions for the digraph structure. The main difference between
1439 1439
    /// the base and this interface is that the digraph alterations
1440 1440
    /// should handled already on this level.
1441 1441
    template <typename _Base = BaseDigraphComponent>
1442 1442
    class ClearableDigraphComponent : public _Base {
1443 1443
    public:
1444 1444

	
1445 1445
      typedef _Base Base;
1446 1446

	
1447 1447
      /// \brief Erase all nodes and arcs from the digraph.
1448 1448
      ///
1449 1449
      /// Erase all nodes and arcs from the digraph.
1450 1450
      ///
1451 1451
      void clear() {}    
1452 1452

	
1453 1453
      template <typename _Digraph>
1454 1454
      struct Constraints {
1455 1455
	void constraints() {
1456 1456
          checkConcept<Base, _Digraph>();
1457 1457
	  digraph.clear();
1458 1458
	}
1459 1459

	
1460 1460
	_Digraph digraph;
1461 1461
      };
1462 1462
    };
1463 1463

	
1464 1464
    /// \brief An empty clearable base undirected graph class.
1465 1465
    ///
1466 1466
    /// This class provides beside the core undirected graph features
1467 1467
    /// core clear functions for the undirected graph structure. The
1468 1468
    /// main difference between the base and this interface is that
1469 1469
    /// the graph alterations should handled already on this level.
1470 1470
    template <typename _Base = BaseGraphComponent>
1471 1471
    class ClearableGraphComponent : public ClearableDigraphComponent<_Base> {
1472 1472
    public:
1473 1473

	
1474 1474
      typedef _Base Base;
1475 1475

	
1476 1476
      template <typename _Graph>
Ignore white space 6 line context
1 1
/* -*- C++ -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library
4 4
 *
5 5
 * Copyright (C) 2003-2008
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_DIJKSTRA_H
20 20
#define LEMON_DIJKSTRA_H
21 21

	
22 22
///\ingroup shortest_path
23 23
///\file
24 24
///\brief Dijkstra algorithm.
25
///
26 25

	
27
#include <lemon/list_digraph.h>
26
#include <lemon/list_graph.h>
28 27
#include <lemon/bin_heap.h>
29 28
#include <lemon/bits/path_dump.h>
30 29
#include <lemon/bits/invalid.h>
31 30
#include <lemon/error.h>
32 31
#include <lemon/maps.h>
33 32

	
34

	
35 33
namespace lemon {
36 34

	
37 35
  /// \brief Default OperationTraits for the Dijkstra algorithm class.
38 36
  ///  
39 37
  /// It defines all computational operations and constants which are
40 38
  /// used in the Dijkstra algorithm.
41 39
  template <typename Value>
42 40
  struct DijkstraDefaultOperationTraits {
43 41
    /// \brief Gives back the zero value of the type.
44 42
    static Value zero() {
45 43
      return static_cast<Value>(0);
46 44
    }
47 45
    /// \brief Gives back the sum of the given two elements.
48 46
    static Value plus(const Value& left, const Value& right) {
49 47
      return left + right;
50 48
    }
51 49
    /// \brief Gives back true only if the first value less than the second.
52 50
    static bool less(const Value& left, const Value& right) {
53 51
      return left < right;
54 52
    }
55 53
  };
56 54

	
57 55
  /// \brief Widest path OperationTraits for the Dijkstra algorithm class.
58 56
  ///  
59 57
  /// It defines all computational operations and constants which are
60 58
  /// used in the Dijkstra algorithm for widest path computation.
61 59
  template <typename Value>
62 60
  struct DijkstraWidestPathOperationTraits {
63 61
    /// \brief Gives back the maximum value of the type.
64 62
    static Value zero() {
65 63
      return std::numeric_limits<Value>::max();
66 64
    }
67 65
    /// \brief Gives back the minimum of the given two elements.
68 66
    static Value plus(const Value& left, const Value& right) {
69 67
      return std::min(left, right);
70 68
    }
71 69
    /// \brief Gives back true only if the first value less than the second.
72 70
    static bool less(const Value& left, const Value& right) {
73 71
      return left < right;
74 72
    }
75 73
  };
76 74
  
77 75
  ///Default traits class of Dijkstra class.
78 76

	
79 77
  ///Default traits class of Dijkstra class.
80 78
  ///\tparam GR Digraph type.
81 79
  ///\tparam LM Type of length map.
82 80
  template<class GR, class LM>
Ignore white space 96 line context
... ...
@@ -357,200 +357,200 @@
357 357
  template <typename _Graph>
358 358
  class ConArcIt : public _Graph::Arc {
359 359
  public:
360 360

	
361 361
    typedef _Graph Graph;
362 362
    typedef typename Graph::Arc Parent;
363 363

	
364 364
    typedef typename Graph::Arc Arc;
365 365
    typedef typename Graph::Node Node;
366 366

	
367 367
    /// \brief Constructor.
368 368
    ///
369 369
    /// Construct a new ConArcIt iterating on the arcs which
370 370
    /// connects the \c u and \c v node.
371 371
    ConArcIt(const Graph& g, Node u, Node v) : _graph(g) {
372 372
      Parent::operator=(findArc(_graph, u, v));
373 373
    }
374 374

	
375 375
    /// \brief Constructor.
376 376
    ///
377 377
    /// Construct a new ConArcIt which continues the iterating from 
378 378
    /// the \c e arc.
379 379
    ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {}
380 380
    
381 381
    /// \brief Increment operator.
382 382
    ///
383 383
    /// It increments the iterator and gives back the next arc.
384 384
    ConArcIt& operator++() {
385 385
      Parent::operator=(findArc(_graph, _graph.source(*this), 
386 386
				_graph.target(*this), *this));
387 387
      return *this;
388 388
    }
389 389
  private:
390 390
    const Graph& _graph;
391 391
  };
392 392

	
393 393
  namespace _graph_utils_bits {
394 394
    
395 395
    template <typename Graph, typename Enable = void>
396 396
    struct FindEdgeSelector {
397 397
      typedef typename Graph::Node Node;
398 398
      typedef typename Graph::Edge Edge;
399 399
      static Edge find(const Graph &g, Node u, Node v, Edge e) {
400 400
        bool b;
401 401
        if (u != v) {
402 402
          if (e == INVALID) {
403 403
            g.firstInc(e, b, u);
404 404
          } else {
405
            b = g.source(e) == u;
405
            b = g.u(e) == u;
406 406
            g.nextInc(e, b);
407 407
          }
408
          while (e != INVALID && (b ? g.target(e) : g.source(e)) != v) {
408
          while (e != INVALID && (b ? g.v(e) : g.u(e)) != v) {
409 409
            g.nextInc(e, b);
410 410
          }
411 411
        } else {
412 412
          if (e == INVALID) {
413 413
            g.firstInc(e, b, u);
414 414
          } else {
415 415
            b = true;
416 416
            g.nextInc(e, b);
417 417
          }
418
          while (e != INVALID && (!b || g.target(e) != v)) {
418
          while (e != INVALID && (!b || g.v(e) != v)) {
419 419
            g.nextInc(e, b);
420 420
          }
421 421
        }
422 422
        return e;
423 423
      }
424 424
    };
425 425

	
426 426
    template <typename Graph>
427 427
    struct FindEdgeSelector<
428 428
      Graph, 
429 429
      typename enable_if<typename Graph::FindEdgeTag, void>::type> 
430 430
    {
431 431
      typedef typename Graph::Node Node;
432 432
      typedef typename Graph::Edge Edge;
433 433
      static Edge find(const Graph &g, Node u, Node v, Edge prev) {
434 434
        return g.findEdge(u, v, prev);
435 435
      }
436 436
    };    
437 437
  }
438 438

	
439 439
  /// \brief Finds an edge between two nodes of a graph.
440 440
  ///
441 441
  /// Finds an edge from node \c u to node \c v in graph \c g.
442 442
  /// If the node \c u and node \c v is equal then each loop edge
443 443
  /// will be enumerated once.
444 444
  ///
445 445
  /// If \c prev is \ref INVALID (this is the default value), then
446 446
  /// it finds the first arc from \c u to \c v. Otherwise it looks for
447 447
  /// the next arc from \c u to \c v after \c prev.
448 448
  /// \return The found arc or \ref INVALID if there is no such an arc.
449 449
  ///
450 450
  /// Thus you can iterate through each arc from \c u to \c v as it follows.
451 451
  ///\code
452 452
  /// for(Edge e = findEdge(g,u,v); e != INVALID; 
453 453
  ///     e = findEdge(g,u,v,e)) {
454 454
  ///   ...
455 455
  /// }
456 456
  ///\endcode
457 457
  ///
458
  ///\sa ConArcIt
458
  ///\sa ConEdgeIt
459 459

	
460 460
  template <typename Graph>
461 461
  inline typename Graph::Edge 
462 462
  findEdge(const Graph &g, typename Graph::Node u, typename Graph::Node v,
463 463
            typename Graph::Edge p = INVALID) {
464 464
    return _graph_utils_bits::FindEdgeSelector<Graph>::find(g, u, v, p);
465 465
  }
466 466

	
467 467
  /// \brief Iterator for iterating on edges connected the same nodes.
468 468
  ///
469 469
  /// Iterator for iterating on edges connected the same nodes. It is 
470 470
  /// higher level interface for the findEdge() function. You can
471 471
  /// use it the following way:
472 472
  ///\code
473 473
  /// for (ConEdgeIt<Graph> it(g, src, trg); it != INVALID; ++it) {
474 474
  ///   ...
475 475
  /// }
476 476
  ///\endcode
477 477
  ///
478 478
  ///\sa findEdge()
479 479
  template <typename _Graph>
480 480
  class ConEdgeIt : public _Graph::Edge {
481 481
  public:
482 482

	
483 483
    typedef _Graph Graph;
484 484
    typedef typename Graph::Edge Parent;
485 485

	
486 486
    typedef typename Graph::Edge Edge;
487 487
    typedef typename Graph::Node Node;
488 488

	
489 489
    /// \brief Constructor.
490 490
    ///
491 491
    /// Construct a new ConEdgeIt iterating on the edges which
492 492
    /// connects the \c u and \c v node.
493 493
    ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g) {
494 494
      Parent::operator=(findEdge(_graph, u, v));
495 495
    }
496 496

	
497 497
    /// \brief Constructor.
498 498
    ///
499 499
    /// Construct a new ConEdgeIt which continues the iterating from 
500 500
    /// the \c e edge.
501 501
    ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {}
502 502
    
503 503
    /// \brief Increment operator.
504 504
    ///
505 505
    /// It increments the iterator and gives back the next edge.
506 506
    ConEdgeIt& operator++() {
507
      Parent::operator=(findEdge(_graph, _graph.source(*this), 
508
				 _graph.target(*this), *this));
507
      Parent::operator=(findEdge(_graph, _graph.u(*this), 
508
				 _graph.v(*this), *this));
509 509
      return *this;
510 510
    }
511 511
  private:
512 512
    const Graph& _graph;
513 513
  };
514 514

	
515 515
  namespace _graph_utils_bits {
516 516

	
517 517
    template <typename Digraph, typename Item, typename RefMap>
518 518
    class MapCopyBase {
519 519
    public:
520 520
      virtual void copy(const Digraph& from, const RefMap& refMap) = 0;
521 521
      
522 522
      virtual ~MapCopyBase() {}
523 523
    };
524 524

	
525 525
    template <typename Digraph, typename Item, typename RefMap, 
526 526
              typename ToMap, typename FromMap>
527 527
    class MapCopy : public MapCopyBase<Digraph, Item, RefMap> {
528 528
    public:
529 529

	
530 530
      MapCopy(ToMap& tmap, const FromMap& map) 
531 531
        : _tmap(tmap), _map(map) {}
532 532
      
533 533
      virtual void copy(const Digraph& digraph, const RefMap& refMap) {
534 534
        typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
535 535
        for (ItemIt it(digraph); it != INVALID; ++it) {
536 536
          _tmap.set(refMap[it], _map[it]);
537 537
        }
538 538
      }
539 539

	
540 540
    private:
541 541
      ToMap& _tmap;
542 542
      const FromMap& _map;
543 543
    };
544 544

	
545 545
    template <typename Digraph, typename Item, typename RefMap, typename It>
546 546
    class ItemCopy : public MapCopyBase<Digraph, Item, RefMap> {
547 547
    public:
548 548

	
549 549
      ItemCopy(It& it, const Item& item) : _it(it), _item(item) {}
550 550
      
551 551
      virtual void copy(const Digraph&, const RefMap& refMap) {
552 552
        _it = refMap[_item];
553 553
      }
554 554

	
555 555
    private:
556 556
      It& _it;
0 comments (0 inline)