Index: src/work/marci/graph_wrapper.h
===================================================================
--- src/work/marci/graph_wrapper.h	(revision 237)
+++ src/work/marci/graph_wrapper.h	(revision 238)
@@ -334,25 +334,25 @@
     typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt OutEdgeIt;
 
+    RevGraphWrapper(GraphWrapper _gw) : 
+      GraphWrapperSkeleton<GraphWrapper>(_gw) { }  
+
     Node head(const Edge& e) const 
       { return GraphWrapperSkeleton<GraphWrapper>::tail(e); }
     Node tail(const Edge& e) const 
       { return GraphWrapperSkeleton<GraphWrapper>::head(e); }
-    
-    RevGraphWrapper(GraphWrapper _gw) : 
-      GraphWrapperSkeleton<GraphWrapper>(_gw) { }  
   };
 
 
-
-//   template<typename Graph>
+//   template<typename GraphWrapper>
 //   class UndirGraphWrapper {
 //   protected:
-//     Graph* graph;
-  
+//     //Graph* graph;
+//     GraphWrapper gw;
+
 //   public:
-//     typedef Graph BaseGraph;
-
-//     typedef typename Graph::Node Node;
-//     typedef typename Graph::NodeIt NodeIt;
+//     typedef GraphWrapper BaseGraph;
+
+//     typedef typename GraphWrapper::Node Node;
+//     typedef typename GraphWrapper::NodeIt NodeIt;
 
 //     //typedef typename Graph::Edge Edge;
@@ -363,17 +363,17 @@
 
 //     //private:
-//     typedef typename Graph::Edge GraphEdge;
-//     typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
-//     typedef typename Graph::InEdgeIt GraphInEdgeIt;
+//     typedef typename GraphWrapper::Edge GraphEdge;
+//     typedef typename GraphWrapper::OutEdgeIt GraphOutEdgeIt;
+//     typedef typename GraphWrapper::InEdgeIt GraphInEdgeIt;
 //     //public:
 
 //     //UndirGraphWrapper() : graph(0) { }
-//     UndirGraphWrapper(Graph& _graph) : graph(&_graph) { }
-
-//     void setGraph(Graph& _graph) { graph = &_graph; }
-//     Graph& getGraph() const { return (*graph); }
+//     UndirGraphWrapper(GraphWrapper _gw) : gw(_gw) { }
+
+//     //void setGraph(Graph& _graph) { graph = &_graph; }
+//     //Graph& getGraph() const { return (*graph); }
   
 //     class Edge {
-//       friend class UndirGraphWrapper<Graph>;
+//       friend class UndirGraphWrapper<GraphWrapper>;
 //       bool out_or_in; //true iff out
 //       GraphOutEdgeIt out;
@@ -400,14 +400,15 @@
 
 //     class OutEdgeIt : public Edge {
-//       friend class UndirGraphWrapper<Graph>;
+//       friend class UndirGraphWrapper<GraphWrapper>;
 //     public:
 //       OutEdgeIt() : Edge() { }
 //       OutEdgeIt(const Invalid& i) : Edge(i) { }
-//       OutEdgeIt(const UndirGraphWrapper& _G, const Node& n) : Edge() { 
+//       OutEdgeIt(const UndirGraphWrapper<GraphWrapper>& _G, const Node& n) 
+// 	: Edge() { 
 // 	out_or_in=true;
-// 	_G.graph->first(out, n);
-// 	if (!(_G.graph->valid(out))) {
+// 	_G.gw.first(out, n);
+// 	if (!(_G.gw.valid(out))) {
 // 	  out_or_in=false;
-// 	  _G.graph->first(in, n);
+// 	  _G.gw.first(in, n);
 // 	}
 //       }
@@ -416,8 +417,8 @@
 //     OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
 //       e.out_or_in=true;
-//       graph->first(e.out, n);
-//       if (!(graph->valid(e.out))) {
+//       gw.first(e.out, n);
+//       if (!(gw.valid(e.out))) {
 // 	e.out_or_in=false;
-// 	graph->first(e.in, n);
+// 	gw.first(e.in, n);
 //       }
 //       return e;
@@ -426,12 +427,12 @@
 //     OutEdgeIt& next(OutEdgeIt& e) const {
 //       if (e.out_or_in) {
