# HG changeset patch # User marci # Date 1079973430 0 # Node ID 348f8fd374ee738a36380e6a0885c383c9c6e5a2 # Parent 57ef4fd493d517d9e24f073e09b0778567a0688e RevGraphWrapper diff -r 57ef4fd493d5 -r 348f8fd374ee src/work/iterator_bfs_demo.cc --- a/src/work/iterator_bfs_demo.cc Mon Mar 22 16:07:42 2004 +0000 +++ b/src/work/iterator_bfs_demo.cc Mon Mar 22 16:37:10 2004 +0000 @@ -78,55 +78,55 @@ cout << " \\--> -------------> "<< endl; // typedef TrivGraphWrapper CGW; -// CGW wG(G); +// CGW gw(G); // cout << "bfs and dfs demo on the directed graph" << endl; -// for(CGW::NodeIt n=wG.first(); n.valid(); ++n) { +// for(CGW::NodeIt n=gw.first(); n.valid(); ++n) { // cout << n << ": "; // cout << "out edges: "; -// for(CGW::OutEdgeIt e=wG.first(n); e.valid(); ++e) +// for(CGW::OutEdgeIt e=gw.first(n); e.valid(); ++e) // cout << e << " "; // cout << "in edges: "; -// for(CGW::InEdgeIt e=wG.first(n); e.valid(); ++e) +// for(CGW::InEdgeIt e=gw.first(n); e.valid(); ++e) // cout << e << " "; // cout << endl; // } { typedef TrivGraphWrapper GW; - GW wG(G); + GW gw(G); - EdgeNameMap< GW, Graph::NodeMap > edge_name(wG, node_name); + EdgeNameMap< GW, Graph::NodeMap > edge_name(gw, node_name); cout << "bfs and dfs iterator demo on the directed graph" << endl; - for(GW::NodeIt n=wG.first(); wG.valid(n); wG.next(n)) { + for(GW::NodeIt n=gw.first(); gw.valid(n); gw.next(n)) { cout << node_name.get(n) << ": "; cout << "out edges: "; - for(GW::OutEdgeIt e=wG.first(n); wG.valid(e); wG.next(e)) + for(GW::OutEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << "in edges: "; - for(GW::InEdgeIt e=wG.first(n); wG.valid(e); wG.next(e)) + for(GW::InEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << endl; } cout << "bfs from s ..." << endl; - BfsIterator5< GW, GW::NodeMap > bfs(wG); + BfsIterator5< GW, GW::NodeMap > bfs(gw); bfs.pushAndSetReached(s); while (!bfs.finished()) { //cout << "edge: "; - if (wG.valid(bfs)) { + if (gw.valid(bfs)) { cout << edge_name.get(bfs) << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(wG.aNode(bfs)) << + node_name.get(gw.aNode(bfs)) << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ node_name.get(wG.bNode(bfs)) << + node_name.get(gw.bNode(bfs)) << (bfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(bfs.aNode()) << + node_name.get(bfs.aNode()) << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ + "invalid."; } cout << endl; @@ -144,23 +144,23 @@ cout << " \\--> -------------> "<< endl; cout << "dfs from s ..." << endl; - DfsIterator5< GW, GW::NodeMap > dfs(wG); + DfsIterator5< GW, GW::NodeMap > dfs(gw); dfs.pushAndSetReached(s); while (!dfs.finished()) { ++dfs; //cout << "edge: "; - if (wG.valid(dfs)) { + if (gw.valid(dfs)) { cout << edge_name.get(dfs) << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(wG.aNode(dfs)) << + node_name.get(gw.aNode(dfs)) << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ node_name.get(wG.bNode(dfs)) << + node_name.get(gw.bNode(dfs)) << (dfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(dfs.aNode()) << + node_name.get(dfs.aNode()) << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ + "invalid."; } cout << endl; @@ -169,40 +169,40 @@ { - typedef RevGraphWrapper GW; - GW wG(G); + typedef RevGraphWrapper > GW; + GW gw(G); - EdgeNameMap< GW, Graph::NodeMap > edge_name(wG, node_name); + EdgeNameMap< GW, Graph::NodeMap > edge_name(gw, node_name); cout << "bfs and dfs iterator demo on the reversed directed graph" << endl; - for(GW::NodeIt n=wG.first(); wG.valid(n); wG.next(n)) { + for(GW::NodeIt n=gw.first(); gw.valid(n); gw.next(n)) { cout << node_name.get(n) << ": "; cout << "out edges: "; - for(GW::OutEdgeIt e=wG.first(n); wG.valid(e); wG.next(e)) + for(GW::OutEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << "in edges: "; - for(GW::InEdgeIt e=wG.first(n); wG.valid(e); wG.next(e)) + for(GW::InEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << endl; } cout << "bfs from t ..." << endl; - BfsIterator5< GW, GW::NodeMap > bfs(wG); + BfsIterator5< GW, GW::NodeMap > bfs(gw); bfs.pushAndSetReached(t); while (!bfs.finished()) { //cout << "edge: "; - if (wG.valid(bfs)) { + if (gw.valid(bfs)) { cout << edge_name.get(bfs) << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(wG.aNode(bfs)) << + node_name.get(gw.aNode(bfs)) << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ node_name.get(wG.bNode(bfs)) << + node_name.get(gw.bNode(bfs)) << (bfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(bfs.aNode()) << + node_name.get(bfs.aNode()) << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ + "invalid."; } cout << endl; @@ -220,23 +220,23 @@ cout << " \\--> -------------> "<< endl; cout << "dfs from t ..." << endl; - DfsIterator5< GW, GW::NodeMap > dfs(wG); + DfsIterator5< GW, GW::NodeMap > dfs(gw); dfs.pushAndSetReached(t); while (!dfs.finished()) { ++dfs; //cout << "edge: "; - if (wG.valid(dfs)) { + if (gw.valid(dfs)) { cout << edge_name.get(dfs) << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(wG.aNode(dfs)) << + node_name.get(gw.aNode(dfs)) << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ node_name.get(wG.bNode(dfs)) << + node_name.get(gw.bNode(dfs)) << (dfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(dfs.aNode()) << + node_name.get(dfs.aNode()) << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ + "invalid."; } cout << endl; @@ -245,39 +245,39 @@ { typedef UndirGraphWrapper GW; - GW wG(G); + GW gw(G); - EdgeNameMap< GW, Graph::NodeMap > edge_name(wG, node_name); + EdgeNameMap< GW, Graph::NodeMap > edge_name(gw, node_name); cout << "bfs and dfs iterator demo on the undirected graph" << endl; - for(GW::NodeIt n=wG.first(); wG.valid(n); wG.next(n)) { + for(GW::NodeIt n=gw.first(); gw.valid(n); gw.next(n)) { cout << node_name.get(n) << ": "; cout << "out edges: "; - for(GW::OutEdgeIt e=wG.first(n); wG.valid(e); wG.next(e)) + for(GW::OutEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << "in edges: "; - for(GW::InEdgeIt e=wG.first(n); wG.valid(e); wG.next(e)) + for(GW::InEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << endl; } cout << "bfs from t ..." << endl; - BfsIterator5< GW, GW::NodeMap > bfs(wG); + BfsIterator5< GW, GW::NodeMap > bfs(gw); bfs.pushAndSetReached(t); while (!bfs.finished()) { //cout << "edge: "; - if (wG.valid(GW::OutEdgeIt(bfs))) { + if (gw.valid(GW::OutEdgeIt(bfs))) { cout << edge_name.get(GW::OutEdgeIt(bfs)) << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(wG.aNode(bfs)) << + node_name.get(gw.aNode(bfs)) << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ node_name.get(wG.bNode(bfs)) << + node_name.get(gw.bNode(bfs)) << (bfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(bfs.aNode()) << + node_name.get(bfs.aNode()) << (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ + "invalid."; } cout << endl; @@ -295,23 +295,23 @@ cout << " \\--> -------------> "<< endl; cout << "dfs from t ..." << endl; - DfsIterator5< GW, GW::NodeMap > dfs(wG); + DfsIterator5< GW, GW::NodeMap > dfs(gw); dfs.pushAndSetReached(t); while (!dfs.finished()) { ++dfs; //cout << "edge: "; - if (wG.valid(GW::OutEdgeIt(dfs))) { + if (gw.valid(GW::OutEdgeIt(dfs))) { cout << edge_name.get(GW::OutEdgeIt(dfs)) << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(wG.aNode(dfs)) << + node_name.get(gw.aNode(dfs)) << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ node_name.get(wG.bNode(dfs)) << + node_name.get(gw.bNode(dfs)) << (dfs.isBNodeNewlyReached() ? ": is newly reached." : ": is not newly reached."); } else { cout << "invalid" << /*endl*/", " << - /*" aNode: " <<*/ node_name.get(dfs.aNode()) << + node_name.get(dfs.aNode()) << (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << - /*" bNode: " <<*/ + "invalid."; } cout << endl; diff -r 57ef4fd493d5 -r 348f8fd374ee src/work/marci/graph_wrapper.h --- a/src/work/marci/graph_wrapper.h Mon Mar 22 16:07:42 2004 +0000 +++ b/src/work/marci/graph_wrapper.h Mon Mar 22 16:37:10 2004 +0000 @@ -240,9 +240,10 @@ // }; // }; - template + template*/ > class RevGraphWrapper : - public GraphWrapperSkeleton< TrivGraphWrapper > { + public GraphWrapper/*GraphWrapperSkeleton< TrivGraphWrapper >*/ { protected: //Graph* graph; @@ -253,13 +254,13 @@ //typedef typename Graph::NodeIt NodeIt; //typedef typename Graph::Edge Edge; - typedef typename GraphWrapperSkeleton< TrivGraphWrapper >::OutEdgeIt InEdgeIt; - typedef typename GraphWrapperSkeleton< TrivGraphWrapper >::InEdgeIt OutEdgeIt; + typedef typename GraphWrapper/*typename GraphWrapperSkeleton< TrivGraphWrapper >*/::OutEdgeIt InEdgeIt; + typedef typename GraphWrapper/*typename GraphWrapperSkeleton< TrivGraphWrapper >*/::InEdgeIt OutEdgeIt; //typedef typename Graph::SymEdgeIt SymEdgeIt; //typedef typename Graph::EdgeIt EdgeIt; //RevGraphWrapper() : graph(0) { } - RevGraphWrapper(Graph& _graph) : GraphWrapperSkeleton< TrivGraphWrapper >(TrivGraphWrapper(_graph)) { } + RevGraphWrapper(GraphWrapper _gw/*BaseGraph& _graph*/) : GraphWrapper/*GraphWrapperSkeleton< TrivGraphWrapper >*/(_gw/*TrivGraphWrapper(_graph)*/) { } //void setGraph(Graph& _graph) { graph = &_graph; } //Graph& getGraph() const { return (*graph); } @@ -304,22 +305,22 @@ //void clear() const { graph->clear(); } template class NodeMap : - public GraphWrapperSkeleton< TrivGraphWrapper >::NodeMap + public GraphWrapper/*Skeleton< TrivGraphWrapper >*/::NodeMap { public: - NodeMap(const RevGraphWrapper& _G) : - GraphWrapperSkeleton< TrivGraphWrapper >::NodeMap(_G) { } - NodeMap(const RevGraphWrapper& _G, T a) : - GraphWrapperSkeleton< TrivGraphWrapper >::NodeMap(_G, a) { } + NodeMap(const RevGraphWrapper& _gw) : + GraphWrapper/*Skeleton< TrivGraphWrapper >*/::NodeMap(_gw) { } + NodeMap(const RevGraphWrapper& _gw, T a) : + GraphWrapper/*Skeleton< TrivGraphWrapper >*/::NodeMap(_gw, a) { } }; template class EdgeMap : - public GraphWrapperSkeleton< TrivGraphWrapper >::EdgeMap { + public GraphWrapper/*Skeleton< TrivGraphWrapper >*/::EdgeMap { public: - EdgeMap(const RevGraphWrapper& _G) : - GraphWrapperSkeleton< TrivGraphWrapper >::EdgeMap(_G) { } - EdgeMap(const RevGraphWrapper& _G, T a) : - GraphWrapperSkeleton< TrivGraphWrapper >::EdgeMap(_G, a) { } + EdgeMap(const RevGraphWrapper& _gw) : + GraphWrapper/*Skeleton< TrivGraphWrapper >*/::EdgeMap(_gw) { } + EdgeMap(const RevGraphWrapper& _gw, T a) : + GraphWrapper/*Skeleton< TrivGraphWrapper >*/::EdgeMap(_gw, a) { } }; };