# HG changeset patch
# User Gabor Gevay <ggab90@gmail.com>
# Date 1390056610 -3600
# Sat Jan 18 15:50:10 2014 +0100
# Node ID 79271f3a7b98e3797fdd852d73f9637a01b4092c
# Parent fe4d0623659c53def73f443f989632de7ae96520
STL style iterator for Bellman-Ford ActiveIt.
diff --git a/contrib/stlit_test/stlit_test.cc b/contrib/stlit_test/stlit_test.cc
|
a
|
b
|
|
| 8 | 8 | #include <lemon/smart_graph.h> |
| 9 | 9 | #include <lemon/path.h> |
| 10 | 10 | #include <lemon/bfs.h> |
| | 11 | #include <lemon/bellman_ford.h> |
| | 12 | #include <lemon/euler.h> |
| 11 | 13 | |
| 12 | 14 | |
| 13 | 15 | using namespace std; |
| … |
… |
|
| 141 | 143 | cout<<g4.id(g4.target(a))<<endl; |
| 142 | 144 | } |
| 143 | 145 | |
| | 146 | // cout<<endl; |
| | 147 | |
| | 148 | // { |
| | 149 | // SmartDigraph g; |
| | 150 | // auto u=g.addNode(), v=g.addNode(); |
| | 151 | // g.addArc(u,v); g.addArc(u,v); |
| | 152 | // int c=0; |
| | 153 | // for(auto a: conArcs(g,u,v)) |
| | 154 | // //for(ConArcIt<SmartDigraph> a(g,u,v); a!=INVALID; ++a) |
| | 155 | // c++; |
| | 156 | // cout<<c<<endl; |
| | 157 | // } |
| | 158 | |
| | 159 | // { |
| | 160 | // SmartDigraph g; |
| | 161 | // auto u=g.addNode(), v=g.addNode(); |
| | 162 | // g.addArc(u,v); g.addArc(v,u); |
| | 163 | // //for(auto a: diEulerTour(g,u)) |
| | 164 | // //for(auto a=diEulerTour(g,u).begin(); a!=INVALID; ++a) |
| | 165 | // // cout<<g.id(g.target(a))<<endl; |
| | 166 | // auto t = diEulerTour(g,u); |
| | 167 | // auto a = t.begin(); |
| | 168 | // } |
| | 169 | |
| | 170 | |
| | 171 | |
| 144 | 172 | return 0; |
| 145 | 173 | } |
| | 174 | |
| | 175 | |
| | 176 | void checkBellmanFordCompile() |
| | 177 | { |
| | 178 | typedef int Value; |
| | 179 | typedef concepts::Digraph Digraph; |
| | 180 | typedef concepts::ReadMap<Digraph::Arc,Value> LengthMap; |
| | 181 | typedef BellmanFord<Digraph, LengthMap> BF; |
| | 182 | |
| | 183 | Digraph gr; |
| | 184 | LengthMap length; |
| | 185 | |
| | 186 | { |
| | 187 | BF bf_test(gr,length); |
| | 188 | const BF& const_bf_test = bf_test; |
| | 189 | |
| | 190 | for (BF::ActiveIt it(const_bf_test); it != INVALID; ++it) {} |
| | 191 | for (BF::ActiveIt it(bf_test); it != INVALID; ++it) {} |
| | 192 | } |
| | 193 | } |
diff --git a/lemon/bellman_ford.h b/lemon/bellman_ford.h
|
a
|
b
|
|
| 690 | 690 | int _index; |
| 691 | 691 | }; |
| 692 | 692 | |
| | 693 | /// \brief Gets the collection of the active nodes. |
| | 694 | /// |
| | 695 | /// This function can be used for iterating on the active nodes of the |
| | 696 | /// Bellman-Ford algorithm after the last phase. |
| | 697 | /// These nodes should be checked in the next phase to |
| | 698 | /// find augmenting arcs outgoing from them. |
| | 699 | /// It returns a wrapped ActiveIt, which looks |
| | 700 | /// like an STL container (by having begin() and end()) |
| | 701 | /// which you can use in range-based for loops, stl algorithms, etc. |
| | 702 | LemonRangeWrapper1<ActiveIt, BellmanFord> |
| | 703 | activeNodes(const BellmanFord& algorithm) const { |
| | 704 | return LemonRangeWrapper1<ActiveIt, BellmanFord>(algorithm); |
| | 705 | } |
| | 706 | |
| | 707 | |
| 693 | 708 | /// \name Query Functions |
| 694 | 709 | /// The result of the Bellman-Ford algorithm can be obtained using these |
| 695 | 710 | /// functions.\n |