src/work/iterator_bfs_demo.cc
changeset 158 4f54d89fa9d2
parent 107 8d62f0072ff0
child 174 44700ed9ffaa
     1.1 --- a/src/work/iterator_bfs_demo.cc	Sun Mar 07 19:33:34 2004 +0000
     1.2 +++ b/src/work/iterator_bfs_demo.cc	Mon Mar 08 12:29:07 2004 +0000
     1.3 @@ -7,16 +7,32 @@
     1.4  #include <graph_wrapper.h>
     1.5  
     1.6  using namespace hugo;
     1.7 +using std::cout; 
     1.8 +using std::endl;
     1.9 +using std::string;
    1.10 +
    1.11 +template <typename Graph, typename NodeNameMap>
    1.12 +class EdgeNameMap {
    1.13 +  Graph& graph;
    1.14 +  NodeNameMap& node_name_map;
    1.15 +public:
    1.16 +  EdgeNameMap(Graph& _graph, NodeNameMap& _node_name_map) : 
    1.17 +    graph(_graph), node_name_map(_node_name_map) { }
    1.18 +  string get(typename Graph::EdgeIt e) const { 
    1.19 +    return 
    1.20 +      (node_name_map.get(graph.tail(e))+"->"+node_name_map.get(graph.head(e)));
    1.21 +  }
    1.22 +};
    1.23  
    1.24  int main (int, char*[])
    1.25  {
    1.26    typedef ListGraph::NodeIt NodeIt;
    1.27    typedef ListGraph::EdgeIt EdgeIt;
    1.28 -  typedef ListGraph::EachNodeIt EachNodeIt;
    1.29 -  typedef ListGraph::EachEdgeIt EachEdgeIt;
    1.30 -  typedef ListGraph::OutEdgeIt OutEdgeIt;
    1.31 -  typedef ListGraph::InEdgeIt InEdgeIt;
    1.32 -  typedef ListGraph::SymEdgeIt SymEdgeIt;
    1.33 +  //typedef ListGraph::EachNodeIt EachNodeIt;
    1.34 +  //typedef ListGraph::EachEdgeIt EachEdgeIt;
    1.35 +  //typedef ListGraph::OutEdgeIt OutEdgeIt;
    1.36 +  //typedef ListGraph::InEdgeIt InEdgeIt;
    1.37 +  //typedef ListGraph::SymEdgeIt SymEdgeIt;
    1.38   
    1.39    ListGraph G;
    1.40  
    1.41 @@ -27,6 +43,14 @@
    1.42    NodeIt v4=G.addNode();
    1.43    NodeIt t=G.addNode();
    1.44    
    1.45 +  ListGraph::NodeMap<string> node_name(G);
    1.46 +  node_name.set(s, "s");
    1.47 +  node_name.set(v1, "v1");
    1.48 +  node_name.set(v2, "v2");
    1.49 +  node_name.set(v3, "v3");
    1.50 +  node_name.set(v4, "v4");
    1.51 +  node_name.set(t, "t");
    1.52 +
    1.53    G.addEdge(s, v1);
    1.54    G.addEdge(s, v2);
    1.55    G.addEdge(v1, v2);
    1.56 @@ -38,123 +62,317 @@
    1.57    G.addEdge(v3, t);
    1.58    G.addEdge(v4, t);
    1.59  
    1.60 -  std::cout << "bfs and dfs demo on the directed graph" << std::endl;
    1.61 -  for(EachNodeIt i=G.first<EachNodeIt>(); i.valid(); ++i) { 
    1.62 -    std::cout << i << ": ";
    1.63 -    std::cout << "out edges: ";
    1.64 -    for(OutEdgeIt j=G.first<OutEdgeIt>(i); j.valid(); ++j) 
    1.65 -      std::cout << j << " ";
    1.66 -    std::cout << "in edges: ";
    1.67 -    for(InEdgeIt j=G.first<InEdgeIt>(i); j.valid(); ++j) 
    1.68 -      std::cout << j << " ";
    1.69 -    std::cout << std::endl;
    1.70 +  cout << "    /-->    ------------->            "<< endl;
    1.71 +  cout << "   / /-- v1 <-\\      /---- v3-\\      "<< endl;
    1.72 +  cout << "  / |          |    /  /->     \\     "<< endl;
    1.73 +  cout << " /  |          |   /  |    ^    \\  "<< endl;
    1.74 +  cout << "s   |          |  /   |    |     \\->  t "<< endl;
    1.75 +  cout << " \\  |          | /    |    |     /->  "<< endl;
    1.76 +  cout << "  \\ |       --/ /     |    |    /     "<< endl;
    1.77 +  cout << "   \\ \\-> v2 <--/       \\-- v4 -/      "<< endl;
    1.78 +  cout << "    \\-->    ------------->         "<< endl;
    1.79 +  
    1.80 +/*
    1.81 +  {
    1.82 +  cout << "iterator bfs demo 4 ..." << endl;
    1.83 +  BfsIterator4< ListGraph, ListGraph::OutEdgeIt, ListGraph::NodeMap<bool> > bfs(G);
    1.84 +  bfs.pushAndSetReached(s);
    1.85 +  while (!bfs.finished()) {
    1.86 +  if (OutEdgeIt(bfs).valid()) {
    1.87 +  cout << "OutEdgeIt: " << bfs; 
    1.88 +  cout << " aNode: " << G.aNode(bfs); 
    1.89 +  cout << " bNode: " << G.bNode(bfs) << " ";
    1.90 +  } else { 
    1.91 +  cout << "OutEdgeIt: " << "invalid"; 
    1.92 +  cout << " aNode: " << bfs.aNode(); 
    1.93 +  cout << " bNode: " << "invalid" << " ";
    1.94    }
    1.95 -  
    1.96 +  if (bfs.isBNodeNewlyReached()) { 
    1.97 +  cout << "bNodeIsNewlyReached ";
    1.98 +  } else { 
    1.99 +  cout << "bNodeIsNotNewlyReached ";
   1.100 +  } 
   1.101 +  if (bfs.isANodeExamined()) { 
   1.102 +  cout << "aNodeIsExamined ";
   1.103 +  } else { 
   1.104 +  cout << "aNodeIsNotExamined ";
   1.105 +  } 
   1.106 +  cout << endl;
   1.107 +  ++bfs;
   1.108 +  }
   1.109 +  }
   1.110 +
   1.111    {
   1.112 -    std::cout << "iterator bfs demo 4 ..." << std::endl;
   1.113 -    BfsIterator4< ListGraph, ListGraph::OutEdgeIt, ListGraph::NodeMap<bool> > bfs(G);
   1.114 +  cout << "iterator dfs demo 4 ..." << endl;
   1.115 +  DfsIterator4< ListGraph, ListGraph::OutEdgeIt, ListGraph::NodeMap<bool> > dfs(G);
   1.116 +  dfs.pushAndSetReached(s);
   1.117 +  while (!dfs.finished()) {
   1.118 +  ++dfs;
   1.119 +  if (OutEdgeIt(dfs).valid()) {
   1.120 +  cout << "OutEdgeIt: " << dfs; 
   1.121 +  cout << " aNode: " << G.aNode(dfs); 
   1.122 +  cout << " bNode: " << G.bNode(dfs) << " ";
   1.123 +  } else { 
   1.124 +  cout << "OutEdgeIt: " << "invalid"; 
   1.125 +  cout << " aNode: " << dfs.aNode(); 
   1.126 +  cout << " bNode: " << "invalid" << " ";
   1.127 +  }
   1.128 +  if (dfs.isBNodeNewlyReached()) { 
   1.129 +  cout << "bNodeIsNewlyReached ";
   1.130 +  } else { 
   1.131 +  cout << "bNodeIsNotNewlyReached ";
   1.132 +  } 
   1.133 +  if (dfs.isANodeExamined()) { 
   1.134 +  cout << "aNodeIsExamined ";
   1.135 +  } else { 
   1.136 +  cout << "aNodeIsNotExamined ";
   1.137 +  } 
   1.138 +  cout << endl;
   1.139 +  //++dfs;
   1.140 +  }
   1.141 +  }
   1.142 +*/
   1.143 +
   1.144 +//   typedef TrivGraphWrapper<const ListGraph> CGW;
   1.145 +//   CGW wG(G);
   1.146 +
   1.147 +//   cout << "bfs and dfs demo on the directed graph" << endl;
   1.148 +//   for(CGW::EachNodeIt n=wG.first<CGW::EachNodeIt>(); n.valid(); ++n) { 
   1.149 +//     cout << n << ": ";
   1.150 +//     cout << "out edges: ";
   1.151 +//     for(CGW::OutEdgeIt e=wG.first<CGW::OutEdgeIt>(n); e.valid(); ++e) 
   1.152 +//       cout << e << " ";
   1.153 +//     cout << "in edges: ";
   1.154 +//     for(CGW::InEdgeIt e=wG.first<CGW::InEdgeIt>(n); e.valid(); ++e) 
   1.155 +//       cout << e << " ";
   1.156 +//     cout << endl;
   1.157 +//   }
   1.158 +
   1.159 +  {
   1.160 +    typedef TrivGraphWrapper<const ListGraph> GW;
   1.161 +    GW wG(G);
   1.162 +
   1.163 +    EdgeNameMap< GW, ListGraph::NodeMap<string> > edge_name(wG, node_name);
   1.164 +    
   1.165 +    cout << "bfs and dfs iterator demo on the directed graph" << endl;
   1.166 +    for(GW::EachNodeIt n=wG.first<GW::EachNodeIt>(); wG.valid(n); wG.next(n)) { 
   1.167 +      cout << node_name.get(n) << ": ";
   1.168 +      cout << "out edges: ";
   1.169 +      for(GW::OutEdgeIt e=wG.first<GW::OutEdgeIt>(n); wG.valid(e); wG.next(e)) 
   1.170 +	cout << edge_name.get(e) << " ";
   1.171 +      cout << "in edges: ";
   1.172 +      for(GW::InEdgeIt e=wG.first<GW::InEdgeIt>(n); wG.valid(e); wG.next(e)) 
   1.173 +	cout << edge_name.get(e) << " ";
   1.174 +      cout << endl;
   1.175 +    }
   1.176 +
   1.177 +    cout << "bfs from s ..." << endl;
   1.178 +    BfsIterator5< GW, GW::NodeMap<bool> > bfs(wG);
   1.179      bfs.pushAndSetReached(s);
   1.180      while (!bfs.finished()) {
   1.181 -      if (OutEdgeIt(bfs).valid()) {
   1.182 -	std::cout << "OutEdgeIt: " << bfs; 
   1.183 -	std::cout << " aNode: " << G.aNode(bfs); 
   1.184 -	std::cout << " bNode: " << G.bNode(bfs) << " ";
   1.185 +      //cout << "edge: ";
   1.186 +      if (wG.valid(bfs)) {
   1.187 +	cout << edge_name.get(bfs) << /*endl*/", " << 
   1.188 +	  /*" aNode: " <<*/ node_name.get(wG.aNode(bfs)) << 
   1.189 +	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.190 +	  /*" bNode: " <<*/ node_name.get(wG.bNode(bfs)) << 
   1.191 +	  (bfs.isBNodeNewlyReached() ? ": is newly reached." : 
   1.192 +	   ": is not newly reached.");
   1.193        } else { 
   1.194 -	std::cout << "OutEdgeIt: " << "invalid"; 
   1.195 -	std::cout << " aNode: " << bfs.aNode(); 
   1.196 -	std::cout << " bNode: " << "invalid" << " ";
   1.197 +	cout << "invalid" << /*endl*/", " << 
   1.198 +	  /*" aNode: " <<*/ node_name.get(bfs.aNode()) << 
   1.199 +	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.200 +	  /*" bNode: " <<*/ 
   1.201 +	  "invalid.";
   1.202        }
   1.203 -      if (bfs.isBNodeNewlyReached()) { 
   1.204 -	std::cout << "bNodeIsNewlyReached ";
   1.205 +      cout << endl;
   1.206 +      ++bfs;
   1.207 +    }
   1.208 +
   1.209 +    cout << "    /-->    ------------->            "<< endl;
   1.210 +    cout << "   / /-- v1 <-\\      /---- v3-\\      "<< endl;
   1.211 +    cout << "  / |          |    /  /->     \\     "<< endl;
   1.212 +    cout << " /  |          |   /  |    ^    \\  "<< endl;
   1.213 +    cout << "s   |          |  /   |    |     \\->  t "<< endl;
   1.214 +    cout << " \\  |          | /    |    |     /->  "<< endl;
   1.215 +    cout << "  \\ |       --/ /     |    |    /     "<< endl;
   1.216 +    cout << "   \\ \\-> v2 <--/       \\-- v4 -/      "<< endl;
   1.217 +    cout << "    \\-->    ------------->         "<< endl;
   1.218 +
   1.219 +    cout << "dfs from s ..." << endl;
   1.220 +    DfsIterator5< GW, GW::NodeMap<bool> > dfs(wG);
   1.221 +    dfs.pushAndSetReached(s);
   1.222 +    while (!dfs.finished()) {
   1.223 +      ++dfs;
   1.224 +      //cout << "edge: ";
   1.225 +      if (wG.valid(dfs)) {
   1.226 +	cout << edge_name.get(dfs) << /*endl*/", " << 
   1.227 +	  /*" aNode: " <<*/ node_name.get(wG.aNode(dfs)) << 
   1.228 +	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.229 +	  /*" bNode: " <<*/ node_name.get(wG.bNode(dfs)) << 
   1.230 +	  (dfs.isBNodeNewlyReached() ? ": is newly reached." : 
   1.231 +	   ": is not newly reached.");
   1.232        } else { 
   1.233 -	std::cout << "bNodeIsNotNewlyReached ";
   1.234 -      } 
   1.235 -      if (bfs.isANodeExamined()) { 
   1.236 -	std::cout << "aNodeIsExamined ";
   1.237 +	cout << "invalid" << /*endl*/", " << 
   1.238 +	  /*" aNode: " <<*/ node_name.get(dfs.aNode()) << 
   1.239 +	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.240 +	  /*" bNode: " <<*/ 
   1.241 +	  "invalid.";
   1.242 +      }
   1.243 +      cout << endl;
   1.244 +    }
   1.245 +  }
   1.246 +
   1.247 +
   1.248 +  {
   1.249 +    typedef RevGraphWrapper<const ListGraph> GW;
   1.250 +    GW wG(G);
   1.251 +    
   1.252 +    EdgeNameMap< GW, ListGraph::NodeMap<string> > edge_name(wG, node_name);
   1.253 +    
   1.254 +    cout << "bfs and dfs iterator demo on the reversed directed graph" << endl;
   1.255 +    for(GW::EachNodeIt n=wG.first<GW::EachNodeIt>(); wG.valid(n); wG.next(n)) { 
   1.256 +      cout << node_name.get(n) << ": ";
   1.257 +      cout << "out edges: ";
   1.258 +      for(GW::OutEdgeIt e=wG.first<GW::OutEdgeIt>(n); wG.valid(e); wG.next(e)) 
   1.259 +	cout << edge_name.get(e) << " ";
   1.260 +      cout << "in edges: ";
   1.261 +      for(GW::InEdgeIt e=wG.first<GW::InEdgeIt>(n); wG.valid(e); wG.next(e)) 
   1.262 +	cout << edge_name.get(e) << " ";
   1.263 +      cout << endl;
   1.264 +    }
   1.265 +
   1.266 +    cout << "bfs from t ..." << endl;
   1.267 +    BfsIterator5< GW, GW::NodeMap<bool> > bfs(wG);
   1.268 +    bfs.pushAndSetReached(t);
   1.269 +    while (!bfs.finished()) {
   1.270 +      //cout << "edge: ";
   1.271 +      if (wG.valid(bfs)) {
   1.272 +	cout << edge_name.get(bfs) << /*endl*/", " << 
   1.273 +	  /*" aNode: " <<*/ node_name.get(wG.aNode(bfs)) << 
   1.274 +	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.275 +	  /*" bNode: " <<*/ node_name.get(wG.bNode(bfs)) << 
   1.276 +	  (bfs.isBNodeNewlyReached() ? ": is newly reached." : 
   1.277 +	   ": is not newly reached.");
   1.278        } else { 
   1.279 -	std::cout << "aNodeIsNotExamined ";
   1.280 -      } 
   1.281 -      std::cout<<std::endl;
   1.282 +	cout << "invalid" << /*endl*/", " << 
   1.283 +	  /*" aNode: " <<*/ node_name.get(bfs.aNode()) << 
   1.284 +	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.285 +	  /*" bNode: " <<*/ 
   1.286 +	  "invalid.";
   1.287 +      }
   1.288 +      cout << endl;
   1.289        ++bfs;
   1.290      }
   1.291 +
   1.292 +    cout << "    /-->    ------------->            "<< endl;
   1.293 +    cout << "   / /-- v1 <-\\      /---- v3-\\      "<< endl;
   1.294 +    cout << "  / |          |    /  /->     \\     "<< endl;
   1.295 +    cout << " /  |          |   /  |    ^    \\  "<< endl;
   1.296 +    cout << "s   |          |  /   |    |     \\->  t "<< endl;
   1.297 +    cout << " \\  |          | /    |    |     /->  "<< endl;
   1.298 +    cout << "  \\ |       --/ /     |    |    /     "<< endl;
   1.299 +    cout << "   \\ \\-> v2 <--/       \\-- v4 -/      "<< endl;
   1.300 +    cout << "    \\-->    ------------->         "<< endl;
   1.301 +    
   1.302 +    cout << "dfs from t ..." << endl;
   1.303 +    DfsIterator5< GW, GW::NodeMap<bool> > dfs(wG);
   1.304 +    dfs.pushAndSetReached(t);
   1.305 +    while (!dfs.finished()) {
   1.306 +      ++dfs;
   1.307 +      //cout << "edge: ";
   1.308 +      if (wG.valid(dfs)) {
   1.309 +	cout << edge_name.get(dfs) << /*endl*/", " << 
   1.310 +	  /*" aNode: " <<*/ node_name.get(wG.aNode(dfs)) << 
   1.311 +	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.312 +	  /*" bNode: " <<*/ node_name.get(wG.bNode(dfs)) << 
   1.313 +	  (dfs.isBNodeNewlyReached() ? ": is newly reached." : 
   1.314 +	   ": is not newly reached.");
   1.315 +      } else { 
   1.316 +	cout << "invalid" << /*endl*/", " << 
   1.317 +	  /*" aNode: " <<*/ node_name.get(dfs.aNode()) << 
   1.318 +	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.319 +	  /*" bNode: " <<*/ 
   1.320 +	  "invalid.";
   1.321 +      }
   1.322 +      cout << endl;
   1.323 +    }
   1.324    }
   1.325  
   1.326    {
   1.327 -    std::cout << "iterator dfs demo 4 ..." << std::endl;
   1.328 -    DfsIterator4< ListGraph, ListGraph::OutEdgeIt, ListGraph::NodeMap<bool> > dfs(G);
   1.329 -    dfs.pushAndSetReached(s);
   1.330 +    typedef UndirGraphWrapper<const ListGraph> GW;
   1.331 +    GW wG(G);
   1.332 +    
   1.333 +    EdgeNameMap< GW, ListGraph::NodeMap<string> > edge_name(wG, node_name);
   1.334 +    
   1.335 +    cout << "bfs and dfs iterator demo on the undirected graph" << endl;
   1.336 +    for(GW::EachNodeIt n=wG.first<GW::EachNodeIt>(); wG.valid(n); wG.next(n)) { 
   1.337 +      cout << node_name.get(n) << ": ";
   1.338 +      cout << "out edges: ";
   1.339 +      for(GW::OutEdgeIt e=wG.first<GW::OutEdgeIt>(n); wG.valid(e); wG.next(e)) 
   1.340 +	cout << edge_name.get(e) << " ";
   1.341 +      cout << "in edges: ";
   1.342 +      for(GW::InEdgeIt e=wG.first<GW::InEdgeIt>(n); wG.valid(e); wG.next(e)) 
   1.343 +	cout << edge_name.get(e) << " ";
   1.344 +      cout << endl;
   1.345 +    }
   1.346 +
   1.347 +    cout << "bfs from t ..." << endl;
   1.348 +    BfsIterator5< GW, GW::NodeMap<bool> > bfs(wG);
   1.349 +    bfs.pushAndSetReached(t);
   1.350 +    while (!bfs.finished()) {
   1.351 +      //cout << "edge: ";
   1.352 +      if (wG.valid(GW::OutEdgeIt(bfs))) {
   1.353 +	cout << edge_name.get(GW::OutEdgeIt(bfs)) << /*endl*/", " << 
   1.354 +	  /*" aNode: " <<*/ node_name.get(wG.aNode(bfs)) << 
   1.355 +	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.356 +	  /*" bNode: " <<*/ node_name.get(wG.bNode(bfs)) << 
   1.357 +	  (bfs.isBNodeNewlyReached() ? ": is newly reached." : 
   1.358 +	   ": is not newly reached.");
   1.359 +      } else { 
   1.360 +	cout << "invalid" << /*endl*/", " << 
   1.361 +	  /*" aNode: " <<*/ node_name.get(bfs.aNode()) << 
   1.362 +	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.363 +	  /*" bNode: " <<*/ 
   1.364 +	  "invalid.";
   1.365 +      }
   1.366 +      cout << endl;
   1.367 +      ++bfs;
   1.368 +    }
   1.369 +
   1.370 +    cout << "    /-->    ------------->            "<< endl;
   1.371 +    cout << "   / /-- v1 <-\\      /---- v3-\\      "<< endl;
   1.372 +    cout << "  / |          |    /  /->     \\     "<< endl;
   1.373 +    cout << " /  |          |   /  |    ^    \\  "<< endl;
   1.374 +    cout << "s   |          |  /   |    |     \\->  t "<< endl;
   1.375 +    cout << " \\  |          | /    |    |     /->  "<< endl;
   1.376 +    cout << "  \\ |       --/ /     |    |    /     "<< endl;
   1.377 +    cout << "   \\ \\-> v2 <--/       \\-- v4 -/      "<< endl;
   1.378 +    cout << "    \\-->    ------------->         "<< endl;
   1.379 +    
   1.380 +    cout << "dfs from t ..." << endl;
   1.381 +    DfsIterator5< GW, GW::NodeMap<bool> > dfs(wG);
   1.382 +    dfs.pushAndSetReached(t);
   1.383      while (!dfs.finished()) {
   1.384        ++dfs;
   1.385 -      if (OutEdgeIt(dfs).valid()) {
   1.386 -	std::cout << "OutEdgeIt: " << dfs; 
   1.387 -	std::cout << " aNode: " << G.aNode(dfs); 
   1.388 -	std::cout << " bNode: " << G.bNode(dfs) << " ";
   1.389 +      //cout << "edge: ";
   1.390 +      if (wG.valid(GW::OutEdgeIt(dfs))) {
   1.391 +	cout << edge_name.get(GW::OutEdgeIt(dfs)) << /*endl*/", " << 
   1.392 +	  /*" aNode: " <<*/ node_name.get(wG.aNode(dfs)) << 
   1.393 +	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.394 +	  /*" bNode: " <<*/ node_name.get(wG.bNode(dfs)) << 
   1.395 +	  (dfs.isBNodeNewlyReached() ? ": is newly reached." : 
   1.396 +	   ": is not newly reached.");
   1.397        } else { 
   1.398 -	std::cout << "OutEdgeIt: " << "invalid"; 
   1.399 -	std::cout << " aNode: " << dfs.aNode(); 
   1.400 -	std::cout << " bNode: " << "invalid" << " ";
   1.401 +	cout << "invalid" << /*endl*/", " << 
   1.402 +	  /*" aNode: " <<*/ node_name.get(dfs.aNode()) << 
   1.403 +	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.404 +	  /*" bNode: " <<*/ 
   1.405 +	  "invalid.";
   1.406        }
   1.407 -      if (dfs.isBNodeNewlyReached()) { 
   1.408 -	std::cout << "bNodeIsNewlyReached ";
   1.409 -      } else { 
   1.410 -	std::cout << "bNodeIsNotNewlyReached ";
   1.411 -      } 
   1.412 -      if (dfs.isANodeExamined()) { 
   1.413 -	std::cout << "aNodeIsExamined ";
   1.414 -      } else { 
   1.415 -	std::cout << "aNodeIsNotExamined ";
   1.416 -      } 
   1.417 -      std::cout<<std::endl;
   1.418 -      //++dfs;
   1.419 +      cout << endl;
   1.420      }
   1.421    }
   1.422  
   1.423 -
   1.424 -  typedef ConstTrivGraphWrapper<ListGraph> CTGW;
   1.425 -  CTGW wG(G);
   1.426 -
   1.427 -  std::cout << "bfs and dfs demo on the directed graph" << std::endl;
   1.428 -  for(CTGW::EachNodeIt i=wG.first<CTGW::EachNodeIt>(); i.valid(); ++i) { 
   1.429 -    std::cout << i << ": ";
   1.430 -    std::cout << "out edges: ";
   1.431 -    for(CTGW::OutEdgeIt j=wG.first<CTGW::OutEdgeIt>(i); j.valid(); ++j) 
   1.432 -      std::cout << j << " ";
   1.433 -    std::cout << "in edges: ";
   1.434 -    for(CTGW::InEdgeIt j=wG.first<CTGW::InEdgeIt>(i); j.valid(); ++j) 
   1.435 -      std::cout << j << " ";
   1.436 -    std::cout << std::endl;
   1.437 -  }
   1.438 -
   1.439 -
   1.440 -  {
   1.441 -    std::cout << "iterator bfs demo 5 ..." << std::endl;
   1.442 -    BfsIterator5< CTGW, CTGW::NodeMap<bool> > bfs(wG);
   1.443 -    bfs.pushAndSetReached(s);
   1.444 -    while (!bfs.finished()) {
   1.445 -      if (OutEdgeIt(bfs).valid()) {
   1.446 -	std::cout << "OutEdgeIt: " << bfs; 
   1.447 -	std::cout << " aNode: " << wG.aNode(bfs); 
   1.448 -	std::cout << " bNode: " << wG.bNode(bfs) << " ";
   1.449 -      } else { 
   1.450 -	std::cout << "OutEdgeIt: " << "invalid"; 
   1.451 -	std::cout << " aNode: " << bfs.aNode(); 
   1.452 -	std::cout << " bNode: " << "invalid" << " ";
   1.453 -      }
   1.454 -      if (bfs.isBNodeNewlyReached()) { 
   1.455 -	std::cout << "bNodeIsNewlyReached ";
   1.456 -      } else { 
   1.457 -	std::cout << "bNodeIsNotNewlyReached ";
   1.458 -      } 
   1.459 -      if (bfs.isANodeExamined()) { 
   1.460 -	std::cout << "aNodeIsExamined ";
   1.461 -      } else { 
   1.462 -	std::cout << "aNodeIsNotExamined ";
   1.463 -      } 
   1.464 -      std::cout<<std::endl;
   1.465 -      ++bfs;
   1.466 -    }
   1.467 -  }
   1.468 -
   1.469 -
   1.470    return 0;
   1.471  }