Index: src/work/marci/edmonds_karp.h
===================================================================
--- src/work/marci/edmonds_karp.h	(revision 303)
+++ src/work/marci/edmonds_karp.h	(revision 311)
@@ -10,4 +10,5 @@
 #include <invalid.h>
 #include <graph_wrapper.h>
+#include <maps.h>
 
 namespace hugo {
@@ -354,6 +355,8 @@
 
       MG F;
-      typedef SubGraphWrapper<ResGW, DistanceMap<ResGW> > FilterResGW;
-      FilterResGW filter_res_graph(res_graph, dist);
+      ConstMap<typename ResGW::Node, bool> true_map(true);
+      typedef SubGraphWrapper<ResGW, ConstMap<typename ResGW::Node, bool>, 
+	DistanceMap<ResGW> > FilterResGW;
+      FilterResGW filter_res_graph(res_graph, true_map, dist);
       typename ResGW::NodeMap<typename MG::Node> res_graph_to_F(res_graph);
       {
@@ -568,6 +571,8 @@
 
       //Subgraph containing the edges on some shortest paths
-      typedef SubGraphWrapper<ResGW, DistanceMap<ResGW> > FilterResGW;
-      FilterResGW filter_res_graph(res_graph, dist);
+      ConstMap<typename ResGW::Node, bool> true_map(true);
+      typedef SubGraphWrapper<ResGW, ConstMap<typename ResGW::Node, bool>, 
+	DistanceMap<ResGW> > FilterResGW;
+      FilterResGW filter_res_graph(res_graph, true_map, dist);
 
       //Subgraph, which is able to delete edges which are already 
@@ -592,14 +597,14 @@
 
  	__augment=false;
- 	//computing blocking flow with dfs
+  	//computing blocking flow with dfs
 	typedef typename ErasingResGW::NodeMap<bool> BlockingReachedMap;
- 	DfsIterator5< ErasingResGW, BlockingReachedMap > 
- 	  dfs(erasing_res_graph);
+  	DfsIterator5< ErasingResGW, BlockingReachedMap > 
+  	  dfs(erasing_res_graph);
  	typename ErasingResGW::NodeMap<typename ErasingResGW::OutEdgeIt> 
  	  pred(erasing_res_graph); 
  	pred.set(s, INVALID);
- 	//invalid iterators for sources
-
- 	typename ErasingResGW::NodeMap<Number> free(erasing_res_graph);
+  	//invalid iterators for sources
+
+  	typename ErasingResGW::NodeMap<Number> free(erasing_res_graph);
 
  	dfs.pushAndSetReached(s);
@@ -609,5 +614,5 @@
  		/*typename ErasingResGW::OutEdgeIt*/(dfs))) 
  	  { 
- 	    if (dfs.isBNodeNewlyReached()) {
+  	    if (dfs.isBNodeNewlyReached()) {
 	  
  	      typename ErasingResGW::Node v=erasing_res_graph.aNode(dfs);
@@ -626,12 +631,12 @@
  		break; 
  	      }
-	    } else {
-	      erasing_res_graph.erase(dfs);
+ 	    } else {
+ 	      erasing_res_graph.erase(dfs);
 	    }
 	  }
 	}	
 
- 	if (__augment) {
- 	  typename ErasingResGW::Node n=t;
+  	if (__augment) {
+  	  typename ErasingResGW::Node n=t;
  	  Number augment_value=free[n];
  	  while (erasing_res_graph.valid(pred[n])) { 
@@ -641,6 +646,6 @@
  	    if (res_graph.resCap(e)==0)
  	      erasing_res_graph.erase(e);
- 	  }
- 	}
+	}
+      }
       
       } //while (__augment) 
Index: src/work/marci/edmonds_karp_demo.cc
===================================================================
--- src/work/marci/edmonds_karp_demo.cc	(revision 305)
+++ src/work/marci/edmonds_karp_demo.cc	(revision 311)
@@ -9,9 +9,5 @@
 #include <time_measure.h>
 //#include <graph_wrapper.h>
