COIN-OR::LEMON - Graph Library

Ticket #298: 298-new-impr-5a74b94f19c5.patch

File 298-new-impr-5a74b94f19c5.patch, 2.2 KB (added by Peter Kovacs, 15 years ago)

An extended version of the previous patch

  • lemon/network_simplex.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1253038577 -7200
    # Node ID 5a74b94f19c509485ea3c79001e4a7c6b5e2879b
    # Parent  6d5f547e5bfb8131568ad50ea406129a056ac9ed
    Small improvements for NetworkSimplex (#298)
    
    diff --git a/lemon/network_simplex.h b/lemon/network_simplex.h
    a b  
    161161
    162162    TEMPLATE_DIGRAPH_TYPEDEFS(GR);
    163163
    164     typedef std::vector<Arc> ArcVector;
    165     typedef std::vector<Node> NodeVector;
    166164    typedef std::vector<int> IntVector;
    167165    typedef std::vector<bool> BoolVector;
    168166    typedef std::vector<Value> ValueVector;
     
    685683        if ((i += k) >= _arc_num) i = (i % k) + 1;
    686684      }
    687685     
    688       // Initialize maps
    689       for (int i = 0; i != _node_num; ++i) {
    690         _supply[i] = 0;
    691       }
    692       for (int i = 0; i != _arc_num; ++i) {
    693         _lower[i] = 0;
    694         _upper[i] = INF;
    695         _cost[i] = 1;
    696       }
    697       _have_lower = false;
    698       _stype = GEQ;
     686      // Reset parameters
     687      reset();
    699688    }
    700689
    701690    /// \name Parameters
     
    768757    /// This function sets the supply values of the nodes.
    769758    /// If neither this function nor \ref stSupply() is used before
    770759    /// calling \ref run(), the supply of each node will be set to zero.
    771     /// (It makes sense only if non-zero lower bounds are given.)
    772760    ///
    773761    /// \param map A node map storing the supply values.
    774762    /// Its \c Value type must be convertible to the \c Value type
     
    789777    /// and the required flow value.
    790778    /// If neither this function nor \ref supplyMap() is used before
    791779    /// calling \ref run(), the supply of each node will be set to zero.
    792     /// (It makes sense only if non-zero lower bounds are given.)
    793780    ///
    794781    /// Using this function has the same effect as using \ref supplyMap()
    795782    /// with such a map in which \c k is assigned to \c s, \c -k is
     
    944931      Number c = 0;
    945932      for (ArcIt a(_graph); a != INVALID; ++a) {
    946933        int i = _arc_id[a];
    947         c += Number(_flow[i]) * Number(_cost[i]);
     934        c += static_cast<Number>(_flow[i]) * static_cast<Number>(_cost[i]);
    948935      }
    949936      return c;
    950937    }