[Lemon-commits] [lemon_svn] marci: r208 - in hugo/trunk/src/work: . marci

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:38:07 CET 2006


Author: marci
Date: Wed Mar  3 15:30:38 2004
New Revision: 208

Modified:
   hugo/trunk/src/work/bfs_iterator.hh
   hugo/trunk/src/work/edmonds_karp.hh
   hugo/trunk/src/work/list_graph.hh
   hugo/trunk/src/work/marci/graph_wrapper.h

Log:
G.next(...), G.valid(...), ...


Modified: hugo/trunk/src/work/bfs_iterator.hh
==============================================================================
--- hugo/trunk/src/work/bfs_iterator.hh	(original)
+++ hugo/trunk/src/work/bfs_iterator.hh	Wed Mar  3 15:30:38 2004
@@ -544,7 +544,7 @@
 
 
   template <typename Graph, typename OutEdgeIt, 
-	    typename ReachedMap=typename Graph::NodeMap<bool> >
+	    typename ReachedMap/*=typename Graph::NodeMap<bool>*/ >
   class BfsIterator4 {
     typedef typename Graph::NodeIt NodeIt;
     const Graph& G;
@@ -566,7 +566,7 @@
       if (bfs_queue.empty()) {
 	bfs_queue.push(s);
 	G.getFirst(actual_edge, s);
-	if (actual_edge.valid()) { 
+	if (G.valid(actual_edge)/*.valid()*/) { 
 	  NodeIt w=G.bNode(actual_edge);
 	  if (!reached.get(w)) {
 	    bfs_queue.push(w);
@@ -582,9 +582,9 @@
     }
     BfsIterator4<Graph, OutEdgeIt, ReachedMap>& 
     operator++() { 
-      if (actual_edge.valid()) { 
-	++actual_edge;
-	if (actual_edge.valid()) {
+      if (G.valid(actual_edge)/*.valid()*/) { 
+	/*++*/G.next(actual_edge);
+	if (G.valid(actual_edge)/*.valid()*/) {
 	  NodeIt w=G.bNode(actual_edge);
 	  if (!reached.get(w)) {
 	    bfs_queue.push(w);
@@ -598,7 +598,7 @@
 	bfs_queue.pop(); 
 	if (!bfs_queue.empty()) {
 	  G.getFirst(actual_edge, bfs_queue.front());
-	  if (actual_edge.valid()) {
+	  if (G.valid(actual_edge)/*.valid()*/) {
 	    NodeIt w=G.bNode(actual_edge);
 	    if (!reached.get(w)) {
 	      bfs_queue.push(w);
@@ -615,15 +615,95 @@
     bool finished() const { return bfs_queue.empty(); }
     operator OutEdgeIt () const { return actual_edge; }
     bool isBNodeNewlyReached() const { return b_node_newly_reached; }
-    bool isANodeExamined() const { return !(actual_edge.valid()); }
+    bool isANodeExamined() const { return !(G.valid(actual_edge)/*.valid()*/); }
     NodeIt aNode() const { return bfs_queue.front(); }
     NodeIt bNode() const { return G.bNode(actual_edge); }
     const ReachedMap& getReachedMap() const { return reached; }
     const std::queue<NodeIt>& getBfsQueue() const { return bfs_queue; }
  };  
 
+
+  template <typename GraphWrapper, typename OutEdgeIt, 
+	    typename ReachedMap/*=typename GraphWrapper::NodeMap<bool>*/ >
+  class BfsIterator5 {
+    typedef typename GraphWrapper::NodeIt NodeIt;
+    GraphWrapper G;
+    std::queue<NodeIt> bfs_queue;
+    ReachedMap& reached;
+    bool b_node_newly_reached;
+    OutEdgeIt actual_edge;
+    bool own_reached_map;
+  public:
+    BfsIterator5(const GraphWrapper& _G, ReachedMap& _reached) : 
+      G(_G), reached(_reached), 
+      own_reached_map(false) { }
+    BfsIterator5(const GraphWrapper& _G) : 
+      G(_G), reached(*(new ReachedMap(G /*, false*/))), 
+      own_reached_map(true) { }
+    ~BfsIterator5() { if (own_reached_map) delete &reached; }
+    void pushAndSetReached(NodeIt s) { 
+      reached.set(s, true);
+      if (bfs_queue.empty()) {
+	bfs_queue.push(s);
+	G.getFirst(actual_edge, s);
+	if (G.valid(actual_edge)/*.valid()*/) { 
+	  NodeIt w=G.bNode(actual_edge);
+	  if (!reached.get(w)) {
+	    bfs_queue.push(w);
+	    reached.set(w, true);
+	    b_node_newly_reached=true;
+	  } else {
+	    b_node_newly_reached=false;
+	  }
+	} 
+      } else {
+	bfs_queue.push(s);
+      }
+    }
+    BfsIterator5<GraphWrapper, OutEdgeIt, ReachedMap>& 
+    operator++() { 
+      if (G.valid(actual_edge)/*.valid()*/) { 
+	/*++*/G.next(actual_edge);
+	if (G.valid(actual_edge)/*.valid()*/) {
+	  NodeIt w=G.bNode(actual_edge);
+	  if (!reached.get(w)) {
+	    bfs_queue.push(w);
+	    reached.set(w, true);
+	    b_node_newly_reached=true;
+	  } else {
+	    b_node_newly_reached=false;
+	  }
+	}
+      } else {
+	bfs_queue.pop(); 
+	if (!bfs_queue.empty()) {
+	  G.getFirst(actual_edge, bfs_queue.front());
+	  if (G.valid(actual_edge)/*.valid()*/) {
+	    NodeIt w=G.bNode(actual_edge);
+	    if (!reached.get(w)) {
+	      bfs_queue.push(w);
+	      reached.set(w, true);
+	      b_node_newly_reached=true;
+	    } else {
+	      b_node_newly_reached=false;
+	    }
+	  }
+	}
+      }
+      return *this;
+    }
+    bool finished() const { return bfs_queue.empty(); }
+    operator OutEdgeIt () const { return actual_edge; }
+    bool isBNodeNewlyReached() const { return b_node_newly_reached; }
+    bool isANodeExamined() const { return !(G.valid(actual_edge)/*.valid()*/); }
+    NodeIt aNode() const { return bfs_queue.front(); }
+    NodeIt bNode() const { return G.bNode(actual_edge); }
+    const ReachedMap& getReachedMap() const { return reached; }
+    const std::queue<NodeIt>& getBfsQueue() const { return bfs_queue; }
+  };  
+
   template <typename Graph, typename OutEdgeIt, 
-	    typename ReachedMap=typename Graph::NodeMap<bool> >
+	    typename ReachedMap/*=typename Graph::NodeMap<bool>*/ >
   class DfsIterator4 {
     typedef typename Graph::NodeIt NodeIt;
     const Graph& G;
@@ -650,7 +730,7 @@
     operator++() { 
       actual_edge=dfs_stack.top();
       //actual_node=G.aNode(actual_edge);
-      if (actual_edge.valid()) { 
+      if (G.valid(actual_edge)/*.valid()*/) { 
 	NodeIt w=G.bNode(actual_edge);
 	actual_node=w;
 	if (!reached.get(w)) {
@@ -659,7 +739,7 @@
 	  b_node_newly_reached=true;
 	} else {
 	  actual_node=G.aNode(actual_edge);
-	  ++(dfs_stack.top());
+	  /*++*/G.next(dfs_stack.top());
 	  b_node_newly_reached=false;
 	}
       } else {
@@ -671,87 +751,68 @@
     bool finished() const { return dfs_stack.empty(); }
     operator OutEdgeIt () const { return actual_edge; }
     bool isBNodeNewlyReached() const { return b_node_newly_reached; }
-    bool isANodeExamined() const { return !(actual_edge.valid()); }
+    bool isANodeExamined() const { return !(G.valid(actual_edge)/*.valid()*/); }
     NodeIt aNode() const { return actual_node; /*FIXME*/}
     NodeIt bNode() const { return G.bNode(actual_edge); }
     const ReachedMap& getReachedMap() const { return reached; }
     const std::stack<OutEdgeIt>& getDfsStack() const { return dfs_stack; }
   };
 
-
-
-  template <typename GraphWrapper, typename ReachedMap>
-  class BfsIterator5 {
+  template <typename GraphWrapper, typename OutEdgeIt, 
+	    typename ReachedMap/*=typename GraphWrapper::NodeMap<bool>*/ >
+  class DfsIterator5 {
     typedef typename GraphWrapper::NodeIt NodeIt;
-    typedef typename GraphWrapper::OutEdgeIt OutEdgeIt;
-    GraphWrapper gw;
-    std::queue<NodeIt> bfs_queue;
-    ReachedMap reached;
+    GraphWrapper G;
+    std::stack<OutEdgeIt> dfs_stack;
     bool b_node_newly_reached;
     OutEdgeIt actual_edge;
+    NodeIt actual_node;
+    ReachedMap& reached;
+    bool own_reached_map;
   public:
-    BfsIterator5(GraphWrapper _gw) : 
-      gw(_gw), reached(_gw.getGraph()) { }
+    DfsIterator5(const GraphWrapper& _G, ReachedMap& _reached) : 
+      G(_G), reached(_reached), 
+      own_reached_map(false) { }
+    DfsIterator5(const GraphWrapper& _G) : 
+      G(_G), reached(*(new ReachedMap(G /*, false*/))), 
+      own_reached_map(true) { }
+    ~DfsIterator5() { if (own_reached_map) delete &reached; }
     void pushAndSetReached(NodeIt s) { 
+      actual_node=s;
       reached.set(s, true);
-      if (bfs_queue.empty()) {
-	bfs_queue.push(s);
-	gw.getFirst(actual_edge, s);
-	if (actual_edge.valid()) { 
-	  NodeIt w=gw.bNode(actual_edge);
-	  if (!reached.get(w)) {
-	    bfs_queue.push(w);
-	    reached.set(w, true);
-	    b_node_newly_reached=true;
-	  } else {
-	    b_node_newly_reached=false;
-	  }
-	} 
-      } else {
-	bfs_queue.push(s);
-      }
+      dfs_stack.push(G.template first<OutEdgeIt>(s)); 
     }
-    BfsIterator5<GraphWrapper, ReachedMap>& 
+    DfsIterator5<GraphWrapper, OutEdgeIt, ReachedMap>& 
     operator++() { 
-      if (actual_edge.valid()) { 
-	++actual_edge;
-	if (actual_edge.valid()) {
-	  NodeIt w=gw.bNode(actual_edge);
-	  if (!reached.get(w)) {
-	    bfs_queue.push(w);
-	    reached.set(w, true);
-	    b_node_newly_reached=true;
-	  } else {
-	    b_node_newly_reached=false;
-	  }
+      actual_edge=dfs_stack.top();
+      //actual_node=G.aNode(actual_edge);
+      if (G.valid(actual_edge)/*.valid()*/) { 
+	NodeIt w=G.bNode(actual_edge);
+	actual_node=w;
+	if (!reached.get(w)) {
+	  dfs_stack.push(G.template first<OutEdgeIt>(w));
+	  reached.set(w, true);
+	  b_node_newly_reached=true;
+	} else {
+	  actual_node=G.aNode(actual_edge);
+	  /*++*/G.next(dfs_stack.top());
+	  b_node_newly_reached=false;
 	}
       } else {
-	bfs_queue.pop(); 
-	if (!bfs_queue.empty()) {
-	  gw.getFirst(actual_edge, bfs_queue.front());
-	  if (actual_edge.valid()) {
-	    NodeIt w=gw.bNode(actual_edge);
-	    if (!reached.get(w)) {
-	      bfs_queue.push(w);
-	      reached.set(w, true);
-	      b_node_newly_reached=true;
-	    } else {
-	      b_node_newly_reached=false;
-	    }
-	  }
-	}
+	//actual_node=G.aNode(dfs_stack.top());
+	dfs_stack.pop();
       }
       return *this;
     }
-    bool finished() const { return bfs_queue.empty(); }
+    bool finished() const { return dfs_stack.empty(); }
     operator OutEdgeIt () const { return actual_edge; }
     bool isBNodeNewlyReached() const { return b_node_newly_reached; }
-    bool isANodeExamined() const { return !(actual_edge.valid()); }
-    NodeIt aNode() const { return bfs_queue.front(); }
-    NodeIt bNode() const { return gw.bNode(actual_edge); }
+    bool isANodeExamined() const { return !(G.valid(actual_edge)/*.valid()*/); }
+    NodeIt aNode() const { return actual_node; /*FIXME*/}
+    NodeIt bNode() const { return G.bNode(actual_edge); }
     const ReachedMap& getReachedMap() const { return reached; }
-    const std::queue<NodeIt>& getBfsQueue() const { return bfs_queue; }
- };
+    const std::stack<OutEdgeIt>& getDfsStack() const { return dfs_stack; }
+  };
 
 
 

Modified: hugo/trunk/src/work/edmonds_karp.hh
==============================================================================
--- hugo/trunk/src/work/edmonds_karp.hh	(original)
+++ hugo/trunk/src/work/edmonds_karp.hh	Wed Mar  3 15:30:38 2004
@@ -148,9 +148,9 @@
       //OldSymEdgeIt sym;
       OldOutEdgeIt out;
       OldInEdgeIt in;
-      bool out_or_in; //1, iff out
+      bool out_or_in; //true, iff out
     public:
-      EdgeIt() : out_or_in(1) { } 
+      EdgeIt() : out_or_in(true) { } 
       Number free() const { 
 	if (out_or_in) { 
 	  return (resG->capacity.get(out)-resG->flow.get(out)); 
@@ -246,30 +246,29 @@
   };
 
   template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
-  class ResGraph3 {
+  class ResGraphWrapper {
   public:
     typedef typename Graph::NodeIt NodeIt;
     typedef typename Graph::EachNodeIt EachNodeIt;
-
   private:
-    //typedef typename Graph::SymEdgeIt OldSymEdgeIt;
     typedef typename Graph::OutEdgeIt OldOutEdgeIt;
     typedef typename Graph::InEdgeIt OldInEdgeIt;
-    const Graph& G;
-    FlowMap& flow;
-    const CapacityMap& capacity;
+    const Graph* G;
+    FlowMap* flow;
+    const CapacityMap* capacity;
   public:
-    ResGraph3(const Graph& _G, FlowMap& _flow, 
+    ResGraphWrapper(const Graph& _G, FlowMap& _flow, 
 	     const CapacityMap& _capacity) : 
-      G(_G), flow(_flow), capacity(_capacity) { }
-
+      G(&_G), flow(&_flow), capacity(&_capacity) { }
+//     ResGraphWrapper(const ResGraphWrapper& res_graph_wrapper) : 
+//       G(res_graph_wrapper.G), flow(res_graph_wrapper.flow), capacity(res_graph_wrapper.capacity) { }
     class EdgeIt; 
     class OutEdgeIt; 
     friend class EdgeIt; 
     friend class OutEdgeIt; 
 
     class EdgeIt {
-      friend class ResGraph3<Graph, Number, FlowMap, CapacityMap>;
+      friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
     protected:
       //const ResGraph3<Graph, Number, FlowMap, CapacityMap>* resG;
       const Graph* G;
@@ -278,9 +277,11 @@
       //OldSymEdgeIt sym;
       OldOutEdgeIt out;
       OldInEdgeIt in;
-      bool out_or_in; //1, iff out
+      bool out_or_in; //true, iff out
     public:
-      EdgeIt() : out_or_in(1) { } 
+      EdgeIt() : out_or_in(true) { } 
+      EdgeIt(const Graph& _G, FlowMap& _flow, const CapacityMap& _capacity) : 
+	G(&_G), flow(&_flow), capacity(&_capacity), out_or_in(true) { }
       //EdgeIt(const EdgeIt& e) : G(e.G), flow(e.flow), capacity(e.capacity), out(e.out), in(e.in), out_or_in(e.out_or_in) { }
       Number free() const { 
 	if (out_or_in) { 
@@ -317,23 +318,27 @@
       }
     };
 
+    Number free(OldOutEdgeIt out) const { 
+      return (/*resG->*/capacity->get(out)-/*resG->*/flow->get(out)); 
+    }
+    Number free(OldInEdgeIt in) const { 
+      return (/*resG->*/flow->get(in)); 
+    }
+
     class OutEdgeIt : public EdgeIt {
-      friend class ResGraph3<Graph, Number, FlowMap, CapacityMap>;
+      friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
     public:
       OutEdgeIt() { }
     private:
-      OutEdgeIt(const Graph& _G, NodeIt v, FlowMap& _flow, const CapacityMap& _capacity) { 
-      	G=&_G;
-	flow=&_flow;
-	capacity=&_capacity;
+      OutEdgeIt(const Graph& _G, NodeIt v, FlowMap& _flow, const CapacityMap& _capacity) : EdgeIt(_G, _flow, _capacity) { 
 	//out=/*resG->*/G->template first<OldOutEdgeIt>(v);
 	G->getFirst(out, v);
-	while( out.valid() && !(free()>0) ) { ++out; }
+	while( out.valid() && !(EdgeIt::free()>0) ) { ++out; }
 	if (!out.valid()) {
 	  out_or_in=0;
 	  //in=/*resG->*/G->template first<OldInEdgeIt>(v);
 	  G->getFirst(in, v);
-	  while( in.valid() && !(free()>0) ) { ++in; }
+	  while( in.valid() && !(EdgeIt::free()>0) ) { ++in; }
 	}
       }
     public:
@@ -341,91 +346,141 @@
 	if (out_or_in) {
 	  NodeIt v=/*resG->*/G->aNode(out);
 	  ++out;
-	  while( out.valid() && !(free()>0) ) { ++out; }
+	  while( out.valid() && !(EdgeIt::free()>0) ) { ++out; }
 	  if (!out.valid()) {
 	    out_or_in=0;
 	    G->getFirst(in, v); //=/*resG->*/G->template first<OldInEdgeIt>(v);
-	    while( in.valid() && !(free()>0) ) { ++in; }
+	    while( in.valid() && !(EdgeIt::free()>0) ) { ++in; }
 	  }
 	} else {
 	  ++in;
-	  while( in.valid() && !(free()>0) ) { ++in; } 
+	  while( in.valid() && !(EdgeIt::free()>0) ) { ++in; } 
 	}
 	return *this; 
       }
     };
 
     class EachEdgeIt : public EdgeIt {
+      friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
       typename Graph::EachNodeIt v;
     public:
       EachEdgeIt() { }
       //EachEdgeIt(const EachEdgeIt& e) : EdgeIt(e), v(e.v) { }
-      EachEdgeIt(const Graph& _G, FlowMap& _flow, const CapacityMap& _capacity) { 
-	G=&_G;
-	flow=&_flow;
-	capacity=&_capacity;
-	out_or_in=1;
+      EachEdgeIt(const Graph& _G, FlowMap& _flow, const CapacityMap& _capacity) : EdgeIt(_G, _flow, _capacity) { 
+	out_or_in=true;
 	G->getFirst(v);
 	if (v.valid()) G->getFirst(out, v); else out=OldOutEdgeIt();
-	while (out.valid() && !(free()>0) ) { ++out; }
+	while (out.valid() && !(EdgeIt::free()>0) ) { ++out; }
 	while (v.valid() && !out.valid()) { 
 	  ++v; 
 	  if (v.valid()) G->getFirst(out, v); 
-	  while (out.valid() && !(free()>0) ) { ++out; }
+	  while (out.valid() && !(EdgeIt::free()>0) ) { ++out; }
 	}
 	if (!out.valid()) {
 	  out_or_in=0;
 	  G->getFirst(v);
 	  if (v.valid()) G->getFirst(in, v); else in=OldInEdgeIt();
-	  while (in.valid() && !(free()>0) ) { ++in; }
+	  while (in.valid() && !(EdgeIt::free()>0) ) { ++in; }
 	  while (v.valid() && !in.valid()) { 
 	    ++v; 
 	    if (v.valid()) G->getFirst(in, v); 
-	    while (in.valid() && !(free()>0) ) { ++in; }
+	    while (in.valid() && !(EdgeIt::free()>0) ) { ++in; }
 	  }
 	}
       }
       EachEdgeIt& operator++() { 
 	if (out_or_in) {
 	  ++out;
-	  while (out.valid() && !(free()>0) ) { ++out; }
+	  while (out.valid() && !(EdgeIt::free()>0) ) { ++out; }
 	  while (v.valid() && !out.valid()) { 
 	    ++v; 
 	    if (v.valid()) G->getFirst(out, v); 
-	    while (out.valid() && !(free()>0) ) { ++out; }
+	    while (out.valid() && !(EdgeIt::free()>0) ) { ++out; }
 	  }
 	  if (!out.valid()) {
 	    out_or_in=0;
 	    G->getFirst(v);
 	    if (v.valid()) G->getFirst(in, v); else in=OldInEdgeIt();
-	    while (in.valid() && !(free()>0) ) { ++in; }
+	    while (in.valid() && !(EdgeIt::free()>0) ) { ++in; }
 	    while (v.valid() && !in.valid()) { 
 	      ++v; 
 	      if (v.valid()) G->getFirst(in, v); 
-	      while (in.valid() && !(free()>0) ) { ++in; }
+	      while (in.valid() && !(EdgeIt::free()>0) ) { ++in; }
 	    }  
 	  }
 	} else {
 	  ++in;
-	  while (in.valid() && !(free()>0) ) { ++in; }
+	  while (in.valid() && !(EdgeIt::free()>0) ) { ++in; }
 	  while (v.valid() && !in.valid()) { 
 	    ++v; 
 	    if (v.valid()) G->getFirst(in, v); 
-	    while (in.valid() && !(free()>0) ) { ++in; }
+	    while (in.valid() && !(EdgeIt::free()>0) ) { ++in; }
 	  }
 	}
 	return *this;
       }
     };
 
+    void getFirst(EachNodeIt& v) const { G->getFirst(v); }
     void getFirst(OutEdgeIt& e, NodeIt v) const { 
-      e=OutEdgeIt(G, v, flow, capacity); 
+      e=OutEdgeIt(*G, v, *flow, *capacity); 
     }
     void getFirst(EachEdgeIt& e) const { 
-      e=EachEdgeIt(G, flow, capacity); 
+      e=EachEdgeIt(*G, *flow, *capacity); 
     }
-    void getFirst(EachNodeIt& v) const { G.getFirst(v); }
+   
+    EachNodeIt& next(EachNodeIt& n) const { return G->next(n); }
+
+    OutEdgeIt& next(OutEdgeIt& e) const { 
+      if (e.out_or_in) {
+	NodeIt v=G->aNode(e.out);
+	++(e.out);
+	while( G->valid(e.out) && !(e.free()>0) ) { ++(e.out); }
+	if (!G->valid(e.out)) {
+	  e.out_or_in=0;
+	  G->getFirst(e.in, v); //=/*resG->*/G->template first<OldInEdgeIt>(v);
+	  while( G->valid(e.in) && !(e.free()>0) ) { ++(e.in); }
+	}
+      } else {
+	++(e.in);
+	while( G->valid(e.in) && !(e.free()>0) ) { ++(e.in); } 
+      }
+      return e;
+    }
+
+    EachEdgeIt& next(EachEdgeIt& e) const { 
+      if (e.out_or_in) {
+	++(e.out);
+	while (G->valid(e.out) && !(e.free()>0) ) { ++(e.out); }
+	  while (G->valid(e.v) && !G->valid(e.out)) { 
+	    ++(e.v); 
+	    if (G->valid(e.v)) G->getFirst(e.out, e.v); 
+	    while (G->valid(e.out) && !(e.free()>0) ) { ++(e.out); }
+	  }
+	  if (!G->valid(e.out)) {
+	    e.out_or_in=0;
+	    G->getFirst(e.v);
+	    if (G->valid(e.v)) G->getFirst(e.in, e.v); else e.in=OldInEdgeIt();
+	    while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); }
+	    while (G->valid(e.v) && !G->valid(e.in)) { 
+	      ++(e.v); 
+	      if (G->valid(e.v)) G->getFirst(e.in, e.v); 
+	      while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); }
+	    }  
+	  }
+	} else {
+	  ++(e.in);
+	  while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); }
+	  while (G->valid(e.v) && !G->valid(e.in)) { 
+	    ++(e.v); 
+	    if (G->valid(e.v)) G->getFirst(e.in, e.v); 
+	    while (G->valid(e.in) && !(e.free()>0) ) { ++(e.in); }
+	  }
+	}
+	return e;
+      }
     
+
     template< typename It >
     It first() const { 
       It e;
@@ -441,23 +496,27 @@
     }
 
     NodeIt tail(EdgeIt e) const { 
-      return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
+      return ((e.out_or_in) ? G->aNode(e.out) : G->aNode(e.in)); }
     NodeIt head(EdgeIt e) const { 
-      return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
+      return ((e.out_or_in) ? G->bNode(e.out) : G->bNode(e.in)); }
 
     NodeIt aNode(OutEdgeIt e) const { 
-      return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
+      return ((e.out_or_in) ? G->aNode(e.out) : G->aNode(e.in)); }
     NodeIt bNode(OutEdgeIt e) const { 
-      return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
+      return ((e.out_or_in) ? G->bNode(e.out) : G->bNode(e.in)); }
 
-    int id(NodeIt v) const { return G.id(v); }
+    int id(NodeIt v) const { return G->id(v); }
+
+    bool valid(NodeIt n) const { return G->valid(n); }
+    bool valid(EdgeIt e) const { 
+      return e.out_or_in ? G->valid(e.out) : G->valid(e.in); }
 
     template <typename T>
     class NodeMap {
       typename Graph::NodeMap<T> node_map; 
     public:
-      NodeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(_G.G) { }
-      NodeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G, T a) : node_map(_G.G, a) { }
+      NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(*(_G.G)) { }
+      NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : node_map(*(_G.G), a) { }
       void set(NodeIt nit, T a) { node_map.set(nit, a); }
       T get(NodeIt nit) const { return node_map.get(nit); }
     };
@@ -466,8 +525,8 @@
     class EdgeMap {
       typename Graph::EdgeMap<T> forward_map, backward_map; 
     public:
-      EdgeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.G), backward_map(_G.G) { }
-      EdgeMap(const ResGraph3<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.G, a), backward_map(_G.G, a) { }
+      EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(*(_G.G)), backward_map(*(_G.G)) { }
+      EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(*(_G.G), a), backward_map(*(_G.G), a) { }
       void set(EdgeIt e, T a) { 
 	if (e.out_or_in) 
 	  forward_map.set(e.out, a); 
@@ -494,12 +553,12 @@
     typedef typename Graph::InEdgeIt InEdgeIt;
 
   private:
-    const Graph& G;
+    const Graph* G;
     NodeIt s;
     NodeIt t;
-    FlowMap& flow;
-    const CapacityMap& capacity;
-    typedef ResGraph3<Graph, Number, FlowMap, CapacityMap > AugGraph;
+    FlowMap* flow;
+    const CapacityMap* capacity;
+    typedef ResGraphWrapper<Graph, Number, FlowMap, CapacityMap > AugGraph;
     typedef typename AugGraph::OutEdgeIt AugOutEdgeIt;
     typedef typename AugGraph::EdgeIt AugEdgeIt;
 
@@ -509,15 +568,15 @@
     //typename AugGraph::NodeMap<Number> free;
   public:
     MaxFlow(const Graph& _G, NodeIt _s, NodeIt _t, FlowMap& _flow, const CapacityMap& _capacity) : 
-      G(_G), s(_s), t(_t), flow(_flow), capacity(_capacity) //,  
+      G(&_G), s(_s), t(_t), flow(&_flow), capacity(&_capacity) //,  
       //res_graph(G, flow, capacity), pred(res_graph), free(res_graph) 
       { }
     bool augmentOnShortestPath() {
-      AugGraph res_graph(G, flow, capacity);
+      AugGraph res_graph(*G, *flow, *capacity);
       bool _augment=false;
       
       typedef typename AugGraph::NodeMap<bool> ReachedMap;
-      BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > res_bfs(res_graph);
+      BfsIterator5< AugGraph, AugOutEdgeIt, ReachedMap > res_bfs(res_graph);
       res_bfs.pushAndSetReached(s);
 	
       typename AugGraph::NodeMap<AugEdgeIt> pred(res_graph); 
@@ -529,11 +588,11 @@
       //searching for augmenting path
       while ( !res_bfs.finished() ) { 
 	AugOutEdgeIt e=/*AugOutEdgeIt*/(res_bfs);
-	if (e.valid() && res_bfs.isBNodeNewlyReached()) {
+	if (res_graph.valid(e) && res_bfs.isBNodeNewlyReached()) {
 	  NodeIt v=res_graph.tail(e);
 	  NodeIt w=res_graph.head(e);
 	  pred.set(w, e);
-	  if (pred.get(v).valid()) {
+	  if (res_graph.valid(pred.get(v))) {
 	    free.set(w, std::min(free.get(v), e.free()));
 	  } else {
 	    free.set(w, e.free()); 
@@ -547,7 +606,7 @@
       if (_augment) {
 	NodeIt n=t;
 	Number augment_value=free.get(t);
-	while (pred.get(n).valid()) { 
+	while (res_graph.valid(pred.get(n))) { 
 	  AugEdgeIt e=pred.get(n);
 	  e.augment(augment_value); 
 	  n=res_graph.tail(e);
@@ -560,7 +619,7 @@
     template<typename MutableGraph> bool augmentOnBlockingFlow() {
       bool _augment=false;
 
-      AugGraph res_graph(G, flow, capacity);
+      AugGraph res_graph(*G, *flow, *capacity);
 
       typedef typename AugGraph::NodeMap<bool> ReachedMap;
       BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > bfs(res_graph);
@@ -569,7 +628,7 @@
       typename AugGraph::NodeMap<int> dist(res_graph); //filled up with 0's
       while ( !bfs.finished() ) { 
 	AugOutEdgeIt e=/*AugOutEdgeIt*/(bfs);
-	if (e.valid() && bfs.isBNodeNewlyReached()) {
+	if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
 	  dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
 	}
 	
@@ -578,7 +637,7 @@
 
       MutableGraph F;
       typename AugGraph::NodeMap<NodeIt> res_graph_to_F(res_graph);
-      for(typename AugGraph::EachNodeIt n=res_graph.template first<typename AugGraph::EachNodeIt>(); n.valid(); ++n) {
+      for(typename AugGraph::EachNodeIt n=res_graph.template first<typename AugGraph::EachNodeIt>(); res_graph.valid(n); res_graph.next(n)) {
 	res_graph_to_F.set(n, F.addNode());
       }
       
@@ -586,17 +645,17 @@
       typename MutableGraph::NodeIt tF=res_graph_to_F.get(t);
 
       typename MutableGraph::EdgeMap<AugEdgeIt> original_edge(F);
-      typename MutableGraph::EdgeMap<Number> free_on_edge(F);
+      typename MutableGraph::EdgeMap<Number> residual_capacity(F);
 
       //Making F to the graph containing the edges of the residual graph 
       //which are in some shortest paths
-      for(typename AugGraph::EachEdgeIt e=res_graph.template first<typename AugGraph::EachEdgeIt>(); e.valid(); ++e) {
+      for(typename AugGraph::EachEdgeIt e=res_graph.template first<typename AugGraph::EachEdgeIt>(); res_graph.valid(e); res_graph.next(e)) {
 	if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
 	  typename MutableGraph::EdgeIt f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
 	  original_edge.update();
 	  original_edge.set(f, e);
-	  free_on_edge.update();
-	  free_on_edge.set(f, e.free());
+	  residual_capacity.update();
+	  residual_capacity.set(f, e.free());
 	} 
       }
 
@@ -613,7 +672,7 @@
 	dfs.pushAndSetReached(sF);      
 	while (!dfs.finished()) {
 	  ++dfs;
-	  if (typename MutableGraph::OutEdgeIt(dfs).valid()) {
+	  if (F.valid(typename MutableGraph::OutEdgeIt(dfs))) {
 	    //std::cout << "OutEdgeIt: " << dfs; 
 	    //std::cout << " aNode: " << F.aNode(dfs); 
 	    //std::cout << " bNode: " << F.bNode(dfs) << " ";
@@ -621,10 +680,10 @@
 	    typename MutableGraph::NodeIt v=F.aNode(dfs);
 	    typename MutableGraph::NodeIt w=F.bNode(dfs);
 	    pred.set(w, dfs);
-	    if (pred.get(v).valid()) {
-	      free.set(w, std::min(free.get(v), free_on_edge.get(dfs)));
+	    if (F.valid(pred.get(v))) {
+	      free.set(w, std::min(free.get(v), residual_capacity.get(dfs)));
 	    } else {
-	      free.set(w, free_on_edge.get(dfs)/*original_edge.get(dfs).free()*/); 
+	      free.set(w, residual_capacity.get(dfs)/*original_edge.get(dfs).free()*/); 
 	    }
 	    if (w==tF) { 
 	      //std::cout << "AUGMENTATION"<<std::endl;
@@ -657,14 +716,14 @@
 	if (__augment) {
 	  typename MutableGraph::NodeIt n=tF;
 	  Number augment_value=free.get(tF);
-	  while (pred.get(n).valid()) { 
+	  while (F.valid(pred.get(n))) { 
 	    typename MutableGraph::EdgeIt e=pred.get(n);
 	    original_edge.get(e).augment(augment_value); 
 	    n=F.tail(e);
-	    if (free_on_edge.get(e)==augment_value) 
+	    if (residual_capacity.get(e)==augment_value) 
 	      F.erase(e); 
 	    else 
-	      free_on_edge.set(e, free_on_edge.get(e)-augment_value);
+	      residual_capacity.set(e, residual_capacity.get(e)-augment_value);
 	  }
 	}
       
@@ -690,59 +749,14 @@
     }
     Number flowValue() { 
       Number a=0;
-      for(OutEdgeIt i=G.template first<OutEdgeIt>(s); i.valid(); ++i) {
-	a+=flow.get(i);
+      OutEdgeIt e;
+      for(G->getFirst(e, s); G->valid(e); G->next(e)) {
+	a+=flow->get(e);
       }
       return a;
     }
   };
 
-
-/*
-  template <typename Graph>
-  class IteratorBoolNodeMap {
-    typedef typename Graph::NodeIt NodeIt;
-    typedef typename Graph::EachNodeIt EachNodeIt;
-    class BoolItem {
-    public:
-      bool value;
-      NodeIt prev;
-      NodeIt next;
-      BoolItem() : value(false), prev(), next() {}
-    };
-    NodeIt first_true;
-    //NodeIt last_true;
-    NodeIt first_false;
-    //NodeIt last_false;
-    const Graph& G; 
-    typename Graph::NodeMap<BoolItem> container;
-  public:
-    typedef bool ValueType;
-    typedef NodeIt KeyType;
-    IteratorBoolNodeMap(const Graph& _G) : G(_G), container(G), first_true(NodeIt()) { 
-      //for (EachNodeIt e=G.template first<EacNodeIt>(); e.valid(); ++e) {
-      //BoolItem b=container.get(e);
-      //b.me=e;
-      //container.set(b);
-      //} 
-      G.getFirst(first_false);
-      NodeIt e_prev;
-      for (EachNodeIt e=G.template first<EacNodeIt>(); e.valid(); ++e) {
-	container[e].prev=e_prev;
-	if (e_prev.valid()) container[e_prev].next=e;
-	e_prev=e;
-      }
-    }
-    //NodeMap(const Graph& _G, T a) : 
-    //  G(_G), container(G.node_id, a) { }
-    //FIXME
-    void set(NodeIt nit, T a) { container[G.id(nit)]=a; }
-    T get(NodeIt nit) const { return container[G.id(nit)]; }
-    //void update() { container.resize(G.node_id); }
-    //void update(T a) { container.resize(G.node_id, a); }
-  };
-*/
-
   
   template <typename Graph, typename Number, typename FlowMap, typename CapacityMap>
   class MaxFlow2 {

Modified: hugo/trunk/src/work/list_graph.hh
==============================================================================
--- hugo/trunk/src/work/list_graph.hh	(original)
+++ hugo/trunk/src/work/list_graph.hh	Wed Mar  3 15:30:38 2004
@@ -302,8 +302,8 @@
       return e; 
     }
 
-    bool valid(EdgeIt e) const { return e.valid(); }
     bool valid(NodeIt n) const { return n.valid(); }
+    bool valid(EdgeIt e) const { return e.valid(); }
     
     template <typename It> It getNext(It it) const { 
       It tmp(it); return next(tmp); }

Modified: hugo/trunk/src/work/marci/graph_wrapper.h
==============================================================================
--- hugo/trunk/src/work/marci/graph_wrapper.h	(original)
+++ hugo/trunk/src/work/marci/graph_wrapper.h	Wed Mar  3 15:30:38 2004
@@ -275,299 +275,300 @@
   };
 
 
-// FIXME: comparison should be made better!!!
-  template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>
-  class ResGraphWrapper
-  {
-    Graph* graph;
+
+// // FIXME: comparison should be made better!!!
+//   template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>
+//   class ResGraphWrapper
+//   {
+//     Graph* graph;
   
-  public:
-    typedef Graph BaseGraph;
+//   public:
+//     typedef Graph BaseGraph;
 
-    typedef typename Graph::NodeIt NodeIt;
-    typedef typename Graph::EdgeIt EdgeIt;
+//     typedef typename Graph::NodeIt NodeIt;
+//     typedef typename Graph::EdgeIt EdgeIt;
   
-    typedef typename Graph::EachNodeIt EachNodeIt;
+//     typedef typename Graph::EachNodeIt EachNodeIt;
    
-    class OutEdgeIt {
-    public:
-      //Graph::NodeIt n;
-      bool out_or_in;
-      typename Graph::OutEdgeIt o;
-      typename Graph::InEdgeIt i;   
-    };
-    class InEdgeIt {
-    public:
-      //Graph::NodeIt n;
-      bool out_or_in;
-      typename Graph::OutEdgeIt o;
-      typename Graph::InEdgeIt i;   
-    };
-    typedef typename Graph::SymEdgeIt SymEdgeIt;
-    typedef typename Graph::EachEdgeIt EachEdgeIt;
-
-    int nodeNum() const { return graph->nodeNum(); }
-    int edgeNum() const { return graph->edgeNum(); }
-
-    NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); }
-
-    // EachEdge and SymEdge  is missing!!!!
-    // EdgeIt <-> In/OutEdgeIt conversion is missing!!!!
-
-    //FIXME
-    OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const 
-      {
-	e.n=n;
-	graph->getFirst(e.o,n);
-	while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
-	  graph->goNext(e.o);
-	if(!graph->valid(e.o)) {
-	  graph->getFirst(e.i,n);
-	  while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
-	    graph->goNext(e.i);
-	}
-	return e;
-      }
-/*
-  OutEdgeIt &goNext(OutEdgeIt &e)
-  {
-  if(graph->valid(e.o)) {
-  while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
-  graph->goNext(e.o);
-  if(graph->valid(e.o)) return e;
-  else graph->getFirst(e.i,e.n);
-  }
-  else {
-  while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
-  graph->goNext(e.i);
-  return e;
-  }
-  }
-  OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
-*/
-    //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);}
-
-    //FIXME
-    InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const 
-      {
-	e.n=n;
-	graph->getFirst(e.i,n);
-	while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
-	  graph->goNext(e.i);
-	if(!graph->valid(e.i)) {
-	  graph->getFirst(e.o,n);
-	  while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
-	    graph->goNext(e.o);
-	}
-	return e;
-      }
-/*
-  InEdgeIt &goNext(InEdgeIt &e)
-  {
-  if(graph->valid(e.i)) {
-  while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
-  graph->goNext(e.i);
-  if(graph->valid(e.i)) return e;
-  else graph->getFirst(e.o,e.n);
-  }
-  else {
-  while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
-  graph->goNext(e.o);
-  return e;
-  }
-  }
-  InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
-*/
-    //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);}
-
-    //template<typename I> I &goNext(I &i); { return graph->goNext(i); }
-    //template<typename I> I next(const I i); { return graph->goNext(i); }
-
-    template< typename It > It first() const { 
-      It e; getFirst(e); return e; }
-
-    template< typename It > It first(NodeIt v) const { 
-      It e; getFirst(e, v); return e; }
-
-    NodeIt head(const EdgeIt& e) const { return graph->head(e); }
-    NodeIt tail(const EdgeIt& e) const { return graph->tail(e); }
-  
-    template<typename I> NodeIt aNode(const I& e) const { 
-      return graph->aNode(e); }
-    template<typename I> NodeIt bNode(const I& e) const { 
-      return graph->bNode(e); }
-  
-    //template<typename I> bool valid(const I i);
-    //{ return graph->valid(i); }
-  
-    //template<typename I> void setInvalid(const I &i);
-    //{ return graph->setInvalid(i); }
-  
-    NodeIt addNode() { return graph->addNode(); }
-    EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { 
-      return graph->addEdge(tail, head); }
-  
-    template<typename I> void erase(const I& i) { graph->erase(i); }
-  
-    void clear() { graph->clear(); }
-  
-    template<typename S> class NodeMap : public Graph::NodeMap<S> { };
-    template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };
-  
-    void setGraph(Graph& _graph) { graph = &_graph; }
-    Graph& getGraph() { return (*graph); }
-
-    //ResGraphWrapper() : graph(0) { }
-    ResGraphWrapper(Graph& _graph) : graph(&_graph) { }
-  };
-
+//     class OutEdgeIt {
+//     public:
+//       //Graph::NodeIt n;
+//       bool out_or_in;
+//       typename Graph::OutEdgeIt o;
+//       typename Graph::InEdgeIt i;   
+//     };
+//     class InEdgeIt {
+//     public:
+//       //Graph::NodeIt n;
+//       bool out_or_in;
+//       typename Graph::OutEdgeIt o;
+//       typename Graph::InEdgeIt i;   
+//     };
+//     typedef typename Graph::SymEdgeIt SymEdgeIt;
+//     typedef typename Graph::EachEdgeIt EachEdgeIt;
+
+//     int nodeNum() const { return graph->nodeNum(); }
+//     int edgeNum() const { return graph->edgeNum(); }
+
+//     NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); }
+
+//     // EachEdge and SymEdge  is missing!!!!
+//     // EdgeIt <-> In/OutEdgeIt conversion is missing!!!!
+
+//     //FIXME
+//     OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const 
+//       {
+// 	e.n=n;
+// 	graph->getFirst(e.o,n);
+// 	while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
+// 	  graph->goNext(e.o);
+// 	if(!graph->valid(e.o)) {
+// 	  graph->getFirst(e.i,n);
+// 	  while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
+// 	    graph->goNext(e.i);
+// 	}
+// 	return e;
+//       }
+// /*
+//   OutEdgeIt &goNext(OutEdgeIt &e)
+//   {
+//   if(graph->valid(e.o)) {
+//   while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
+//   graph->goNext(e.o);
+//   if(graph->valid(e.o)) return e;
+//   else graph->getFirst(e.i,e.n);
+//   }
+//   else {
+//   while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
+//   graph->goNext(e.i);
+//   return e;
+//   }
+//   }
+//   OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
+// */
+//     //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);}
+
+//     //FIXME
+//     InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const 
+//       {
+// 	e.n=n;
+// 	graph->getFirst(e.i,n);
+// 	while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
+// 	  graph->goNext(e.i);
+// 	if(!graph->valid(e.i)) {
+// 	  graph->getFirst(e.o,n);
+// 	  while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
+// 	    graph->goNext(e.o);
+// 	}
+// 	return e;
+//       }
+// /*
+//   InEdgeIt &goNext(InEdgeIt &e)
+//   {
+//   if(graph->valid(e.i)) {
+//   while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
+//   graph->goNext(e.i);
+//   if(graph->valid(e.i)) return e;
+//   else graph->getFirst(e.o,e.n);
+//   }
+//   else {
+//   while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
+//   graph->goNext(e.o);
+//   return e;
+//   }
+//   }
+//   InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
+// */
+//     //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);}
+
+//     //template<typename I> I &goNext(I &i); { return graph->goNext(i); }
+//     //template<typename I> I next(const I i); { return graph->goNext(i); }
+
+//     template< typename It > It first() const { 
+//       It e; getFirst(e); return e; }
+
+//     template< typename It > It first(NodeIt v) const { 
+//       It e; getFirst(e, v); return e; }
+
+//     NodeIt head(const EdgeIt& e) const { return graph->head(e); }
+//     NodeIt tail(const EdgeIt& e) const { return graph->tail(e); }
+  
+//     template<typename I> NodeIt aNode(const I& e) const { 
+//       return graph->aNode(e); }
+//     template<typename I> NodeIt bNode(const I& e) const { 
+//       return graph->bNode(e); }
+  
+//     //template<typename I> bool valid(const I i);
+//     //{ return graph->valid(i); }
+  
+//     //template<typename I> void setInvalid(const I &i);
+//     //{ return graph->setInvalid(i); }
+  
+//     NodeIt addNode() { return graph->addNode(); }
+//     EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { 
+//       return graph->addEdge(tail, head); }
+  
+//     template<typename I> void erase(const I& i) { graph->erase(i); }
+  
+//     void clear() { graph->clear(); }
+  
+//     template<typename S> class NodeMap : public Graph::NodeMap<S> { };
+//     template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };
+  
+//     void setGraph(Graph& _graph) { graph = &_graph; }
+//     Graph& getGraph() { return (*graph); }
+
+//     //ResGraphWrapper() : graph(0) { }
+//     ResGraphWrapper(Graph& _graph) : graph(&_graph) { }
+//   };
+
+
+// // FIXME: comparison should be made better!!!
+//   template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>
+//   class ConstResGraphWrapper
+//   {
+//     const Graph* graph;
+//     const LowerMap* low;
+//     FlowMap* flow;
+//     const UpperMap* up;
+//   public:
+//     typedef Graph BaseGraph;
 
-// FIXME: comparison should be made better!!!
-  template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>
-  class ConstResGraphWrapper
-  {
-    const Graph* graph;
-    const LowerMap* low;
-    FlowMap* flow;
-    const UpperMap* up;
-  public:
-    typedef Graph BaseGraph;
-
-    typedef typename Graph::NodeIt NodeIt;
-    typedef typename Graph::EdgeIt EdgeIt;
+//     typedef typename Graph::NodeIt NodeIt;
+//     typedef typename Graph::EdgeIt EdgeIt;
   
-    typedef typename Graph::EachNodeIt EachNodeIt;
+//     typedef typename Graph::EachNodeIt EachNodeIt;
    
-    class OutEdgeIt {
-    public:
-      //Graph::NodeIt n;
-      bool out_or_in;
-      typename Graph::SymEdgeIt sym;
-    };
-    class InEdgeIt {
-    public:
-      //Graph::NodeIt n;
-      bool out_or_in;
-      typename Graph::OutEdgeIt sym;
-    };
-    //typedef typename Graph::SymEdgeIt SymEdgeIt;
-    //typedef typename Graph::EachEdgeIt EachEdgeIt;
+//     class OutEdgeIt {
+//     public:
+//       //Graph::NodeIt n;
+//       bool out_or_in;
+//       typename Graph::SymEdgeIt sym;
+//     };
+//     class InEdgeIt {
+//     public:
+//       //Graph::NodeIt n;
+//       bool out_or_in;
+//       typename Graph::OutEdgeIt sym;
+//     };
+//     //typedef typename Graph::SymEdgeIt SymEdgeIt;
+//     //typedef typename Graph::EachEdgeIt EachEdgeIt;
 
-    int nodeNum() const { return graph->nodeNum(); }
-    //int edgeNum() const { return graph->edgeNum(); }
+//     int nodeNum() const { return graph->nodeNum(); }
+//     //int edgeNum() const { return graph->edgeNum(); }
 
-    NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); }
+//     NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); }
 
-    // EachEdge and SymEdge  is missing!!!!
-    // EdgeIt <-> In/OutEdgeIt conversion is missing!!!!
+//     // EachEdge and SymEdge  is missing!!!!
+//     // EdgeIt <-> In/OutEdgeIt conversion is missing!!!!
 
     
-    //FIXME
-    OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const 
-      {
-	e.n=n;
-	graph->getFirst(e.o,n);
-	while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
-	  graph->goNext(e.o);
-	if(!graph->valid(e.o)) {
-	  graph->getFirst(e.i,n);
-	  while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
-	    graph->goNext(e.i);
-	}
-	return e;
-      }
-/*
-  OutEdgeIt &goNext(OutEdgeIt &e)
-  {
-  if(graph->valid(e.o)) {
-  while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
-  graph->goNext(e.o);
-  if(graph->valid(e.o)) return e;
-  else graph->getFirst(e.i,e.n);
-  }
-  else {
-  while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
-  graph->goNext(e.i);
-  return e;
-  }
-  }
-  OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
-*/
-    //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);}
-
-    //FIXME
-    InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const 
-      {
-	e.n=n;
-	graph->getFirst(e.i,n);
-	while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
-	  graph->goNext(e.i);
-	if(!graph->valid(e.i)) {
-	  graph->getFirst(e.o,n);
-	  while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
-	    graph->goNext(e.o);
-	}
-	return e;
-      }
-/*
-  InEdgeIt &goNext(InEdgeIt &e)
-  {
-  if(graph->valid(e.i)) {
-  while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
-  graph->goNext(e.i);
-  if(graph->valid(e.i)) return e;
-  else graph->getFirst(e.o,e.n);
-  }
-  else {
-  while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
-  graph->goNext(e.o);
-  return e;
-  }
-  }
-  InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
-*/
-    //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);}
-
-    //template<typename I> I &goNext(I &i); { return graph->goNext(i); }
-    //template<typename I> I next(const I i); { return graph->goNext(i); }
-
-    template< typename It > It first() const { 
-      It e; getFirst(e); return e; }
-
-    template< typename It > It first(NodeIt v) const { 
-      It e; getFirst(e, v); return e; }
-
-    NodeIt head(const EdgeIt& e) const { return graph->head(e); }
-    NodeIt tail(const EdgeIt& e) const { return graph->tail(e); }
-  
-    template<typename I> NodeIt aNode(const I& e) const { 
-      return graph->aNode(e); }
-    template<typename I> NodeIt bNode(const I& e) const { 
-      return graph->bNode(e); }
-  
-    //template<typename I> bool valid(const I i);
-    //{ return graph->valid(i); }
-  
-    //template<typename I> void setInvalid(const I &i);
-    //{ return graph->setInvalid(i); }
-  
-    NodeIt addNode() { return graph->addNode(); }
-    EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { 
-      return graph->addEdge(tail, head); }
-  
-    template<typename I> void erase(const I& i) { graph->erase(i); }
-  
-    void clear() { graph->clear(); }
-  
-    template<typename S> class NodeMap : public Graph::NodeMap<S> { };
-    template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };
-  
-    void setGraph(const Graph& _graph) { graph = &_graph; }
-    const Graph& getGraph() { return (*graph); }
-
-    //ConstResGraphWrapper() : graph(0) { }
-    ConstResGraphWrapper(const Graph& _graph) : graph(&_graph) { }
-  };
+//     //FIXME
+//     OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const 
+//       {
+// 	e.n=n;
+// 	graph->getFirst(e.o,n);
+// 	while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
+// 	  graph->goNext(e.o);
+// 	if(!graph->valid(e.o)) {
+// 	  graph->getFirst(e.i,n);
+// 	  while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
+// 	    graph->goNext(e.i);
+// 	}
+// 	return e;
+//       }
+// /*
+//   OutEdgeIt &goNext(OutEdgeIt &e)
+//   {
+//   if(graph->valid(e.o)) {
+//   while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
+//   graph->goNext(e.o);
+//   if(graph->valid(e.o)) return e;
+//   else graph->getFirst(e.i,e.n);
+//   }
+//   else {
+//   while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
+//   graph->goNext(e.i);
+//   return e;
+//   }
+//   }
+//   OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
+// */
+//     //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);}
+
+//     //FIXME
+//     InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const 
+//       {
+// 	e.n=n;
+// 	graph->getFirst(e.i,n);
+// 	while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
+// 	  graph->goNext(e.i);
+// 	if(!graph->valid(e.i)) {
+// 	  graph->getFirst(e.o,n);
+// 	  while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
+// 	    graph->goNext(e.o);
+// 	}
+// 	return e;
+//       }
+// /*
+//   InEdgeIt &goNext(InEdgeIt &e)
+//   {
+//   if(graph->valid(e.i)) {
+//   while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
+//   graph->goNext(e.i);
+//   if(graph->valid(e.i)) return e;
+//   else graph->getFirst(e.o,e.n);
+//   }
+//   else {
+//   while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
+//   graph->goNext(e.o);
+//   return e;
+//   }
+//   }
+//   InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
+// */
+//     //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);}
+
+//     //template<typename I> I &goNext(I &i); { return graph->goNext(i); }
+//     //template<typename I> I next(const I i); { return graph->goNext(i); }
+
+//     template< typename It > It first() const { 
+//       It e; getFirst(e); return e; }
+
+//     template< typename It > It first(NodeIt v) const { 
+//       It e; getFirst(e, v); return e; }
+
+//     NodeIt head(const EdgeIt& e) const { return graph->head(e); }
+//     NodeIt tail(const EdgeIt& e) const { return graph->tail(e); }
+  
+//     template<typename I> NodeIt aNode(const I& e) const { 
+//       return graph->aNode(e); }
+//     template<typename I> NodeIt bNode(const I& e) const { 
+//       return graph->bNode(e); }
+  
+//     //template<typename I> bool valid(const I i);
+//     //{ return graph->valid(i); }
+  
+//     //template<typename I> void setInvalid(const I &i);
+//     //{ return graph->setInvalid(i); }
+  
+//     NodeIt addNode() { return graph->addNode(); }
+//     EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { 
+//       return graph->addEdge(tail, head); }
+  
+//     template<typename I> void erase(const I& i) { graph->erase(i); }
+  
+//     void clear() { graph->clear(); }
+  
+//     template<typename S> class NodeMap : public Graph::NodeMap<S> { };
+//     template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };
+  
+//     void setGraph(const Graph& _graph) { graph = &_graph; }
+//     const Graph& getGraph() { return (*graph); }
+
+//     //ConstResGraphWrapper() : graph(0) { }
+//     ConstResGraphWrapper(const Graph& _graph) : graph(&_graph) { }
+//   };
 
 
 



More information about the Lemon-commits mailing list