minor changes
authormarci
Sat, 03 Apr 2004 14:22:33 +0000
changeset 279be43902fadb7
parent 278 c11f84e3da21
child 280 19f3943521ab
minor changes
src/work/bfs_iterator.h
src/work/edmonds_karp.h
src/work/iterator_bfs_demo.cc
src/work/list_graph.h
src/work/marci/graph_wrapper.h
     1.1 --- a/src/work/bfs_iterator.h	Fri Apr 02 18:31:19 2004 +0000
     1.2 +++ b/src/work/bfs_iterator.h	Sat Apr 03 14:22:33 2004 +0000
     1.3 @@ -796,7 +796,9 @@
     1.4      void pushAndSetReached(Node s) { 
     1.5        actual_node=s;
     1.6        reached.set(s, true);
     1.7 -      dfs_stack.push(G.template first<OutEdgeIt>(s)); 
     1.8 +      OutEdgeIt e;
     1.9 +      G.first(e, s);
    1.10 +      dfs_stack.push(e); 
    1.11      }
    1.12      DfsIterator5<GraphWrapper, /*OutEdgeIt,*/ ReachedMap>& 
    1.13      operator++() { 
    1.14 @@ -806,7 +808,9 @@
    1.15  	Node w=G.bNode(actual_edge);
    1.16  	actual_node=w;
    1.17  	if (!reached.get(w)) {
    1.18 -	  dfs_stack.push(G.template first<OutEdgeIt>(w));
    1.19 +	  OutEdgeIt e;
    1.20 +	  G.first(e, w);
    1.21 +	  dfs_stack.push(e);
    1.22  	  reached.set(w, true);
    1.23  	  b_node_newly_reached=true;
    1.24  	} else {
     2.1 --- a/src/work/edmonds_karp.h	Fri Apr 02 18:31:19 2004 +0000
     2.2 +++ b/src/work/edmonds_karp.h	Sat Apr 03 14:22:33 2004 +0000
     2.3 @@ -352,8 +352,11 @@
     2.4        typedef SubGraphWrapper<ResGW, DistanceMap<ResGW> > FilterResGW;
     2.5        FilterResGW filter_res_graph(res_graph, dist);
     2.6        typename ResGW::NodeMap<typename MG::Node> res_graph_to_F(res_graph);
     2.7 -      for(typename ResGW::NodeIt n=res_graph.template first<typename ResGW::NodeIt>(); res_graph.valid(n); res_graph.next(n)) {
     2.8 -	res_graph_to_F.set(n, F.addNode());
     2.9 +      {
    2.10 +	typename ResGW::NodeIt n;
    2.11 +	for(res_graph.first(n); res_graph.valid(n); res_graph.next(n)) {
    2.12 +	  res_graph_to_F.set(n, F.addNode());
    2.13 +	}
    2.14        }
    2.15  
    2.16        typename MG::Node sF=res_graph_to_F.get(s);
    2.17 @@ -363,14 +366,17 @@
    2.18  
    2.19        //Making F to the graph containing the edges of the residual graph 
    2.20        //which are in some shortest paths
    2.21 -      for(typename FilterResGW::EdgeIt e=filter_res_graph.template first<typename FilterResGW::EdgeIt>(); filter_res_graph.valid(e); filter_res_graph.next(e)) {
    2.22 -	//if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
    2.23 +      {
    2.24 +	typename FilterResGW::EdgeIt e;
    2.25 +	for(filter_res_graph.first(e); filter_res_graph.valid(e); filter_res_graph.next(e)) {
    2.26 +	  //if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
    2.27  	  typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
    2.28  	  original_edge.update();
    2.29  	  original_edge.set(f, e);
    2.30  	  residual_capacity.update();
    2.31  	  residual_capacity.set(f, res_graph.resCap(e));
    2.32  	  //} 
    2.33 +	}
    2.34        }
    2.35  
    2.36        bool __augment=true;
    2.37 @@ -446,8 +452,11 @@
    2.38        //with the set of edges which are on shortest paths
    2.39        MG F;
    2.40        typename ResGW::NodeMap<typename MG::Node> res_graph_to_F(res_graph);
    2.41 -      for(typename ResGW::NodeIt n=res_graph.template first<typename ResGW::NodeIt>(); res_graph.valid(n); res_graph.next(n)) {
    2.42 -	res_graph_to_F.set(n, F.addNode());
    2.43 +      {
    2.44 +	typename ResGW::NodeIt n;
    2.45 +	for(res_graph.first(n); res_graph.valid(n); res_graph.next(n)) {
    2.46 +	  res_graph_to_F.set(n, F.addNode());
    2.47 +	}
    2.48        }
    2.49  
    2.50        typename MG::Node sF=res_graph_to_F.get(s);
     3.1 --- a/src/work/iterator_bfs_demo.cc	Fri Apr 02 18:31:19 2004 +0000
     3.2 +++ b/src/work/iterator_bfs_demo.cc	Sat Apr 03 14:22:33 2004 +0000
     3.3 @@ -33,11 +33,6 @@
     3.4  
     3.5    typedef Graph::Node Node;
     3.6    typedef Graph::Edge Edge;
     3.7 -  //typedef Graph::NodeIt NodeIt;
     3.8 -  //typedef Graph::EdgeIt EdgeIt;
     3.9 -  //typedef Graph::OutEdgeIt OutEdgeIt;
    3.10 -  //typedef Graph::InEdgeIt InEdgeIt;
    3.11 -  //typedef Graph::SymEdgeIt SymEdgeIt;
    3.12   
    3.13    Graph G;
    3.14  
    3.15 @@ -99,15 +94,13 @@
    3.16      EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name);
    3.17      
    3.18      cout << "bfs and dfs iterator demo on the directed graph" << endl;
    3.19 -    for(GW::NodeIt n=gw.first<GW::NodeIt>(); 
    3.20 -	gw.valid(n); 
    3.21 -	gw.next(n)) { 
    3.22 +    for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { 
    3.23        cout << node_name.get(n) << ": ";
    3.24        cout << "out edges: ";
    3.25 -      for(GW::OutEdgeIt e=gw.first<GW::OutEdgeIt>(n); gw.valid(e); gw.next(e)) 
    3.26 +      for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
    3.27  	cout << edge_name.get(e) << " ";
    3.28        cout << "in edges: ";
    3.29 -      for(GW::InEdgeIt e=gw.first<GW::InEdgeIt>(n); gw.valid(e); gw.next(e)) 
    3.30 +      for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
    3.31  	cout << edge_name.get(e) << " ";
    3.32        cout << endl;
    3.33      }
    3.34 @@ -177,13 +170,13 @@
    3.35      EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name);
    3.36      
    3.37      cout << "bfs and dfs iterator demo on the reversed directed graph" << endl;
    3.38 -    for(GW::NodeIt n=gw.first<GW::NodeIt>(); gw.valid(n); gw.next(n)) { 
    3.39 +    for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { 
    3.40        cout << node_name.get(n) << ": ";
    3.41        cout << "out edges: ";
    3.42 -      for(GW::OutEdgeIt e=gw.first<GW::OutEdgeIt>(n); gw.valid(e); gw.next(e)) 
    3.43 +      for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
    3.44  	cout << edge_name.get(e) << " ";
    3.45        cout << "in edges: ";
    3.46 -      for(GW::InEdgeIt e=gw.first<GW::InEdgeIt>(n); gw.valid(e); gw.next(e)) 
    3.47 +      for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
    3.48  	cout << edge_name.get(e) << " ";
    3.49        cout << endl;
    3.50      }
    3.51 @@ -253,13 +246,13 @@
    3.52      EdgeNameMap< GW, Graph::NodeMap<string> > edge_name(gw, node_name);
    3.53      
    3.54      cout << "bfs and dfs iterator demo on the undirected graph" << endl;
    3.55 -    for(GW::NodeIt n=gw.first<GW::NodeIt>(); gw.valid(n); gw.next(n)) { 
    3.56 +    for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { 
    3.57        cout << node_name.get(n) << ": ";
    3.58        cout << "out edges: ";
    3.59 -      for(GW::OutEdgeIt e=gw.first<GW::OutEdgeIt>(n); gw.valid(e); gw.next(e)) 
    3.60 +      for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
    3.61  	cout << edge_name.get(e) << " ";
    3.62        cout << "in edges: ";
    3.63 -      for(GW::InEdgeIt e=gw.first<GW::InEdgeIt>(n); gw.valid(e); gw.next(e)) 
    3.64 +      for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
    3.65  	cout << edge_name.get(e) << " ";
    3.66        cout << endl;
    3.67      }
     4.1 --- a/src/work/list_graph.h	Fri Apr 02 18:31:19 2004 +0000
     4.2 +++ b/src/work/list_graph.h	Sat Apr 03 14:22:33 2004 +0000
     4.3 @@ -309,8 +309,8 @@
     4.4      bool valid(Node n) const { return n.valid(); }
     4.5      bool valid(Edge e) const { return e.valid(); }
     4.6      
     4.7 -    template <typename It> It getNext(It it) const { 
     4.8 -      It tmp(it); next(tmp); return tmp; }
     4.9 +//    template <typename It> It getNext(It it) const { 
    4.10 +//      It tmp(it); next(tmp); return tmp; }
    4.11  //     NodeIt& next(NodeIt& it) const { return ++it; }
    4.12  //     EdgeIt& next(EdgeIt& it) const { return ++it; }
    4.13  //     OutEdgeIt& next(OutEdgeIt& it) const { return ++it; }
     5.1 --- a/src/work/marci/graph_wrapper.h	Fri Apr 02 18:31:19 2004 +0000
     5.2 +++ b/src/work/marci/graph_wrapper.h	Sat Apr 03 14:22:33 2004 +0000
     5.3 @@ -448,12 +448,19 @@
     5.4  //     };
     5.5  //   };
     5.6  
     5.7 -
     5.8    template<typename GraphWrapper>
     5.9    class RevGraphWrapper : public GraphWrapperSkeleton<GraphWrapper> {
    5.10    public:
    5.11      typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
    5.12      typedef typename GraphWrapperSkeleton<GraphWrapper>::Edge Edge;
    5.13 +    //FIXME 
    5.14 +    //If GraphWrapper::OutEdgeIt is not defined
    5.15 +    //and we do not want to use RevGraphWrapper::InEdgeIt,
    5.16 +    //this won't work, because of typedef
    5.17 +    //OR
    5.18 +    //graphs have to define their non-existing iterators to void
    5.19 +    //Unfortunately all the typedefs are instantiated in templates, 
    5.20 +    //unlike other stuff
    5.21      typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt InEdgeIt;
    5.22      typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt OutEdgeIt;
    5.23  
    5.24 @@ -702,6 +709,7 @@
    5.25    
    5.26      class Edge {
    5.27        friend class UndirGraphWrapper<GraphWrapper>;
    5.28 +    protected:
    5.29        bool out_or_in; //true iff out
    5.30        GraphOutEdgeIt out;
    5.31        GraphInEdgeIt in;