Changes in / [84:8161012eaa61:83:3654324ec035] in lemon-main
- Location:
- lemon
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/graph_extender.h
r78 r57 21 21 22 22 #include <lemon/bits/invalid.h> 23 #include <lemon/bits/utility.h>24 23 25 24 #include <lemon/bits/map_extender.h> … … 65 64 } 66 65 67 Node oppositeNode(const Node &n ode, const Arc &arc) const {68 if (n ode == Parent::source(arc))69 return Parent::target( arc);70 else if(n ode == Parent::target(arc))71 return Parent::source( arc);66 Node oppositeNode(const Node &n, const Arc &e) const { 67 if (n == Parent::source(e)) 68 return Parent::target(e); 69 else if(n==Parent::target(e)) 70 return Parent::source(e); 72 71 else 73 72 return INVALID; … … 96 95 97 96 class NodeIt : public Node { 98 const Digraph* _digraph;97 const Digraph* digraph; 99 98 public: 100 99 … … 103 102 NodeIt(Invalid i) : Node(i) { } 104 103 105 explicit NodeIt(const Digraph& digraph) : _digraph(&digraph) {106 _digraph ->first(static_cast<Node&>(*this));107 } 108 109 NodeIt(const Digraph& digraph, const Node& node)110 : Node(node), _digraph(&digraph) {}104 explicit NodeIt(const Digraph& _digraph) : digraph(&_digraph) { 105 _digraph.first(static_cast<Node&>(*this)); 106 } 107 108 NodeIt(const Digraph& _digraph, const Node& node) 109 : Node(node), digraph(&_digraph) {} 111 110 112 111 NodeIt& operator++() { 113 _digraph->next(*this);112 digraph->next(*this); 114 113 return *this; 115 114 } … … 119 118 120 119 class ArcIt : public Arc { 121 const Digraph* _digraph;120 const Digraph* digraph; 122 121 public: 123 122 … … 126 125 ArcIt(Invalid i) : Arc(i) { } 127 126 128 explicit ArcIt(const Digraph& digraph) : _digraph(&digraph) {129 _digraph ->first(static_cast<Arc&>(*this));130 } 131 132 ArcIt(const Digraph& digraph, const Arc& arc) :133 Arc( arc), _digraph(&digraph) { }127 explicit ArcIt(const Digraph& _digraph) : digraph(&_digraph) { 128 _digraph.first(static_cast<Arc&>(*this)); 129 } 130 131 ArcIt(const Digraph& _digraph, const Arc& e) : 132 Arc(e), digraph(&_digraph) { } 134 133 135 134 ArcIt& operator++() { 136 _digraph->next(*this);135 digraph->next(*this); 137 136 return *this; 138 137 } … … 142 141 143 142 class OutArcIt : public Arc { 144 const Digraph* _digraph;143 const Digraph* digraph; 145 144 public: 146 145 … … 149 148 OutArcIt(Invalid i) : Arc(i) { } 150 149 151 OutArcIt(const Digraph& digraph, const Node& node)152 : _digraph(&digraph) {153 _digraph ->firstOut(*this, node);154 } 155 156 OutArcIt(const Digraph& digraph, const Arc& arc)157 : Arc(arc), _digraph(&digraph) {}150 OutArcIt(const Digraph& _digraph, const Node& node) 151 : digraph(&_digraph) { 152 _digraph.firstOut(*this, node); 153 } 154 155 OutArcIt(const Digraph& _digraph, const Arc& arc) 156 : Arc(arc), digraph(&_digraph) {} 158 157 159 158 OutArcIt& operator++() { 160 _digraph->nextOut(*this);159 digraph->nextOut(*this); 161 160 return *this; 162 161 } … … 166 165 167 166 class InArcIt : public Arc { 168 const Digraph* _digraph;167 const Digraph* digraph; 169 168 public: 170 169 … … 173 172 InArcIt(Invalid i) : Arc(i) { } 174 173 175 InArcIt(const Digraph& digraph, const Node& node)176 : _digraph(&digraph) {177 _digraph ->firstIn(*this, node);178 } 179 180 InArcIt(const Digraph& digraph, const Arc& arc) :181 Arc(arc), _digraph(&digraph) {}174 InArcIt(const Digraph& _digraph, const Node& node) 175 : digraph(&_digraph) { 176 _digraph.firstIn(*this, node); 177 } 178 179 InArcIt(const Digraph& _digraph, const Arc& arc) : 180 Arc(arc), digraph(&_digraph) {} 182 181 183 182 InArcIt& operator++() { 184 _digraph->nextIn(*this);183 digraph->nextIn(*this); 185 184 return *this; 186 185 } … … 191 190 /// 192 191 /// Returns the base node (i.e. the source in this case) of the iterator 193 Node baseNode(const OutArcIt & arc) const {194 return Parent::source( arc);192 Node baseNode(const OutArcIt &e) const { 193 return Parent::source(e); 195 194 } 196 195 /// \brief Running node of the iterator … … 198 197 /// Returns the running node (i.e. the target in this case) of the 199 198 /// iterator 200 Node runningNode(const OutArcIt & arc) const {201 return Parent::target( arc);199 Node runningNode(const OutArcIt &e) const { 200 return Parent::target(e); 202 201 } 203 202 … … 205 204 /// 206 205 /// Returns the base node (i.e. the target in this case) of the iterator 207 Node baseNode(const InArcIt & arc) const {208 return Parent::target( arc);206 Node baseNode(const InArcIt &e) const { 207 return Parent::target(e); 209 208 } 210 209 /// \brief Running node of the iterator … … 212 211 /// Returns the running node (i.e. the source in this case) of the 213 212 /// iterator 214 Node runningNode(const InArcIt & arc) const {215 return Parent::source( arc);213 Node runningNode(const InArcIt &e) const { 214 return Parent::source(e); 216 215 } 217 216 … … 325 324 }; 326 325 327 /// \ingroup _graphbits326 /// \ingroup graphbits 328 327 /// 329 328 /// \brief Extender for the Graphs … … 333 332 334 333 typedef Base Parent; 335 typedef GraphExtender Graph; 336 337 typedef True UndirectedTag; 334 typedef GraphExtender Digraph; 338 335 339 336 typedef typename Parent::Node Node; … … 376 373 } 377 374 378 Arc oppositeArc(const Arc & arc) const {379 return Parent::direct( arc, !Parent::direction(arc));375 Arc oppositeArc(const Arc &e) const { 376 return Parent::direct(e, !Parent::direction(e)); 380 377 } 381 378 382 379 using Parent::direct; 383 Arc direct(const Edge & edge, const Node &node) const {384 return Parent::direct( edge, Parent::source(edge) == node);380 Arc direct(const Edge &ue, const Node &s) const { 381 return Parent::direct(ue, Parent::source(ue) == s); 385 382 } 386 383 … … 415 412 416 413 class NodeIt : public Node { 417 const Graph* _graph;414 const Digraph* digraph; 418 415 public: 419 416 … … 422 419 NodeIt(Invalid i) : Node(i) { } 423 420 424 explicit NodeIt(const Graph& graph) : _graph(&graph) {425 _ graph->first(static_cast<Node&>(*this));426 } 427 428 NodeIt(const Graph&graph, const Node& node)429 : Node(node), _graph(&graph) {}421 explicit NodeIt(const Digraph& _digraph) : digraph(&_digraph) { 422 _digraph.first(static_cast<Node&>(*this)); 423 } 424 425 NodeIt(const Digraph& _digraph, const Node& node) 426 : Node(node), digraph(&_digraph) {} 430 427 431 428 NodeIt& operator++() { 432 _graph->next(*this);429 digraph->next(*this); 433 430 return *this; 434 431 } … … 438 435 439 436 class ArcIt : public Arc { 440 const Graph* _graph;437 const Digraph* digraph; 441 438 public: 442 439 … … 445 442 ArcIt(Invalid i) : Arc(i) { } 446 443 447 explicit ArcIt(const Graph& graph) : _graph(&graph) {448 _ graph->first(static_cast<Arc&>(*this));449 } 450 451 ArcIt(const Graph& graph, const Arc& arc) :452 Arc( arc), _graph(&graph) { }444 explicit ArcIt(const Digraph& _digraph) : digraph(&_digraph) { 445 _digraph.first(static_cast<Arc&>(*this)); 446 } 447 448 ArcIt(const Digraph& _digraph, const Arc& e) : 449 Arc(e), digraph(&_digraph) { } 453 450 454 451 ArcIt& operator++() { 455 _graph->next(*this);452 digraph->next(*this); 456 453 return *this; 457 454 } … … 461 458 462 459 class OutArcIt : public Arc { 463 const Graph* _graph;460 const Digraph* digraph; 464 461 public: 465 462 … … 468 465 OutArcIt(Invalid i) : Arc(i) { } 469 466 470 OutArcIt(const Graph&graph, const Node& node)471 : _graph(&graph) {472 _ graph->firstOut(*this, node);473 } 474 475 OutArcIt(const Graph&graph, const Arc& arc)476 : Arc(arc), _graph(&graph) {}467 OutArcIt(const Digraph& _digraph, const Node& node) 468 : digraph(&_digraph) { 469 _digraph.firstOut(*this, node); 470 } 471 472 OutArcIt(const Digraph& _digraph, const Arc& arc) 473 : Arc(arc), digraph(&_digraph) {} 477 474 478 475 OutArcIt& operator++() { 479 _graph->nextOut(*this);476 digraph->nextOut(*this); 480 477 return *this; 481 478 } … … 485 482 486 483 class InArcIt : public Arc { 487 const Graph* _graph;484 const Digraph* digraph; 488 485 public: 489 486 … … 492 489 InArcIt(Invalid i) : Arc(i) { } 493 490 494 InArcIt(const Graph&graph, const Node& node)495 : _graph(&graph) {496 _ graph->firstIn(*this, node);497 } 498 499 InArcIt(const Graph&graph, const Arc& arc) :500 Arc(arc), _graph(&graph) {}491 InArcIt(const Digraph& _digraph, const Node& node) 492 : digraph(&_digraph) { 493 _digraph.firstIn(*this, node); 494 } 495 496 InArcIt(const Digraph& _digraph, const Arc& arc) : 497 Arc(arc), digraph(&_digraph) {} 501 498 502 499 InArcIt& operator++() { 503 _graph->nextIn(*this);500 digraph->nextIn(*this); 504 501 return *this; 505 502 } … … 509 506 510 507 class EdgeIt : public Parent::Edge { 511 const Graph* _graph;508 const Digraph* digraph; 512 509 public: 513 510 … … 516 513 EdgeIt(Invalid i) : Edge(i) { } 517 514 518 explicit EdgeIt(const Graph& graph) : _graph(&graph) {519 _ graph->first(static_cast<Edge&>(*this));520 } 521 522 EdgeIt(const Graph& graph, const Edge& edge) :523 Edge(e dge), _graph(&graph) { }515 explicit EdgeIt(const Digraph& _digraph) : digraph(&_digraph) { 516 _digraph.first(static_cast<Edge&>(*this)); 517 } 518 519 EdgeIt(const Digraph& _digraph, const Edge& e) : 520 Edge(e), digraph(&_digraph) { } 524 521 525 522 EdgeIt& operator++() { 526 _graph->next(*this);527 return *this; 528 } 529 530 }; 531 532 class Inc EdgeIt : public Parent::Edge {523 digraph->next(*this); 524 return *this; 525 } 526 527 }; 528 529 class IncArcIt : public Parent::Edge { 533 530 friend class GraphExtender; 534 const Graph* _graph;535 bool _direction;536 public: 537 538 Inc EdgeIt() { }539 540 Inc EdgeIt(Invalid i) : Edge(i), _direction(false) { }541 542 Inc EdgeIt(const Graph& graph, const Node &node) : _graph(&graph) {543 _ graph->firstInc(*this, _direction, node);544 } 545 546 Inc EdgeIt(const Graph& graph, const Edge &edge, const Node &node)547 : _graph(&graph), Edge(edge) {548 _direction = (_graph->source(edge) == node);549 } 550 551 Inc EdgeIt& operator++() {552 _graph->nextInc(*this, _direction);531 const Digraph* digraph; 532 bool direction; 533 public: 534 535 IncArcIt() { } 536 537 IncArcIt(Invalid i) : Edge(i), direction(false) { } 538 539 IncArcIt(const Digraph& _digraph, const Node &n) : digraph(&_digraph) { 540 _digraph.firstInc(*this, direction, n); 541 } 542 543 IncArcIt(const Digraph& _digraph, const Edge &ue, const Node &n) 544 : digraph(&_digraph), Edge(ue) { 545 direction = (_digraph.source(ue) == n); 546 } 547 548 IncArcIt& operator++() { 549 digraph->nextInc(*this, direction); 553 550 return *this; 554 551 } … … 558 555 /// 559 556 /// Returns the base node (ie. the source in this case) of the iterator 560 Node baseNode(const OutArcIt & arc) const {561 return Parent::source(static_cast<const Arc&>( arc));557 Node baseNode(const OutArcIt &e) const { 558 return Parent::source(static_cast<const Arc&>(e)); 562 559 } 563 560 /// \brief Running node of the iterator … … 565 562 /// Returns the running node (ie. the target in this case) of the 566 563 /// iterator 567 Node runningNode(const OutArcIt & arc) const {568 return Parent::target(static_cast<const Arc&>( arc));564 Node runningNode(const OutArcIt &e) const { 565 return Parent::target(static_cast<const Arc&>(e)); 569 566 } 570 567 … … 572 569 /// 573 570 /// Returns the base node (ie. the target in this case) of the iterator 574 Node baseNode(const InArcIt & arc) const {575 return Parent::target(static_cast<const Arc&>( arc));571 Node baseNode(const InArcIt &e) const { 572 return Parent::target(static_cast<const Arc&>(e)); 576 573 } 577 574 /// \brief Running node of the iterator … … 579 576 /// Returns the running node (ie. the source in this case) of the 580 577 /// iterator 581 Node runningNode(const InArcIt & arc) const {582 return Parent::source(static_cast<const Arc&>( arc));578 Node runningNode(const InArcIt &e) const { 579 return Parent::source(static_cast<const Arc&>(e)); 583 580 } 584 581 … … 586 583 /// 587 584 /// Returns the base node of the iterator 588 Node baseNode(const Inc EdgeIt &edge) const {589 return e dge._direction ? source(edge) : target(edge);585 Node baseNode(const IncArcIt &e) const { 586 return e.direction ? source(e) : target(e); 590 587 } 591 588 /// Running node of the iterator 592 589 /// 593 590 /// Returns the running node of the iterator 594 Node runningNode(const Inc EdgeIt &edge) const {595 return e dge._direction ? target(edge) : source(edge);591 Node runningNode(const IncArcIt &e) const { 592 return e.direction ? target(e) : source(e); 596 593 } 597 594 … … 600 597 template <typename _Value> 601 598 class NodeMap 602 : public MapExtender<DefaultMap< Graph, Node, _Value> > {603 public: 604 typedef GraphExtender Graph;605 typedef MapExtender<DefaultMap< Graph, Node, _Value> > Parent;606 607 NodeMap(const Graph&graph)608 : Parent( graph) {}609 NodeMap(const Graph&graph, const _Value& value)610 : Parent( graph, value) {}599 : public MapExtender<DefaultMap<Digraph, Node, _Value> > { 600 public: 601 typedef GraphExtender Digraph; 602 typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent; 603 604 NodeMap(const Digraph& digraph) 605 : Parent(digraph) {} 606 NodeMap(const Digraph& digraph, const _Value& value) 607 : Parent(digraph, value) {} 611 608 612 609 NodeMap& operator=(const NodeMap& cmap) { … … 624 621 template <typename _Value> 625 622 class ArcMap 626 : public MapExtender<DefaultMap< Graph, Arc, _Value> > {627 public: 628 typedef GraphExtender Graph;629 typedef MapExtender<DefaultMap< Graph, Arc, _Value> > Parent;630 631 ArcMap(const Graph&graph)632 : Parent( graph) {}633 ArcMap(const Graph&graph, const _Value& value)634 : Parent( graph, value) {}623 : public MapExtender<DefaultMap<Digraph, Arc, _Value> > { 624 public: 625 typedef GraphExtender Digraph; 626 typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent; 627 628 ArcMap(const Digraph& digraph) 629 : Parent(digraph) {} 630 ArcMap(const Digraph& digraph, const _Value& value) 631 : Parent(digraph, value) {} 635 632 636 633 ArcMap& operator=(const ArcMap& cmap) { … … 648 645 template <typename _Value> 649 646 class EdgeMap 650 : public MapExtender<DefaultMap< Graph, Edge, _Value> > {651 public: 652 typedef GraphExtender Graph;653 typedef MapExtender<DefaultMap< Graph, Edge, _Value> > Parent;654 655 EdgeMap(const Graph&graph)656 : Parent( graph) {}657 658 EdgeMap(const Graph&graph, const _Value& value)659 : Parent( graph, value) {}647 : public MapExtender<DefaultMap<Digraph, Edge, _Value> > { 648 public: 649 typedef GraphExtender Digraph; 650 typedef MapExtender<DefaultMap<Digraph, Edge, _Value> > Parent; 651 652 EdgeMap(const Digraph& digraph) 653 : Parent(digraph) {} 654 655 EdgeMap(const Digraph& digraph, const _Value& value) 656 : Parent(digraph, value) {} 660 657 661 658 EdgeMap& operator=(const EdgeMap& cmap) { … … 696 693 } 697 694 698 template <typename Graph, typename NodeRefMap, typename EdgeRefMap>699 void build(const Graph&graph, NodeRefMap& nodeRef,695 template <typename Digraph, typename NodeRefMap, typename EdgeRefMap> 696 void build(const Digraph& digraph, NodeRefMap& nodeRef, 700 697 EdgeRefMap& edgeRef) { 701 Parent::build( graph, nodeRef, edgeRef);698 Parent::build(digraph, nodeRef, edgeRef); 702 699 notifier(Node()).build(); 703 700 notifier(Edge()).build(); … … 724 721 725 722 void erase(const Edge& edge) { 726 std::vector<Arc> av;727 av.push_back(Parent::direct(edge, true));728 av.push_back(Parent::direct(edge, false));729 notifier(Arc()).erase( av);723 std::vector<Arc> ev; 724 ev.push_back(Parent::direct(edge, true)); 725 ev.push_back(Parent::direct(edge, false)); 726 notifier(Arc()).erase(ev); 730 727 notifier(Edge()).erase(edge); 731 728 Parent::erase(edge); -
lemon/concepts/graph.h
r78 r61 64 64 /// the EdgeMap to map values for the edges. The InArcIt and 65 65 /// OutArcIt iterates on the same edges but with opposite 66 /// direction. The Inc EdgeIt iterates also on the same edges66 /// direction. The IncArcIt iterates also on the same edges 67 67 /// as the OutArcIt and InArcIt but it is not convertible to Arc just 68 68 /// to Edge. … … 271 271 ///\code 272 272 /// int count=0; 273 /// for(Graph::Inc EdgeIt e(g, n); e!=INVALID; ++e) ++count;273 /// for(Graph::IncArcIt e(g, n); e!=INVALID; ++e) ++count; 274 274 ///\endcode 275 class Inc EdgeIt : public Edge {276 public: 277 /// Default constructor 278 279 /// @warning The default constructor sets the iterator 280 /// to an undefined value. 281 Inc EdgeIt() { }282 /// Copy constructor. 283 284 /// Copy constructor. 285 /// 286 Inc EdgeIt(const IncEdgeIt& e) : Edge(e) { }287 /// Initialize the iterator to be invalid. 288 289 /// Initialize the iterator to be invalid. 290 /// 291 Inc EdgeIt(Invalid) { }275 class IncArcIt : public Edge { 276 public: 277 /// Default constructor 278 279 /// @warning The default constructor sets the iterator 280 /// to an undefined value. 281 IncArcIt() { } 282 /// Copy constructor. 283 284 /// Copy constructor. 285 /// 286 IncArcIt(const IncArcIt& e) : Edge(e) { } 287 /// Initialize the iterator to be invalid. 288 289 /// Initialize the iterator to be invalid. 290 /// 291 IncArcIt(Invalid) { } 292 292 /// This constructor sets the iterator to first incident arc. 293 293 294 294 /// This constructor set the iterator to the first incident arc of 295 295 /// the node. 296 Inc EdgeIt(const Graph&, const Node&) { }297 /// Edge -> Inc EdgeIt conversion296 IncArcIt(const Graph&, const Node&) { } 297 /// Edge -> IncArcIt conversion 298 298 299 299 /// Sets the iterator to the value of the trivial iterator \c e. 300 300 /// This feature necessitates that each time we 301 301 /// iterate the arc-set, the iteration order is the same. 302 Inc EdgeIt(const Graph&, const Edge&) { }302 IncArcIt(const Graph&, const Edge&) { } 303 303 /// Next incident arc 304 304 305 305 /// Assign the iterator to the next incident arc 306 306 /// of the corresponding node. 307 Inc EdgeIt& operator++() { return *this; }307 IncArcIt& operator++() { return *this; } 308 308 }; 309 309 … … 721 721 /// 722 722 /// Returns the base node of the iterator 723 Node baseNode(Inc EdgeIt) const {723 Node baseNode(IncArcIt) const { 724 724 return INVALID; 725 725 } … … 728 728 /// 729 729 /// Returns the running node of the iterator 730 Node runningNode(Inc EdgeIt) const {730 Node runningNode(IncArcIt) const { 731 731 return INVALID; 732 732 } -
lemon/concepts/graph_components.h
r78 r57 829 829 /// This iterator goes trough the incident arcs of a certain 830 830 /// node of a graph. 831 typedef GraphIncIt<Graph, Edge, Node, 'u'> Inc EdgeIt;831 typedef GraphIncIt<Graph, Edge, Node, 'u'> IncArcIt; 832 832 /// \brief The base node of the iterator. 833 833 /// 834 834 /// Gives back the base node of the iterator. 835 Node baseNode(const Inc EdgeIt&) const { return INVALID; }835 Node baseNode(const IncArcIt&) const { return INVALID; } 836 836 837 837 /// \brief The running node of the iterator. 838 838 /// 839 839 /// Gives back the running node of the iterator. 840 Node runningNode(const Inc EdgeIt&) const { return INVALID; }840 Node runningNode(const IncArcIt&) const { return INVALID; } 841 841 842 842 /// @} … … 866 866 typename _Graph::EdgeIt >(); 867 867 checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 868 typename _Graph::Node, 'u'>, typename _Graph::Inc EdgeIt>();868 typename _Graph::Node, 'u'>, typename _Graph::IncArcIt>(); 869 869 870 870 typename _Graph::Node n; 871 typename _Graph::Inc EdgeIt ueit(INVALID);871 typename _Graph::IncArcIt ueit(INVALID); 872 872 n = graph.baseNode(ueit); 873 873 n = graph.runningNode(ueit);
Note: See TracChangeset
for help on using the changeset viewer.