athos@276: // -*- c++ -*- athos@306: #ifndef HUGO_MINLENGTHPATHS_H athos@306: #define HUGO_MINLENGTHPATHS_H athos@276: alpar@294: ///\file athos@306: ///\brief An algorithm for finding k paths of minimal total length. alpar@294: athos@276: #include athos@276: #include athos@276: #include athos@306: #include athos@306: athos@276: namespace hugo { athos@276: athos@276: klao@310: ///\brief Implementation of an algorithm for finding k paths between 2 nodes athos@306: /// of minimal total length klao@310: /// klao@310: /// The class \ref hugo::MinLengthPaths "MinLengthPaths" implements klao@310: /// an algorithm which finds k edge-disjoint paths klao@310: /// from a given source node to a given target node in an klao@310: /// edge-weighted directed graph having minimal total weigth (length). athos@276: klao@310: template athos@306: class MinLengthPaths { athos@276: klao@310: typedef typename LengthMap::ValueType Length; athos@276: athos@276: typedef typename Graph::Node Node; athos@276: typedef typename Graph::NodeIt NodeIt; athos@276: typedef typename Graph::Edge Edge; athos@276: typedef typename Graph::OutEdgeIt OutEdgeIt; athos@306: typedef typename Graph::EdgeMap EdgeIntMap; athos@306: athos@306: typedef ConstMap ConstMap; athos@306: klao@310: typedef ResGraphWrapper ResGraphType; athos@276: athos@306: athos@306: class ModLengthMap { klao@310: typedef typename ResGraphType::NodeMap NodeMap; athos@306: const ResGraphType& G; klao@310: const EdgeIntMap& rev; klao@310: const LengthMap &ol; klao@310: const NodeMap &pot; athos@306: public : athos@306: typedef typename LengthMap::KeyType KeyType; athos@306: typedef typename LengthMap::ValueType ValueType; athos@306: athos@306: ValueType operator[](typename ResGraphType::Edge e) const { athos@306: if ( (1-2*rev[e])*ol[e]-(pot[G.head(e)]-pot[G.tail(e)] ) <0 ){ athos@306: ///\TODO This has to be removed athos@306: std::cout<<"Negative length!!"< dijkstra_dist(res_graph); klao@310: ModLengthMap mod_length(res_graph, reversed, length, dijkstra_dist); athos@306: athos@306: Dijkstra dijkstra(res_graph, mod_length); athos@276: athos@276: for (int i=0; i