[Lemon-commits] [lemon_svn] athos: r720 - hugo/trunk/src/work/athos
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:41:08 CET 2006
Author: athos
Date: Thu May 6 16:23:48 2004
New Revision: 720
Modified:
hugo/trunk/src/work/athos/mincostflows.h
Log:
Modified a little bit
Modified: hugo/trunk/src/work/athos/mincostflows.h
==============================================================================
--- hugo/trunk/src/work/athos/mincostflows.h (original)
+++ hugo/trunk/src/work/athos/mincostflows.h Thu May 6 16:23:48 2004
@@ -52,8 +52,10 @@
typedef ResGraphWrapper<const Graph,int,CapacityMap,EdgeIntMap> ResGraphType;
typedef typename ResGraphType::Edge ResGraphEdge;
+
class ModLengthMap {
- typedef typename ResGraphType::template NodeMap<Length> NodeMap;
+ //typedef typename ResGraphType::template NodeMap<Length> NodeMap;
+ typedef typename Graph::template NodeMap<Length> NodeMap;
const ResGraphType& G;
// const EdgeIntMap& rev;
const LengthMap &ol;
@@ -87,6 +89,7 @@
//If the algorithm has finished, the edges of the seeked paths are
//exactly those that are reversed
EdgeIntMap flow;
+ typename Graph::template NodeMap<Length> potential;
//Container to store found paths
std::vector< std::vector<Edge> > paths;
@@ -100,7 +103,7 @@
MinCostFlows(Graph& _G, LengthMap& _length, CapacityMap& _cap) : G(_G),
- length(_length), capacity(_cap), flow(_G)/*, dijkstra_dist(_G)*/{ }
+ length(_length), capacity(_cap), flow(_G), potential(_G){ }
///Runs the algorithm.
@@ -112,17 +115,27 @@
//Resetting variables from previous runs
total_length = 0;
+
FOR_EACH_LOC(typename Graph::EdgeIt, e, G){
flow.set(e,0);
}
+
+ FOR_EACH_LOC(typename Graph::NodeIt, n, G){
+ //cout << potential[n]<<endl;
+ potential.set(n,0);
+ }
+
//We need a residual graph
ResGraphType res_graph(G, capacity, flow);
//Initialize the copy of the Dijkstra potential to zero
- typename ResGraphType::template NodeMap<Length> dijkstra_dist(res_graph);
- ModLengthMap mod_length(res_graph, length, dijkstra_dist);
+
+ //typename ResGraphType::template NodeMap<Length> potential(res_graph);
+
+
+ ModLengthMap mod_length(res_graph, length, potential);
Dijkstra<ResGraphType, ModLengthMap> dijkstra(res_graph, mod_length);
@@ -138,7 +151,7 @@
//We have to copy the potential
typename ResGraphType::NodeIt n;
for ( res_graph.first(n) ; res_graph.valid(n) ; res_graph.next(n) ) {
- dijkstra_dist[n] += dijkstra.distMap()[n];
+ potential[n] += dijkstra.distMap()[n];
}
}
@@ -166,6 +179,7 @@
+
///This function gives back the total length of the found paths.
///Assumes that \c run() has been run and nothing changed since then.
Length totalLength(){
More information about the Lemon-commits
mailing list