1.1 --- a/src/work/bfsdemo2.cc Tue Dec 16 17:52:52 2003 +0000
1.2 +++ b/src/work/bfsdemo2.cc Tue Dec 16 18:17:51 2003 +0000
1.3 @@ -15,16 +15,23 @@
1.4
1.5 TestGraph::NodeIterator tn,n2;
1.6
1.7 - for(int i=1;i<=5000;i++)
1.8 + cout << "Create nodes\n";
1.9 +
1.10 + for(int i=1;i<=500;i++)
1.11 {
1.12 *(tn=G.AddNode())=i;
1.13 if(i==2) n2=tn;
1.14 }
1.15
1.16 + cout << "Create Edges\n";
1.17 +
1.18 for(TestGraph::NodeIterator n(G);n.isValid();++n)
1.19 - for(TestGraph::NodeIterator m(G);m.isValid();++m)
1.20 + for(TestGraph::NodeIterator m(G);m.isValid();++m) if(n!=m)
1.21 if(gcd(*n,*m)>1) G.AddEdge(n,m);
1.22
1.23 +
1.24 + cout << "Run BFS\n";
1.25 +
1.26 Bfs<default_bfs_T<TestGraph> > bfs;
1.27
1.28 bfs.SetG(G);
1.29 @@ -32,7 +39,12 @@
1.30 bfs.Run();
1.31
1.32 for(TestGraph::NodeIterator n(G);n.isValid();++n)
1.33 - cout << Get(bfs.tree_map,n).From() << "->" << Get(bfs.tree_map,n).To()
1.34 - << '\n';
1.35 + if((*n)!=2)
1.36 + cout << (Get(bfs.dist_map,n)) << '\n';
1.37
1.38 + for(TestGraph::NodeIterator n(G);n.isValid();++n)
1.39 + if(Get(bfs.dist_map,n))
1.40 + cout << *(Get(bfs.tree_map,n).From()) << "->"
1.41 + << *(Get(bfs.tree_map,n).To())
1.42 + << '\n';
1.43 }