[Lemon-commits] [lemon_svn] alpar: r1001 - hugo/trunk/src/work/alpar

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


Author: alpar
Date: Tue Jul 27 20:56:10 2004
New Revision: 1001

Modified:
   hugo/trunk/src/work/alpar/bfs-named-param.cc

Log:
Bugfix + working example


Modified: hugo/trunk/src/work/alpar/bfs-named-param.cc
==============================================================================
--- hugo/trunk/src/work/alpar/bfs-named-param.cc	(original)
+++ hugo/trunk/src/work/alpar/bfs-named-param.cc	Tue Jul 27 20:56:10 2004
@@ -3,6 +3,7 @@
 #include <hugo/smart_graph.h>
 #include <hugo/maps.h>
 #include <vector>
+#include <iostream>
 
 using namespace hugo;
 
@@ -89,29 +90,29 @@
   }
 
   template<class T>
-  _BFS<Graph,Visited,_BFS_CUSTOM_VIS,T,PredEdge,Priority>
+  _BFS<Graph,Visited,DefaultVisitedTag,T,PredEdge,Priority>
   setPredNodeMap(T &t)
   {
-    return _BFS<Graph,Visited,_BFS_CUSTOM_VIS,T,PredEdge,Priority>
+    return _BFS<Graph,Visited,DefaultVisitedTag,T,PredEdge,Priority>
       (_graph,_source,
        _visited,
        t,_predEdge,_priority);
   }
 
   template<class T>
-  _BFS<Graph,Visited,_BFS_CUSTOM_VIS,PredNode,T,Priority>
+  _BFS<Graph,Visited,DefaultVisitedTag,PredNode,T,Priority>
   setPredEdgeMap(T &t)
   {
-    return _BFS<Graph,Visited,_BFS_CUSTOM_VIS,PredNode,T,Priority>
+    return _BFS<Graph,Visited,DefaultVisitedTag,PredNode,T,Priority>
       (_graph,_source,
        _visited,
       _predNode,t,_priority);
   }
 
-  _BFS<Graph,Visited,_BFS_CUSTOM_VIS,PredNode,PredEdge,Priority>
+  _BFS<Graph,Visited,DefaultVisitedTag,PredNode,PredEdge,Priority>
   setNothing()
   {
-    return _BFS<Graph,Visited,_BFS_CUSTOM_VIS,PredNode,PredEdge,Priority>
+    return _BFS<Graph,Visited,DefaultVisitedTag,PredNode,PredEdge,Priority>
       (_graph,_source,
        _visited,
        _predNode,_predEdge,_priority);
@@ -145,15 +146,49 @@
 }
 
 
+class MyVisitedMap : public SmartGraph::NodeMap<bool>
+{
+  const SmartGraph &_G;
+public:
+  MyVisitedMap(const SmartGraph &G) : SmartGraph::NodeMap<bool>(G), _G(G) {}
+  void set(SmartGraph::Node n,bool b)
+  {
+    SmartGraph::NodeMap<bool>::set(n,b);
+    if(b) std::cout << _G.id(n) << std::endl;
+  }
+};
+
+
 int main()
 {
   SmartGraph G;
-  SmartGraph::NodeIt n(G);
+  SmartGraph::Node s=G.addNode();
+  SmartGraph::Node n1=G.addNode();
+  SmartGraph::Node n2=G.addNode();
+  SmartGraph::Node n3=G.addNode();
+  SmartGraph::Node n4=G.addNode();
+  SmartGraph::Node n5=G.addNode();
+  SmartGraph::Node n6=G.addNode();
+  SmartGraph::Node n7=G.addNode();
+
+  G.addEdge(s,n1);G.addEdge(s,n3);G.addEdge(n1,n2);G.addEdge(n1,n3);
+  G.addEdge(s,n4);G.addEdge(n4,n7);G.addEdge(n7,n6);G.addEdge(n4,n5);
+  G.addEdge(n7,n2);G.addEdge(n6,n3);G.addEdge(n4,s);G.addEdge(n1,s);
+
+  
+  
   SmartGraph::NodeMap<SmartGraph::Node> m(G);
   SmartGraph::NodeMap<SmartGraph::Edge> em(G);
-  
-  bfs(G,n).run();
-  bfs(G,n).setPredNodeMap(m).run();
-  bfs(G,n).setPredNodeMap(m).setPredEdgeMap(em).run();
+
+  MyVisitedMap vm(G);
+
+
+  //bfs(G,n).run(); 
+
+  bfs(G,s).setPredNodeMap(m).run();
+
+  bfs(G,s).setPredNodeMap(m).setPredEdgeMap(em).run();
+
+  bfs(G,s).setVisitMap(vm).run();
 
 }



More information about the Lemon-commits mailing list