ResGraph3::EdgeMap<T>
authormarci
Mon, 01 Mar 2004 11:33:10 +0000
changeset 1376364b07f8cd4
parent 136 e342e66d9762
child 138 c6297c121409
ResGraph3::EdgeMap<T>
src/work/edmonds_karp.hh
     1.1 --- a/src/work/edmonds_karp.hh	Fri Feb 27 14:20:47 2004 +0000
     1.2 +++ b/src/work/edmonds_karp.hh	Mon Mar 01 11:33:10 2004 +0000
     1.3 @@ -452,19 +452,38 @@
     1.4  
     1.5      int id(NodeIt v) const { return G.id(v); }
     1.6  
     1.7 -    template <typename S>
     1.8 +    template <typename T>
     1.9      class NodeMap {
    1.10 -      typename Graph::NodeMap<S> node_map; 
    1.11 +      typename Graph::NodeMap<T> node_map; 
    1.12      public:
    1.13        NodeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(_G.G) { }
    1.14 -      NodeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G, S a) : node_map(_G.G, a) { }
    1.15 -      void set(NodeIt nit, S a) { node_map.set(nit, a); }
    1.16 -      S get(NodeIt nit) const { return node_map.get(nit); }
    1.17 +      NodeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G, T a) : node_map(_G.G, a) { }
    1.18 +      void set(NodeIt nit, T a) { node_map.set(nit, a); }
    1.19 +      T get(NodeIt nit) const { return node_map.get(nit); }
    1.20 +    };
    1.21 +
    1.22 +    template <typename T>
    1.23 +    class EdgeMap {
    1.24 +      typename Graph::EdgeMap<T> forward_map, backward_map; 
    1.25 +    public:
    1.26 +      EdgeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.G), backward_map(_G.G) { }
    1.27 +      EdgeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.G, a), backward_map(_G.G, a) { }
    1.28 +      void set(EdgeIt e, T a) { 
    1.29 +	if (e.out_or_in) 
    1.30 +	  forward_map.set(e.out, a); 
    1.31 +	else 
    1.32 +	  backward_map.set(e.in, a); 
    1.33 +      }
    1.34 +      T get(EdgeIt e) { 
    1.35 +	if (e.out_or_in) 
    1.36 +	  return forward_map.get(e.out); 
    1.37 +	else 
    1.38 +	  return backward_map.get(e.in); 
    1.39 +      }
    1.40      };
    1.41  
    1.42    };
    1.43  
    1.44 -
    1.45    template <typename Graph, typename Number, typename FlowMap, typename CapacityMap>
    1.46    class MaxFlow {
    1.47    public: