src/lemon/min_cost_flow.h
changeset 1026 bd7ea1a718e2
parent 986 e997802b855c
child 1027 4ec35d1cd897
equal deleted inserted replaced
2:bc89ef68e59a 3:1acd38c45e92
    57   ///
    57   ///
    58   ///\author Attila Bernath
    58   ///\author Attila Bernath
    59   template <typename Graph, typename LengthMap, typename CapacityMap>
    59   template <typename Graph, typename LengthMap, typename CapacityMap>
    60   class MinCostFlow {
    60   class MinCostFlow {
    61 
    61 
    62     typedef typename LengthMap::ValueType Length;
    62     typedef typename LengthMap::Value Length;
    63 
    63 
    64     //Warning: this should be integer type
    64     //Warning: this should be integer type
    65     typedef typename CapacityMap::ValueType Capacity;
    65     typedef typename CapacityMap::Value Capacity;
    66     
    66     
    67     typedef typename Graph::Node Node;
    67     typedef typename Graph::Node Node;
    68     typedef typename Graph::NodeIt NodeIt;
    68     typedef typename Graph::NodeIt NodeIt;
    69     typedef typename Graph::Edge Edge;
    69     typedef typename Graph::Edge Edge;
    70     typedef typename Graph::OutEdgeIt OutEdgeIt;
    70     typedef typename Graph::OutEdgeIt OutEdgeIt;
    92       typedef typename Graph::template NodeMap<Length> NodeMap;
    92       typedef typename Graph::template NodeMap<Length> NodeMap;
    93       const ResGW& g;
    93       const ResGW& g;
    94       const LengthMap &length;
    94       const LengthMap &length;
    95       const NodeMap &pot;
    95       const NodeMap &pot;
    96     public :
    96     public :
    97       typedef typename LengthMap::KeyType KeyType;
    97       typedef typename LengthMap::Key Key;
    98       typedef typename LengthMap::ValueType ValueType;
    98       typedef typename LengthMap::Value Value;
    99 
    99 
   100       ModLengthMap(const ResGW& _g, 
   100       ModLengthMap(const ResGW& _g, 
   101 		   const LengthMap &_length, const NodeMap &_pot) : 
   101 		   const LengthMap &_length, const NodeMap &_pot) : 
   102 	g(_g), /*rev(_rev),*/ length(_length), pot(_pot) { }
   102 	g(_g), /*rev(_rev),*/ length(_length), pot(_pot) { }
   103 	
   103 	
   104       ValueType operator[](typename ResGW::Edge e) const {     
   104       Value operator[](typename ResGW::Edge e) const {     
   105 	if (g.forward(e))
   105 	if (g.forward(e))
   106 	  return  length[e]-(pot[g.target(e)]-pot[g.source(e)]);   
   106 	  return  length[e]-(pot[g.target(e)]-pot[g.source(e)]);   
   107 	else
   107 	else
   108 	  return -length[e]-(pot[g.target(e)]-pot[g.source(e)]);   
   108 	  return -length[e]-(pot[g.target(e)]-pot[g.source(e)]);   
   109       }     
   109       }