# HG changeset patch # User marci # Date 1081185025 0 # Node ID 10d035c2e81c1df8a1c0893b2b2b81d7c91c55aa # Parent 1b377a730d027d439d1c7c5b14ff50a2f50d5fcd ez mar kafa diff -r 1b377a730d02 -r 10d035c2e81c src/work/list_graph.h --- a/src/work/list_graph.h Mon Apr 05 16:52:46 2004 +0000 +++ b/src/work/list_graph.h Mon Apr 05 17:10:25 2004 +0000 @@ -44,7 +44,7 @@ NodeMap(const ListGraph& _G, T a) : G(_G), container(G.node_id, a) { } void set(Node n, T a) { container[/*G.id(n)*/n.node->id]=a; } - T get(Node n) const { return container[/*G.id(n)*/n.node->id]; } +// T get(Node n) const { return container[/*G.id(n)*/n.node->id]; } typename std::vector::reference operator[](Node n) { return container[/*G.id(n)*/n.node->id]; } typename std::vector::const_reference operator[](Node n) const { @@ -65,7 +65,7 @@ EdgeMap(const ListGraph& _G, T a) : G(_G), container(G.edge_id, a) { } void set(Edge e, T a) { container[/*G.id(e)*/e.edge->id]=a; } - T get(Edge e) const { return container[/*G.id(e)*/e.edge->id]; } +// T get(Edge e) const { return container[/*G.id(e)*/e.edge->id]; } typename std::vector::reference operator[](Edge e) { return container[/*G.id(e)*/e.edge->id]; } typename std::vector::const_reference operator[](Edge e) const { @@ -267,15 +267,15 @@ /* same methods in other style */ /* for experimental purpose */ - NodeIt& /*getF*/first(NodeIt& v) const { + NodeIt& first(NodeIt& v) const { v=NodeIt(*this); return v; } - EdgeIt& /*getF*/first(EdgeIt& e) const { + EdgeIt& first(EdgeIt& e) const { e=EdgeIt(*this); return e; } - OutEdgeIt& /*getF*/first(OutEdgeIt& e, Node v) const { + OutEdgeIt& first(OutEdgeIt& e, Node v) const { e=OutEdgeIt(*this, v); return e; } - InEdgeIt& /*getF*/first(InEdgeIt& e, Node v) const { + InEdgeIt& first(InEdgeIt& e, Node v) const { e=InEdgeIt(*this, v); return e; } - SymEdgeIt& /*getF*/first(SymEdgeIt& e, Node v) const { + SymEdgeIt& first(SymEdgeIt& e, Node v) const { e=SymEdgeIt(*this, v); return e; } //void getTail(Node& n, const Edge& e) const { n=tail(e); } //void getHead(Node& n, const Edge& e) const { n=head(e); } @@ -295,14 +295,14 @@ template< typename It > It first() const { It e; - /*getF*/first(e); + first(e); return e; } template< typename It > It first(Node v) const { It e; - /*getF*/first(e, v); + first(e, v); return e; } diff -r 1b377a730d02 -r 10d035c2e81c src/work/marci/iterator_bfs_demo.cc --- a/src/work/marci/iterator_bfs_demo.cc Mon Apr 05 16:52:46 2004 +0000 +++ b/src/work/marci/iterator_bfs_demo.cc Mon Apr 05 17:10:25 2004 +0000 @@ -20,9 +20,9 @@ public: EdgeNameMap(Graph& _graph, NodeNameMap& _node_name_map) : graph(_graph), node_name_map(_node_name_map) { } - string get(typename Graph::Edge e) const { + string operator[](typename Graph::Edge e) const { return - (node_name_map.get(graph.tail(e))+"->"+node_name_map.get(graph.head(e))); + (node_name_map[graph.tail(e)]+"->"+node_name_map[graph.head(e)]); } }; @@ -95,13 +95,13 @@ cout << "bfs and dfs iterator demo on the directed graph" << endl; for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { - cout << node_name.get(n) << ": "; + cout << node_name[n] << ": "; cout << "out edges: "; for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) - cout << edge_name.get(e) << " "; + cout << edge_name[e] << " "; cout << "in edges: "; for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) - cout << edge_name.get(e) << " "; + cout << edge_name[e] << " "; cout << endl; } @@ -111,15 +111,15 @@ while (!bfs.finished()) { //cout << "edge: "; if (gw.valid(bfs)) { - cout << edge_name.get(bfs) << /*endl*/", " << - node_name.get(gw.aNode(bfs)) << + cout << edge_name[bfs] << /*endl*/", " << + node_name[gw.aNode(bfs)] << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - node_name.get(gw.bNode(bfs)) << + node_name[gw.bNode(bfs)] << (bfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - node_name.get(bfs.aNode()) << + node_name[bfs.aNode()] << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << "invalid."; @@ -145,15 +145,15 @@ ++dfs; //cout << "edge: "; if (gw.valid(dfs)) { - cout << edge_name.get(dfs) << /*endl*/", " << - node_name.get(gw.aNode(dfs)) << + cout << edge_name[dfs] << /*endl*/", " << + node_name[gw.aNode(dfs)] << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - node_name.get(gw.bNode(dfs)) << + node_name[gw.bNode(dfs)] << (dfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - node_name.get(dfs.aNode()) << + node_name[dfs.aNode()] << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << "invalid."; @@ -171,13 +171,13 @@ cout << "bfs and dfs iterator demo on the reversed directed graph" << endl; for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { - cout << node_name.get(n) << ": "; + cout << node_name[n] << ": "; cout << "out edges: "; for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) - cout << edge_name.get(e) << " "; + cout << edge_name[e] << " "; cout << "in edges: "; for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) - cout << edge_name.get(e) << " "; + cout << edge_name[e] << " "; cout << endl; } @@ -187,15 +187,15 @@ while (!bfs.finished()) { //cout << "edge: "; if (gw.valid(bfs)) { - cout << edge_name.get(bfs) << /*endl*/", " << - node_name.get(gw.aNode(bfs)) << + cout << edge_name[bfs] << /*endl*/", " << + node_name[gw.aNode(bfs)] << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - node_name.get(gw.bNode(bfs)) << + node_name[gw.bNode(bfs)] << (bfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - node_name.get(bfs.aNode()) << + node_name[bfs.aNode()] << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << "invalid."; @@ -221,15 +221,15 @@ ++dfs; //cout << "edge: "; if (gw.valid(dfs)) { - cout << edge_name.get(dfs) << /*endl*/", " << - node_name.get(gw.aNode(dfs)) << + cout << edge_name[dfs] << /*endl*/", " << + node_name[gw.aNode(dfs)] << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - node_name.get(gw.bNode(dfs)) << + node_name[gw.bNode(dfs)] << (dfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - node_name.get(dfs.aNode()) << + node_name[dfs.aNode()] << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << "invalid."; @@ -247,13 +247,13 @@ cout << "bfs and dfs iterator demo on the undirected graph" << endl; for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { - cout << node_name.get(n) << ": "; + cout << node_name[n] << ": "; cout << "out edges: "; for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) - cout << edge_name.get(e) << " "; + cout << edge_name[e] << " "; cout << "in edges: "; for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) - cout << edge_name.get(e) << " "; + cout << edge_name[e] << " "; cout << endl; } // for(GW::EdgeIt e=gw.first(); gw.valid(e); gw.next(e)) { @@ -267,15 +267,15 @@ while (!bfs.finished()) { //cout << "edge: "; if (gw.valid(GW::OutEdgeIt(bfs))) { - cout << edge_name.get(GW::OutEdgeIt(bfs)) << /*endl*/", " << - node_name.get(gw.aNode(bfs)) << + cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " << + node_name[gw.aNode(bfs)] << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - node_name.get(gw.bNode(bfs)) << + node_name[gw.bNode(bfs)] << (bfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - node_name.get(bfs.aNode()) << + node_name[bfs.aNode()] << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << "invalid."; @@ -301,15 +301,15 @@ ++dfs; //cout << "edge: "; if (gw.valid(GW::OutEdgeIt(dfs))) { - cout << edge_name.get(GW::OutEdgeIt(dfs)) << /*endl*/", " << - node_name.get(gw.aNode(dfs)) << + cout << edge_name[GW::OutEdgeIt(dfs)] << /*endl*/", " << + node_name[gw.aNode(dfs)] << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - node_name.get(gw.bNode(dfs)) << + node_name[gw.bNode(dfs)] << (dfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - node_name.get(dfs.aNode()) << + node_name[dfs.aNode()] << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << "invalid.";