COIN-OR::LEMON - Graph Library

Ticket #266: circ-dacc2cee2b4c.patch

File circ-dacc2cee2b4c.patch, 24.8 KB (added by Peter Kovacs, 16 years ago)
  • lemon/circulation.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1239984875 -7200
    # Node ID dacc2cee2b4c4ec7481d3edec47aaf834b5db47c
    # Parent  e6927fe719e6e2cc97345c5f89f1cb0d66d2d0c9
    Slightly modify the interface of Circulation and Preflow (#266)
    in order to synchronize them to the interface of NetworkSimplex.
    
    Circulation:
     - The "delta" notation is replaced by "supply".
     - lowerCapMap(), upperCapMap() are renamed to lowerMap() and upperMap().
     - Value is renamed to Flow.
    
    Preflow:
     - Value is renamed to Flow.
    
    diff --git a/lemon/circulation.h b/lemon/circulation.h
    a b  
    3131  /// \brief Default traits class of Circulation class.
    3232  ///
    3333  /// Default traits class of Circulation class.
    34   /// \tparam GR Digraph type.
    35   /// \tparam LM Lower bound capacity map type.
    36   /// \tparam UM Upper bound capacity map type.
    37   /// \tparam DM Delta map type.
     34  ///
     35  /// \tparam GR Type of the digraph the algorithm runs on.
     36  /// \tparam LM The type of the lower bound map.
     37  /// \tparam UM The type of the upper bound (capacity) map.
     38  /// \tparam SM The type of the supply map.
    3839  template <typename GR, typename LM,
    39             typename UM, typename DM>
     40            typename UM, typename SM>
    4041  struct CirculationDefaultTraits {
    4142
    4243    /// \brief The type of the digraph the algorithm runs on.
    4344    typedef GR Digraph;
    4445
    45     /// \brief The type of the map that stores the circulation lower
    46     /// bound.
     46    /// \brief The type of the lower bound map.
    4747    ///
    48     /// The type of the map that stores the circulation lower bound.
    49     /// It must meet the \ref concepts::ReadMap "ReadMap" concept.
    50     typedef LM LCapMap;
     48    /// The type of the map that stores the lower bounds on the arcs.
     49    /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
     50    typedef LM LowerMap;
    5151
    52     /// \brief The type of the map that stores the circulation upper
    53     /// bound.
     52    /// \brief The type of the upper bound (capacity) map.
    5453    ///
    55     /// The type of the map that stores the circulation upper bound.
    56     /// It must meet the \ref concepts::ReadMap "ReadMap" concept.
    57     typedef UM UCapMap;
     54    /// The type of the map that stores the upper bounds (capacities)
     55    /// on the arcs.
     56    /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
     57    typedef UM UpperMap;
    5858
    59     /// \brief The type of the map that stores the lower bound for
    60     /// the supply of the nodes.
     59    /// \brief The type of supply map.
    6160    ///
    62     /// The type of the map that stores the lower bound for the supply
    63     /// of the nodes. It must meet the \ref concepts::ReadMap "ReadMap"
    64     /// concept.
    65     typedef DM DeltaMap;
     61    /// The type of the map that stores the signed supply values of the
     62    /// nodes.
     63    /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
     64    typedef SM SupplyMap;
    6665
    6766    /// \brief The type of the flow values.
    68     typedef typename DeltaMap::Value Value;
     67    typedef typename SupplyMap::Value Flow;
    6968
    7069    /// \brief The type of the map that stores the flow values.
    7170    ///
    7271    /// The type of the map that stores the flow values.
    73     /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    74     typedef typename Digraph::template ArcMap<Value> FlowMap;
     72    /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap"
     73    /// concept.
     74    typedef typename Digraph::template ArcMap<Flow> FlowMap;
    7575
    7676    /// \brief Instantiates a FlowMap.
    7777    ///
    7878    /// This function instantiates a \ref FlowMap.
    79     /// \param digraph The digraph, to which we would like to define
     79    /// \param digraph The digraph for which we would like to define
    8080    /// the flow map.
    8181    static FlowMap* createFlowMap(const Digraph& digraph) {
    8282      return new FlowMap(digraph);
     
    9393    /// \brief Instantiates an Elevator.
    9494    ///
    9595    /// This function instantiates an \ref Elevator.
    96     /// \param digraph The digraph, to which we would like to define
     96    /// \param digraph The digraph for which we would like to define
    9797    /// the elevator.
    9898    /// \param max_level The maximum level of the elevator.
    9999    static Elevator* createElevator(const Digraph& digraph, int max_level) {
     
    103103    /// \brief The tolerance used by the algorithm
    104104    ///
    105105    /// The tolerance used by the algorithm to handle inexact computation.
    106     typedef lemon::Tolerance<Value> Tolerance;
     106    typedef lemon::Tolerance<Flow> Tolerance;
    107107
    108108  };
    109109
     
    111111     \brief Push-relabel algorithm for the network circulation problem.
    112112
    113113     \ingroup max_flow
    114      This class implements a push-relabel algorithm for the network
    115      circulation problem.
     114     This class implements a push-relabel algorithm for the \e network
     115     \e circulation problem.
    116116     It is to find a feasible circulation when lower and upper bounds
    117      are given for the flow values on the arcs and lower bounds
    118      are given for the supply values of the nodes.
     117     are given for the flow values on the arcs and lower bounds are
     118     given for the difference between the outgoing and incoming flow
     119     at the nodes.
    119120
    120121     The exact formulation of this problem is the following.
    121122     Let \f$G=(V,A)\f$ be a digraph,
    122      \f$lower, upper: A\rightarrow\mathbf{R}^+_0\f$,
    123      \f$delta: V\rightarrow\mathbf{R}\f$. Find a feasible circulation
    124      \f$f: A\rightarrow\mathbf{R}^+_0\f$ so that
    125      \f[ \sum_{a\in\delta_{out}(v)} f(a) - \sum_{a\in\delta_{in}(v)} f(a)
    126      \geq delta(v) \quad \forall v\in V, \f]
    127      \f[ lower(a)\leq f(a) \leq upper(a) \quad \forall a\in A. \f]
    128      \note \f$delta(v)\f$ specifies a lower bound for the supply of node
    129      \f$v\f$. It can be either positive or negative, however note that
    130      \f$\sum_{v\in V}delta(v)\f$ should be zero or negative in order to
    131      have a feasible solution.
     123     \f$lower, upper: A\rightarrow\mathbf{R}^+_0\f$ denote the lower and
     124     upper bounds on the arcs, for which \f$0 \leq lower(uv) \leq upper(uv)\f$
     125     holds for all \f$uv\in A\f$, and \f$sup: V\rightarrow\mathbf{R}\f$
     126     denotes the signed supply values of the nodes.
     127     If \f$sup(u)>0\f$, then \f$u\f$ is a supply node with \f$sup(u)\f$
     128     supply, if \f$sup(u)<0\f$, then \f$u\f$ is a demand node with
     129     \f$-sup(u)\f$ demand.
     130     A feasible circulation is an \f$f: A\rightarrow\mathbf{R}^+_0\f$
     131     solution of the following problem.
    132132
    133      \note A special case of this problem is when
    134      \f$\sum_{v\in V}delta(v) = 0\f$. Then the supply of each node \f$v\f$
    135      will be \e equal \e to \f$delta(v)\f$, if a circulation can be found.
    136      Thus a feasible solution for the
    137      \ref min_cost_flow "minimum cost flow" problem can be calculated
    138      in this way.
     133     \f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu)
     134     \geq sup(u) \quad \forall u\in V, \f]
     135     \f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A. \f]
     136     
     137     The sum of the supply values, i.e. \f$\sum_{u\in V} sup(u)\f$ must be
     138     zero or negative in order to have a feasible solution (since the sum
     139     of the expressions on the left-hand side of the inequalities is zero).
     140     It means that the total demand must be greater or equal to the total
     141     supply and all the supplies have to be carried out from the supply nodes,
     142     but there could be demands that are not satisfied.
     143     If \f$\sum_{u\in V} sup(u)\f$ is zero, then all the supply/demand
     144     constraints have to be satisfied with equality, i.e. all demands
     145     have to be satisfied and all supplies have to be used.
     146     
     147     If you need the opposite inequalities in the supply/demand constraints
     148     (i.e. the total demand is less than the total supply and all the demands
     149     have to be satisfied while there could be supplies that are not used),
     150     then you could easily transform the problem to the above form by reversing
     151     the direction of the arcs and taking the negative of the supply values
     152     (e.g. using \ref ReverseDigraph and \ref NegMap adaptors).
     153
     154     Note that this algorithm also provides a feasible solution for the
     155     \ref min_cost_flow "minimum cost flow problem".
    139156
    140157     \tparam GR The type of the digraph the algorithm runs on.
    141      \tparam LM The type of the lower bound capacity map. The default
     158     \tparam LM The type of the lower bound map. The default
    142159     map type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>".
    143      \tparam UM The type of the upper bound capacity map. The default
    144      map type is \c LM.
    145      \tparam DM The type of the map that stores the lower bound
    146      for the supply of the nodes. The default map type is
     160     \tparam UM The type of the upper bound (capacity) map.
     161     The default map type is \c LM.
     162     \tparam SM The type of the supply map. The default map type is
    147163     \ref concepts::Digraph::NodeMap "GR::NodeMap<UM::Value>".
    148164  */
    149165#ifdef DOXYGEN
    150166template< typename GR,
    151167          typename LM,
    152168          typename UM,
    153           typename DM,
     169          typename SM,
    154170          typename TR >
    155171#else
    156172template< typename GR,
    157173          typename LM = typename GR::template ArcMap<int>,
    158174          typename UM = LM,
    159           typename DM = typename GR::template NodeMap<typename UM::Value>,
    160           typename TR = CirculationDefaultTraits<GR, LM, UM, DM> >
     175          typename SM = typename GR::template NodeMap<typename UM::Value>,
     176          typename TR = CirculationDefaultTraits<GR, LM, UM, SM> >
    161177#endif
    162178  class Circulation {
    163179  public:
     
    167183    ///The type of the digraph the algorithm runs on.
    168184    typedef typename Traits::Digraph Digraph;
    169185    ///The type of the flow values.
    170     typedef typename Traits::Value Value;
     186    typedef typename Traits::Flow Flow;
    171187
    172     /// The type of the lower bound capacity map.
    173     typedef typename Traits::LCapMap LCapMap;
    174     /// The type of the upper bound capacity map.
    175     typedef typename Traits::UCapMap UCapMap;
    176     /// \brief The type of the map that stores the lower bound for
    177     /// the supply of the nodes.
    178     typedef typename Traits::DeltaMap DeltaMap;
     188    ///The type of the lower bound map.
     189    typedef typename Traits::LowerMap LowerMap;
     190    ///The type of the upper bound (capacity) map.
     191    typedef typename Traits::UpperMap UpperMap;
     192    ///The type of the supply map.
     193    typedef typename Traits::SupplyMap SupplyMap;
    179194    ///The type of the flow map.
    180195    typedef typename Traits::FlowMap FlowMap;
    181196
     
    191206    const Digraph &_g;
    192207    int _node_num;
    193208
    194     const LCapMap *_lo;
    195     const UCapMap *_up;
    196     const DeltaMap *_delta;
     209    const LowerMap *_lo;
     210    const UpperMap *_up;
     211    const SupplyMap *_supply;
    197212
    198213    FlowMap *_flow;
    199214    bool _local_flow;
     
    201216    Elevator* _level;
    202217    bool _local_level;
    203218
    204     typedef typename Digraph::template NodeMap<Value> ExcessMap;
     219    typedef typename Digraph::template NodeMap<Flow> ExcessMap;
    205220    ExcessMap* _excess;
    206221
    207222    Tolerance _tol;
     
    231246    /// type.
    232247    template <typename _FlowMap>
    233248    struct SetFlowMap
    234       : public Circulation<Digraph, LCapMap, UCapMap, DeltaMap,
     249      : public Circulation<Digraph, LowerMap, UpperMap, SupplyMap,
    235250                           SetFlowMapTraits<_FlowMap> > {
    236       typedef Circulation<Digraph, LCapMap, UCapMap, DeltaMap,
     251      typedef Circulation<Digraph, LowerMap, UpperMap, SupplyMap,
    237252                          SetFlowMapTraits<_FlowMap> > Create;
    238253    };
    239254
     
    257272    /// \sa SetStandardElevator
    258273    template <typename _Elevator>
    259274    struct SetElevator
    260       : public Circulation<Digraph, LCapMap, UCapMap, DeltaMap,
     275      : public Circulation<Digraph, LowerMap, UpperMap, SupplyMap,
    261276                           SetElevatorTraits<_Elevator> > {
    262       typedef Circulation<Digraph, LCapMap, UCapMap, DeltaMap,
     277      typedef Circulation<Digraph, LowerMap, UpperMap, SupplyMap,
    263278                          SetElevatorTraits<_Elevator> > Create;
    264279    };
    265280
     
    285300    /// \sa SetElevator
    286301    template <typename _Elevator>
    287302    struct SetStandardElevator
    288       : public Circulation<Digraph, LCapMap, UCapMap, DeltaMap,
     303      : public Circulation<Digraph, LowerMap, UpperMap, SupplyMap,
    289304                       SetStandardElevatorTraits<_Elevator> > {
    290       typedef Circulation<Digraph, LCapMap, UCapMap, DeltaMap,
     305      typedef Circulation<Digraph, LowerMap, UpperMap, SupplyMap,
    291306                      SetStandardElevatorTraits<_Elevator> > Create;
    292307    };
    293308
     
    299314
    300315  public:
    301316
    302     /// The constructor of the class.
     317    /// Constructor.
    303318
    304319    /// The constructor of the class.
    305     /// \param g The digraph the algorithm runs on.
    306     /// \param lo The lower bound capacity of the arcs.
    307     /// \param up The upper bound capacity of the arcs.
    308     /// \param delta The lower bound for the supply of the nodes.
    309     Circulation(const Digraph &g,const LCapMap &lo,
    310                 const UCapMap &up,const DeltaMap &delta)
    311       : _g(g), _node_num(),
    312         _lo(&lo),_up(&up),_delta(&delta),_flow(0),_local_flow(false),
    313         _level(0), _local_level(false), _excess(0), _el() {}
     320    ///
     321    /// \param graph The digraph the algorithm runs on.
     322    /// \param lower The lower bounds for the flow values on the arcs.
     323    /// \param upper The upper bounds (capacities) for the flow values
     324    /// on the arcs.
     325    /// \param supply The signed supply values of the nodes.
     326    Circulation(const Digraph &graph, const LowerMap &lower,
     327                const UpperMap &upper, const SupplyMap &supply)
     328      : _g(graph), _lo(&lower), _up(&upper), _supply(&supply),
     329        _flow(NULL), _local_flow(false), _level(NULL), _local_level(false),
     330        _excess(NULL) {}
    314331
    315332    /// Destructor.
    316333    ~Circulation() {
     
    350367
    351368  public:
    352369
    353     /// Sets the lower bound capacity map.
     370    /// Sets the lower bound map.
    354371
    355     /// Sets the lower bound capacity map.
     372    /// Sets the lower bound map.
    356373    /// \return <tt>(*this)</tt>
    357     Circulation& lowerCapMap(const LCapMap& map) {
     374    Circulation& lowerMap(const LowerMap& map) {
    358375      _lo = &map;
    359376      return *this;
    360377    }
    361378
    362     /// Sets the upper bound capacity map.
     379    /// Sets the upper bound (capacity) map.
    363380
    364     /// Sets the upper bound capacity map.
     381    /// Sets the upper bound (capacity) map.
    365382    /// \return <tt>(*this)</tt>
    366     Circulation& upperCapMap(const LCapMap& map) {
     383    Circulation& upperMap(const LowerMap& map) {
    367384      _up = &map;
    368385      return *this;
    369386    }
    370387
    371     /// Sets the lower bound map for the supply of the nodes.
     388    /// Sets the supply map.
    372389
    373     /// Sets the lower bound map for the supply of the nodes.
     390    /// Sets the supply map.
    374391    /// \return <tt>(*this)</tt>
    375     Circulation& deltaMap(const DeltaMap& map) {
    376       _delta = &map;
     392    Circulation& supplyMap(const SupplyMap& map) {
     393      _supply = &map;
    377394      return *this;
    378395    }
    379396
     
    453470      createStructures();
    454471
    455472      for(NodeIt n(_g);n!=INVALID;++n) {
    456         _excess->set(n, (*_delta)[n]);
     473        _excess->set(n, (*_supply)[n]);
    457474      }
    458475
    459476      for (ArcIt e(_g);e!=INVALID;++e) {
     
    482499      createStructures();
    483500
    484501      for(NodeIt n(_g);n!=INVALID;++n) {
    485         _excess->set(n, (*_delta)[n]);
     502        _excess->set(n, (*_supply)[n]);
    486503      }
    487504
    488505      for (ArcIt e(_g);e!=INVALID;++e) {
     
    495512          _excess->set(_g.target(e), (*_excess)[_g.target(e)] + (*_lo)[e]);
    496513          _excess->set(_g.source(e), (*_excess)[_g.source(e)] - (*_lo)[e]);
    497514        } else {
    498           Value fc = -(*_excess)[_g.target(e)];
     515          Flow fc = -(*_excess)[_g.target(e)];
    499516          _flow->set(e, fc);
    500517          _excess->set(_g.target(e), 0);
    501518          _excess->set(_g.source(e), (*_excess)[_g.source(e)] - fc);
     
    528545      while((act=_level->highestActive())!=INVALID) {
    529546        int actlevel=(*_level)[act];
    530547        int mlevel=_node_num;
    531         Value exc=(*_excess)[act];
     548        Flow exc=(*_excess)[act];
    532549
    533550        for(OutArcIt e(_g,act);e!=INVALID; ++e) {
    534551          Node v = _g.target(e);
    535           Value fc=(*_up)[e]-(*_flow)[e];
     552          Flow fc=(*_up)[e]-(*_flow)[e];
    536553          if(!_tol.positive(fc)) continue;
    537554          if((*_level)[v]<actlevel) {
    538555            if(!_tol.less(fc, exc)) {
     
    556573        }
    557574        for(InArcIt e(_g,act);e!=INVALID; ++e) {
    558575          Node v = _g.source(e);
    559           Value fc=(*_flow)[e]-(*_lo)[e];
     576          Flow fc=(*_flow)[e]-(*_lo)[e];
    560577          if(!_tol.positive(fc)) continue;
    561578          if((*_level)[v]<actlevel) {
    562579            if(!_tol.less(fc, exc)) {
     
    632649    ///
    633650    /// \pre Either \ref run() or \ref init() must be called before
    634651    /// using this function.
    635     Value flow(const Arc& arc) const {
     652    Flow flow(const Arc& arc) const {
    636653      return (*_flow)[arc];
    637654    }
    638655
     
    651668
    652669       Barrier is a set \e B of nodes for which
    653670
    654        \f[ \sum_{a\in\delta_{out}(B)} upper(a) -
    655            \sum_{a\in\delta_{in}(B)} lower(a) < \sum_{v\in B}delta(v) \f]
     671       \f[ \sum_{uv\in A: u\in B} upper(uv) -
     672           \sum_{uv\in A: v\in B} lower(uv) < \sum_{v\in B} sup(v) \f]
    656673
    657674       holds. The existence of a set with this property prooves that a
    658675       feasible circualtion cannot exist.
     
    715732        if((*_flow)[e]<(*_lo)[e]||(*_flow)[e]>(*_up)[e]) return false;
    716733      for(NodeIt n(_g);n!=INVALID;++n)
    717734        {
    718           Value dif=-(*_delta)[n];
     735          Flow dif=-(*_supply)[n];
    719736          for(InArcIt e(_g,n);e!=INVALID;++e) dif-=(*_flow)[e];
    720737          for(OutArcIt e(_g,n);e!=INVALID;++e) dif+=(*_flow)[e];
    721738          if(_tol.negative(dif)) return false;
     
    730747    ///\sa barrierMap()
    731748    bool checkBarrier() const
    732749    {
    733       Value delta=0;
     750      Flow delta=0;
    734751      for(NodeIt n(_g);n!=INVALID;++n)
    735752        if(barrier(n))
    736           delta-=(*_delta)[n];
     753          delta-=(*_supply)[n];
    737754      for(ArcIt e(_g);e!=INVALID;++e)
    738755        {
    739756          Node s=_g.source(e);
  • lemon/preflow.h

    diff --git a/lemon/preflow.h b/lemon/preflow.h
    a b  
    4646    typedef CM CapacityMap;
    4747
    4848    /// \brief The type of the flow values.
    49     typedef typename CapacityMap::Value Value;
     49    typedef typename CapacityMap::Value Flow;
    5050
    5151    /// \brief The type of the map that stores the flow values.
    5252    ///
    5353    /// The type of the map that stores the flow values.
    5454    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
    55     typedef typename Digraph::template ArcMap<Value> FlowMap;
     55    typedef typename Digraph::template ArcMap<Flow> FlowMap;
    5656
    5757    /// \brief Instantiates a FlowMap.
    5858    ///
    5959    /// This function instantiates a \ref FlowMap.
    60     /// \param digraph The digraph, to which we would like to define
     60    /// \param digraph The digraph for which we would like to define
    6161    /// the flow map.
    6262    static FlowMap* createFlowMap(const Digraph& digraph) {
    6363      return new FlowMap(digraph);
     
    7474    /// \brief Instantiates an Elevator.
    7575    ///
    7676    /// This function instantiates an \ref Elevator.
    77     /// \param digraph The digraph, to which we would like to define
     77    /// \param digraph The digraph for which we would like to define
    7878    /// the elevator.
    7979    /// \param max_level The maximum level of the elevator.
    8080    static Elevator* createElevator(const Digraph& digraph, int max_level) {
     
    8484    /// \brief The tolerance used by the algorithm
    8585    ///
    8686    /// The tolerance used by the algorithm to handle inexact computation.
    87     typedef lemon::Tolerance<Value> Tolerance;
     87    typedef lemon::Tolerance<Flow> Tolerance;
    8888
    8989  };
    9090
     
    124124    ///The type of the capacity map.
    125125    typedef typename Traits::CapacityMap CapacityMap;
    126126    ///The type of the flow values.
    127     typedef typename Traits::Value Value;
     127    typedef typename Traits::Flow Flow;
    128128
    129129    ///The type of the flow map.
    130130    typedef typename Traits::FlowMap FlowMap;
     
    150150    Elevator* _level;
    151151    bool _local_level;
    152152
    153     typedef typename Digraph::template NodeMap<Value> ExcessMap;
     153    typedef typename Digraph::template NodeMap<Flow> ExcessMap;
    154154    ExcessMap* _excess;
    155155
    156156    Tolerance _tolerance;
     
    469469      }
    470470
    471471      for (NodeIt n(_graph); n != INVALID; ++n) {
    472         Value excess = 0;
     472        Flow excess = 0;
    473473        for (InArcIt e(_graph, n); e != INVALID; ++e) {
    474474          excess += (*_flow)[e];
    475475        }
     
    518518      _level->initFinish();
    519519
    520520      for (OutArcIt e(_graph, _source); e != INVALID; ++e) {
    521         Value rem = (*_capacity)[e] - (*_flow)[e];
     521        Flow rem = (*_capacity)[e] - (*_flow)[e];
    522522        if (_tolerance.positive(rem)) {
    523523          Node u = _graph.target(e);
    524524          if ((*_level)[u] == _level->maxLevel()) continue;
     
    530530        }
    531531      }
    532532      for (InArcIt e(_graph, _source); e != INVALID; ++e) {
    533         Value rem = (*_flow)[e];
     533        Flow rem = (*_flow)[e];
    534534        if (_tolerance.positive(rem)) {
    535535          Node v = _graph.source(e);
    536536          if ((*_level)[v] == _level->maxLevel()) continue;
     
    563563        int num = _node_num;
    564564
    565565        while (num > 0 && n != INVALID) {
    566           Value excess = (*_excess)[n];
     566          Flow excess = (*_excess)[n];
    567567          int new_level = _level->maxLevel();
    568568
    569569          for (OutArcIt e(_graph, n); e != INVALID; ++e) {
    570             Value rem = (*_capacity)[e] - (*_flow)[e];
     570            Flow rem = (*_capacity)[e] - (*_flow)[e];
    571571            if (!_tolerance.positive(rem)) continue;
    572572            Node v = _graph.target(e);
    573573            if ((*_level)[v] < level) {
     
    590590          }
    591591
    592592          for (InArcIt e(_graph, n); e != INVALID; ++e) {
    593             Value rem = (*_flow)[e];
     593            Flow rem = (*_flow)[e];
    594594            if (!_tolerance.positive(rem)) continue;
    595595            Node v = _graph.source(e);
    596596            if ((*_level)[v] < level) {
     
    636636
    637637        num = _node_num * 20;
    638638        while (num > 0 && n != INVALID) {
    639           Value excess = (*_excess)[n];
     639          Flow excess = (*_excess)[n];
    640640          int new_level = _level->maxLevel();
    641641
    642642          for (OutArcIt e(_graph, n); e != INVALID; ++e) {
    643             Value rem = (*_capacity)[e] - (*_flow)[e];
     643            Flow rem = (*_capacity)[e] - (*_flow)[e];
    644644            if (!_tolerance.positive(rem)) continue;
    645645            Node v = _graph.target(e);
    646646            if ((*_level)[v] < level) {
     
    663663          }
    664664
    665665          for (InArcIt e(_graph, n); e != INVALID; ++e) {
    666             Value rem = (*_flow)[e];
     666            Flow rem = (*_flow)[e];
    667667            if (!_tolerance.positive(rem)) continue;
    668668            Node v = _graph.source(e);
    669669            if ((*_level)[v] < level) {
     
    777777
    778778      Node n;
    779779      while ((n = _level->highestActive()) != INVALID) {
    780         Value excess = (*_excess)[n];
     780        Flow excess = (*_excess)[n];
    781781        int level = _level->highestActiveLevel();
    782782        int new_level = _level->maxLevel();
    783783
    784784        for (OutArcIt e(_graph, n); e != INVALID; ++e) {
    785           Value rem = (*_capacity)[e] - (*_flow)[e];
     785          Flow rem = (*_capacity)[e] - (*_flow)[e];
    786786          if (!_tolerance.positive(rem)) continue;
    787787          Node v = _graph.target(e);
    788788          if ((*_level)[v] < level) {
     
    805805        }
    806806
    807807        for (InArcIt e(_graph, n); e != INVALID; ++e) {
    808           Value rem = (*_flow)[e];
     808          Flow rem = (*_flow)[e];
    809809          if (!_tolerance.positive(rem)) continue;
    810810          Node v = _graph.source(e);
    811811          if ((*_level)[v] < level) {
     
    896896    ///
    897897    /// \pre Either \ref run() or \ref init() must be called before
    898898    /// using this function.
    899     Value flowValue() const {
     899    Flow flowValue() const {
    900900      return (*_excess)[_target];
    901901    }
    902902
     
    907907    ///
    908908    /// \pre Either \ref run() or \ref init() must be called before
    909909    /// using this function.
    910     Value flow(const Arc& arc) const {
     910    Flow flow(const Arc& arc) const {
    911911      return (*_flow)[arc];
    912912    }
    913913
  • test/circulation_test.cc

    diff --git a/test/circulation_test.cc b/test/circulation_test.cc
    a b  
    5757  typedef Digraph::Node Node;
    5858  typedef Digraph::Arc Arc;
    5959  typedef concepts::ReadMap<Arc,VType> CapMap;
    60   typedef concepts::ReadMap<Node,VType> DeltaMap;
     60  typedef concepts::ReadMap<Node,VType> SupplyMap;
    6161  typedef concepts::ReadWriteMap<Arc,VType> FlowMap;
    6262  typedef concepts::WriteMap<Node,bool> BarrierMap;
    6363
     
    6868  Node n;
    6969  Arc a;
    7070  CapMap lcap, ucap;
    71   DeltaMap delta;
     71  SupplyMap supply;
    7272  FlowMap flow;
    7373  BarrierMap bar;
    7474
    75   Circulation<Digraph, CapMap, CapMap, DeltaMap>
     75  Circulation<Digraph, CapMap, CapMap, SupplyMap>
    7676    ::SetFlowMap<FlowMap>
    7777    ::SetElevator<Elev>
    7878    ::SetStandardElevator<LinkedElev>
    79     ::Create circ_test(g,lcap,ucap,delta);
     79    ::Create circ_test(g,lcap,ucap,supply);
    8080
    81   circ_test.lowerCapMap(lcap);
    82   circ_test.upperCapMap(ucap);
    83   circ_test.deltaMap(delta);
     81  circ_test.lowerMap(lcap);
     82  circ_test.upperMap(ucap);
     83  circ_test.supplyMap(supply);
    8484  flow = circ_test.flowMap();
    8585  circ_test.flowMap(flow);
    8686