src/work/edmonds_karp.hh
changeset 140 ca164520d31a
parent 135 1e5060d1fa1d
child 141 a17d2a6462ee
equal deleted inserted replaced
10:80860ab66948 11:1a9a18a884ef
   450     NodeIt bNode(OutEdgeIt e) const { 
   450     NodeIt bNode(OutEdgeIt e) const { 
   451       return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
   451       return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
   452 
   452 
   453     int id(NodeIt v) const { return G.id(v); }
   453     int id(NodeIt v) const { return G.id(v); }
   454 
   454 
   455     template <typename S>
   455     template <typename T>
   456     class NodeMap {
   456     class NodeMap {
   457       typename Graph::NodeMap<S> node_map; 
   457       typename Graph::NodeMap<T> node_map; 
   458     public:
   458     public:
   459       NodeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(_G.G) { }
   459       NodeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(_G.G) { }
   460       NodeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G, S a) : node_map(_G.G, a) { }
   460       NodeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G, T a) : node_map(_G.G, a) { }
   461       void set(NodeIt nit, S a) { node_map.set(nit, a); }
   461       void set(NodeIt nit, T a) { node_map.set(nit, a); }
   462       S get(NodeIt nit) const { return node_map.get(nit); }
   462       T get(NodeIt nit) const { return node_map.get(nit); }
       
   463     };
       
   464 
       
   465     template <typename T>
       
   466     class EdgeMap {
       
   467       typename Graph::EdgeMap<T> forward_map, backward_map; 
       
   468     public:
       
   469       EdgeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.G), backward_map(_G.G) { }
       
   470       EdgeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.G, a), backward_map(_G.G, a) { }
       
   471       void set(EdgeIt e, T a) { 
       
   472 	if (e.out_or_in) 
       
   473 	  forward_map.set(e.out, a); 
       
   474 	else 
       
   475 	  backward_map.set(e.in, a); 
       
   476       }
       
   477       T get(EdgeIt e) { 
       
   478 	if (e.out_or_in) 
       
   479 	  return forward_map.get(e.out); 
       
   480 	else 
       
   481 	  return backward_map.get(e.in); 
       
   482       }
   463     };
   483     };
   464 
   484 
   465   };
   485   };
   466 
       
   467 
   486 
   468   template <typename Graph, typename Number, typename FlowMap, typename CapacityMap>
   487   template <typename Graph, typename Number, typename FlowMap, typename CapacityMap>
   469   class MaxFlow {
   488   class MaxFlow {
   470   public:
   489   public:
   471     typedef typename Graph::NodeIt NodeIt;
   490     typedef typename Graph::NodeIt NodeIt;