diff -r def920ddaba7 -r 7550fed0cd91 src/work/athos/mincostflows.h --- a/src/work/athos/mincostflows.h Tue May 04 14:06:00 2004 +0000 +++ b/src/work/athos/mincostflows.h Tue May 04 14:54:21 2004 +0000 @@ -38,6 +38,8 @@ class MinCostFlows { typedef typename LengthMap::ValueType Length; + + typedef typename LengthMap::ValueType Length; typedef typename Graph::Node Node; typedef typename Graph::NodeIt NodeIt; @@ -45,14 +47,14 @@ typedef typename Graph::OutEdgeIt OutEdgeIt; typedef typename Graph::template EdgeMap EdgeIntMap; - typedef ConstMap ConstMap; + // typedef ConstMap ConstMap; - typedef ResGraphWrapper ResGraphType; + typedef ResGraphWrapper ResGraphType; class ModLengthMap { typedef typename ResGraphType::template NodeMap NodeMap; const ResGraphType& G; - const EdgeIntMap& rev; + // const EdgeIntMap& rev; const LengthMap &ol; const NodeMap &pot; public : @@ -60,29 +62,30 @@ typedef typename LengthMap::ValueType ValueType; ValueType operator[](typename ResGraphType::Edge e) const { - //if ( (1-2*rev[e])*ol[e]-(pot[G.head(e)]-pot[G.tail(e)] ) <0 ){ - // std::cout<<"Negative length!!"< > paths; @@ -95,8 +98,8 @@ public : - MinLengthPaths(Graph& _G, LengthMap& _length) : G(_G), - length(_length), reversed(_G)/*, dijkstra_dist(_G)*/{ } + MinLengthPaths(Graph& _G, LengthMap& _length, EdgeIntMap& _cap) : G(_G), + length(_length), capacity(_cap), flow(_G)/*, dijkstra_dist(_G)*/{ } ///Runs the algorithm. @@ -105,15 +108,14 @@ ///Returns k if there are at least k edge-disjoint paths from s to t. ///Otherwise it returns the number of found edge-disjoint paths from s to t. int run(Node s, Node t, int k) { - ConstMap const1map(1); - //We need a residual graph, in which some of the edges are reversed - ResGraphType res_graph(G, const1map, reversed); + //We need a residual graph + ResGraphType res_graph(G, capacity, flow); //Initialize the copy of the Dijkstra potential to zero typename ResGraphType::template NodeMap dijkstra_dist(res_graph); - ModLengthMap mod_length(res_graph, reversed, length, dijkstra_dist); + ModLengthMap mod_length(res_graph, length, dijkstra_dist); Dijkstra dijkstra(res_graph, mod_length); @@ -134,18 +136,21 @@ } - //Reversing the sortest path + //Augmenting on the sortest path Node n=t; Edge e; while (n!=s){ e = dijkstra.pred(n); n = dijkstra.predNode(n); - reversed[e] = 1-reversed[e]; + G.augment(e,1); } } + /* + ///\TODO To be implemented later + //Let's find the paths //We put the paths into stl vectors (as an inner representation). //In the meantime we lose the information stored in 'reversed'. @@ -175,6 +180,7 @@ } } + */ return i; } @@ -206,4 +212,4 @@ } //namespace hugo -#endif //HUGO_MINLENGTHPATHS_H +#endif //HUGO_MINCOSTFLOW_H