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

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


Author: marci
Date: Mon Mar 22 17:37:10 2004
New Revision: 331

Modified:
   hugo/trunk/src/work/iterator_bfs_demo.cc
   hugo/trunk/src/work/marci/graph_wrapper.h

Log:
RevGraphWrapper


Modified: hugo/trunk/src/work/iterator_bfs_demo.cc
==============================================================================
--- hugo/trunk/src/work/iterator_bfs_demo.cc	(original)
+++ hugo/trunk/src/work/iterator_bfs_demo.cc	Mon Mar 22 17:37:10 2004
@@ -78,55 +78,55 @@
   cout << "    \\-->    ------------->         "<< endl;
   
 //   typedef TrivGraphWrapper<const Graph> CGW;
-//   CGW wG(G);
+//   CGW gw(G);
 
 //   cout << "bfs and dfs demo on the directed graph" << endl;
-//   for(CGW::NodeIt n=wG.first<CGW::NodeIt>(); n.valid(); ++n) { 
+//   for(CGW::NodeIt n=gw.first<CGW::NodeIt>(); n.valid(); ++n) { 
 //     cout << n << ": ";
 //     cout << "out edges: ";
-//     for(CGW::OutEdgeIt e=wG.first<CGW::OutEdgeIt>(n); e.valid(); ++e) 
+//     for(CGW::OutEdgeIt e=gw.first<CGW::OutEdgeIt>(n); e.valid(); ++e) 
 //       cout << e << " ";
 //     cout << "in edges: ";
-//     for(CGW::InEdgeIt e=wG.first<CGW::InEdgeIt>(n); e.valid(); ++e) 
+//     for(CGW::InEdgeIt e=gw.first<CGW::InEdgeIt>(n); e.valid(); ++e) 
 //       cout << e << " ";
 //     cout << endl;
 //   }
 
   {
     typedef TrivGraphWrapper<const Graph> GW;
-    GW wG(G);
+    GW gw(G);
 
-    EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(wG, node_name);
+    EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name);
     
     cout << "bfs and dfs iterator demo on the directed graph" << endl;
