src/lemon/preflow.h
changeset 1299 e2545ef5d7d8
parent 1227 01f668e3e168
child 1359 1581f961cfaa
equal deleted inserted replaced
6:2d6beee61874 7:d4d2176a576c
    40   ///graph. The preflow algorithms are the fastest known max flow algorithms
    40   ///graph. The preflow algorithms are the fastest known max flow algorithms
    41   ///up to now. The \e source node, the \e target node, the \e
    41   ///up to now. The \e source node, the \e target node, the \e
    42   ///capacity of the edges and the \e starting \e flow value of the
    42   ///capacity of the edges and the \e starting \e flow value of the
    43   ///edges should be passed to the algorithm through the
    43   ///edges should be passed to the algorithm through the
    44   ///constructor. It is possible to change these quantities using the
    44   ///constructor. It is possible to change these quantities using the
    45   ///functions \ref source, \ref target, \ref setCap and \ref
    45   ///functions \ref source, \ref target, \ref capacityMap and \ref
    46   ///setFlow.
    46   ///flowMap.
    47   ///
    47   ///
    48   ///After running \ref lemon::Preflow::phase1() "phase1()"
    48   ///After running \ref lemon::Preflow::phase1() "phase1()"
    49   ///or \ref lemon::Preflow::run() "run()", the maximal flow
    49   ///or \ref lemon::Preflow::run() "run()", the maximal flow
    50   ///value can be obtained by calling \ref flowValue(). The minimum
    50   ///value can be obtained by calling \ref flowValue(). The minimum
    51   ///value cut can be written into a <tt>bool</tt> node map by
    51   ///value cut can be written into a <tt>bool</tt> node map by
   132     
   132     
   133   public: 
   133   public: 
   134     ///The constructor of the class.
   134     ///The constructor of the class.
   135 
   135 
   136     ///The constructor of the class. 
   136     ///The constructor of the class. 
   137     ///\param _G The directed graph the algorithm runs on. 
   137     ///\param _gr The directed graph the algorithm runs on. 
   138     ///\param _s The source node.
   138     ///\param _s The source node.
   139     ///\param _t The target node.
   139     ///\param _t The target node.
   140     ///\param _cap The capacity of the edges. 
   140     ///\param _cap The capacity of the edges. 
   141     ///\param _f The flow of the edges. 
   141     ///\param _f The flow of the edges. 
   142     ///Except the graph, all of these parameters can be reset by
   142     ///Except the graph, all of these parameters can be reset by
   143     ///calling \ref source, \ref target, \ref setCap and \ref
   143     ///calling \ref source, \ref target, \ref capacityMap and \ref
   144     ///setFlow, resp.
   144     ///flowMap, resp.
   145       Preflow(const Graph& _gr, Node _s, Node _t, 
   145       Preflow(const Graph& _gr, Node _s, Node _t, 
   146 	      const CapacityMap& _cap, FlowMap& _f) :
   146 	      const CapacityMap& _cap, FlowMap& _f) :
   147 	_g(&_gr), _source(_s), _target(_t), _capacity(&_cap),
   147 	_g(&_gr), _source(_s), _target(_t), _capacity(&_cap),
   148 	_flow(&_f), _node_num(countNodes(_gr)), level(_gr), excess(_gr,0), 
   148 	_flow(&_f), _node_num(countNodes(_gr)), level(_gr), excess(_gr,0), 
   149 	flow_prop(NO_FLOW), status(AFTER_NOTHING) { }
   149 	flow_prop(NO_FLOW), status(AFTER_NOTHING) { }
   176       
   176       
   177     ///Runs the first phase of the preflow algorithm.
   177     ///Runs the first phase of the preflow algorithm.
   178 
   178 
   179     ///The preflow algorithm consists of two phases, this method runs
   179     ///The preflow algorithm consists of two phases, this method runs
   180     ///the first phase. After the first phase the maximum flow value
   180     ///the first phase. After the first phase the maximum flow value
   181     ///and a minimum value cut can already be computed, though a
   181     ///and a minimum value cut can already be computed, although a
   182     ///maximum flow is not yet obtained. So after calling this method
   182     ///maximum flow is not yet obtained. So after calling this method
   183     ///\ref flowValue returns the value of a maximum flow and \ref
   183     ///\ref flowValue returns the value of a maximum flow and \ref
   184     ///minCut returns a minimum cut.     
   184     ///minCut returns a minimum cut.     
   185     ///\warning \ref minMinCut and \ref maxMinCut do not give minimum
   185     ///\warning \ref minMinCut and \ref maxMinCut do not give minimum
   186     ///value cuts unless calling \ref phase2.  
   186     ///value cuts unless calling \ref phase2.  
   198     
   198     
   199     ///Runs the first phase of the preflow algorithm.
   199     ///Runs the first phase of the preflow algorithm.
   200 
   200 
   201     ///The preflow algorithm consists of two phases, this method runs
   201     ///The preflow algorithm consists of two phases, this method runs
   202     ///the first phase. After the first phase the maximum flow value
   202     ///the first phase. After the first phase the maximum flow value
   203     ///and a minimum value cut can already be computed, though a
   203     ///and a minimum value cut can already be computed, although a
   204     ///maximum flow is not yet obtained. So after calling this method
   204     ///maximum flow is not yet obtained. So after calling this method
   205     ///\ref flowValue returns the value of a maximum flow and \ref
   205     ///\ref flowValue returns the value of a maximum flow and \ref
   206     ///minCut returns a minimum cut.
   206     ///minCut returns a minimum cut.
   207     ///\warning \ref minCut(), \ref minMinCut() and \ref maxMinCut() do not
   207     ///\warning \ref minCut(), \ref minMinCut() and \ref maxMinCut() do not
   208     ///give minimum value cuts unless calling \ref phase2().
   208     ///give minimum value cuts unless calling \ref phase2().
   512     /// 
   512     /// 
   513     void capacityMap(const CapacityMap& _cap) { 
   513     void capacityMap(const CapacityMap& _cap) { 
   514       _capacity=&_cap; 
   514       _capacity=&_cap; 
   515       status=AFTER_NOTHING; 
   515       status=AFTER_NOTHING; 
   516     }
   516     }
   517     /// Returns a reference to to capacity map.
   517     /// Returns a reference to capacity map.
   518 
   518 
   519     /// Returns a reference to to capacity map.
   519     /// Returns a reference to capacity map.
   520     /// 
   520     /// 
   521     const CapacityMap &capacityMap() const { 
   521     const CapacityMap &capacityMap() const { 
   522       return *_capacity;
   522       return *_capacity;
   523     }
   523     }
   524 
   524 
   530       _flow=&_f; 
   530       _flow=&_f; 
   531       flow_prop=NO_FLOW;
   531       flow_prop=NO_FLOW;
   532       status=AFTER_NOTHING; 
   532       status=AFTER_NOTHING; 
   533     }
   533     }
   534      
   534      
   535     /// Returns a reference to to flow map.
   535     /// Returns a reference to flow map.
   536 
   536 
   537     /// Returns a reference to to flow map.
   537     /// Returns a reference to flow map.
   538     /// 
   538     /// 
   539     const FlowMap &flowMap() const { 
   539     const FlowMap &flowMap() const { 
   540       return *_flow;
   540       return *_flow;
   541     }
   541     }
   542 
   542