max_flow.h bug correction
authormarci
Fri, 21 May 2004 12:40:39 +0000
changeset 6569971eb8bfbe8
parent 655 a9878222d5c8
child 657 531fc5f575ef
max_flow.h bug correction
src/hugo/graph_wrapper.h
src/work/jacint/max_flow.h
     1.1 --- a/src/hugo/graph_wrapper.h	Fri May 21 10:57:30 2004 +0000
     1.2 +++ b/src/hugo/graph_wrapper.h	Fri May 21 12:40:39 2004 +0000
     1.3 @@ -1380,6 +1380,9 @@
     1.4      const CapacityMap* capacity;
     1.5      const FlowMap* flow;
     1.6    public:
     1.7 +    void setGraph(const Graph& _graph) { graph=&_graph; }
     1.8 +    void setCapacity(const CapacityMap& _capacity) { capacity=&_capacity; }
     1.9 +    void setFlow(const FlowMap& _flow) { flow=&_flow; }
    1.10      ForwardFilter(const Graph& _graph, 
    1.11  		  const CapacityMap& _capacity, const FlowMap& _flow) :
    1.12        graph(&_graph), capacity(&_capacity), flow(&_flow) { }
    1.13 @@ -1395,6 +1398,9 @@
    1.14      const CapacityMap* capacity;
    1.15      const FlowMap* flow;
    1.16    public:
    1.17 +    void setGraph(const Graph& _graph) { graph=&_graph; }
    1.18 +    void setCapacity(const CapacityMap& _capacity) { capacity=&_capacity; }
    1.19 +    void setFlow(const FlowMap& _flow) { flow=&_flow; }
    1.20      BackwardFilter(const Graph& _graph, 
    1.21  		   const CapacityMap& _capacity, const FlowMap& _flow) :
    1.22        graph(&_graph), capacity(&_capacity), flow(&_flow) { }
    1.23 @@ -1424,6 +1430,14 @@
    1.24      FlowMap* flow;
    1.25      ForwardFilter<Graph, Number, CapacityMap, FlowMap> forward_filter;
    1.26      BackwardFilter<Graph, Number, CapacityMap, FlowMap> backward_filter;
    1.27 +//     ResGraphWrapper() : Parent(), 
    1.28 +// 			capacity(0), flow(0) { }
    1.29 +//     void setCapacityMap(const CapacityMap& _capacity) {
    1.30 +//       capacity=&_capacity;
    1.31 +//     }
    1.32 +//     void setFlowMap(FlowMap& _flow) {
    1.33 +//       flow=&_flow;
    1.34 +//     }
    1.35    public:
    1.36      ResGraphWrapper(Graph& _graph, const CapacityMap& _capacity, 
    1.37  		       FlowMap& _flow) : 
     2.1 --- a/src/work/jacint/max_flow.h	Fri May 21 10:57:30 2004 +0000
     2.2 +++ b/src/work/jacint/max_flow.h	Fri May 21 12:40:39 2004 +0000
     2.3 @@ -122,6 +122,7 @@
     2.4      enum StatusEnum {
     2.5        AFTER_NOTHING,
     2.6        AFTER_AUGMENTING,
     2.7 +      AFTER_FAST_AUGMENTING, 
     2.8        AFTER_PRE_FLOW_PHASE_1,      
     2.9        AFTER_PRE_FLOW_PHASE_2
    2.10      };
    2.11 @@ -265,7 +266,7 @@
    2.12      void actMinCut(_CutMap& M) const {
    2.13        NodeIt v;
    2.14        switch (status) {
    2.15 -	case AFTER_PRE_FLOW_PHASE_1:
    2.16 +      case AFTER_PRE_FLOW_PHASE_1:
    2.17  	for(g->first(v); g->valid(v); g->next(v)) {
    2.18  	  if (level[v] < n) {
    2.19  	    M.set(v, false);
    2.20 @@ -274,11 +275,11 @@
    2.21  	  }
    2.22  	}
    2.23  	break;
    2.24 -	case AFTER_PRE_FLOW_PHASE_2:
    2.25 -	case AFTER_NOTHING:
    2.26 +      case AFTER_PRE_FLOW_PHASE_2:
    2.27 +      case AFTER_NOTHING:
    2.28  	minMinCut(M);
    2.29  	break;
    2.30 -	case AFTER_AUGMENTING:
    2.31 +      case AFTER_AUGMENTING:
    2.32  	for(g->first(v); g->valid(v); g->next(v)) {
    2.33  	  if (level[v]) {
    2.34  	    M.set(v, true);
    2.35 @@ -287,6 +288,15 @@
    2.36  	  }
    2.37  	}
    2.38  	break;
    2.39 +      case AFTER_FAST_AUGMENTING:
    2.40 +	for(g->first(v); g->valid(v); g->next(v)) {
    2.41 +	  if (level[v]==number_of_augmentations) {
    2.42 +	    M.set(v, true);
    2.43 +	  } else {
    2.44 +	    M.set(v, false);
    2.45 +	  }
    2.46 +	}
    2.47 +	break;
    2.48        }
    2.49      }
    2.50  
    2.51 @@ -944,9 +954,9 @@
    2.52      ResGW res_graph(*g, *capacity, *flow);
    2.53      bool _augment=false;
    2.54  
    2.55 -    if (status!=AFTER_AUGMENTING) {
    2.56 -      FOR_EACH_LOC(typename Graph::NodeIt, e, *g) level.set(e, 3*n); 
    2.57 -      number_of_augmentations=3*n+1;
    2.58 +    if (status!=AFTER_FAST_AUGMENTING) {
    2.59 +      FOR_EACH_LOC(typename Graph::NodeIt, e, *g) level.set(e, 0); 
    2.60 +      number_of_augmentations=1;
    2.61      } else {
    2.62        ++number_of_augmentations;
    2.63      }
    2.64 @@ -991,7 +1001,7 @@
    2.65        }
    2.66      }
    2.67  
    2.68 -    status=AFTER_AUGMENTING;
    2.69 +    status=AFTER_FAST_AUGMENTING;
    2.70      return _augment;
    2.71    }
    2.72