[Lemon-commits] [lemon_svn] marci: r1388 - in hugo/trunk/src: lemon test

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


Author: marci
Date: Tue Nov 16 14:03:47 2004
New Revision: 1388

Modified:
   hugo/trunk/src/lemon/graph_wrapper.h
   hugo/trunk/src/test/graph_wrapper_test.cc

Log:
ErasingFirstGraphWrapper


Modified: hugo/trunk/src/lemon/graph_wrapper.h
==============================================================================
--- hugo/trunk/src/lemon/graph_wrapper.h	(original)
+++ hugo/trunk/src/lemon/graph_wrapper.h	Tue Nov 16 14:03:47 2004
@@ -1799,6 +1799,68 @@
   };
 
 
+
+  template <typename _Graph, typename FirstOutEdgesMap>
+  class ErasingFirstGraphWrapperBase : public GraphWrapperBase<_Graph> {
+  public:
+    typedef _Graph Graph;
+    typedef GraphWrapperBase<_Graph> Parent;
+  protected:
+    FirstOutEdgesMap* first_out_edges;
+    ErasingFirstGraphWrapperBase() : Parent(), 
+				     first_out_edges(0) { }
+
+    void setFirstOutEdgesMap(FirstOutEdgesMap& _first_out_edges) {
+      first_out_edges=&_first_out_edges;
+    }
+
+  public:
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Edge Edge;
+
+//     using Parent::first;
+//     void first(Node& i) const { 
+//       Parent::first(i); 
+//       while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i); 
+//     }
+//     void first(Edge& i) const { 
+//       Parent::first(i); 
+//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::next(i); 
+//     }
+//     void firstIn(Edge& i, const Node& n) const { 
+//       Parent::firstIn(i, n); 
+//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextIn(i); 
+//     }
+    void firstOut(Edge& i, const Node& n) const { 
+      i=(*first_out_edges)[n];
+    }
+
+    void erase(const Edge& e) const {
+      Node n=source(e);
+      Edge f=e;
+      Parent::nextOut(f);
+      first_out_edges->set(n, f);
+    }    
+//     void next(Node& i) const { 
+//       Parent::next(i); 
+//       while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i); 
+//     }
+//     void next(Edge& i) const { 
+//       Parent::next(i); 
+//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::next(i); 
+//     }
+//     void nextIn(Edge& i) const { 
+//       Parent::nextIn(i); 
+//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextIn(i); 
+//     }
+//     void nextOut(Edge& i) const { 
+//       Parent::nextOut(i); 
+//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextOut(i); 
+//     }
+  };
+
+
   /// For blocking flows.
 
   ///\warning Graph wrappers are in even more experimental state than the other
@@ -1813,52 +1875,70 @@
   /// is called. 
   ///
   /// \author Marton Makai
-  template<typename Graph, typename FirstOutEdgesMap>
-  class ErasingFirstGraphWrapper : public GraphWrapper<Graph> {
-  public:
-    typedef GraphWrapper<Graph> Parent; 
-  protected:
-    FirstOutEdgesMap* first_out_edges;
+  template <typename _Graph, typename FirstOutEdgesMap>
+  class ErasingFirstGraphWrapper : 
+    public IterableGraphExtender<
+    ErasingFirstGraphWrapperBase<_Graph, FirstOutEdgesMap> > {
   public:
+    typedef _Graph Graph;
+    typedef IterableGraphExtender<
+      ErasingFirstGraphWrapperBase<_Graph, FirstOutEdgesMap> > Parent;
     ErasingFirstGraphWrapper(Graph& _graph, 
-			     FirstOutEdgesMap& _first_out_edges) : 
-      GraphWrapper<Graph>(_graph), first_out_edges(&_first_out_edges) { }  
-
-    typedef typename GraphWrapper<Graph>::Node Node;
-    typedef typename GraphWrapper<Graph>::Edge Edge;
-    class OutEdgeIt : public Edge { 
-      friend class GraphWrapper<Graph>;
-      friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
-      const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>* gw;
-    public:
-      OutEdgeIt() { }
-      OutEdgeIt(Invalid i) : Edge(i) { }
-      OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
-		const Node& n) : 
-	Edge((*(_gw.first_out_edges))[n]), gw(&_gw) { }
-      OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
-		const Edge& e) : 
-	Edge(e), gw(&_gw) { }
-      OutEdgeIt& operator++() { 
-	*(static_cast<Edge*>(this))=
-	  ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
-	return *this; 
-      }
-    };
-
+			     FirstOutEdgesMap& _first_out_edges) { 
+      setGraph(_graph);
+      setFirstOutEdgesMap(_first_out_edges);
+    } 
 //     using GraphWrapper<Graph>::first;
 //     OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
 //       i=OutEdgeIt(*this, p); return i;
 //     }
-    void erase(const Edge& e) const {
-      Node n=source(e);
-      typename Graph::OutEdgeIt f(*Parent::graph, n);
-      ++f;
-      first_out_edges->set(n, f);
-    }
-
-    //    KEEP_MAPS(Parent, ErasingFirstGraphWrapper);
   };
