Changeset 511:325c9430723e in lemon-0.x for src/work/athos/minlengthpaths.h
- Timestamp:
- 05/03/04 12:27:20 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@671
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/athos/minlengthpaths.h
r491 r511 11 11 #include <graph_wrapper.h> 12 12 #include <maps.h> 13 #include <vector >13 #include <vector.h> 14 14 15 15 … … 32 32 33 33 typedef typename LengthMap::ValueType Length; 34 34 35 35 typedef typename Graph::Node Node; 36 36 typedef typename Graph::NodeIt NodeIt; 37 37 typedef typename Graph::Edge Edge; 38 38 typedef typename Graph::OutEdgeIt OutEdgeIt; 39 typedef typename Graph:: EdgeMap<int> EdgeIntMap;39 typedef typename Graph::template EdgeMap<int> EdgeIntMap; 40 40 41 41 typedef ConstMap<Edge,int> ConstMap; … … 43 43 typedef ResGraphWrapper<const Graph,int,ConstMap,EdgeIntMap> ResGraphType; 44 44 45 46 45 class ModLengthMap { 47 typedef typename ResGraphType:: NodeMap<Length> NodeMap;46 typedef typename ResGraphType::template NodeMap<Length> NodeMap; 48 47 const ResGraphType& G; 49 48 const EdgeIntMap& rev; … … 53 52 typedef typename LengthMap::KeyType KeyType; 54 53 typedef typename LengthMap::ValueType ValueType; 55 54 56 55 ValueType operator[](typename ResGraphType::Edge e) const { 57 56 //if ( (1-2*rev[e])*ol[e]-(pot[G.head(e)]-pot[G.tail(e)] ) <0 ){ … … 60 59 return (1-2*rev[e])*ol[e]-(pot[G.head(e)]-pot[G.tail(e)]); 61 60 } 62 61 63 62 ModLengthMap(const ResGraphType& _G, const EdgeIntMap& _rev, 64 63 const LengthMap &o, const NodeMap &p) : 65 64 G(_G), rev(_rev), ol(o), pot(p){}; 66 }; 65 };//ModLengthMap 66 67 67 68 68 69 … … 79 80 //Container to store found paths 80 81 std::vector< std::vector<Edge> > paths; 82 //typedef DirPath<Graph> DPath; 83 //DPath paths; 84 85 86 Length total_length; 81 87 82 88 public : … … 95 101 ConstMap const1map(1); 96 102 103 97 104 //We need a residual graph, in which some of the edges are reversed 98 105 ResGraphType res_graph(G, const1map, reversed); 99 106 100 107 //Initialize the copy of the Dijkstra potential to zero 101 typename ResGraphType:: NodeMap<Length> dijkstra_dist(res_graph);108 typename ResGraphType::template NodeMap<Length> dijkstra_dist(res_graph); 102 109 ModLengthMap mod_length(res_graph, reversed, length, dijkstra_dist); 103 110 … … 134 141 135 142 //Let's find the paths 136 //We put the paths into vectors (just for now). In the meantime we lose137 // the information stored in 'reversed'143 //We put the paths into stl vectors (as an inner representation). 144 //In the meantime we lose the information stored in 'reversed'. 138 145 //We suppose the lengths to be positive now. 146 147 //Meanwhile we put the total length of the found paths 148 //in the member variable total_length 139 149 paths.clear(); 150 total_length=0; 140 151 paths.resize(k); 141 152 for (int j=0; j<i; ++j){ … … 153 164 n = G.head(e); 154 165 paths[j].push_back(e); 166 total_length += length[e]; 155 167 reversed[e] = 1-reversed[e]; 156 168 } … … 161 173 } 162 174 175 ///This function gives back the total length of the found paths. 176 ///Assumes that \c run() has been run and nothing changed since then. 177 Length totalLength(){ 178 return total_length; 179 } 180 181 ///This function gives back the \c j-th path in argument p. 182 ///Assumes that \c run() has been run and nothing changed since then. 183 /// \warning It is assumed that \c p is constructed to be a path of graph \c G. 184 template<typename DirPath> 185 void getPath(DirPath& p, int j){ 186 p.clear(); 187 typename DirPath::Builder B(p); 188 for(typename std::vector<Edge>::iterator i=paths[j].begin(); 189 i!=paths[j].end(); ++i ){ 190 B.pushBack(*j); 191 } 192 193 B.commit(); 194 } 163 195 164 196 }; //class MinLengthPaths
Note: See TracChangeset
for help on using the changeset viewer.