-// 	Node n=graph->tail(e.out);
-// 	graph->next(e.out);
-// 	if (!graph->valid(e.out)) {
+// 	Node n=gw.tail(e.out);
+// 	gw.next(e.out);
+// 	if (!gw.valid(e.out)) {
 // 	  e.out_or_in=false;
-// 	  graph->first(e.in, n);
+// 	  gw.first(e.in, n);
 // 	}
 //       } else {
-// 	graph->next(e.in);
+// 	gw.next(e.in);
 //       }
 //       return e;
@@ -439,17 +440,17 @@
 
 //     Node aNode(const OutEdgeIt& e) const { 
-//       if (e.out_or_in) return graph->tail(e); else return graph->head(e); }
+//       if (e.out_or_in) return gw.tail(e); else return gw.head(e); }
 //     Node bNode(const OutEdgeIt& e) const { 
-//       if (e.out_or_in) return graph->head(e); else return graph->tail(e); }
+//       if (e.out_or_in) return gw.head(e); else return gw.tail(e); }
 
 //     typedef OutEdgeIt InEdgeIt; 
 
-//     template<typename I> I& first(I& i) const { return graph->first(i); }
+//     template<typename I> I& first(I& i) const { return gw.first(i); }
 // //     template<typename I, typename P> I& first(I& i, const P& p) const { 
 // //       return graph->first(i, p); }
     
 //     template<typename I> I getNext(const I& i) const { 
-//       return graph->getNext(i); }
-//     template<typename I> I& next(I &i) const { return graph->next(i); }    
+//       return gw.getNext(i); }
+//     template<typename I> I& next(I &i) const { return gw.next(i); }    
 
 //     template< typename It > It first() const { 
@@ -459,15 +460,15 @@
 //       It e; first(e, v); return e; }
 
-//     Node head(const Edge& e) const { return graph->head(e); }
-//     Node tail(const Edge& e) const { return graph->tail(e); }
+//     Node head(const Edge& e) const { return gw.head(e); }
+//     Node tail(const Edge& e) const { return gw.tail(e); }
 
 //     template<typename I> bool valid(const I& i) const 
-//       { return graph->valid(i); }
+//       { return gw.valid(i); }
   
 //     //template<typename I> void setInvalid(const I &i);
 //     //{ return graph->setInvalid(i); }
 
-//     int nodeNum() const { return graph->nodeNum(); }
-//     int edgeNum() const { return graph->edgeNum(); }
+//     int nodeNum() const { return gw.nodeNum(); }
+//     int edgeNum() const { return gw.edgeNum(); }
   
 // //     template<typename I> Node aNode(const I& e) const { 
@@ -476,27 +477,27 @@
 // //       return graph->bNode(e); }
   
-//     Node addNode() const { return graph->addNode(); }
+//     Node addNode() const { return gw.addNode(); }
 // // FIXME: ez igy nem jo, mert nem
 // //    Edge addEdge(const Node& tail, const Node& head) const { 
 // //      return graph->addEdge(tail, head); }
   
-//     template<typename I> void erase(const I& i) const { graph->erase(i); }
-  
-//     void clear() const { graph->clear(); }
-    
-//     template<typename T> class NodeMap : public Graph::NodeMap<T> { 
+//     template<typename I> void erase(const I& i) const { gw.erase(i); }
+  
+//     void clear() const { gw.clear(); }
+    
+//     template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> { 
 //     public:
-//       NodeMap(const UndirGraphWrapper<Graph>& _G) : 
-// 	Graph::NodeMap<T>(_G.getGraph()) { }
-//       NodeMap(const UndirGraphWrapper<Graph>& _G, T a) : 
-// 	Graph::NodeMap<T>(_G.getGraph(), a) { }
+//       NodeMap(const UndirGraphWrapper<GraphWrapper>& _G) : 
+// 	GraphWrapper::NodeMap<T>(_G.gw) { }
+//       NodeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) : 
+// 	GraphWrapper::NodeMap<T>(_G.gw, a) { }
 //     };
 
-//     template<typename T> class EdgeMap : public Graph::EdgeMap<T> { 
+//     template<typename T> class EdgeMap : public GraphWrapper::EdgeMap<T> { 
 //     public:
