Modified a little bit
authorathos
Thu, 06 May 2004 14:23:48 +0000
changeset 54750184b822370
parent 546 bd3e3bfd9148
child 548 61898ac9e9dc
Modified a little bit
src/work/athos/mincostflows.h
     1.1 --- a/src/work/athos/mincostflows.h	Thu May 06 14:21:57 2004 +0000
     1.2 +++ b/src/work/athos/mincostflows.h	Thu May 06 14:23:48 2004 +0000
     1.3 @@ -52,8 +52,10 @@
     1.4  
     1.5      typedef ResGraphWrapper<const Graph,int,CapacityMap,EdgeIntMap> ResGraphType;
     1.6      typedef typename ResGraphType::Edge ResGraphEdge;
     1.7 +
     1.8      class ModLengthMap {   
     1.9 -      typedef typename ResGraphType::template NodeMap<Length> NodeMap;
    1.10 +      //typedef typename ResGraphType::template NodeMap<Length> NodeMap;
    1.11 +      typedef typename Graph::template NodeMap<Length> NodeMap;
    1.12        const ResGraphType& G;
    1.13        //      const EdgeIntMap& rev;
    1.14        const LengthMap &ol;
    1.15 @@ -87,6 +89,7 @@
    1.16      //If the algorithm has finished, the edges of the seeked paths are 
    1.17      //exactly those that are reversed 
    1.18      EdgeIntMap flow; 
    1.19 +    typename Graph::template NodeMap<Length> potential;
    1.20      
    1.21      //Container to store found paths
    1.22      std::vector< std::vector<Edge> > paths;
    1.23 @@ -100,7 +103,7 @@
    1.24  
    1.25  
    1.26      MinCostFlows(Graph& _G, LengthMap& _length, CapacityMap& _cap) : G(_G), 
    1.27 -      length(_length), capacity(_cap), flow(_G)/*, dijkstra_dist(_G)*/{ }
    1.28 +      length(_length), capacity(_cap), flow(_G), potential(_G){ }
    1.29  
    1.30      
    1.31      ///Runs the algorithm.
    1.32 @@ -112,17 +115,27 @@
    1.33  
    1.34        //Resetting variables from previous runs
    1.35        total_length = 0;
    1.36 +      
    1.37        FOR_EACH_LOC(typename Graph::EdgeIt, e, G){
    1.38  	flow.set(e,0);
    1.39        }
    1.40 +      
    1.41 +      FOR_EACH_LOC(typename Graph::NodeIt, n, G){
    1.42 +	//cout << potential[n]<<endl;
    1.43 +	potential.set(n,0);
    1.44 +      }
    1.45 +      
    1.46  
    1.47        
    1.48        //We need a residual graph
    1.49        ResGraphType res_graph(G, capacity, flow);
    1.50  
    1.51        //Initialize the copy of the Dijkstra potential to zero
    1.52 -      typename ResGraphType::template NodeMap<Length> dijkstra_dist(res_graph);
    1.53 -      ModLengthMap mod_length(res_graph, length, dijkstra_dist);
    1.54 +      
    1.55 +      //typename ResGraphType::template NodeMap<Length> potential(res_graph);
    1.56 +
    1.57 +
    1.58 +      ModLengthMap mod_length(res_graph, length, potential);
    1.59  
    1.60        Dijkstra<ResGraphType, ModLengthMap> dijkstra(res_graph, mod_length);
    1.61  
    1.62 @@ -138,7 +151,7 @@
    1.63  	  //We have to copy the potential
    1.64  	  typename ResGraphType::NodeIt n;
    1.65  	  for ( res_graph.first(n) ; res_graph.valid(n) ; res_graph.next(n) ) {
    1.66 -	      dijkstra_dist[n] += dijkstra.distMap()[n];
    1.67 +	      potential[n] += dijkstra.distMap()[n];
    1.68  	  }
    1.69  	}
    1.70  
    1.71 @@ -166,6 +179,7 @@
    1.72  
    1.73  
    1.74  
    1.75 +
    1.76      ///This function gives back the total length of the found paths.
    1.77      ///Assumes that \c run() has been run and nothing changed since then.
    1.78      Length totalLength(){