-
-class CM {
-public:
-  template<typename T> int get(T) const {return 1;}
-};
+#include <preflow.h>
 
 using namespace hugo;
@@ -89,7 +85,35 @@
 //   std::cout << "p2:" << cgw.nodeNum() << std::endl;
 
-
-  {
-    std::cout << "edmonds karp demo (physical blocking flow augmentation)..." << std::endl;
+  {
+    std::cout << "preflow ..." << std::endl;
+    Graph::EdgeMap<int> flow(G); //0 flow
+
+    Timer ts;
+    ts.reset();
+
+    Preflow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
+      max_flow_test(G, s, t, cap, flow);
+    max_flow_test.run();
+//    int i=0;
+//    while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { 
+//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) { 
+//       std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
+//     }
+//     std::cout<<std::endl;
+//      ++i; 
+//    }
+
+//   std::cout << "maximum flow: "<< std::endl;
+//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) { 
+//     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
+//   }
+//   std::cout<<std::endl;
+    std::cout << "elapsed time: " << ts << std::endl;
+//    std::cout << "number of augmentation phases: " << i << std::endl; 
+    std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
+  }
+
+  {
+    std::cout << "physical blocking flow augmentation ..." << std::endl;
     Graph::EdgeMap<int> flow(G); //0 flow
 
@@ -119,5 +143,5 @@
 
   {
-    std::cout << "edmonds karp demo (physical blocking flow 1 augmentation)..." << std::endl;
+    std::cout << "faster physical blocking flow augmentation ..." << std::endl;
     Graph::EdgeMap<int> flow(G); //0 flow
 
@@ -147,5 +171,5 @@
 
   {
-    std::cout << "edmonds karp demo (on-the-fly blocking flow augmentation)..." << std::endl;
+    std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
     Graph::EdgeMap<int> flow(G); //0 flow
 
@@ -175,5 +199,5 @@
 
   {
-    std::cout << "edmonds karp demo (on-the-fly shortest path augmentation)..." << std::endl;
+    std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
     Graph::EdgeMap<int> flow(G); //0 flow
 
Index: src/work/marci/graph_wrapper.h
===================================================================
--- src/work/marci/graph_wrapper.h	(revision 307)
+++ src/work/marci/graph_wrapper.h	(revision 311)
@@ -13,4 +13,5 @@
   
   public:
+//    typedef Graph BaseGraph;
     typedef Graph ParentGraph;
 
@@ -25,7 +26,11 @@
       NodeIt() { }
       NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { }
+//      NodeIt(const typename BaseGraph::NodeIt& n) : Graph::NodeIt(n) { }
       NodeIt(const Invalid& i) : Graph::NodeIt(i) { }
       NodeIt(const TrivGraphWrapper<Graph>& _G) : 
 	Graph::NodeIt(*(_G.graph)) { }
+//      operator typename BaseGraph::NodeIt() { 
+//	return typename BaseGraph::NodeIt(this->Graph::NodeIt);
+//      }
     };
     typedef typename Graph::Edge Edge;
@@ -58,8 +63,4 @@
     NodeIt& first(NodeIt& i) const { 
       i=NodeIt(*this);
-      return i;
-    }
-    EdgeIt& first(EdgeIt& i) const { 
-      i=EdgeIt(*this);
       return i;
     }
@@ -76,4 +77,8 @@
       return i;
     }
+    EdgeIt& first(EdgeIt& i) const { 
+      i=EdgeIt(*this);
+      return i;
+    }
 //     template<typename I, typename P> I& first(I& i, const P& p) const { 
 //       i=I(*this, p);
@@ -83,5 +88,9 @@
 //    template<typename I> I getNext(const I& i) const { 
 //      return graph->getNext(i); }
-    template<typename I> I& next(I &i) const { graph->next(i); return i; }    
+//    template<typename I> I& next(I &i) const { graph->next(i); return i; }    
+    NodeIt& next(NodeIt& i) const { graph->next(i); return i; }
+    OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i); return i; }
+    InEdgeIt& next(InEdgeIt& i) const { graph->next(i); return i; }
+    EdgeIt& next(EdgeIt& i) const { graph->next(i); return i; }
 
     template< typename It > It first() const { 
@@ -158,4 +167,5 @@
   
   public:
+    typedef Graph BaseGraph;
     typedef Graph ParentGraph;
 
@@ -205,8 +215,4 @@
       return i;
     }
-    EdgeIt& first(EdgeIt& i) const { 
-      i=EdgeIt(*this);
-      return i;
-    }
 //     template<typename I> I& first(I& i) const {       
 //       i=I(*this);
@@ -221,4 +227,8 @@
       return i;
     }
