[Lemon-commits] [lemon_svn] marci: r393 - in hugo/trunk/src/work: . marci

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:39:12 CET 2006


Author: marci
Date: Sat Apr  3 16:22:33 2004
New Revision: 393

Modified:
   hugo/trunk/src/work/bfs_iterator.h
   hugo/trunk/src/work/edmonds_karp.h
   hugo/trunk/src/work/iterator_bfs_demo.cc
   hugo/trunk/src/work/list_graph.h
   hugo/trunk/src/work/marci/graph_wrapper.h

Log:
minor changes


Modified: hugo/trunk/src/work/bfs_iterator.h
==============================================================================
--- hugo/trunk/src/work/bfs_iterator.h	(original)
+++ hugo/trunk/src/work/bfs_iterator.h	Sat Apr  3 16:22:33 2004
@@ -796,7 +796,9 @@
     void pushAndSetReached(Node s) { 
       actual_node=s;
       reached.set(s, true);
-      dfs_stack.push(G.template first<OutEdgeIt>(s)); 
+      OutEdgeIt e;
+      G.first(e, s);
+      dfs_stack.push(e); 
     }
     DfsIterator5<GraphWrapper, /*OutEdgeIt,*/ ReachedMap>& 
     operator++() { 
@@ -806,7 +808,9 @@
 	Node w=G.bNode(actual_edge);
 	actual_node=w;
 	if (!reached.get(w)) {
-	  dfs_stack.push(G.template first<OutEdgeIt>(w));
+	  OutEdgeIt e;
+	  G.first(e, w);
+	  dfs_stack.push(e);
 	  reached.set(w, true);
 	  b_node_newly_reached=true;
 	} else {

Modified: hugo/trunk/src/work/edmonds_karp.h
==============================================================================
--- hugo/trunk/src/work/edmonds_karp.h	(original)
+++ hugo/trunk/src/work/edmonds_karp.h	Sat Apr  3 16:22:33 2004
@@ -352,8 +352,11 @@
       typedef SubGraphWrapper<ResGW, DistanceMap<ResGW> > FilterResGW;
       FilterResGW filter_res_graph(res_graph, dist);
       typename ResGW::NodeMap<typename MG::Node> res_graph_to_F(res_graph);
-      for(typename ResGW::NodeIt n=res_graph.template first<typename ResGW::NodeIt>(); 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<typename FilterResGW::EdgeIt>(); 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<typename MG::Node> res_graph_to_F(res_graph);
-      for(typename ResGW::NodeIt n=res_graph.template first<typename ResGW::NodeIt>(); 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);

Modified: hugo/trunk/src/work/iterator_bfs_demo.cc
==============================================================================
--- hugo/trunk/src/work/iterator_bfs_demo.cc	(original)
+++ hugo/trunk/src/work/iterator_bfs_demo.cc	Sat Apr  3 16:22:33 2004
@@ -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<string> > edge_name(gw, node_name);
     
     cout << "bfs and dfs iterator demo on the directed graph" << endl;
-    for(GW::NodeIt n=gw.first<GW::NodeIt>(); 
-	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<GW::OutEdgeIt>(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<GW::InEdgeIt>(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<string> > edge_name(gw, node_name);
     
     cout << "bfs and dfs iterator demo on the reversed directed graph" << endl;
-    for(GW::NodeIt n=gw.first<GW::NodeIt>(); 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<GW::OutEdgeIt>(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<GW::InEdgeIt>(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<string> > edge_name(gw, node_name);
     
     cout << "bfs and dfs iterator demo on the undirected graph" << endl;
-    for(GW::NodeIt n=gw.first<GW::NodeIt>(); 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<GW::OutEdgeIt>(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<GW::InEdgeIt>(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;
     }

Modified: hugo/trunk/src/work/list_graph.h
==============================================================================
--- hugo/trunk/src/work/list_graph.h	(original)
+++ hugo/trunk/src/work/list_graph.h	Sat Apr  3 16:22:33 2004
@@ -309,8 +309,8 @@
     bool valid(Node n) const { return n.valid(); }
     bool valid(Edge e) const { return e.valid(); }
     
-    template <typename It> It getNext(It it) const { 
-      It tmp(it); next(tmp); return tmp; }
+//    template <typename It> 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; }

Modified: hugo/trunk/src/work/marci/graph_wrapper.h
==============================================================================
--- hugo/trunk/src/work/marci/graph_wrapper.h	(original)
+++ hugo/trunk/src/work/marci/graph_wrapper.h	Sat Apr  3 16:22:33 2004
@@ -448,12 +448,19 @@
 //     };
 //   };
 
-
   template<typename GraphWrapper>
   class RevGraphWrapper : public GraphWrapperSkeleton<GraphWrapper> {
   public:
     typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
     typedef typename GraphWrapperSkeleton<GraphWrapper>::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<GraphWrapper>::OutEdgeIt InEdgeIt;
     typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt OutEdgeIt;
 
@@ -702,6 +709,7 @@
   
     class Edge {
       friend class UndirGraphWrapper<GraphWrapper>;
+    protected:
       bool out_or_in; //true iff out
       GraphOutEdgeIt out;
       GraphInEdgeIt in;



More information about the Lemon-commits mailing list