lemon/preflow.h
changeset 1843 1e386f4047c9
parent 1792 febe52db9b67
child 1875 98698b69a902
equal deleted inserted replaced
5:03263a94eb39 6:3af10a2e9ccf
    20 #include <vector>
    20 #include <vector>
    21 #include <queue>
    21 #include <queue>
    22 
    22 
    23 #include <lemon/error.h>
    23 #include <lemon/error.h>
    24 #include <lemon/invalid.h>
    24 #include <lemon/invalid.h>
       
    25 #include <lemon/tolerance.h>
    25 #include <lemon/maps.h>
    26 #include <lemon/maps.h>
    26 #include <lemon/graph_utils.h>
    27 #include <lemon/graph_utils.h>
    27 
    28 
    28 /// \file
    29 /// \file
    29 /// \ingroup flowalgs
    30 /// \ingroup flowalgs
    59   ///
    60   ///
    60   ///\author Jacint Szabo 
    61   ///\author Jacint Szabo 
    61   ///\todo Second template parameter is superfluous
    62   ///\todo Second template parameter is superfluous
    62   template <typename Graph, typename Num,
    63   template <typename Graph, typename Num,
    63 	    typename CapacityMap=typename Graph::template EdgeMap<Num>,
    64 	    typename CapacityMap=typename Graph::template EdgeMap<Num>,
    64             typename FlowMap=typename Graph::template EdgeMap<Num> >
    65             typename FlowMap=typename Graph::template EdgeMap<Num>,
       
    66 	    typename TOL=Tolerance<Num> >
    65   class Preflow {
    67   class Preflow {
    66   protected:
    68   protected:
    67     typedef typename Graph::Node Node;
    69     typedef typename Graph::Node Node;
    68     typedef typename Graph::NodeIt NodeIt;
    70     typedef typename Graph::NodeIt NodeIt;
    69     typedef typename Graph::EdgeIt EdgeIt;
    71     typedef typename Graph::EdgeIt EdgeIt;
    76     const Graph* _g;
    78     const Graph* _g;
    77     Node _source;
    79     Node _source;
    78     Node _target;
    80     Node _target;
    79     const CapacityMap* _capacity;
    81     const CapacityMap* _capacity;
    80     FlowMap* _flow;
    82     FlowMap* _flow;
       
    83 
       
    84     TOL surely;
       
    85     
    81     int _node_num;      //the number of nodes of G
    86     int _node_num;      //the number of nodes of G
    82     
    87     
    83     typename Graph::template NodeMap<int> level;  
    88     typename Graph::template NodeMap<int> level;  
    84     typename Graph::template NodeMap<Num> excess;
    89     typename Graph::template NodeMap<Num> excess;
    85 
    90 
   151     ///\param _f The flow of the edges. 
   156     ///\param _f The flow of the edges. 
   152     ///Except the graph, all of these parameters can be reset by
   157     ///Except the graph, all of these parameters can be reset by
   153     ///calling \ref source, \ref target, \ref capacityMap and \ref
   158     ///calling \ref source, \ref target, \ref capacityMap and \ref
   154     ///flowMap, resp.
   159     ///flowMap, resp.
   155       Preflow(const Graph& _gr, Node _s, Node _t, 
   160       Preflow(const Graph& _gr, Node _s, Node _t, 
   156 	      const CapacityMap& _cap, FlowMap& _f) :
   161 	      const CapacityMap& _cap, FlowMap& _f,
       
   162 	      const TOL &tol=TOL()) :
   157 	_g(&_gr), _source(_s), _target(_t), _capacity(&_cap),
   163 	_g(&_gr), _source(_s), _target(_t), _capacity(&_cap),
   158 	_flow(&_f), _node_num(countNodes(_gr)), level(_gr), excess(_gr,0), 
   164 	_flow(&_f), surely(tol),
       
   165 	_node_num(countNodes(_gr)), level(_gr), excess(_gr,0), 
   159 	flow_prop(NO_FLOW), status(AFTER_NOTHING) { 
   166 	flow_prop(NO_FLOW), status(AFTER_NOTHING) { 
   160 	if ( _source==_target )
   167 	if ( _source==_target )
   161 	  throw InvalidArgument();
   168 	  throw InvalidArgument();
   162       }
   169       }
   163     
   170