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