# HG changeset patch # User marci # Date 1081002153 0 # Node ID be43902fadb70ce7e0558b239bd1b99e90960dde # Parent c11f84e3da2164d22da1c49441d8368525a00c58 minor changes diff -r c11f84e3da21 -r be43902fadb7 src/work/bfs_iterator.h --- a/src/work/bfs_iterator.h Fri Apr 02 18:31:19 2004 +0000 +++ b/src/work/bfs_iterator.h Sat Apr 03 14:22:33 2004 +0000 @@ -796,7 +796,9 @@ void pushAndSetReached(Node s) { actual_node=s; reached.set(s, true); - dfs_stack.push(G.template first(s)); + OutEdgeIt e; + G.first(e, s); + dfs_stack.push(e); } DfsIterator5& operator++() { @@ -806,7 +808,9 @@ Node w=G.bNode(actual_edge); actual_node=w; if (!reached.get(w)) { - dfs_stack.push(G.template first(w)); + OutEdgeIt e; + G.first(e, w); + dfs_stack.push(e); reached.set(w, true); b_node_newly_reached=true; } else { diff -r c11f84e3da21 -r be43902fadb7 src/work/edmonds_karp.h --- a/src/work/edmonds_karp.h Fri Apr 02 18:31:19 2004 +0000 +++ b/src/work/edmonds_karp.h Sat Apr 03 14:22:33 2004 +0000 @@ -352,8 +352,11 @@ typedef SubGraphWrapper > FilterResGW; FilterResGW filter_res_graph(res_graph, dist); typename ResGW::NodeMap res_graph_to_F(res_graph); - for(typename ResGW::NodeIt n=res_graph.template first(); res_graph.valid(n); res_graph.next(n)) { - res_graph_to_F.set(n, F.addNode()); + { + typename ResGW::NodeIt n; + for(res_graph.first(n); res_graph.valid(n); res_graph.next(n)) { + res_graph_to_F.set(n, F.addNode()); + } } typename MG::Node sF=res_graph_to_F.get(s); @@ -363,14 +366,17 @@ //Making F to the graph containing the edges of the residual graph //which are in some shortest paths - for(typename FilterResGW::EdgeIt e=filter_res_graph.template first(); filter_res_graph.valid(e); filter_res_graph.next(e)) { - //if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) { + { + typename FilterResGW::EdgeIt e; + for(filter_res_graph.first(e); filter_res_graph.valid(e); filter_res_graph.next(e)) { + //if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) { typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e))); original_edge.update(); original_edge.set(f, e); residual_capacity.update(); residual_capacity.set(f, res_graph.resCap(e)); //} + } } bool __augment=true; @@ -446,8 +452,11 @@ //with the set of edges which are on shortest paths MG F; typename ResGW::NodeMap res_graph_to_F(res_graph); - for(typename ResGW::NodeIt n=res_graph.template first(); res_graph.valid(n); res_graph.next(n)) { - res_graph_to_F.set(n, F.addNode()); + { + typename ResGW::NodeIt n; + for(res_graph.first(n); res_graph.valid(n); res_graph.next(n)) { + res_graph_to_F.set(n, F.addNode()); + } } typename MG::Node sF=res_graph_to_F.get(s); diff -r c11f84e3da21 -r be43902fadb7 src/work/iterator_bfs_demo.cc --- a/src/work/iterator_bfs_demo.cc Fri Apr 02 18:31:19 2004 +0000 +++ b/src/work/iterator_bfs_demo.cc Sat Apr 03 14:22:33 2004 +0000 @@ -33,11 +33,6 @@ typedef Graph::Node Node; typedef Graph::Edge Edge; - //typedef Graph::NodeIt NodeIt; - //typedef Graph::EdgeIt EdgeIt; - //typedef Graph::OutEdgeIt OutEdgeIt; - //typedef Graph::InEdgeIt InEdgeIt; - //typedef Graph::SymEdgeIt SymEdgeIt; Graph G; @@ -99,15 +94,13 @@ EdgeNameMap< GW, Graph::NodeMap > edge_name(gw, node_name); cout << "bfs and dfs iterator demo on the directed graph" << endl; - for(GW::NodeIt n=gw.first(); - gw.valid(n); - gw.next(n)) { + for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { cout << node_name.get(n) << ": "; cout << "out edges: "; - for(GW::OutEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) + for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << "in edges: "; - for(GW::InEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) + for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << endl; } @@ -177,13 +170,13 @@ 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=gw.first(); gw.valid(n); gw.next(n)) { + for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { cout << node_name.get(n) << ": "; cout << "out edges: "; - for(GW::OutEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) + for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << "in edges: "; - for(GW::InEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) + for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << endl; } @@ -253,13 +246,13 @@ EdgeNameMap< GW, Graph::NodeMap > edge_name(gw, node_name); cout << "bfs and dfs iterator demo on the undirected graph" << endl; - for(GW::NodeIt n=gw.first(); gw.valid(n); gw.next(n)) { + for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { cout << node_name.get(n) << ": "; cout << "out edges: "; - for(GW::OutEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) + for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << "in edges: "; - for(GW::InEdgeIt e=gw.first(n); gw.valid(e); gw.next(e)) + for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) cout << edge_name.get(e) << " "; cout << endl; } diff -r c11f84e3da21 -r be43902fadb7 src/work/list_graph.h --- a/src/work/list_graph.h Fri Apr 02 18:31:19 2004 +0000 +++ b/src/work/list_graph.h Sat Apr 03 14:22:33 2004 +0000 @@ -309,8 +309,8 @@ bool valid(Node n) const { return n.valid(); } bool valid(Edge e) const { return e.valid(); } - template It getNext(It it) const { - It tmp(it); next(tmp); return tmp; } +// template It getNext(It it) const { +// It tmp(it); next(tmp); return tmp; } // NodeIt& next(NodeIt& it) const { return ++it; } // EdgeIt& next(EdgeIt& it) const { return ++it; } // OutEdgeIt& next(OutEdgeIt& it) const { return ++it; } diff -r c11f84e3da21 -r be43902fadb7 src/work/marci/graph_wrapper.h --- a/src/work/marci/graph_wrapper.h Fri Apr 02 18:31:19 2004 +0000 +++ b/src/work/marci/graph_wrapper.h Sat Apr 03 14:22:33 2004 +0000 @@ -448,12 +448,19 @@ // }; // }; - template class RevGraphWrapper : public GraphWrapperSkeleton { public: typedef typename GraphWrapperSkeleton::Node Node; typedef typename GraphWrapperSkeleton::Edge Edge; + //FIXME + //If GraphWrapper::OutEdgeIt is not defined + //and we do not want to use RevGraphWrapper::InEdgeIt, + //this won't work, because of typedef + //OR + //graphs have to define their non-existing iterators to void + //Unfortunately all the typedefs are instantiated in templates, + //unlike other stuff typedef typename GraphWrapperSkeleton::OutEdgeIt InEdgeIt; typedef typename GraphWrapperSkeleton::InEdgeIt OutEdgeIt; @@ -702,6 +709,7 @@ class Edge { friend class UndirGraphWrapper; + protected: bool out_or_in; //true iff out GraphOutEdgeIt out; GraphInEdgeIt in;