31 //typedef SmartGraph Graph; |
31 //typedef SmartGraph Graph; |
32 typedef ListGraph Graph; |
32 typedef ListGraph Graph; |
33 |
33 |
34 typedef Graph::Node Node; |
34 typedef Graph::Node Node; |
35 typedef Graph::Edge Edge; |
35 typedef Graph::Edge Edge; |
36 //typedef Graph::NodeIt NodeIt; |
|
37 //typedef Graph::EdgeIt EdgeIt; |
|
38 //typedef Graph::OutEdgeIt OutEdgeIt; |
|
39 //typedef Graph::InEdgeIt InEdgeIt; |
|
40 //typedef Graph::SymEdgeIt SymEdgeIt; |
|
41 |
36 |
42 Graph G; |
37 Graph G; |
43 |
38 |
44 Node s=G.addNode(); |
39 Node s=G.addNode(); |
45 Node v1=G.addNode(); |
40 Node v1=G.addNode(); |
97 GW gw(G); |
92 GW gw(G); |
98 |
93 |
99 EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name); |
94 EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name); |
100 |
95 |
101 cout << "bfs and dfs iterator demo on the directed graph" << endl; |
96 cout << "bfs and dfs iterator demo on the directed graph" << endl; |
102 for(GW::NodeIt n=gw.first<GW::NodeIt>(); |
97 for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { |
103 gw.valid(n); |
|
104 gw.next(n)) { |
|
105 cout << node_name.get(n) << ": "; |
98 cout << node_name.get(n) << ": "; |
106 cout << "out edges: "; |
99 cout << "out edges: "; |
107 for(GW::OutEdgeIt e=gw.first<GW::OutEdgeIt>(n); gw.valid(e); gw.next(e)) |
100 for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) |
108 cout << edge_name.get(e) << " "; |
101 cout << edge_name.get(e) << " "; |
109 cout << "in edges: "; |
102 cout << "in edges: "; |
110 for(GW::InEdgeIt e=gw.first<GW::InEdgeIt>(n); gw.valid(e); gw.next(e)) |
103 for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) |
111 cout << edge_name.get(e) << " "; |
104 cout << edge_name.get(e) << " "; |
112 cout << endl; |
105 cout << endl; |
113 } |
106 } |
114 |
107 |
115 cout << "bfs from s ..." << endl; |
108 cout << "bfs from s ..." << endl; |
175 GW gw(G); |
168 GW gw(G); |
176 |
169 |
177 EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name); |
170 EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name); |
178 |
171 |
179 cout << "bfs and dfs iterator demo on the reversed directed graph" << endl; |
172 cout << "bfs and dfs iterator demo on the reversed directed graph" << endl; |
180 for(GW::NodeIt n=gw.first<GW::NodeIt>(); gw.valid(n); gw.next(n)) { |
173 for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { |
181 cout << node_name.get(n) << ": "; |
174 cout << node_name.get(n) << ": "; |
182 cout << "out edges: "; |
175 cout << "out edges: "; |
183 for(GW::OutEdgeIt e=gw.first<GW::OutEdgeIt>(n); gw.valid(e); gw.next(e)) |
176 for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) |
184 cout << edge_name.get(e) << " "; |
177 cout << edge_name.get(e) << " "; |
185 cout << "in edges: "; |
178 cout << "in edges: "; |
186 for(GW::InEdgeIt e=gw.first<GW::InEdgeIt>(n); gw.valid(e); gw.next(e)) |
179 for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) |
187 cout << edge_name.get(e) << " "; |
180 cout << edge_name.get(e) << " "; |
188 cout << endl; |
181 cout << endl; |
189 } |
182 } |
190 |
183 |
191 cout << "bfs from t ..." << endl; |
184 cout << "bfs from t ..." << endl; |
251 GW gw(G); |
244 GW gw(G); |
252 |
245 |
253 EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name); |
246 EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name); |
254 |
247 |
255 cout << "bfs and dfs iterator demo on the undirected graph" << endl; |
248 cout << "bfs and dfs iterator demo on the undirected graph" << endl; |
256 for(GW::NodeIt n=gw.first<GW::NodeIt>(); gw.valid(n); gw.next(n)) { |
249 for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { |
257 cout << node_name.get(n) << ": "; |
250 cout << node_name.get(n) << ": "; |
258 cout << "out edges: "; |
251 cout << "out edges: "; |
259 for(GW::OutEdgeIt e=gw.first<GW::OutEdgeIt>(n); gw.valid(e); gw.next(e)) |
252 for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) |
260 cout << edge_name.get(e) << " "; |
253 cout << edge_name.get(e) << " "; |
261 cout << "in edges: "; |
254 cout << "in edges: "; |
262 for(GW::InEdgeIt e=gw.first<GW::InEdgeIt>(n); gw.valid(e); gw.next(e)) |
255 for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) |
263 cout << edge_name.get(e) << " "; |
256 cout << edge_name.get(e) << " "; |
264 cout << endl; |
257 cout << endl; |
265 } |
258 } |
266 // for(GW::EdgeIt e=gw.first<GW::EdgeIt>(); gw.valid(e); gw.next(e)) { |
259 // for(GW::EdgeIt e=gw.first<GW::EdgeIt>(); gw.valid(e); gw.next(e)) { |
267 // cout << edge_name.get(e) << " "; |
260 // cout << edge_name.get(e) << " "; |