+    EdgeIt& first(EdgeIt& i) const { 
+      i=EdgeIt(*this);
+      return i;
+    }
 //     template<typename I, typename P> I& first(I& i, const P& p) const { 
 //       i=I(*this, p);
@@ -228,5 +238,9 @@
 //    template<typename I> I getNext(const I& i) const { 
 //      return gw.getNext(i); }
-    template<typename I> I& next(I &i) const { graph->next(i); return i; }    
+//    template<typename I> I& next(I &i) const { graph->next(i); return i; }    
+    NodeIt& next(NodeIt& i) const { graph->next(i); return i; }
+    OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i); return i; }
+    InEdgeIt& next(InEdgeIt& i) const { graph->next(i); return i; }
+    EdgeIt& next(EdgeIt& i) const { graph->next(i); return i; }    
 
     template< typename It > It first() const { 
@@ -386,42 +400,136 @@
 
   //Subgraph on the same node-set and partial edge-set
-  template<typename Graph, typename EdgeFilterMap>
+  template<typename Graph, typename NodeFilterMap, 
+	   typename EdgeFilterMap>
   class SubGraphWrapper : public GraphWrapper<Graph> {
   protected:
-    EdgeFilterMap* filter_map;
+    NodeFilterMap* node_filter_map;
+    EdgeFilterMap* edge_filter_map;
   public:
-    typedef typename GraphWrapper<Graph>::Node Node;
-    typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
-    typedef typename GraphWrapper<Graph>::Edge Edge;
-    typedef typename GraphWrapper<Graph>::EdgeIt EdgeIt;
-    typedef typename GraphWrapper<Graph>::InEdgeIt InEdgeIt;
-    typedef typename GraphWrapper<Graph>::OutEdgeIt OutEdgeIt;
-
 //     SubGraphWrapper() : GraphWrapper<Graph>(), filter_map(0) { }
-    SubGraphWrapper(Graph& _graph, EdgeFilterMap& _filter_map) : 
-      GraphWrapper<Graph>(_graph), filter_map(&_filter_map) { }  
-
-    template<typename I> I& first(I& i) const { 
-      graph->first(i); 
-      //while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
-      while (graph->valid(i) && !(*filter_map)[i]) { graph->next(i); }
-      return i;
-    }
-    template<typename I, typename P> I& first(I& i, const P& p) const { 
-      graph->first(i, p); 
-//      while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
-      while (graph->valid(i) && !(*filter_map)[i]) { graph->next(i); }
-      return i;
-    }
-    
+    SubGraphWrapper(Graph& _graph, NodeFilterMap& _node_filter_map, 
+		    EdgeFilterMap& _edge_filter_map) : 
+      GraphWrapper<Graph>(_graph), node_filter_map(&_node_filter_map), 
+      edge_filter_map(&_edge_filter_map) { }  
+
+
+    typedef typename Graph::Node Node;
+    class NodeIt : public Graph::NodeIt { 
+//      typedef typename Graph::NodeIt GraphNodeIt;
+    public:
+      NodeIt() { }
+      NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { }
+      NodeIt(const Invalid& i) : Graph::NodeIt(i) { }
+      NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) : 
+	Graph::NodeIt(*(_G.graph)) { 
+	while (_G.graph->valid((*this)/*.GraphNodeIt*/) && 
+	       !(*(_G.node_filter_map))[(*this)/*.GraphNodeIt*/]) 
+	  _G.graph->next((*this)/*.GraphNodeIt*/);
+      }
+    };
+    typedef typename Graph::Edge Edge;
+    class OutEdgeIt : public Graph::OutEdgeIt { 
+//      typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
+    public:
+      OutEdgeIt() { }
+      OutEdgeIt(const typename Graph::OutEdgeIt& e) : Graph::OutEdgeIt(e) { }
+      OutEdgeIt(const Invalid& i) : Graph::OutEdgeIt(i) { }
+      OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& 
+		_G, const Node& n) : 
+	Graph::OutEdgeIt(*(_G.graph), n) { 
+	while (_G.graph->valid((*this)/*.GraphOutEdgeIt*/) && 
+	       !(*(_G.edge_filter_map))[(*this)/*.GraphOutEdgeIt*/]) 
+	  _G.graph->next((*this)/*.GraphOutEdgeIt*/);
+      }
+    };
+    class InEdgeIt : public Graph::InEdgeIt { 
+//      typedef typename Graph::InEdgeIt GraphInEdgeIt;
+    public:
+      InEdgeIt() { }
+      InEdgeIt(const typename Graph::InEdgeIt& e) : Graph::InEdgeIt(e) { }
+      InEdgeIt(const Invalid& i) : Graph::InEdgeIt(i) { }
+      InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G, 
+	       const Node& n) : 
+	Graph::InEdgeIt(*(_G.graph), n) { 
+	while (_G.graph->valid((*this)/*.GraphInEdgeIt*/) && 
+	       !(*(_G.edge_filter_map))[(*this)/*.GraphInEdgeIt*/]) 
+	  _G.graph->next((*this)/*.GraphInEdgeIt*/);
+      }
+    };
+//     //typedef typename Graph::SymEdgeIt SymEdgeIt;
+    class EdgeIt : public Graph::EdgeIt { 
+//      typedef typename Graph::EdgeIt GraphEdgeIt;
+    public:
+      EdgeIt() { }
+      EdgeIt(const typename Graph::EdgeIt& e) : Graph::EdgeIt(e) { }
+      EdgeIt(const Invalid& i) : Graph::EdgeIt(i) { }
+      EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) : 
+	Graph::EdgeIt(*(_G.graph)) { 
+	while (_G.graph->valid((*this)/*.GraphEdgeIt*/) && 
+	       !(*(_G.edge_filter_map))[(*this)/*.GraphEdgeIt*/]) 
+	  _G.graph->next((*this)/*.GraphEdgeIt*/);
+      }
+    };
+   
+    NodeIt& first(NodeIt& i) const {
+      i=NodeIt(*this);
+      return i;
+    }
+    OutEdgeIt& first(OutEdgeIt& i, const Node& n) const {
+      i=OutEdgeIt(*this, n);
+      return i;
+    }
+    InEdgeIt& first(InEdgeIt& i, const Node& n) const {
+      i=InEdgeIt(*this, n);
+      return i;
+    }
+    EdgeIt& first(EdgeIt& i) const {
+      i=EdgeIt(*this);
+      return i;
+    }
+    
+//     template<typename I> I& first(I& i) const { 
+//       graph->first(i); 
+//       //while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
+//       while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
+//       return i;
+//     }
+//     template<typename I, typename P> I& first(I& i, const P& p) const { 
+//       graph->first(i, p); 
+// //      while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
+//       while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
+//       return i;
+//     }
+
+    NodeIt& next(NodeIt& i) const {
+      graph->next(i); 
+      while (graph->valid(i) && !(*node_filter_map)[i]) { graph->next(i); }
+      return i;
+    }
+    OutEdgeIt& next(OutEdgeIt& i) const {
+      graph->next(i); 
+      while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
+      return i;
+    }
+    InEdgeIt& next(InEdgeIt& i) const {
+      graph->next(i); 
+      while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
+      return i;
+    }
+    EdgeIt& next(EdgeIt& i) const {
+      graph->next(i); 
+      while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
+      return i;
+    }
+
     //template<typename I> I getNext(const I& i) const { 
     //  return gw.getNext(i); 
     //}
