Many of the old stuffs has been finally removed.
2 #ifndef HUGO_SUURBALLE_H
3 #define HUGO_SUURBALLE_H
7 #include <graph_wrapper.h>
11 ///\brief Implementation of Suurballe's algorithm
13 /// The class \ref hugo::Suurballe "Suurballe" implements
14 /// Suurballe's algorithm which seeks for k edge-disjoint paths
15 /// from a given source node to a given target node in an
16 /// edge-weighted directed graph having minimal total cost.
21 template <typename Graph, typename T,
22 typename LengthMap=typename Graph::EdgeMap<T> >
29 typedef int ValueType;
30 int operator[](typename Graph::Edge e) const {
35 // template <typename Graph, typename T>
37 typedef typename Graph::EdgeMap<T> EdgeMap;
38 typedef typename Graph::NodeMap<T> NodeMap;
43 typedef typename EdgeMap::KeyType KeyType;
44 typedef typename EdgeMap::ValueType ValueType;
46 double operator[](typename Graph::EdgeIt e) const {
47 return 10;//ol.get(e)-pot.get(v)-pot.get(u);
50 ModLengthMap(const EdgeMap &o,
57 typedef typename Graph::Node Node;
58 typedef typename Graph::NodeIt NodeIt;
59 typedef typename Graph::Edge Edge;
60 typedef typename Graph::OutEdgeIt OutEdgeIt;
61 typedef ResGraphWrapper< Graph,T,typename Graph::EdgeMap<int>, ConstMap > ResGraphType;
64 const LengthMap& length;
69 typename Graph::EdgeMap<int> reversed;
70 typename Graph::NodeMap<T> dijkstra_dist;
75 Suurballe(Graph& _G, LengthMap& _length) : G(_G),
76 length(_length), reversed(_G), dijkstra_dist(_G){ }
78 ///Runs Suurballe's algorithm
79 ///Returns true iff there are k edge-disjoint paths from s to t
80 bool run(Node s, Node t, int k) {
82 LengthMap mod_length_c = length;
84 //ResGraphWrapper< Graph,T,typename Graph::EdgeMap<int>, ConstMap>
85 ResGraphType res_graph(G, reversed, const1map);
86 //ModLengthMap modified_length(length, dijkstra_dist);
87 //Dijkstra<ResGraphType, ModLengthMap> dijkstra(res_graph, modified_length);
88 //ResGraphWrapper< Graph,T,typename Graph::EdgeMap<int>, ConstMap>
89 Dijkstra<ResGraphType, LengthMap> dijkstra(res_graph, mod_length_c);
91 for (int i=0; i<k; ++i){
93 if (!dijkstra.reached(t)){
94 //There is no k path from s to t
98 //We have to copy the potential
99 typename ResGraphType::EdgeIt e;
100 for ( res_graph.first(e) ; res_graph.valid(e) ; res_graph.next(e) ) {
101 //dijkstra_dist[e] = dijkstra.distMap()[e];
102 mod_length_c[Edge(e)] = mod_length_c[Edge(e)] -
103 dijkstra.distMap()[res_graph.head(e)] +
104 dijkstra.distMap()[res_graph.tail(e)];
108 //Reversing the sortest path
113 n=dijkstra.predNode(n);
114 reversed[e] = 1-reversed[e];
133 #endif //HUGO_SUURBALLE_H