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@308: ///\brief Implementation of an algorithm for finding k paths between 2 nodes klao@308: /// of minimal total length klao@308: /// klao@308: /// The class \ref hugo::MinLengthPaths "MinLengthPaths" implements klao@308: /// an algorithm which finds k edge-disjoint paths klao@308: /// from a given source node to a given target node in an klao@308: /// edge-weighted directed graph having minimal total weigth (length). klao@308: /// klao@308: /// klao@308: klao@308: template > klao@308: class MinLengthPaths { klao@308: klao@308: klao@308: // class ConstMap { klao@308: // public : klao@308: // typedef int ValueType; klao@308: // typedef typename Graph::Edge KeyType; klao@308: klao@308: // int operator[](typename Graph::Edge e) const { klao@308: // return 1; klao@308: // } klao@308: // }; klao@308: 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@308: typedef TrivGraphWrapper TrivGraphType; klao@308: typedef ResGraphWrapper ResGraphType; klao@308: klao@308: klao@308: //template klao@308: class ModLengthMap { klao@308: typedef typename ResGraphType::NodeMap NodeMap; klao@308: const ResGraphType& G; klao@308: const EdgeIntMap& rev; klao@308: const LengthMap &ol; klao@308: 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(G); klao@308: 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