lemon/howard.h
changeset 814 11c946fa8d13
parent 811 1fac515a59c1
child 815 0a42883c8221
     1.1 --- a/lemon/howard.h	Tue Aug 11 21:53:39 2009 +0200
     1.2 +++ b/lemon/howard.h	Tue Aug 11 22:52:35 2009 +0200
     1.3 @@ -178,6 +178,9 @@
     1.4  
     1.5      Tolerance _tolerance;
     1.6    
     1.7 +    // Infinite constant
     1.8 +    const LargeValue INF;
     1.9 +
    1.10    public:
    1.11    
    1.12      /// \name Named Template Parameters
    1.13 @@ -230,9 +233,13 @@
    1.14      /// \param length The lengths (costs) of the arcs.
    1.15      Howard( const Digraph &digraph,
    1.16              const LengthMap &length ) :
    1.17 -      _gr(digraph), _length(length), _cycle_path(NULL), _local_path(false),
    1.18 +      _gr(digraph), _length(length), _best_found(false),
    1.19 +      _best_length(0), _best_size(1), _cycle_path(NULL), _local_path(false),
    1.20        _policy(digraph), _reached(digraph), _level(digraph), _dist(digraph),
    1.21 -      _comp(digraph), _in_arcs(digraph)
    1.22 +      _comp(digraph), _in_arcs(digraph),
    1.23 +      INF(std::numeric_limits<LargeValue>::has_infinity ?
    1.24 +          std::numeric_limits<LargeValue>::infinity() :
    1.25 +          std::numeric_limits<LargeValue>::max())
    1.26      {}
    1.27  
    1.28      /// Destructor.
    1.29 @@ -307,7 +314,7 @@
    1.30            if (!computeNodeDistances()) break;
    1.31          }
    1.32          // Update the best cycle (global minimum mean cycle)
    1.33 -        if ( !_best_found || (_curr_found &&
    1.34 +        if ( _curr_found && (!_best_found ||
    1.35               _curr_length * _best_size < _best_length * _curr_size) ) {
    1.36            _best_found = true;
    1.37            _best_length = _curr_length;
    1.38 @@ -446,7 +453,7 @@
    1.39          return false;
    1.40        }
    1.41        for (int i = 0; i < int(_nodes->size()); ++i) {
    1.42 -        _dist[(*_nodes)[i]] = std::numeric_limits<LargeValue>::max();
    1.43 +        _dist[(*_nodes)[i]] = INF;
    1.44        }
    1.45        Node u, v;
    1.46        Arc e;