-//       EdgeMap(const UndirGraphWrapper<Graph>& _G) : 
-// 	Graph::EdgeMap<T>(_G.getGraph()) { }
-//       EdgeMap(const UndirGraphWrapper<Graph>& _G, T a) : 
-// 	Graph::EdgeMap<T>(_G.getGraph(), a) { }
+//       EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G) : 
+// 	GraphWrapper::EdgeMap<T>(_G.gw) { }
+//       EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) : 
+// 	GraphWrapper::EdgeMap<T>(_G.gw, a) { }
 //     };
 //   };
@@ -504,29 +505,25 @@
 
   template<typename GraphWrapper>
-  class UndirGraphWrapper {
+  class UndirGraphWrapper : public GraphWrapperSkeleton<GraphWrapper> {
   protected:
-    //Graph* graph;
-    GraphWrapper gw;
+//    GraphWrapper gw;
 
   public:
-    typedef GraphWrapper BaseGraph;
-
-    typedef typename GraphWrapper::Node Node;
-    typedef typename GraphWrapper::NodeIt NodeIt;
-
-    //typedef typename Graph::Edge Edge;
-    //typedef typename Graph::OutEdgeIt OutEdgeIt;
-    //typedef typename Graph::InEdgeIt InEdgeIt;
-    //typedef typename Graph::SymEdgeIt SymEdgeIt;
-    //typedef typename Graph::EdgeIt EdgeIt;
+    //typedef GraphWrapper BaseGraph;
+
+    typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
+    typedef typename GraphWrapperSkeleton<GraphWrapper>::NodeIt NodeIt;
 
     //private:
-    typedef typename GraphWrapper::Edge GraphEdge;
-    typedef typename GraphWrapper::OutEdgeIt GraphOutEdgeIt;
-    typedef typename GraphWrapper::InEdgeIt GraphInEdgeIt;
+    typedef typename GraphWrapperSkeleton<GraphWrapper>::Edge GraphEdge;
+    typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt GraphOutEdgeIt;
+    typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt GraphInEdgeIt;
     //public:
 
     //UndirGraphWrapper() : graph(0) { }
-    UndirGraphWrapper(GraphWrapper _gw) : gw(_gw) { }
+    UndirGraphWrapper(GraphWrapper _gw) : 
+      GraphWrapperSkeleton<GraphWrapper>(_gw) { }  
+
+    //UndirGraphWrapper(GraphWrapper _gw) : gw(_gw) { }
 
     //void setGraph(Graph& _graph) { graph = &_graph; }
@@ -574,4 +571,26 @@
     };
 
+    typedef OutEdgeIt InEdgeIt; 
+
+    class EdgeIt : public Edge {
+      friend class UndirGraphWrapper<GraphWrapper>;
+    protected:
+      NodeIt v;
+    public:
+      EdgeIt() : Edge() { }
+      EdgeIt(const Invalid& i) : Edge(i) { }
+      EdgeIt(const UndirGraphWrapper<GraphWrapper>& _G) 
+	: Edge() { 
+	out_or_in=true;
+	//Node v;
+	_G.first(v);
+	if (_G.valid(v)) _G.gw.first(out); else out=INVALID;
+	while (_G.valid(v) && !_G.gw.valid(out)) { 
+	  _G.gw.next(v); 
+	  if (_G.valid(v)) _G.gw.first(out); 
+	}
+      }
+    };
+
     OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
       e.out_or_in=true;
@@ -583,4 +602,20 @@
       return e;
     }
+
+    EdgeIt& first(EdgeIt& e) const {
+      e.out_or_in=true;
+      //NodeIt v;
+      first(e.v);
+      if (valid(e.v)) gw.first(e.out, e.v); else e.out=INVALID;
+      while (valid(e.v) && !gw.valid(e.out)) { 
+	gw.next(e.v); 
+	if (valid(e.v)) gw.first(e.out, e.v); 
+      }
+      return e;
+    }
+
+    template<typename I> I& first(I& i) const { return gw.first(i); }
+    template<typename I, typename P> I& first(I& i, const P& p) const { 
+      return graph->first(i, p); }
 
     OutEdgeIt& next(OutEdgeIt& e) const {
@@ -598,67 +633,71 @@
     }
 
