klao@308: // -*- c++ -*- klao@308: #ifndef HUGO_MINLENGTHPATHS_H klao@308: #define HUGO_MINLENGTHPATHS_H klao@308: klao@308: ///\file klao@308: ///\brief An algorithm for finding k paths of minimal total length. klao@308: klao@308: #include klao@308: #include klao@308: #include klao@308: #include klao@308: klao@308: namespace hugo { klao@308: klao@308: klao@310: ///\brief Implementation of an algorithm for finding k paths between 2 nodes klao@308: /// 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). klao@308: klao@310: template klao@308: class MinLengthPaths { klao@308: klao@310: typedef typename LengthMap::ValueType Length; klao@308: klao@308: typedef typename Graph::Node Node; klao@308: typedef typename Graph::NodeIt NodeIt; klao@308: typedef typename Graph::Edge Edge; klao@308: typedef typename Graph::OutEdgeIt OutEdgeIt; klao@308: typedef typename Graph::EdgeMap EdgeIntMap; klao@308: klao@308: typedef ConstMap ConstMap; klao@308: klao@310: typedef ResGraphWrapper ResGraphType; klao@308: klao@308: klao@308: class ModLengthMap { klao@310: typedef typename ResGraphType::NodeMap NodeMap; klao@308: const ResGraphType& G; klao@310: const EdgeIntMap& rev; klao@310: const LengthMap &ol; klao@310: const NodeMap &pot; klao@308: public : klao@308: typedef typename LengthMap::KeyType KeyType; klao@308: typedef typename LengthMap::ValueType ValueType; klao@308: klao@308: ValueType operator[](typename ResGraphType::Edge e) const { klao@308: if ( (1-2*rev[e])*ol[e]-(pot[G.head(e)]-pot[G.tail(e)] ) <0 ){ klao@308: ///\TODO This has to be removed klao@308: std::cout<<"Negative length!!"< dijkstra_dist(res_graph); klao@310: ModLengthMap mod_length(res_graph, reversed, length, dijkstra_dist); klao@308: klao@308: Dijkstra dijkstra(res_graph, mod_length); klao@308: klao@308: for (int i=0; i