# HG changeset patch # User alpar # Date 1090954570 0 # Node ID efab34f23b30187b8e381570f8c62164939f0c56 # Parent 235fd36336b78e0801821b4a290c73474bf382bb Bugfix + working example diff -r 235fd36336b7 -r efab34f23b30 src/work/alpar/bfs-named-param.cc --- a/src/work/alpar/bfs-named-param.cc Tue Jul 27 16:09:42 2004 +0000 +++ b/src/work/alpar/bfs-named-param.cc Tue Jul 27 18:56:10 2004 +0000 @@ -3,6 +3,7 @@ #include #include #include +#include using namespace hugo; @@ -89,29 +90,29 @@ } template - _BFS + _BFS setPredNodeMap(T &t) { - return _BFS + return _BFS (_graph,_source, _visited, t,_predEdge,_priority); } template - _BFS + _BFS setPredEdgeMap(T &t) { - return _BFS + return _BFS (_graph,_source, _visited, _predNode,t,_priority); } - _BFS + _BFS setNothing() { - return _BFS + return _BFS (_graph,_source, _visited, _predNode,_predEdge,_priority); @@ -145,15 +146,49 @@ } +class MyVisitedMap : public SmartGraph::NodeMap +{ + const SmartGraph &_G; +public: + MyVisitedMap(const SmartGraph &G) : SmartGraph::NodeMap(G), _G(G) {} + void set(SmartGraph::Node n,bool b) + { + SmartGraph::NodeMap::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 m(G); SmartGraph::NodeMap 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(); }