src/work/marci/iterator_bfs_demo.cc
changeset 382 f177fc597abd
parent 317 6e6db1c49bc1
child 389 770cc1f4861f
equal deleted inserted replaced
3:3fdd1b517611 4:865ec3bf7662
   101 	cout << edge_name[e] << " ";
   101 	cout << edge_name[e] << " ";
   102       cout << endl;
   102       cout << endl;
   103     }
   103     }
   104 
   104 
   105     cout << "bfs from s ..." << endl;
   105     cout << "bfs from s ..." << endl;
   106     BfsIterator5< Graph, Graph::NodeMap<bool> > bfs(G);
   106     BfsIterator< Graph, Graph::NodeMap<bool> > bfs(G);
   107     bfs.pushAndSetReached(s);
   107     bfs.pushAndSetReached(s);
   108     while (!bfs.finished()) {
   108     while (!bfs.finished()) {
   109       //cout << "edge: ";
   109       //cout << "edge: ";
   110       if (G.valid(bfs)) {
   110       if (G.valid(bfs)) {
   111 	cout << edge_name[bfs] << /*endl*/", " << 
   111 	cout << edge_name[bfs] << /*endl*/", " << 
   134     cout << "  \\ |       --/ /     |    |    /     "<< endl;
   134     cout << "  \\ |       --/ /     |    |    /     "<< endl;
   135     cout << "   \\ \\-> v2 <--/       \\-- v4 -/      "<< endl;
   135     cout << "   \\ \\-> v2 <--/       \\-- v4 -/      "<< endl;
   136     cout << "    \\-->    ------------->         "<< endl;
   136     cout << "    \\-->    ------------->         "<< endl;
   137 
   137 
   138     cout << "dfs from s ..." << endl;
   138     cout << "dfs from s ..." << endl;
   139     DfsIterator5< Graph, Graph::NodeMap<bool> > dfs(G);
   139     DfsIterator< Graph, Graph::NodeMap<bool> > dfs(G);
   140     dfs.pushAndSetReached(s);
   140     dfs.pushAndSetReached(s);
   141     while (!dfs.finished()) {
   141     while (!dfs.finished()) {
   142       ++dfs;
   142       ++dfs;
   143       //cout << "edge: ";
   143       //cout << "edge: ";
   144       if (G.valid(dfs)) {
   144       if (G.valid(dfs)) {
   177 	cout << edge_name[e] << " ";
   177 	cout << edge_name[e] << " ";
   178       cout << endl;
   178       cout << endl;
   179     }
   179     }
   180 
   180 
   181     cout << "bfs from t ..." << endl;
   181     cout << "bfs from t ..." << endl;
   182     BfsIterator5< GW, GW::NodeMap<bool> > bfs(gw);
   182     BfsIterator< GW, GW::NodeMap<bool> > bfs(gw);
   183     bfs.pushAndSetReached(t);
   183     bfs.pushAndSetReached(t);
   184     while (!bfs.finished()) {
   184     while (!bfs.finished()) {
   185       //cout << "edge: ";
   185       //cout << "edge: ";
   186       if (gw.valid(GW::OutEdgeIt(bfs))) {
   186       if (gw.valid(GW::OutEdgeIt(bfs))) {
   187 	cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " << 
   187 	cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " << 
   210     cout << "  \\ |       --/ /     |    |    /     "<< endl;
   210     cout << "  \\ |       --/ /     |    |    /     "<< endl;
   211     cout << "   \\ \\-> v2 <--/       \\-- v4 -/      "<< endl;
   211     cout << "   \\ \\-> v2 <--/       \\-- v4 -/      "<< endl;
   212     cout << "    \\-->    ------------->         "<< endl;
   212     cout << "    \\-->    ------------->         "<< endl;
   213     
   213     
   214     cout << "dfs from t ..." << endl;
   214     cout << "dfs from t ..." << endl;
   215     DfsIterator5< GW, GW::NodeMap<bool> > dfs(gw);
   215     DfsIterator< GW, GW::NodeMap<bool> > dfs(gw);
   216     dfs.pushAndSetReached(t);
   216     dfs.pushAndSetReached(t);
   217     while (!dfs.finished()) {
   217     while (!dfs.finished()) {
   218       ++dfs;
   218       ++dfs;
   219       //cout << "edge: ";
   219       //cout << "edge: ";
   220       if (gw.valid(GW::OutEdgeIt(dfs))) {
   220       if (gw.valid(GW::OutEdgeIt(dfs))) {
   256 //       cout << edge_name.get(e) << " ";
   256 //       cout << edge_name.get(e) << " ";
   257 //     }
   257 //     }
   258 //     cout << endl;
   258 //     cout << endl;
   259 
   259 
   260     cout << "bfs from t ..." << endl;
   260     cout << "bfs from t ..." << endl;
   261     BfsIterator5< GW, GW::NodeMap<bool> > bfs(gw);
   261     BfsIterator< GW, GW::NodeMap<bool> > bfs(gw);
   262     bfs.pushAndSetReached(t);
   262     bfs.pushAndSetReached(t);
   263     while (!bfs.finished()) {
   263     while (!bfs.finished()) {
   264       //cout << "edge: ";
   264       //cout << "edge: ";
   265       if (gw.valid(GW::OutEdgeIt(bfs))) {
   265       if (gw.valid(GW::OutEdgeIt(bfs))) {
   266 	cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " << 
   266 	cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " << 
   289     cout << "  \\ |       --/ /     |    |    /     "<< endl;
   289     cout << "  \\ |       --/ /     |    |    /     "<< endl;
   290     cout << "   \\ \\-> v2 <--/       \\-- v4 -/      "<< endl;
   290     cout << "   \\ \\-> v2 <--/       \\-- v4 -/      "<< endl;
   291     cout << "    \\-->    ------------->         "<< endl;
   291     cout << "    \\-->    ------------->         "<< endl;
   292     
   292     
   293     cout << "dfs from t ..." << endl;
   293     cout << "dfs from t ..." << endl;
   294     DfsIterator5< GW, GW::NodeMap<bool> > dfs(gw);
   294     DfsIterator< GW, GW::NodeMap<bool> > dfs(gw);
   295     dfs.pushAndSetReached(t);
   295     dfs.pushAndSetReached(t);
   296     while (!dfs.finished()) {
   296     while (!dfs.finished()) {
   297       ++dfs;
   297       ++dfs;
   298       //cout << "edge: ";
   298       //cout << "edge: ";
   299       if (gw.valid(GW::OutEdgeIt(dfs))) {
   299       if (gw.valid(GW::OutEdgeIt(dfs))) {