[Lemon-commits] [lemon_svn] athos: r860 - hugo/trunk/src/work/athos

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


Author: athos
Date: Mon May 24 12:43:44 2004
New Revision: 860

Modified:
   hugo/trunk/src/work/athos/mincostflow.h

Log:
Not ready yet.

Modified: hugo/trunk/src/work/athos/mincostflow.h
==============================================================================
--- hugo/trunk/src/work/athos/mincostflow.h	(original)
+++ hugo/trunk/src/work/athos/mincostflow.h	Mon May 24 12:43:44 2004
@@ -10,7 +10,9 @@
 #include <hugo/graph_wrapper.h>
 #include <hugo/maps.h>
 #include <vector>
+#include <list>
 #include <for_each_macros.h>
+#include <hugo/union_find.h>
 
 namespace hugo {
 
@@ -118,7 +120,7 @@
       //total_length = 0;
 
       typedef typename Graph::template NodeMap<int> HeapMap;
-      typedef Heap<Node, SupplyDemand, typename Graph::template NodeMap<int>,
+      typedef Heap< Node, SupplyDemand, typename Graph::template NodeMap<int>,
 	std::greater<SupplyDemand> > 	HeapType;
 
       //A heap for the excess nodes
@@ -129,14 +131,25 @@
       HeapMap deficit_nodes_map(G,-1);
       HeapType deficit_nodes(deficit_nodes_map);
 
+      //A container to store nonabundant arcs
+      list<Edge> nonabundant_arcs;
       
       FOR_EACH_LOC(typename Graph::EdgeIt, e, G){
 	flow.set(e,0);
+	nonabundant_arcs.push_back(e);
       }
 
       //Initial value for delta
       SupplyDemand delta = 0;
 
+      typedef UnionFindEnum<Node, Graph::template NodeMap> UFE;
+
+      //A union-find structure to store the abundant components
+      UFE::MapType abund_comp_map(G);
+      UFE abundant_components(abund_comp_map);
+
+
+
       FOR_EACH_LOC(typename Graph::NodeIt, n, G){
        	excess_deficit.set(n,supply_demand[n]);
 	//A supply node
@@ -153,6 +166,8 @@
 	}
 	//Initialize the copy of the Dijkstra potential to zero
 	potential.set(n,0);
+	//Every single point is an abundant component initially 
+	abundant_components.insert(n);
       }
 
       //It'll be allright as an initial value, though this value 
@@ -171,11 +186,38 @@
 
       while (max_excess > 0){
 
+	//Reset delta if still too big
+	if (8*number_of_nodes*max_excess <= delta){
+	  delta = max_excess;
+	  
+	}
+
 	/*
 	 * Beginning of the delta scaling phase 
 	*/
-	
 	//Merge and stuff
+	{
+	  SupplyDemand buf=8*number_of_nodes*delta;
+	  list<Edge>::iterator i = nonabundant_arcs.begin();
+	  while ( i != nonabundant_arcs.end() ){
+	    if (flow[i]>=buf){
+	      Node a = abundant_components.find(res_graph.head(i));
+	      Node b = abundant_components.find(res_graph.tail(i));
+	      //Merge
+	      if (a != b){
+		//Find path and augment
+		//!!!
+		//Find path and augment
+		abundant_components.join(a,b);
+	      }
+	      //What happens to i?
+	      nonabundant_arcs.erase(i);
+	    }
+	    else
+	      ++i;
+	  }
+	}
+
 
 	Node s = excess_nodes.top(); 
 	SupplyDemand max_excess = excess_nodes[s];
@@ -261,11 +303,7 @@
 	  }
 	}
 	*/
-	//Reset delta if still too big
-	if (8*number_of_nodes*max_excess <= delta){
-	  delta = max_excess;
-	  
-	}
+
 	  
       }//while(max_excess > 0)
       



More information about the Lemon-commits mailing list