src/work/athos/mincostflow.h
changeset 1044 f97380557656
parent 986 e997802b855c
equal deleted inserted replaced
10:db34e7e4db09 11:8b91160ad2a6
    41   ///
    41   ///
    42   ///\author Attila Bernath
    42   ///\author Attila Bernath
    43   template <typename Graph, typename CostMap, typename SupplyDemandMap>
    43   template <typename Graph, typename CostMap, typename SupplyDemandMap>
    44   class MinCostFlow {
    44   class MinCostFlow {
    45 
    45 
    46     typedef typename CostMap::ValueType Cost;
    46     typedef typename CostMap::Value Cost;
    47 
    47 
    48 
    48 
    49     typedef typename SupplyDemandMap::ValueType SupplyDemand;
    49     typedef typename SupplyDemandMap::Value SupplyDemand;
    50     
    50     
    51     typedef typename Graph::Node Node;
    51     typedef typename Graph::Node Node;
    52     typedef typename Graph::NodeIt NodeIt;
    52     typedef typename Graph::NodeIt NodeIt;
    53     typedef typename Graph::Edge Edge;
    53     typedef typename Graph::Edge Edge;
    54     typedef typename Graph::OutEdgeIt OutEdgeIt;
    54     typedef typename Graph::OutEdgeIt OutEdgeIt;
    66       const ResGraph& res_graph;
    66       const ResGraph& res_graph;
    67       //      const EdgeIntMap& rev;
    67       //      const EdgeIntMap& rev;
    68       const CostMap &ol;
    68       const CostMap &ol;
    69       const NodeMap &pot;
    69       const NodeMap &pot;
    70     public :
    70     public :
    71       typedef typename CostMap::KeyType KeyType;
    71       typedef typename CostMap::Key Key;
    72       typedef typename CostMap::ValueType ValueType;
    72       typedef typename CostMap::Value Value;
    73 	
    73 	
    74       ValueType operator[](typename ResGraph::Edge e) const {     
    74       Value operator[](typename ResGraph::Edge e) const {     
    75 	if (res_graph.forward(e))
    75 	if (res_graph.forward(e))
    76 	  return  ol[e]-(pot[res_graph.target(e)]-pot[res_graph.source(e)]);   
    76 	  return  ol[e]-(pot[res_graph.target(e)]-pot[res_graph.source(e)]);   
    77 	else
    77 	else
    78 	  return -ol[e]-(pot[res_graph.target(e)]-pot[res_graph.source(e)]);   
    78 	  return -ol[e]-(pot[res_graph.target(e)]-pot[res_graph.source(e)]);   
    79       }     
    79       }