[Lemon-commits] [lemon_svn] jacint: r504 - hugo/trunk/src/work/jacint

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


Author: jacint
Date: Thu Apr 22 17:56:05 2004
New Revision: 504

Modified:
   hugo/trunk/src/work/jacint/preflow.cc
   hugo/trunk/src/work/jacint/preflowproba.h

Log:


Modified: hugo/trunk/src/work/jacint/preflow.cc
==============================================================================
--- hugo/trunk/src/work/jacint/preflow.cc	(original)
+++ hugo/trunk/src/work/jacint/preflow.cc	Thu Apr 22 17:56:05 2004
@@ -24,9 +24,17 @@
   std::cout << "preflow demo ..." << std::endl;
   
   Graph::EdgeMap<int> flow(G);
-  Preflow<Graph, int> max_flow_test(G, s, t, cap, flow, 1);
+  Preflow<Graph, int> max_flow_test(G, s, t, cap, flow, 1,1);
   ts.reset();
   max_flow_test.run();
+  std::cout << "elapsed time with res: " << ts << std::endl;
+  
+  std::cout << "preflow demo ..." << std::endl;
+  
+  Graph::EdgeMap<int> flow2(G);
+  Preflow<Graph, int> max_flow_test2(G, s, t, cap, flow, 1,0);
+  ts.reset();
+  max_flow_test2.run();
   std::cout << "elapsed time: " << ts << std::endl;
   
   Graph::NodeMap<bool> cut(G);

Modified: hugo/trunk/src/work/jacint/preflowproba.h
==============================================================================
--- hugo/trunk/src/work/jacint/preflowproba.h	(original)
+++ hugo/trunk/src/work/jacint/preflowproba.h	Thu Apr 22 17:56:05 2004
@@ -70,6 +70,7 @@
     FlowMap& flow;
     T value;
     bool constzero;
+    bool res;
 
     typedef ResGraphWrapper<const Graph, T, CapMap, FlowMap> ResGW;
     typedef typename ResGW::OutEdgeIt ResOutEdgeIt;
@@ -78,8 +79,8 @@
  
   public:
     Preflow(Graph& _G, Node _s, Node _t, CapMap& _capacity, 
-	    FlowMap& _flow, bool _constzero ) :
-      G(_G), s(_s), t(_t), capacity(_capacity), flow(_flow), constzero(_constzero) {}
+	    FlowMap& _flow, bool _constzero, bool _res ) :
+      G(_G), s(_s), t(_t), capacity(_capacity), flow(_flow), constzero(_constzero), res(_res) {}
     
     
     void run() {
@@ -302,46 +303,49 @@
 	      bfs_queue.pop();
 	      int l=level[v]+1;
 	      
-	      /*	      ResInEdgeIt e;
-	      for(res_graph.first(e,s); res_graph.valid(e); 
-		  res_graph.next(e)) {
-		Node u=res_graph.tail(e);
-		if ( level[u] >= n ) { 
-		  bfs_queue.push(u);
-		  level.set(u, l);
-		  if ( excess[u] > 0 ) {
-		    next.set(u,active[l]);
-		    active[l]=u;
+	      if (res){	
+		ResInEdgeIt e;
+		for(res_graph.first(e,v); res_graph.valid(e); 
+		    res_graph.next(e)) {
+		  Node u=res_graph.tail(e);
+		  if ( level[u] >= n ) { 
+		    bfs_queue.push(u);
+		    level.set(u, l);
+		    if ( excess[u] > 0 ) {
+		      next.set(u,active[l]);
+		      active[l]=u;
+		    }
 		  }
 		}
-		}*/
-	            InEdgeIt e;
-	      for(G.first(e,v); G.valid(e); G.next(e)) {
-		if ( capacity[e] == flow[e] ) continue;
-		Node u=G.tail(e);
-		if ( level[u] >= n ) { 
-		  bfs_queue.push(u);
-		  level.set(u, l);
-		  if ( excess[u] > 0 ) {
-		    next.set(u,active[l]);
-		    active[l]=u;
+	      } else {
+	        InEdgeIt e;
+		for(G.first(e,v); G.valid(e); G.next(e)) {
+		  if ( capacity[e] == flow[e] ) continue;
+		  Node u=G.tail(e);
+		  if ( level[u] >= n ) { 
+		    bfs_queue.push(u);
+		    level.set(u, l);
+		    if ( excess[u] > 0 ) {
+		      next.set(u,active[l]);
+		      active[l]=u;
+		    }
 		  }
 		}
-	      }
-	    
-	      OutEdgeIt f;
-	      for(G.first(f,v); G.valid(f); G.next(f)) {
-		if ( 0 == flow[f] ) continue;
-		Node u=G.head(f);
-		if ( level[u] >= n ) { 
-		  bfs_queue.push(u);
-		  level.set(u, l);
-		  if ( excess[u] > 0 ) {
-		    next.set(u,active[l]);
-		    active[l]=u;
+		
+		OutEdgeIt f;
+		for(G.first(f,v); G.valid(f); G.next(f)) {
+		  if ( 0 == flow[f] ) continue;
+		  Node u=G.head(f);
+		  if ( level[u] >= n ) { 
+		    bfs_queue.push(u);
+		    level.set(u, l);
+		    if ( excess[u] > 0 ) {
+		      next.set(u,active[l]);
+		      active[l]=u;
+		    }
 		  }
 		}
-		}
+	      }
 	    }
 	    b=n-2;
 	    }



More information about the Lemon-commits mailing list