-    for(GW::NodeIt n=wG.first<GW::NodeIt>(); wG.valid(n); wG.next(n)) { 
+    for(GW::NodeIt n=gw.first<GW::NodeIt>(); gw.valid(n); gw.next(n)) { 
       cout << node_name.get(n) << ": ";
       cout << "out edges: ";
-      for(GW::OutEdgeIt e=wG.first<GW::OutEdgeIt>(n); wG.valid(e); wG.next(e)) 
+      for(GW::OutEdgeIt e=gw.first<GW::OutEdgeIt>(n); gw.valid(e); gw.next(e)) 
 	cout << edge_name.get(e) << " ";
       cout << "in edges: ";
-      for(GW::InEdgeIt e=wG.first<GW::InEdgeIt>(n); wG.valid(e); wG.next(e)) 
+      for(GW::InEdgeIt e=gw.first<GW::InEdgeIt>(n); gw.valid(e); gw.next(e)) 
 	cout << edge_name.get(e) << " ";
       cout << endl;
     }
 
     cout << "bfs from s ..." << endl;
-    BfsIterator5< GW, GW::NodeMap<bool> > bfs(wG);
+    BfsIterator5< GW, GW::NodeMap<bool> > bfs(gw);
     bfs.pushAndSetReached(s);
     while (!bfs.finished()) {
       //cout << "edge: ";
-      if (wG.valid(bfs)) {
+      if (gw.valid(bfs)) {
 	cout << edge_name.get(bfs) << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(wG.aNode(bfs)) << 
+	  node_name.get(gw.aNode(bfs)) << 
 	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ node_name.get(wG.bNode(bfs)) << 
+	  node_name.get(gw.bNode(bfs)) << 
 	  (bfs.isBNodeNewlyReached() ? ": is newly reached." : 
 	   ": is not newly reached.");
       } else { 
 	cout << "invalid" << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(bfs.aNode()) << 
+	  node_name.get(bfs.aNode()) << 
 	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ 
+	  
 	  "invalid.";
       }
       cout << endl;
@@ -144,23 +144,23 @@
     cout << "    \\-->    ------------->         "<< endl;
 
     cout << "dfs from s ..." << endl;
-    DfsIterator5< GW, GW::NodeMap<bool> > dfs(wG);
+    DfsIterator5< GW, GW::NodeMap<bool> > dfs(gw);
     dfs.pushAndSetReached(s);
     while (!dfs.finished()) {
       ++dfs;
       //cout << "edge: ";
-      if (wG.valid(dfs)) {
+      if (gw.valid(dfs)) {
 	cout << edge_name.get(dfs) << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(wG.aNode(dfs)) << 
+	  node_name.get(gw.aNode(dfs)) << 
 	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ node_name.get(wG.bNode(dfs)) << 
+	  node_name.get(gw.bNode(dfs)) << 
 	  (dfs.isBNodeNewlyReached() ? ": is newly reached." : 
 	   ": is not newly reached.");
       } else { 
 	cout << "invalid" << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(dfs.aNode()) << 
+	  node_name.get(dfs.aNode()) << 
 	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ 
+	  
 	  "invalid.";
       }
       cout << endl;
@@ -169,40 +169,40 @@
 
 
   {
-    typedef RevGraphWrapper<const Graph> GW;
-    GW wG(G);
+    typedef RevGraphWrapper<const TrivGraphWrapper<const Graph> > GW;
+    GW gw(G);
     
-    EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(wG, node_name);
+    EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name);
     
     cout << "bfs and dfs iterator demo on the reversed directed graph" << endl;
-    for(GW::NodeIt n=wG.first<GW::NodeIt>(); wG.valid(n); wG.next(n)) { 
+    for(GW::NodeIt n=gw.first<GW::NodeIt>(); gw.valid(n); gw.next(n)) { 
       cout << node_name.get(n) << ": ";
       cout << "out edges: ";
-      for(GW::OutEdgeIt e=wG.first<GW::OutEdgeIt>(n); wG.valid(e); wG.next(e)) 
+      for(GW::OutEdgeIt e=gw.first<GW::OutEdgeIt>(n); gw.valid(e); gw.next(e)) 
 	cout << edge_name.get(e) << " ";
       cout << "in edges: ";
-      for(GW::InEdgeIt e=wG.first<GW::InEdgeIt>(n); wG.valid(e); wG.next(e)) 
+      for(GW::InEdgeIt e=gw.first<GW::InEdgeIt>(n); gw.valid(e); gw.next(e)) 
 	cout << edge_name.get(e) << " ";
       cout << endl;
     }
 
     cout << "bfs from t ..." << endl;
-    BfsIterator5< GW, GW::NodeMap<bool> > bfs(wG);
+    BfsIterator5< GW, GW::NodeMap<bool> > bfs(gw);
     bfs.pushAndSetReached(t);
     while (!bfs.finished()) {
       //cout << "edge: ";
-      if (wG.valid(bfs)) {
+      if (gw.valid(bfs)) {
 	cout << edge_name.get(bfs) << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(wG.aNode(bfs)) << 
+	  node_name.get(gw.aNode(bfs)) << 
 	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ node_name.get(wG.bNode(bfs)) << 
+	  node_name.get(gw.bNode(bfs)) << 
 	  (bfs.isBNodeNewlyReached() ? ": is newly reached." : 
 	   ": is not newly reached.");
       } else { 
 	cout << "invalid" << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(bfs.aNode()) << 
+	  node_name.get(bfs.aNode()) << 
 	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ 
+	  
 	  "invalid.";
       }
       cout << endl;
@@ -220,23 +220,23 @@
     cout << "    \\-->    ------------->         "<< endl;
     
     cout << "dfs from t ..." << endl;
-    DfsIterator5< GW, GW::NodeMap<bool> > dfs(wG);
+    DfsIterator5< GW, GW::NodeMap<bool> > dfs(gw);
     dfs.pushAndSetReached(t);
     while (!dfs.finished()) {
       ++dfs;
       //cout << "edge: ";
-      if (wG.valid(dfs)) {
+      if (gw.valid(dfs)) {
 	cout << edge_name.get(dfs) << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(wG.aNode(dfs)) << 
+	  node_name.get(gw.aNode(dfs)) << 
 	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ node_name.get(wG.bNode(dfs)) << 
+	  node_name.get(gw.bNode(dfs)) << 
 	  (dfs.isBNodeNewlyReached() ? ": is newly reached." : 
 	   ": is not newly reached.");
       } else { 
 	cout << "invalid" << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(dfs.aNode()) << 
+	  node_name.get(dfs.aNode()) << 
 	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ 
+	  
 	  "invalid.";
       }
       cout << endl;
@@ -245,39 +245,39 @@
 
   {
     typedef UndirGraphWrapper<const Graph> GW;
-    GW wG(G);
+    GW gw(G);
     
-    EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(wG, node_name);
+    EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name);
     
     cout << "bfs and dfs iterator demo on the undirected graph" << endl;
-    for(GW::NodeIt n=wG.first<GW::NodeIt>(); wG.valid(n); wG.next(n)) { 
+    for(GW::NodeIt n=gw.first<GW::NodeIt>(); gw.valid(n); gw.next(n)) { 
       cout << node_name.get(n) << ": ";
       cout << "out edges: ";
-      for(GW::OutEdgeIt e=wG.first<GW::OutEdgeIt>(n); wG.valid(e); wG.next(e)) 
+      for(GW::OutEdgeIt e=gw.first<GW::OutEdgeIt>(n); gw.valid(e); gw.next(e)) 
 	cout << edge_name.get(e) << " ";
       cout << "in edges: ";
-      for(GW::InEdgeIt e=wG.first<GW::InEdgeIt>(n); wG.valid(e); wG.next(e)) 
+      for(GW::InEdgeIt e=gw.first<GW::InEdgeIt>(n); gw.valid(e); gw.next(e)) 
 	cout << edge_name.get(e) << " ";
       cout << endl;
     }
 
     cout << "bfs from t ..." << endl;
-    BfsIterator5< GW, GW::NodeMap<bool> > bfs(wG);
+    BfsIterator5< GW, GW::NodeMap<bool> > bfs(gw);
     bfs.pushAndSetReached(t);
     while (!bfs.finished()) {
       //cout << "edge: ";
-      if (wG.valid(GW::OutEdgeIt(bfs))) {
+      if (gw.valid(GW::OutEdgeIt(bfs))) {
 	cout << edge_name.get(GW::OutEdgeIt(bfs)) << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(wG.aNode(bfs)) << 
+	  node_name.get(gw.aNode(bfs)) << 
 	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ node_name.get(wG.bNode(bfs)) << 
+	  node_name.get(gw.bNode(bfs)) << 
 	  (bfs.isBNodeNewlyReached() ? ": is newly reached." : 
 	   ": is not newly reached.");
       } else { 
 	cout << "invalid" << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(bfs.aNode()) << 
+	  node_name.get(bfs.aNode()) << 
 	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ 
+	  
 	  "invalid.";
       }
       cout << endl;
@@ -295,23 +295,23 @@
     cout << "    \\-->    ------------->         "<< endl;
     
     cout << "dfs from t ..." << endl;
-    DfsIterator5< GW, GW::NodeMap<bool> > dfs(wG);
+    DfsIterator5< GW, GW::NodeMap<bool> > dfs(gw);
     dfs.pushAndSetReached(t);
     while (!dfs.finished()) {
       ++dfs;
       //cout << "edge: ";
-      if (wG.valid(GW::OutEdgeIt(dfs))) {
+      if (gw.valid(GW::OutEdgeIt(dfs))) {
 	cout << edge_name.get(GW::OutEdgeIt(dfs)) << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(wG.aNode(dfs)) << 
+	  node_name.get(gw.aNode(dfs)) << 
 	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ node_name.get(wG.bNode(dfs)) << 
+	  node_name.get(gw.bNode(dfs)) << 
 	  (dfs.isBNodeNewlyReached() ? ": is newly reached." : 
 	   ": is not newly reached.");
       } else { 
 	cout << "invalid" << /*endl*/", " << 
-	  /*" aNode: " <<*/ node_name.get(dfs.aNode()) << 
+	  node_name.get(dfs.aNode()) << 
 	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
-	  /*" bNode: " <<*/ 
+	  
 	  "invalid.";
       }
       cout << endl;

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	Mon Mar 22 17:37:10 2004
@@ -240,9 +240,10 @@
 //     };
 //   };
 
-  template<typename Graph>
+  template<typename /*Graph*/GraphWrapper
+  /*=typename GraphWrapperSkeleton< TrivGraphWrapper<Graph>*/ >
   class RevGraphWrapper : 
-    public GraphWrapperSkeleton< TrivGraphWrapper<Graph> > {
+    public GraphWrapper/*GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/ {
   protected:
     //Graph* graph;
     
@@ -253,13 +254,13 @@
     //typedef typename Graph::NodeIt NodeIt;
   
     //typedef typename Graph::Edge Edge;
-    typedef typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::OutEdgeIt InEdgeIt;
-    typedef typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::InEdgeIt OutEdgeIt;
+    typedef typename GraphWrapper/*typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/::OutEdgeIt InEdgeIt;
+    typedef typename GraphWrapper/*typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/::InEdgeIt OutEdgeIt;
     //typedef typename Graph::SymEdgeIt SymEdgeIt;
     //typedef typename Graph::EdgeIt EdgeIt;
 
     //RevGraphWrapper() : graph(0) { }
-    RevGraphWrapper(Graph& _graph) : GraphWrapperSkeleton< TrivGraphWrapper<Graph> >(TrivGraphWrapper<Graph>(_graph)) { }
+    RevGraphWrapper(GraphWrapper _gw/*BaseGraph& _graph*/) : GraphWrapper/*GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/(_gw/*TrivGraphWrapper<Graph>(_graph)*/) { }
     
     //void setGraph(Graph& _graph) { graph = &_graph; }
     //Graph& getGraph() const { return (*graph); }
@@ -304,22 +305,22 @@
     //void clear() const { graph->clear(); }
 
     template<typename T> class NodeMap : 
-      public GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::NodeMap<T> 
+      public GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::NodeMap<T> 
     { 
     public:
-      NodeMap(const RevGraphWrapper<Graph>& _G) : 
-	GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::NodeMap<T>(_G) { }
-      NodeMap(const RevGraphWrapper<Graph>& _G, T a) : 
-	GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::NodeMap<T>(_G, a) { }
+      NodeMap(const RevGraphWrapper<GraphWrapper>& _gw) : 
+	GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::NodeMap<T>(_gw) { }
+      NodeMap(const RevGraphWrapper<GraphWrapper>& _gw, T a) : 
+	GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::NodeMap<T>(_gw, a) { }
     };
     
     template<typename T> class EdgeMap : 
-      public GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::EdgeMap<T> { 
+      public GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::EdgeMap<T> { 
     public:
-      EdgeMap(const RevGraphWrapper<Graph>& _G) : 
-	GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::EdgeMap<T>(_G) { }
-      EdgeMap(const RevGraphWrapper<Graph>& _G, T a) : 
-	GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::EdgeMap<T>(_G, a) { }
+      EdgeMap(const RevGraphWrapper<GraphWrapper>& _gw) : 
+	GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::EdgeMap<T>(_gw) { }
+      EdgeMap(const RevGraphWrapper<GraphWrapper>& _gw, T a) : 
+	GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::EdgeMap<T>(_gw, a) { }
     };
   };
 



More information about the Lemon-commits mailing list