diff -r 50f1d2077d50 -r 76c005b15354 src/work/klao/minlengthpaths.h --- a/src/work/klao/minlengthpaths.h Mon Apr 05 17:56:31 2004 +0000 +++ b/src/work/klao/minlengthpaths.h Mon Apr 05 18:24:37 2004 +0000 @@ -13,31 +13,18 @@ namespace hugo { -///\brief Implementation of an algorithm for finding k paths between 2 nodes + ///\brief Implementation of an algorithm for finding k paths between 2 nodes /// of minimal total length -/// -/// The class \ref hugo::MinLengthPaths "MinLengthPaths" implements -/// an algorithm which finds k edge-disjoint paths -/// from a given source node to a given target node in an -/// edge-weighted directed graph having minimal total weigth (length). -/// -/// + /// + /// The class \ref hugo::MinLengthPaths "MinLengthPaths" implements + /// an algorithm which finds k edge-disjoint paths + /// from a given source node to a given target node in an + /// edge-weighted directed graph having minimal total weigth (length). - template > + template class MinLengthPaths { - -// class ConstMap { -// public : -// typedef int ValueType; -// typedef typename Graph::Edge KeyType; - -// int operator[](typename Graph::Edge e) const { -// return 1; -// } -// }; - + typedef typename LengthMap::ValueType Length; typedef typename Graph::Node Node; typedef typename Graph::NodeIt NodeIt; @@ -47,18 +34,15 @@ typedef ConstMap ConstMap; - typedef TrivGraphWrapper TrivGraphType; - typedef ResGraphWrapper ResGraphType; + typedef ResGraphWrapper ResGraphType; - //template class ModLengthMap { - typedef typename ResGraphType::NodeMap NodeMap; + typedef typename ResGraphType::NodeMap NodeMap; const ResGraphType& G; - const EdgeIntMap& rev; - const LengthMap &ol; - const NodeMap &pot; + const EdgeIntMap& rev; + const LengthMap &ol; + const NodeMap &pot; public : typedef typename LengthMap::KeyType KeyType; typedef typename LengthMap::ValueType ValueType; @@ -71,8 +55,8 @@ return (1-2*rev[e])*ol[e]-(pot[G.head(e)]-pot[G.tail(e)]); } - ModLengthMap( const ResGraphType& _G, const EdgeIntMap& _rev, - const LengthMap &o, const NodeMap &p) : + ModLengthMap(const ResGraphType& _G, const EdgeIntMap& _rev, + const LengthMap &o, const NodeMap &p) : G(_G), rev(_rev), ol(o), pot(p){}; }; @@ -86,7 +70,7 @@ public : - + MinLengthPaths(Graph& _G, LengthMap& _length) : G(_G), length(_length), reversed(_G)/*, dijkstra_dist(_G)*/{ } @@ -102,8 +86,8 @@ ResGraphType res_graph(G, reversed, const1map); //Initialize the copy of the Dijkstra potential to zero - typename ResGraphType::NodeMap dijkstra_dist(G); - ModLengthMap mod_length( res_graph, reversed, length, dijkstra_dist); + typename ResGraphType::NodeMap dijkstra_dist(res_graph); + ModLengthMap mod_length(res_graph, reversed, length, dijkstra_dist); Dijkstra dijkstra(res_graph, mod_length); @@ -111,7 +95,8 @@ dijkstra.run(s); if (!dijkstra.reached(t)){ //There is no k path from s to t - return ++i; + /// \TODO mit keresett itt ez a ++? + return i; }; { @@ -123,19 +108,6 @@ } - /* - { - //We have to copy the potential - typename ResGraphType::EdgeIt e; - for ( res_graph.first(e) ; res_graph.valid(e) ; res_graph.next(e) ) { - //dijkstra_dist[e] = dijkstra.distMap()[e]; - mod_length_c[Edge(e)] = mod_length_c[Edge(e)] - - dijkstra.distMap()[res_graph.head(e)] + - dijkstra.distMap()[res_graph.tail(e)]; - } - } - */ - //Reversing the sortest path Node n=t; Edge e; @@ -149,14 +121,12 @@ } return k; } - - - };//class MinLengthPaths + }; //class MinLengthPaths } //namespace hugo