# HG changeset patch
# User Gabor Gevay <ggab90@gmail.com>
# Date 1428763765 -7200
# Sat Apr 11 16:49:25 2015 +0200
# Node ID 72900babc6c2f320c386d3bcb5d9c1d34521cdc6
# Parent d9521d1a0c08a1ba16af15be9307300c6a9693cc
STL style iterators for the adaptors.
diff -r d9521d1a0c08 -r 72900babc6c2 contrib/stlit_test/stlit_test.cc
|
a
|
b
|
|
| 14 | 14 | #include <lemon/maps.h> |
| 15 | 15 | //#include <lemon/matching.h> |
| 16 | 16 | #include <lemon/glpk.h> |
| | 17 | #include <lemon/adaptors.h> |
| 17 | 18 | |
| 18 | 19 | |
| 19 | 20 | using namespace std; |
| … |
… |
|
| 69 | 70 | for(auto u: g.nodes()) |
| 70 | 71 | cout<<g.id(u)<<endl; |
| 71 | 72 | |
| | 73 | |
| 72 | 74 | /*//Test postincrement |
| 73 | 75 | for(auto it=g.nodes().begin(); it!=g.nodes().end(); it++) { |
| 74 | 76 | auto u=*it; |
| … |
… |
|
| 90 | 92 | |
| 91 | 93 | cout<<endl; |
| 92 | 94 | |
| | 95 | ReverseDigraph<ListDigraph> gr(g); |
| | 96 | for(auto u: gr.nodes()) { |
| | 97 | //cout<<":"<<g.id(u)<<endl; |
| | 98 | for(auto v: gr.outArcs(u)) |
| | 99 | cout<<g.id(u)<<":"<<g.id(v)<<endl; |
| | 100 | } |
| | 101 | cout<<endl; |
| | 102 | |
| | 103 | Undirector<ListDigraph> gu(g); |
| | 104 | for(auto u: gu.nodes()) { |
| | 105 | //cout<<":"<<g.id(u)<<endl; |
| | 106 | for(auto v: gu.incEdges(u)) |
| | 107 | cout<<g.id(u)<<"::"<<g.id(v)<<endl; |
| | 108 | } |
| | 109 | cout<<endl; |
| | 110 | |
| 93 | 111 | |
| 94 | 112 | LemonItWrapper<ListDigraph::NodeIt> st1 = g.nodes().begin(); |
| 95 | 113 | //auto st1 = g.nodes().begin(); |
diff -r d9521d1a0c08 -r 72900babc6c2 lemon/bits/graph_adaptor_extender.h
|
a
|
b
|
|
| 85 | 85 | |
| 86 | 86 | }; |
| 87 | 87 | |
| | 88 | LemonRangeWrapper1<NodeIt, Adaptor> nodes() { |
| | 89 | return LemonRangeWrapper1<NodeIt, Adaptor>(*this); |
| | 90 | } |
| 88 | 91 | |
| 89 | 92 | class ArcIt : public Arc { |
| 90 | 93 | const Adaptor* _adaptor; |
| … |
… |
|
| 108 | 111 | |
| 109 | 112 | }; |
| 110 | 113 | |
| | 114 | LemonRangeWrapper1<ArcIt, Adaptor> arcs() { |
| | 115 | return LemonRangeWrapper1<ArcIt, Adaptor>(*this); |
| | 116 | } |
| | 117 | |
| 111 | 118 | |
| 112 | 119 | class OutArcIt : public Arc { |
| 113 | 120 | const Adaptor* _adaptor; |
| … |
… |
|
| 132 | 139 | |
| 133 | 140 | }; |
| 134 | 141 | |
| | 142 | LemonRangeWrapper2<OutArcIt, Adaptor, Node> outArcs(const Node& u) const { |
| | 143 | return LemonRangeWrapper2<OutArcIt, Adaptor, Node>(*this, u); |
| | 144 | } |
| | 145 | |
| 135 | 146 | |
| 136 | 147 | class InArcIt : public Arc { |
| 137 | 148 | const Adaptor* _adaptor; |
| … |
… |
|
| 156 | 167 | |
| 157 | 168 | }; |
| 158 | 169 | |
| | 170 | LemonRangeWrapper2<InArcIt, Adaptor, Node> inArcs(const Node& u) const { |
| | 171 | return LemonRangeWrapper2<InArcIt, Adaptor, Node>(*this, u); |
| | 172 | } |
| | 173 | |
| 159 | 174 | Node baseNode(const OutArcIt &e) const { |
| 160 | 175 | return Parent::source(e); |
| 161 | 176 | } |
| … |
… |
|
| 254 | 269 | |
| 255 | 270 | }; |
| 256 | 271 | |
| | 272 | LemonRangeWrapper1<NodeIt, Adaptor> nodes() { |
| | 273 | return LemonRangeWrapper1<NodeIt, Adaptor>(*this); |
| | 274 | } |
| | 275 | |
| 257 | 276 | |
| 258 | 277 | class ArcIt : public Arc { |
| 259 | 278 | const Adaptor* _adaptor; |
| … |
… |
|
| 277 | 296 | |
| 278 | 297 | }; |
| 279 | 298 | |
| | 299 | LemonRangeWrapper1<ArcIt, Adaptor> arcs() { |
| | 300 | return LemonRangeWrapper1<ArcIt, Adaptor>(*this); |
| | 301 | } |
| | 302 | |
| 280 | 303 | |
| 281 | 304 | class OutArcIt : public Arc { |
| 282 | 305 | const Adaptor* _adaptor; |
| … |
… |
|
| 301 | 324 | |
| 302 | 325 | }; |
| 303 | 326 | |
| | 327 | LemonRangeWrapper2<OutArcIt, Adaptor, Node> outArcs(const Node& u) const { |
| | 328 | return LemonRangeWrapper2<OutArcIt, Adaptor, Node>(*this, u); |
| | 329 | } |
| | 330 | |
| 304 | 331 | |
| 305 | 332 | class InArcIt : public Arc { |
| 306 | 333 | const Adaptor* _adaptor; |
| … |
… |
|
| 325 | 352 | |
| 326 | 353 | }; |
| 327 | 354 | |
| | 355 | LemonRangeWrapper2<InArcIt, Adaptor, Node> inArcs(const Node& u) const { |
| | 356 | return LemonRangeWrapper2<InArcIt, Adaptor, Node>(*this, u); |
| | 357 | } |
| | 358 | |
| 328 | 359 | class EdgeIt : public Parent::Edge { |
| 329 | 360 | const Adaptor* _adaptor; |
| 330 | 361 | public: |
| … |
… |
|
| 347 | 378 | |
| 348 | 379 | }; |
| 349 | 380 | |
| | 381 | LemonRangeWrapper1<EdgeIt, Adaptor> edges() { |
| | 382 | return LemonRangeWrapper1<EdgeIt, Adaptor>(*this); |
| | 383 | } |
| | 384 | |
| | 385 | |
| 350 | 386 | class IncEdgeIt : public Edge { |
| 351 | 387 | friend class GraphAdaptorExtender; |
| 352 | 388 | const Adaptor* _adaptor; |
| … |
… |
|
| 372 | 408 | } |
| 373 | 409 | }; |
| 374 | 410 | |
| | 411 | LemonRangeWrapper2<IncEdgeIt, Adaptor, Node> incEdges(const Node& u) const { |
| | 412 | return LemonRangeWrapper2<IncEdgeIt, Adaptor, Node>(*this, u); |
| | 413 | } |
| | 414 | |
| | 415 | |
| 375 | 416 | Node baseNode(const OutArcIt &a) const { |
| 376 | 417 | return Parent::source(a); |
| 377 | 418 | } |