Changeset 304:10d035c2e81c in lemon-0.x
- Timestamp:
- 04/05/04 19:10:25 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@422
- Location:
- src/work
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/list_graph.h
r279 r304 45 45 G(_G), container(G.node_id, a) { } 46 46 void set(Node n, T a) { container[/*G.id(n)*/n.node->id]=a; } 47 T get(Node n) const { return container[/*G.id(n)*/n.node->id]; }47 // T get(Node n) const { return container[/*G.id(n)*/n.node->id]; } 48 48 typename std::vector<T>::reference operator[](Node n) { 49 49 return container[/*G.id(n)*/n.node->id]; } … … 66 66 G(_G), container(G.edge_id, a) { } 67 67 void set(Edge e, T a) { container[/*G.id(e)*/e.edge->id]=a; } 68 T get(Edge e) const { return container[/*G.id(e)*/e.edge->id]; }68 // T get(Edge e) const { return container[/*G.id(e)*/e.edge->id]; } 69 69 typename std::vector<T>::reference operator[](Edge e) { 70 70 return container[/*G.id(e)*/e.edge->id]; } … … 268 268 /* for experimental purpose */ 269 269 270 NodeIt& /*getF*/first(NodeIt& v) const {270 NodeIt& first(NodeIt& v) const { 271 271 v=NodeIt(*this); return v; } 272 EdgeIt& /*getF*/first(EdgeIt& e) const {272 EdgeIt& first(EdgeIt& e) const { 273 273 e=EdgeIt(*this); return e; } 274 OutEdgeIt& /*getF*/first(OutEdgeIt& e, Node v) const {274 OutEdgeIt& first(OutEdgeIt& e, Node v) const { 275 275 e=OutEdgeIt(*this, v); return e; } 276 InEdgeIt& /*getF*/first(InEdgeIt& e, Node v) const {276 InEdgeIt& first(InEdgeIt& e, Node v) const { 277 277 e=InEdgeIt(*this, v); return e; } 278 SymEdgeIt& /*getF*/first(SymEdgeIt& e, Node v) const {278 SymEdgeIt& first(SymEdgeIt& e, Node v) const { 279 279 e=SymEdgeIt(*this, v); return e; } 280 280 //void getTail(Node& n, const Edge& e) const { n=tail(e); } … … 296 296 It first() const { 297 297 It e; 298 /*getF*/first(e);298 first(e); 299 299 return e; 300 300 } … … 303 303 It first(Node v) const { 304 304 It e; 305 /*getF*/first(e, v);305 first(e, v); 306 306 return e; 307 307 } -
src/work/marci/iterator_bfs_demo.cc
r301 r304 21 21 EdgeNameMap(Graph& _graph, NodeNameMap& _node_name_map) : 22 22 graph(_graph), node_name_map(_node_name_map) { } 23 string get(typename Graph::Edge e) const {23 string operator[](typename Graph::Edge e) const { 24 24 return 25 (node_name_map .get(graph.tail(e))+"->"+node_name_map.get(graph.head(e)));25 (node_name_map[graph.tail(e)]+"->"+node_name_map[graph.head(e)]); 26 26 } 27 27 }; … … 96 96 cout << "bfs and dfs iterator demo on the directed graph" << endl; 97 97 for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { 98 cout << node_name .get(n)<< ": ";98 cout << node_name[n] << ": "; 99 99 cout << "out edges: "; 100 100 for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 101 cout << edge_name .get(e)<< " ";101 cout << edge_name[e] << " "; 102 102 cout << "in edges: "; 103 103 for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 104 cout << edge_name .get(e)<< " ";104 cout << edge_name[e] << " "; 105 105 cout << endl; 106 106 } … … 112 112 //cout << "edge: "; 113 113 if (gw.valid(bfs)) { 114 cout << edge_name .get(bfs)<< /*endl*/", " <<115 node_name .get(gw.aNode(bfs))<<116 (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 117 node_name .get(gw.bNode(bfs))<<114 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)] << 118 118 (bfs.isBNodeNewlyReached() ? ": is newly reached." : 119 119 ": is not newly reached."); 120 120 } else { 121 121 cout << "invalid" << /*endl*/", " << 122 node_name .get(bfs.aNode())<<122 node_name[bfs.aNode()] << 123 123 (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 124 124 … … 146 146 //cout << "edge: "; 147 147 if (gw.valid(dfs)) { 148 cout << edge_name .get(dfs)<< /*endl*/", " <<149 node_name .get(gw.aNode(dfs))<<150 (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 151 node_name .get(gw.bNode(dfs))<<148 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)] << 152 152 (dfs.isBNodeNewlyReached() ? ": is newly reached." : 153 153 ": is not newly reached."); 154 154 } else { 155 155 cout << "invalid" << /*endl*/", " << 156 node_name .get(dfs.aNode())<<156 node_name[dfs.aNode()] << 157 157 (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 158 158 … … 172 172 cout << "bfs and dfs iterator demo on the reversed directed graph" << endl; 173 173 for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { 174 cout << node_name .get(n)<< ": ";174 cout << node_name[n] << ": "; 175 175 cout << "out edges: "; 176 176 for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 177 cout << edge_name .get(e)<< " ";177 cout << edge_name[e] << " "; 178 178 cout << "in edges: "; 179 179 for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 180 cout << edge_name .get(e)<< " ";180 cout << edge_name[e] << " "; 181 181 cout << endl; 182 182 } … … 188 188 //cout << "edge: "; 189 189 if (gw.valid(bfs)) { 190 cout << edge_name .get(bfs)<< /*endl*/", " <<191 node_name .get(gw.aNode(bfs))<<192 (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 193 node_name .get(gw.bNode(bfs))<<190 cout << edge_name[bfs] << /*endl*/", " << 191 node_name[gw.aNode(bfs)] << 192 (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 193 node_name[gw.bNode(bfs)] << 194 194 (bfs.isBNodeNewlyReached() ? ": is newly reached." : 195 195 ": is not newly reached."); 196 196 } else { 197 197 cout << "invalid" << /*endl*/", " << 198 node_name .get(bfs.aNode())<<198 node_name[bfs.aNode()] << 199 199 (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 200 200 … … 222 222 //cout << "edge: "; 223 223 if (gw.valid(dfs)) { 224 cout << edge_name .get(dfs)<< /*endl*/", " <<225 node_name .get(gw.aNode(dfs))<<226 (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 227 node_name .get(gw.bNode(dfs))<<224 cout << edge_name[dfs] << /*endl*/", " << 225 node_name[gw.aNode(dfs)] << 226 (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 227 node_name[gw.bNode(dfs)] << 228 228 (dfs.isBNodeNewlyReached() ? ": is newly reached." : 229 229 ": is not newly reached."); 230 230 } else { 231 231 cout << "invalid" << /*endl*/", " << 232 node_name .get(dfs.aNode())<<232 node_name[dfs.aNode()] << 233 233 (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 234 234 … … 248 248 cout << "bfs and dfs iterator demo on the undirected graph" << endl; 249 249 for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { 250 cout << node_name .get(n)<< ": ";250 cout << node_name[n] << ": "; 251 251 cout << "out edges: "; 252 252 for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 253 cout << edge_name .get(e)<< " ";253 cout << edge_name[e] << " "; 254 254 cout << "in edges: "; 255 255 for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 256 cout << edge_name .get(e)<< " ";256 cout << edge_name[e] << " "; 257 257 cout << endl; 258 258 } … … 268 268 //cout << "edge: "; 269 269 if (gw.valid(GW::OutEdgeIt(bfs))) { 270 cout << edge_name .get(GW::OutEdgeIt(bfs))<< /*endl*/", " <<271 node_name .get(gw.aNode(bfs))<<272 (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 273 node_name .get(gw.bNode(bfs))<<270 cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " << 271 node_name[gw.aNode(bfs)] << 272 (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 273 node_name[gw.bNode(bfs)] << 274 274 (bfs.isBNodeNewlyReached() ? ": is newly reached." : 275 275 ": is not newly reached."); 276 276 } else { 277 277 cout << "invalid" << /*endl*/", " << 278 node_name .get(bfs.aNode())<<278 node_name[bfs.aNode()] << 279 279 (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 280 280 … … 302 302 //cout << "edge: "; 303 303 if (gw.valid(GW::OutEdgeIt(dfs))) { 304 cout << edge_name .get(GW::OutEdgeIt(dfs))<< /*endl*/", " <<305 node_name .get(gw.aNode(dfs))<<306 (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 307 node_name .get(gw.bNode(dfs))<<304 cout << edge_name[GW::OutEdgeIt(dfs)] << /*endl*/", " << 305 node_name[gw.aNode(dfs)] << 306 (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 307 node_name[gw.bNode(dfs)] << 308 308 (dfs.isBNodeNewlyReached() ? ": is newly reached." : 309 309 ": is not newly reached."); 310 310 } else { 311 311 cout << "invalid" << /*endl*/", " << 312 node_name .get(dfs.aNode())<<312 node_name[dfs.aNode()] << 313 313 (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 314 314
Note: See TracChangeset
for help on using the changeset viewer.