+    EdgeIt& next(EdgeIt& e) const {
+      //NodeIt v=tail(e);
+      gw.next(e.out);
+      while (valid(e.v) && !gw.valid(e.out)) { 
+	next(e.v); 
+	if (valid(e.v)) gw.first(e.out, e.v); 
+      }
+      return e;
+    }
+
+    template<typename I> I& next(I &i) const { return gw.next(i); }    
+    
+    template<typename I> I getNext(const I& i) const { 
+      return gw.getNext(i); }
+
+    template< typename It > It first() const { 
+      It e; first(e); return e; }
+
+    template< typename It > It first(const Node& v) const { 
+      It e; first(e, v); return e; }
+
+//    Node head(const Edge& e) const { return gw.head(e); }
+//    Node tail(const Edge& e) const { return gw.tail(e); }
+
+//    template<typename I> bool valid(const I& i) const 
+//      { return gw.valid(i); }
+  
+//    int nodeNum() const { return gw.nodeNum(); }
+//    int edgeNum() const { return gw.edgeNum(); }
+  
+//     template<typename I> Node aNode(const I& e) const { 
+//       return graph->aNode(e); }
+//     template<typename I> Node bNode(const I& e) const { 
+//       return graph->bNode(e); }
+
     Node aNode(const OutEdgeIt& e) const { 
       if (e.out_or_in) return gw.tail(e); else return gw.head(e); }
     Node bNode(const OutEdgeIt& e) const { 
       if (e.out_or_in) return gw.head(e); else return gw.tail(e); }
-
-    typedef OutEdgeIt InEdgeIt; 
-
-    template<typename I> I& first(I& i) const { return gw.first(i); }
-//     template<typename I, typename P> I& first(I& i, const P& p) const { 
-//       return graph->first(i, p); }
-    
-    template<typename I> I getNext(const I& i) const { 
-      return gw.getNext(i); }
-    template<typename I> I& next(I &i) const { return gw.next(i); }    
-
-    template< typename It > It first() const { 
-      It e; first(e); return e; }
-
-    template< typename It > It first(const Node& v) const { 
-      It e; first(e, v); return e; }
-
-    Node head(const Edge& e) const { return gw.head(e); }
-    Node tail(const Edge& e) const { return gw.tail(e); }
-
-    template<typename I> bool valid(const I& i) const 
-      { return gw.valid(i); }
-  
-    //template<typename I> void setInvalid(const I &i);
-    //{ return graph->setInvalid(i); }
-
-    int nodeNum() const { return gw.nodeNum(); }
-    int edgeNum() const { return gw.edgeNum(); }
-  
-//     template<typename I> Node aNode(const I& e) const { 
-//       return graph->aNode(e); }
-//     template<typename I> Node bNode(const I& e) const { 
-//       return graph->bNode(e); }
-  
-    Node addNode() const { return gw.addNode(); }
+  
+//    Node addNode() const { return gw.addNode(); }
+
 // FIXME: ez igy nem jo, mert nem
 //    Edge addEdge(const Node& tail, const Node& head) const { 
 //      return graph->addEdge(tail, head); }
   
-    template<typename I> void erase(const I& i) const { gw.erase(i); }
-  
-    void clear() const { gw.clear(); }
-    
-    template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> { 
-    public:
-      NodeMap(const UndirGraphWrapper<GraphWrapper>& _G) : 
-	GraphWrapper::NodeMap<T>(_G.gw) { }
-      NodeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) : 
-	GraphWrapper::NodeMap<T>(_G.gw, a) { }
-    };
-
-    template<typename T> class EdgeMap : public GraphWrapper::EdgeMap<T> { 
-    public:
-      EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G) : 
-	GraphWrapper::EdgeMap<T>(_G.gw) { }
-      EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) : 
-	GraphWrapper::EdgeMap<T>(_G.gw, a) { }
-    };
-  };
+//    template<typename I> void erase(const I& i) const { gw.erase(i); }
+  
+//    void clear() const { gw.clear(); }
+    
+//     template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> { 
+//     public:
+//       NodeMap(const UndirGraphWrapper<GraphWrapper>& _G) : 
+// 	GraphWrapper::NodeMap<T>(_G.gw) { }
+//       NodeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) : 
+// 	GraphWrapper::NodeMap<T>(_G.gw, a) { }
+//     };
+
+//     template<typename T> class EdgeMap : 
+//       public GraphWrapperSkeleton<GraphWrapper>::EdgeMap<T> { 
+//     public:
+//       EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G) : 
+// 	GraphWrapperSkeleton<GraphWrapper>::EdgeMap<T>(_G.gw) { }
+//       EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) : 
+// 	GraphWrapper::EdgeMap<T>(_G.gw, a) { }
+//     };
+   };
 
 