+//   template<typename Graph, typename FirstOutEdgesMap>
+//   class ErasingFirstGraphWrapper : public GraphWrapper<Graph> {
+//   public:
+//     typedef GraphWrapper<Graph> Parent; 
+//   protected:
+//     FirstOutEdgesMap* first_out_edges;
+//   public:
+//     ErasingFirstGraphWrapper(Graph& _graph, 
+// 			     FirstOutEdgesMap& _first_out_edges) : 
+//       GraphWrapper<Graph>(_graph), first_out_edges(&_first_out_edges) { }  
+
+//     typedef typename GraphWrapper<Graph>::Node Node;
+//     typedef typename GraphWrapper<Graph>::Edge Edge;
+//     class OutEdgeIt : public Edge { 
+//       friend class GraphWrapper<Graph>;
+//       friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
+//       const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>* gw;
+//     public:
+//       OutEdgeIt() { }
+//       OutEdgeIt(Invalid i) : Edge(i) { }
+//       OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
+// 		const Node& n) : 
+// 	Edge((*(_gw.first_out_edges))[n]), gw(&_gw) { }
+//       OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
+// 		const Edge& e) : 
+// 	Edge(e), gw(&_gw) { }
+//       OutEdgeIt& operator++() { 
+// 	*(static_cast<Edge*>(this))=
+// 	  ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+// 	return *this; 
+//       }
+//     };
+
+// //     using GraphWrapper<Graph>::first;
+// //     OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
+// //       i=OutEdgeIt(*this, p); return i;
+// //     }
+//     void erase(const Edge& e) const {
+//       Node n=source(e);
+//       typename Graph::OutEdgeIt f(*Parent::graph, n);
+//       ++f;
+//       first_out_edges->set(n, f);
+//     }
+
+//     //    KEEP_MAPS(Parent, ErasingFirstGraphWrapper);
+//   };
 
   ///@}
 

Modified: hugo/trunk/src/test/graph_wrapper_test.cc
==============================================================================
--- hugo/trunk/src/test/graph_wrapper_test.cc	(original)
+++ hugo/trunk/src/test/graph_wrapper_test.cc	Tue Nov 16 14:03:47 2004
@@ -42,26 +42,26 @@
 int main() 
 {
   {
-    checkConcept<StaticGraph, GraphWrapper<StaticGraph> >();
+    typedef StaticGraph Graph;
+    checkConcept<StaticGraph, GraphWrapper<Graph> >();
 
-    checkConcept<StaticGraph, RevGraphWrapper<StaticGraph> >();
+    checkConcept<StaticGraph, RevGraphWrapper<Graph> >();
 
-    checkConcept<StaticGraph, SubGraphWrapper<StaticGraph, 
-      StaticGraph::NodeMap<bool> , StaticGraph::EdgeMap<bool> > >();
-    checkConcept<StaticGraph, NodeSubGraphWrapper<StaticGraph, 
-      StaticGraph::NodeMap<bool> > >();
-    checkConcept<StaticGraph, EdgeSubGraphWrapper<StaticGraph, 
-      StaticGraph::EdgeMap<bool> > >();
+    checkConcept<StaticGraph, SubGraphWrapper<Graph, 
+      Graph::NodeMap<bool> , Graph::EdgeMap<bool> > >();
+    checkConcept<StaticGraph, NodeSubGraphWrapper<Graph, 
+      Graph::NodeMap<bool> > >();
+    checkConcept<StaticGraph, EdgeSubGraphWrapper<Graph, 
+      Graph::EdgeMap<bool> > >();
     
-    checkConcept<StaticGraph, SubBidirGraphWrapper<StaticGraph, 
-      StaticGraph::EdgeMap<bool>, StaticGraph::EdgeMap<bool> > >();
+    checkConcept<StaticGraph, SubBidirGraphWrapper<Graph, 
+      Graph::EdgeMap<bool>, Graph::EdgeMap<bool> > >();
+    checkConcept<StaticGraph, BidirGraph<Graph> >();
+    checkConcept<StaticGraph, ResGraphWrapper<Graph, int, 
+      Graph::EdgeMap<int>, Graph::EdgeMap<int> > >();
 
-    checkConcept<StaticGraph, BidirGraph<StaticGraph> >();
-
-    checkConcept<StaticGraph, ResGraphWrapper<StaticGraph, int, 
-      StaticGraph::EdgeMap<int>, StaticGraph::EdgeMap<int> > >();
-
-//     function_requires<StaticGraphConcept<ErasingFirstGraphWrapper<Graph, Graph::NodeMap<Graph::Edge> > > >();
+    checkConcept<StaticGraph, ErasingFirstGraphWrapper<Graph, 
+      Graph::NodeMap<Graph::Edge> > >(); 
   }
   std::cout << __FILE__ ": All tests passed.\n";
 



More information about the Lemon-commits mailing list