-    template<typename I> I& next(I &i) const { 
-      graph->next(i); 
-//      while (graph->valid(i) && !filter_map-get(i)) { graph->next(i); }
-      while (graph->valid(i) && !(*filter_map)[i]) { graph->next(i); }
-      return i;
-    }
+//     template<typename I> I& next(I &i) const { 
+//       graph->next(i); 
+// //      while (graph->valid(i) && !filter_map-get(i)) { graph->next(i); }
+//       while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
+//       return i;
+//     }
     
     template< typename It > It first() const { 
@@ -845,8 +953,5 @@
 
   template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
-  class ResGraphWrapper : public GraphWrapper<Graph>{
-  public:
-    typedef typename GraphWrapper<Graph>::Node Node;
-    typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
+  class ResGraphWrapper : public GraphWrapper<Graph> {
   protected:
     typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
@@ -866,4 +971,6 @@
     friend class OutEdgeIt; 
 
+    typedef typename GraphWrapper<Graph>::Node Node;
+    typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
     class Edge {
       friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
@@ -893,6 +1000,4 @@
       }
     };
-
-
     class OutEdgeIt : public Edge {
       friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
@@ -931,5 +1036,5 @@
 
     //FIXME This is just for having InEdgeIt
-    typedef void InEdgeIt;
+//    class InEdgeIt : public Edge { };
 
     class EdgeIt : public Edge {
@@ -994,9 +1099,17 @@
     };
 
-    NodeIt& first(NodeIt& v) const { graph->first(v); return v; }
-    OutEdgeIt& first(OutEdgeIt& e, Node v) const { 
-      e=OutEdgeIt(*this, v); 
-      return e;
-    }
+    NodeIt& first(NodeIt& i) const { 
+      i=NodeIt(*this); 
+      return i; 
+    }
+    OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
+      i=OutEdgeIt(*this, p);
+      return i;
+    }
+    //FIXME Not yet implemented
+    //InEdgeIt& first(InEdgeIt& i, const Node& p) const {
+    //i=InEdgeIt(*this, p);
+    //  return i;
+    //}
     EdgeIt& first(EdgeIt& e) const { 
       e=EdgeIt(*this); 
@@ -1005,5 +1118,4 @@
    
     NodeIt& next(NodeIt& n) const { graph->next(n); return n; }
-
     OutEdgeIt& next(OutEdgeIt& e) const { 
       if (e.out_or_in) {
@@ -1022,5 +1134,8 @@
       return e;
     }
-
+    //FIXME Not yet implemented
+    //InEdgeIt& next(InEdgeIt& e) const {
+    //  return e;
+    //}
     EdgeIt& next(EdgeIt& e) const { 
       if (e.out_or_in) {
@@ -1170,36 +1285,104 @@
     FirstOutEdgesMap* first_out_edges;
   public:
-    typedef typename GraphWrapper<Graph>::Node Node;
-    typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
-    typedef typename GraphWrapper<Graph>::Edge Edge;
-    typedef typename GraphWrapper<Graph>::EdgeIt EdgeIt;
-    typedef typename GraphWrapper<Graph>::InEdgeIt InEdgeIt;
-    typedef typename GraphWrapper<Graph>::OutEdgeIt OutEdgeIt;
-
     ErasingFirstGraphWrapper(Graph& _graph, 
 			     FirstOutEdgesMap& _first_out_edges) : 
       GraphWrapper<Graph>(_graph), first_out_edges(&_first_out_edges) { }  
 
-    template<typename I> I& first(I& i) const { 
-      graph->first(i); 
-      return i;
-    }
-    OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
-//      e=first_out_edges->get(n);
-      e=(*first_out_edges)[n];
-      return e;
-    }
-    template<typename I, typename P> I& first(I& i, const P& p) const { 
-      graph->first(i, p); 
-      return i;
-    }
+    typedef typename Graph::Node Node;
+    class NodeIt : public Graph::NodeIt { 
+    public:
+      NodeIt() { }
+      NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { }
+      NodeIt(const Invalid& i) : Graph::NodeIt(i) { }
+      NodeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) : 
+	Graph::NodeIt(*(_G.graph)) { }
+    };
+    typedef typename Graph::Edge Edge;
+    class OutEdgeIt : public Graph::OutEdgeIt { 
+    public:
+      OutEdgeIt() { }
+      OutEdgeIt(const typename Graph::OutEdgeIt& e) : Graph::OutEdgeIt(e) { }
+      OutEdgeIt(const Invalid& i) : Graph::OutEdgeIt(i) { }
+      OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G, 
+		const Node& n) : 
+	Graph::OutEdgeIt((*_G.first_out_edges)[n]) { }
+    };
+    class InEdgeIt : public Graph::InEdgeIt { 
+    public:
+      InEdgeIt() { }
+      InEdgeIt(const typename Graph::InEdgeIt& e) : Graph::InEdgeIt(e) { }
+      InEdgeIt(const Invalid& i) : Graph::InEdgeIt(i) { }
+      InEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G, 
+	       const Node& n) : 
+	Graph::InEdgeIt(*(_G.graph), n) { }
+    };
+    //typedef typename Graph::SymEdgeIt SymEdgeIt;
+    class EdgeIt : public Graph::EdgeIt { 
+    public:
+      EdgeIt() { }
+      EdgeIt(const typename Graph::EdgeIt& e) : Graph::EdgeIt(e) { }
+      EdgeIt(const Invalid& i) : Graph::EdgeIt(i) { }
+      EdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) : 
+	Graph::EdgeIt(*(_G.graph)) { }
+    };
+
+    NodeIt& first(NodeIt& i) const {
+      i=NodeIt(*this);
+      return i;
+    }
+    OutEdgeIt& first(OutEdgeIt& i, const Node& n) const {
+      i=OutEdgeIt(*this, n);
+//      i=(*first_out_edges)[n];
+      return i;
+    }
+    InEdgeIt& first(InEdgeIt& i, const Node& n) const {
+      i=InEdgeIt(*this, n);
+      return i;
+    }
+    EdgeIt& first(EdgeIt& i) const {
+      i=EdgeIt(*this);
+      return i;
+    }
+
+//     template<typename I> I& first(I& i) const { 
+//       graph->first(i); 
+//       return i;
+//     }
+//     OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
+// //      e=first_out_edges->get(n);
+//       e=(*first_out_edges)[n];
+//       return e;
+//     }
+//     template<typename I, typename P> I& first(I& i, const P& p) const { 
+//       graph->first(i, p); 
+//       return i;
+//     }
     
     //template<typename I> I getNext(const I& i) const { 
     //  return gw.getNext(i); 
     //}
-    template<typename I> I& next(I &i) const { 
+
+
+    NodeIt& next(NodeIt& i) const {
       graph->next(i); 
       return i;
     }
+    OutEdgeIt& next(OutEdgeIt& i) const {
+      graph->next(i); 
+      return i;
+    }
+    InEdgeIt& next(InEdgeIt& i) const {
+      graph->next(i); 
+      return i;
+    }
+    EdgeIt& next(EdgeIt& i) const {
+      graph->next(i); 
+      return i;
+    }
+
+//     template<typename I> I& next(I &i) const { 
+//       graph->next(i); 
+//       return i;
+//     }
     
     template< typename It > It first() const { 
