Changeset 312:54e07057eb47 in lemon0.x for src/work/marci/iterator_bfs_demo.cc
 Timestamp:
 04/07/04 12:57:58 (16 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@430
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/work/marci/iterator_bfs_demo.cc
r304 r312 89 89 90 90 { 91 typedef TrivGraphWrapper<const Graph> GW; 92 GW gw(G); 93 94 EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name); 91 EdgeNameMap< Graph, Graph::NodeMap<string> > edge_name(G, node_name); 95 92 96 93 cout << "bfs and dfs iterator demo on the directed graph" << endl; 97 for(G W::NodeIt n(gw); gw.valid(n); gw.next(n)) {94 for(Graph::NodeIt n(G); G.valid(n); G.next(n)) { 98 95 cout << node_name[n] << ": "; 99 96 cout << "out edges: "; 100 for(G W::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e))97 for(Graph::OutEdgeIt e(G, n); G.valid(e); G.next(e)) 101 98 cout << edge_name[e] << " "; 102 99 cout << "in edges: "; 103 for(G W::InEdgeIt e(gw, n); gw.valid(e); gw.next(e))100 for(Graph::InEdgeIt e(G, n); G.valid(e); G.next(e)) 104 101 cout << edge_name[e] << " "; 105 102 cout << endl; … … 107 104 108 105 cout << "bfs from s ..." << endl; 109 BfsIterator5< G W, GW::NodeMap<bool> > bfs(gw);106 BfsIterator5< Graph, Graph::NodeMap<bool> > bfs(G); 110 107 bfs.pushAndSetReached(s); 111 108 while (!bfs.finished()) { 112 109 //cout << "edge: "; 113 if ( gw.valid(bfs)) {110 if (G.valid(bfs)) { 114 111 cout << edge_name[bfs] << /*endl*/", " << 115 node_name[ gw.aNode(bfs)] <<116 (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 117 node_name[ gw.bNode(bfs)] <<112 node_name[G.aNode(bfs)] << 113 (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 114 node_name[G.bNode(bfs)] << 118 115 (bfs.isBNodeNewlyReached() ? ": is newly reached." : 119 116 ": is not newly reached."); … … 140 137 141 138 cout << "dfs from s ..." << endl; 142 DfsIterator5< G W, GW::NodeMap<bool> > dfs(gw);139 DfsIterator5< Graph, Graph::NodeMap<bool> > dfs(G); 143 140 dfs.pushAndSetReached(s); 144 141 while (!dfs.finished()) { 145 142 ++dfs; 146 143 //cout << "edge: "; 147 if ( gw.valid(dfs)) {144 if (G.valid(dfs)) { 148 145 cout << edge_name[dfs] << /*endl*/", " << 149 node_name[ gw.aNode(dfs)] <<150 (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 151 node_name[ gw.bNode(dfs)] <<146 node_name[G.aNode(dfs)] << 147 (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 148 node_name[G.bNode(dfs)] << 152 149 (dfs.isBNodeNewlyReached() ? ": is newly reached." : 153 150 ": is not newly reached."); … … 165 162 166 163 { 167 typedef RevGraphWrapper<const TrivGraphWrapper<const Graph>> GW;164 typedef RevGraphWrapper<const Graph> GW; 168 165 GW gw(G); 169 166 … … 241 238 { 242 239 //typedef UndirGraphWrapper<const Graph> GW; 243 typedef UndirGraphWrapper<const TrivGraphWrapper<const Graph>> GW;240 typedef UndirGraphWrapper<const Graph> GW; 244 241 GW gw(G); 245 242
Note: See TracChangeset
for help on using the changeset viewer.