lemon/cost_scaling.h
changeset 1298 a78e5b779b69
parent 1271 fb1c7da561ce
parent 1297 c0c2f5c87aa6
     1.1 --- a/lemon/cost_scaling.h	Wed Sep 25 11:15:56 2013 +0200
     1.2 +++ b/lemon/cost_scaling.h	Thu Oct 17 15:08:41 2013 +0200
     1.3 @@ -256,7 +256,7 @@
     1.4      int _root;
     1.5  
     1.6      // Parameters of the problem
     1.7 -    bool _have_lower;
     1.8 +    bool _has_lower;
     1.9      Value _sum_supply;
    1.10      int _sup_node_num;
    1.11  
    1.12 @@ -372,10 +372,9 @@
    1.13      /// \return <tt>(*this)</tt>
    1.14      template <typename LowerMap>
    1.15      CostScaling& lowerMap(const LowerMap& map) {
    1.16 -      _have_lower = true;
    1.17 +      _has_lower = true;
    1.18        for (ArcIt a(_graph); a != INVALID; ++a) {
    1.19          _lower[_arc_idf[a]] = map[a];
    1.20 -        _lower[_arc_idb[a]] = map[a];
    1.21        }
    1.22        return *this;
    1.23      }
    1.24 @@ -568,7 +567,7 @@
    1.25          _scost[j] = 0;
    1.26          _scost[_reverse[j]] = 0;
    1.27        }
    1.28 -      _have_lower = false;
    1.29 +      _has_lower = false;
    1.30        return *this;
    1.31      }
    1.32  
    1.33 @@ -780,7 +779,7 @@
    1.34        // Remove infinite upper bounds and check negative arcs
    1.35        const Value MAX = std::numeric_limits<Value>::max();
    1.36        int last_out;
    1.37 -      if (_have_lower) {
    1.38 +      if (_has_lower) {
    1.39          for (int i = 0; i != _root; ++i) {
    1.40            last_out = _first_out[i+1];
    1.41            for (int j = _first_out[i]; j != last_out; ++j) {
    1.42 @@ -837,7 +836,7 @@
    1.43        for (NodeIt n(_graph); n != INVALID; ++n) {
    1.44          sup[n] = _supply[_node_id[n]];
    1.45        }
    1.46 -      if (_have_lower) {
    1.47 +      if (_has_lower) {
    1.48          for (ArcIt a(_graph); a != INVALID; ++a) {
    1.49            int j = _arc_idf[a];
    1.50            Value c = _lower[j];
    1.51 @@ -907,11 +906,11 @@
    1.52        return OPTIMAL;
    1.53      }
    1.54  
    1.55 -    // Check if the upper bound is greater or equal to the lower bound
    1.56 -    // on each arc.
    1.57 +    // Check if the upper bound is greater than or equal to the lower bound
    1.58 +    // on each forward arc.
    1.59      bool checkBoundMaps() {
    1.60        for (int j = 0; j != _res_arc_num; ++j) {
    1.61 -        if (_upper[j] < _lower[j]) return false;
    1.62 +        if (_forward[j] && _upper[j] < _lower[j]) return false;
    1.63        }
    1.64        return true;
    1.65      }
    1.66 @@ -991,10 +990,10 @@
    1.67        }
    1.68  
    1.69        // Handle non-zero lower bounds
    1.70 -      if (_have_lower) {
    1.71 +      if (_has_lower) {
    1.72          int limit = _first_out[_root];
    1.73          for (int j = 0; j != limit; ++j) {
    1.74 -          if (!_forward[j]) _res_cap[j] += _lower[j];
    1.75 +          if (_forward[j]) _res_cap[_reverse[j]] += _lower[j];
    1.76          }
    1.77        }
    1.78      }