src/work/marci/iterator_bfs_demo.cc
changeset 777 a82713ed19f3
parent 774 4297098d9677
child 921 818510fa3d99
     1.1 --- a/src/work/marci/iterator_bfs_demo.cc	Tue Aug 31 13:40:07 2004 +0000
     1.2 +++ b/src/work/marci/iterator_bfs_demo.cc	Tue Aug 31 17:54:22 2004 +0000
     1.3 @@ -9,6 +9,7 @@
     1.4  #include <hugo/graph_wrapper.h>
     1.5  
     1.6  using namespace hugo;
     1.7 +
     1.8  using std::cout; 
     1.9  using std::endl;
    1.10  using std::string;
    1.11 @@ -72,21 +73,6 @@
    1.12    cout << "   \\ \\-> v2 <--/       \\-- v4 -/      "<< endl;
    1.13    cout << "    \\-->    ------------->         "<< endl;
    1.14    
    1.15 -//   typedef TrivGraphWrapper<const Graph> CGW;
    1.16 -//   CGW gw(G);
    1.17 -
    1.18 -//   cout << "bfs and dfs demo on the directed graph" << endl;
    1.19 -//   for(CGW::NodeIt n=gw.first<CGW::NodeIt>(); n.valid(); ++n) { 
    1.20 -//     cout << n << ": ";
    1.21 -//     cout << "out edges: ";
    1.22 -//     for(CGW::OutEdgeIt e=gw.first<CGW::OutEdgeIt>(n); e.valid(); ++e) 
    1.23 -//       cout << e << " ";
    1.24 -//     cout << "in edges: ";
    1.25 -//     for(CGW::InEdgeIt e=gw.first<CGW::InEdgeIt>(n); e.valid(); ++e) 
    1.26 -//       cout << e << " ";
    1.27 -//     cout << endl;
    1.28 -//   }
    1.29 -
    1.30    {
    1.31      EdgeNameMap< Graph, Graph::NodeMap<string> > edge_name(G, node_name);
    1.32      
    1.33 @@ -107,7 +93,7 @@
    1.34      bfs.pushAndSetReached(s);
    1.35      while (!bfs.finished()) {
    1.36        //cout << "edge: ";
    1.37 -      if (Graph::Edge(Graph::OutEdgeIt(bfs))!=INVALID) {
    1.38 +      if (Graph::Edge(bfs)!=INVALID) {
    1.39  	cout << edge_name[bfs] << /*endl*/", " << 
    1.40  	  node_name[G.tail(bfs)] << 
    1.41  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    1.42 @@ -116,7 +102,7 @@
    1.43  	   ": is not newly reached.");
    1.44        } else { 
    1.45  	cout << "invalid" << /*endl*/", " << 
    1.46 -	  node_name[bfs.aNode()] << 
    1.47 +	  node_name[bfs.tail()] << 
    1.48  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    1.49  	  
    1.50  	  "invalid.";
    1.51 @@ -141,7 +127,7 @@
    1.52      while (!dfs.finished()) {
    1.53        ++dfs;
    1.54        //cout << "edge: ";
    1.55 -      if (Graph::Edge(Graph::OutEdgeIt(dfs))!=INVALID) {
    1.56 +      if (Graph::Edge(dfs)!=INVALID) {
    1.57  	cout << edge_name[dfs] << /*endl*/", " << 
    1.58  	  node_name[G.tail(dfs)] << 
    1.59  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    1.60 @@ -150,7 +136,7 @@
    1.61  	   ": is not newly reached.");
    1.62        } else { 
    1.63  	cout << "invalid" << /*endl*/", " << 
    1.64 -	  node_name[dfs.aNode()] << 
    1.65 +	  node_name[dfs.tail()] << 
    1.66  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    1.67  	  
    1.68  	  "invalid.";
    1.69 @@ -183,8 +169,8 @@
    1.70      bfs.pushAndSetReached(t);
    1.71      while (!bfs.finished()) {
    1.72        //cout << "edge: ";
    1.73 -      if (GW::Edge(GW::OutEdgeIt(bfs))!=INVALID) {
    1.74 -	cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " << 
    1.75 +      if (GW::Edge(bfs)!=INVALID) {
    1.76 +	cout << edge_name[GW::Edge(bfs)] << /*endl*/", " << 
    1.77  	  node_name[gw.tail(bfs)] << 
    1.78  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    1.79  	  node_name[gw.head(bfs)] << 
    1.80 @@ -192,7 +178,7 @@
    1.81  	   ": is not newly reached.");
    1.82        } else { 
    1.83  	cout << "invalid" << /*endl*/", " << 
    1.84 -	  node_name[bfs.aNode()] << 
    1.85 +	  node_name[bfs.tail()] << 
    1.86  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    1.87  	  
    1.88  	  "invalid.";
    1.89 @@ -217,8 +203,8 @@
    1.90      while (!dfs.finished()) {
    1.91        ++dfs;
    1.92        //cout << "edge: ";
    1.93 -      if (GW::OutEdgeIt(dfs)!=INVALID) {
    1.94 -	cout << edge_name[GW::OutEdgeIt(dfs)] << /*endl*/", " << 
    1.95 +      if (GW::Edge(dfs)!=INVALID) {
    1.96 +	cout << edge_name[GW::Edge(dfs)] << /*endl*/", " << 
    1.97  	  node_name[gw.tail(dfs)] << 
    1.98  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    1.99  	  node_name[gw.head(dfs)] << 
   1.100 @@ -226,7 +212,7 @@
   1.101  	   ": is not newly reached.");
   1.102        } else { 
   1.103  	cout << "invalid" << /*endl*/", " << 
   1.104 -	  node_name[dfs.aNode()] << 
   1.105 +	  node_name[dfs.tail()] << 
   1.106  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.107  	  
   1.108  	  "invalid.";
   1.109 @@ -346,8 +332,8 @@
   1.110      bfs.pushAndSetReached(t);
   1.111      while (!bfs.finished()) {
   1.112        //cout << "edge: ";
   1.113 -      if (GW::OutEdgeIt(bfs)!=INVALID) {
   1.114 -	cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " << 
   1.115 +      if (GW::Edge(bfs)!=INVALID) {
   1.116 +	cout << edge_name[GW::Edge(bfs)] << /*endl*/", " << 
   1.117  	  node_name[gw.tail(bfs)] << 
   1.118  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.119  	  node_name[gw.head(bfs)] << 
   1.120 @@ -355,7 +341,7 @@
   1.121  	   ": is not newly reached.");
   1.122        } else { 
   1.123  	cout << "invalid" << /*endl*/", " << 
   1.124 -	  node_name[bfs.aNode()] << 
   1.125 +	  node_name[bfs.tail()] << 
   1.126  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.127  	  
   1.128  	  "invalid.";
   1.129 @@ -380,8 +366,8 @@
   1.130      while (!dfs.finished()) {
   1.131        ++dfs;
   1.132        //cout << "edge: ";
   1.133 -      if (GW::OutEdgeIt(dfs)!=INVALID) {
   1.134 -	cout << edge_name[GW::OutEdgeIt(dfs)] << /*endl*/", " << 
   1.135 +      if (GW::Edge(dfs)!=INVALID) {
   1.136 +	cout << edge_name[GW::Edge(dfs)] << /*endl*/", " << 
   1.137  	  node_name[gw.tail(dfs)] << 
   1.138  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.139  	  node_name[gw.head(dfs)] << 
   1.140 @@ -389,7 +375,7 @@
   1.141  	   ": is not newly reached.");
   1.142        } else { 
   1.143  	cout << "invalid" << /*endl*/", " << 
   1.144 -	  node_name[dfs.aNode()] << 
   1.145 +	  node_name[dfs.tail()] << 
   1.146  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   1.147  	  
   1.148  	  "invalid.";