Changeset 1159:7fdaa05a69a1 in lemon for lemon/bits/edge_set_extender.h
 Timestamp:
 09/13/12 11:56:19 (12 years ago)
 Branch:
 default
 Children:
 1160:00f8d9f9920d, 1401:cd72eae05bdf
 Parents:
 1153:4bb9e72e1a41 (diff), 1157:761fe0846f49 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.  Phase:
 public
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

lemon/bits/edge_set_extender.h
r1107 r1159 524 524 // Returns the base node of the iterator 525 525 Node baseNode(const IncEdgeIt &e) const { 526 return e.direction ? u(e) :v(e);526 return e.direction ? this>u(e) : this>v(e); 527 527 } 528 528 // Running node of the iterator … … 530 530 // Returns the running node of the iterator 531 531 Node runningNode(const IncEdgeIt &e) const { 532 return e.direction ? v(e) :u(e);532 return e.direction ? this>v(e) : this>u(e); 533 533 } 534 534 
lemon/bits/edge_set_extender.h
r1157 r1159 1 /* * C++*1 /* * mode: C++; indenttabsmode: nil; * 2 2 * 3 * This file is a part of LEMON, a generic C++ optimization library 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 200320 085 * Copyright (C) 20032010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 64 64 Node oppositeNode(const Node &n, const Arc &e) const { 65 65 if (n == Parent::source(e)) 66 66 return Parent::target(e); 67 67 else if(n==Parent::target(e)) 68 68 return Parent::source(e); 69 69 else 70 70 return INVALID; 71 71 } 72 72 … … 92 92 // Iterable extensions 93 93 94 class NodeIt : public Node { 94 class NodeIt : public Node { 95 95 const Digraph* digraph; 96 96 public: … … 101 101 102 102 explicit NodeIt(const Digraph& _graph) : digraph(&_graph) { 103 104 } 105 106 NodeIt(const Digraph& _graph, const Node& node) 107 108 109 NodeIt& operator++() { 110 111 return *this; 112 } 113 114 }; 115 116 117 class ArcIt : public Arc { 103 _graph.first(static_cast<Node&>(*this)); 104 } 105 106 NodeIt(const Digraph& _graph, const Node& node) 107 : Node(node), digraph(&_graph) {} 108 109 NodeIt& operator++() { 110 digraph>next(*this); 111 return *this; 112 } 113 114 }; 115 116 117 class ArcIt : public Arc { 118 118 const Digraph* digraph; 119 119 public: … … 124 124 125 125 explicit ArcIt(const Digraph& _graph) : digraph(&_graph) { 126 127 } 128 129 ArcIt(const Digraph& _graph, const Arc& e) : 130 131 132 ArcIt& operator++() { 133 134 return *this; 135 } 136 137 }; 138 139 140 class OutArcIt : public Arc { 126 _graph.first(static_cast<Arc&>(*this)); 127 } 128 129 ArcIt(const Digraph& _graph, const Arc& e) : 130 Arc(e), digraph(&_graph) { } 131 132 ArcIt& operator++() { 133 digraph>next(*this); 134 return *this; 135 } 136 137 }; 138 139 140 class OutArcIt : public Arc { 141 141 const Digraph* digraph; 142 142 public: … … 146 146 OutArcIt(Invalid i) : Arc(i) { } 147 147 148 OutArcIt(const Digraph& _graph, const Node& node) 149 150 151 } 152 153 OutArcIt(const Digraph& _graph, const Arc& arc) 154 155 156 OutArcIt& operator++() { 157 158 return *this; 159 } 160 161 }; 162 163 164 class InArcIt : public Arc { 148 OutArcIt(const Digraph& _graph, const Node& node) 149 : digraph(&_graph) { 150 _graph.firstOut(*this, node); 151 } 152 153 OutArcIt(const Digraph& _graph, const Arc& arc) 154 : Arc(arc), digraph(&_graph) {} 155 156 OutArcIt& operator++() { 157 digraph>nextOut(*this); 158 return *this; 159 } 160 161 }; 162 163 164 class InArcIt : public Arc { 165 165 const Digraph* digraph; 166 166 public: … … 170 170 InArcIt(Invalid i) : Arc(i) { } 171 171 172 InArcIt(const Digraph& _graph, const Node& node) 173 174 175 } 176 177 InArcIt(const Digraph& _graph, const Arc& arc) : 178 179 180 InArcIt& operator++() { 181 182 return *this; 172 InArcIt(const Digraph& _graph, const Node& node) 173 : digraph(&_graph) { 174 _graph.firstIn(*this, node); 175 } 176 177 InArcIt(const Digraph& _graph, const Arc& arc) : 178 Arc(arc), digraph(&_graph) {} 179 180 InArcIt& operator++() { 181 digraph>nextIn(*this); 182 return *this; 183 183 } 184 184 … … 216 216 217 217 // Mappable extension 218 218 219 219 template <typename _Value> 220 class ArcMap 220 class ArcMap 221 221 : public MapExtender<DefaultMap<Digraph, Arc, _Value> > { 222 222 typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent; 223 223 224 224 public: 225 explicit ArcMap(const Digraph& _g) 226 227 ArcMap(const Digraph& _g, const _Value& _v) 228 225 explicit ArcMap(const Digraph& _g) 226 : Parent(_g) {} 227 ArcMap(const Digraph& _g, const _Value& _v) 228 : Parent(_g, _v) {} 229 229 230 230 ArcMap& operator=(const ArcMap& cmap) { 231 231 return operator=<ArcMap>(cmap); 232 232 } 233 233 … … 235 235 ArcMap& operator=(const CMap& cmap) { 236 236 Parent::operator=(cmap); 237 237 return *this; 238 238 } 239 239 … … 248 248 return arc; 249 249 } 250 250 251 251 void clear() { 252 252 notifier(Arc()).clear(); … … 313 313 Node oppositeNode(const Node &n, const Edge &e) const { 314 314 if( n == Parent::u(e)) 315 315 return Parent::v(e); 316 316 else if( n == Parent::v(e)) 317 317 return Parent::u(e); 318 318 else 319 319 return INVALID; 320 320 } 321 321 … … 341 341 342 342 using Parent::notifier; 343 343 344 344 ArcNotifier& notifier(Arc) const { 345 345 return arc_notifier; … … 351 351 352 352 353 class NodeIt : public Node { 353 class NodeIt : public Node { 354 354 const Graph* graph; 355 355 public: … … 360 360 361 361 explicit NodeIt(const Graph& _graph) : graph(&_graph) { 362 363 } 364 365 NodeIt(const Graph& _graph, const Node& node) 366 367 368 NodeIt& operator++() { 369 370 return *this; 371 } 372 373 }; 374 375 376 class ArcIt : public Arc { 362 _graph.first(static_cast<Node&>(*this)); 363 } 364 365 NodeIt(const Graph& _graph, const Node& node) 366 : Node(node), graph(&_graph) {} 367 368 NodeIt& operator++() { 369 graph>next(*this); 370 return *this; 371 } 372 373 }; 374 375 376 class ArcIt : public Arc { 377 377 const Graph* graph; 378 378 public: … … 383 383 384 384 explicit ArcIt(const Graph& _graph) : graph(&_graph) { 385 386 } 387 388 ArcIt(const Graph& _graph, const Arc& e) : 389 390 391 ArcIt& operator++() { 392 393 return *this; 394 } 395 396 }; 397 398 399 class OutArcIt : public Arc { 385 _graph.first(static_cast<Arc&>(*this)); 386 } 387 388 ArcIt(const Graph& _graph, const Arc& e) : 389 Arc(e), graph(&_graph) { } 390 391 ArcIt& operator++() { 392 graph>next(*this); 393 return *this; 394 } 395 396 }; 397 398 399 class OutArcIt : public Arc { 400 400 const Graph* graph; 401 401 public: … … 405 405 OutArcIt(Invalid i) : Arc(i) { } 406 406 407 OutArcIt(const Graph& _graph, const Node& node) 408 409 410 } 411 412 OutArcIt(const Graph& _graph, const Arc& arc) 413 414 415 OutArcIt& operator++() { 416 417 return *this; 418 } 419 420 }; 421 422 423 class InArcIt : public Arc { 407 OutArcIt(const Graph& _graph, const Node& node) 408 : graph(&_graph) { 409 _graph.firstOut(*this, node); 410 } 411 412 OutArcIt(const Graph& _graph, const Arc& arc) 413 : Arc(arc), graph(&_graph) {} 414 415 OutArcIt& operator++() { 416 graph>nextOut(*this); 417 return *this; 418 } 419 420 }; 421 422 423 class InArcIt : public Arc { 424 424 const Graph* graph; 425 425 public: … … 429 429 InArcIt(Invalid i) : Arc(i) { } 430 430 431 InArcIt(const Graph& _graph, const Node& node) 432 433 434 } 435 436 InArcIt(const Graph& _graph, const Arc& arc) : 437 438 439 InArcIt& operator++() { 440 441 return *this; 442 } 443 444 }; 445 446 447 class EdgeIt : public Parent::Edge { 431 InArcIt(const Graph& _graph, const Node& node) 432 : graph(&_graph) { 433 _graph.firstIn(*this, node); 434 } 435 436 InArcIt(const Graph& _graph, const Arc& arc) : 437 Arc(arc), graph(&_graph) {} 438 439 InArcIt& operator++() { 440 graph>nextIn(*this); 441 return *this; 442 } 443 444 }; 445 446 447 class EdgeIt : public Parent::Edge { 448 448 const Graph* graph; 449 449 public: … … 454 454 455 455 explicit EdgeIt(const Graph& _graph) : graph(&_graph) { 456 457 } 458 459 EdgeIt(const Graph& _graph, const Edge& e) : 460 461 462 EdgeIt& operator++() { 463 464 return *this; 456 _graph.first(static_cast<Edge&>(*this)); 457 } 458 459 EdgeIt(const Graph& _graph, const Edge& e) : 460 Edge(e), graph(&_graph) { } 461 462 EdgeIt& operator++() { 463 graph>next(*this); 464 return *this; 465 465 } 466 466 … … 478 478 479 479 IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) { 480 480 _graph.firstInc(*this, direction, n); 481 481 } 482 482 483 483 IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n) 484 485 484 : graph(&_graph), Edge(ue) { 485 direction = (_graph.source(ue) == n); 486 486 } 487 487 488 488 IncEdgeIt& operator++() { 489 490 return *this; 489 graph>nextInc(*this, direction); 490 return *this; 491 491 } 492 492 }; … … 535 535 536 536 template <typename _Value> 537 class ArcMap 537 class ArcMap 538 538 : public MapExtender<DefaultMap<Graph, Arc, _Value> > { 539 539 typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent; 540 540 541 541 public: 542 explicit ArcMap(const Graph& _g) 543 544 ArcMap(const Graph& _g, const _Value& _v) 545 542 explicit ArcMap(const Graph& _g) 543 : Parent(_g) {} 544 ArcMap(const Graph& _g, const _Value& _v) 545 : Parent(_g, _v) {} 546 546 547 547 ArcMap& operator=(const ArcMap& cmap) { 548 548 return operator=<ArcMap>(cmap); 549 549 } 550 550 … … 552 552 ArcMap& operator=(const CMap& cmap) { 553 553 Parent::operator=(cmap); 554 554 return *this; 555 555 } 556 556 … … 559 559 560 560 template <typename _Value> 561 class EdgeMap 561 class EdgeMap 562 562 : public MapExtender<DefaultMap<Graph, Edge, _Value> > { 563 563 typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent; 564 564 565 565 public: 566 explicit EdgeMap(const Graph& _g) 567 568 569 EdgeMap(const Graph& _g, const _Value& _v) 570 566 explicit EdgeMap(const Graph& _g) 567 : Parent(_g) {} 568 569 EdgeMap(const Graph& _g, const _Value& _v) 570 : Parent(_g, _v) {} 571 571 572 572 EdgeMap& operator=(const EdgeMap& cmap) { 573 573 return operator=<EdgeMap>(cmap); 574 574 } 575 575 … … 577 577 EdgeMap& operator=(const CMap& cmap) { 578 578 Parent::operator=(cmap); 579 579 return *this; 580 580 } 581 581 … … 594 594 return edge; 595 595 } 596 596 597 597 void clear() { 598 598 notifier(Arc()).clear(); … … 620 620 arc_notifier.clear(); 621 621 } 622 622 623 623 }; 624 624
Note: See TracChangeset
for help on using the changeset viewer.