# HG changeset patch # User athos # Date 1085395424 0 # Node ID 531fc5f575efd3f9842e3756c8bbc1131e31ccf1 # Parent 9971eb8bfbe88b859525584c329ab70518098c5d Not ready yet. diff -r 9971eb8bfbe8 -r 531fc5f575ef src/work/athos/mincostflow.h --- a/src/work/athos/mincostflow.h Fri May 21 12:40:39 2004 +0000 +++ b/src/work/athos/mincostflow.h Mon May 24 10:43:44 2004 +0000 @@ -10,7 +10,9 @@ #include #include #include +#include #include +#include namespace hugo { @@ -118,7 +120,7 @@ //total_length = 0; typedef typename Graph::template NodeMap HeapMap; - typedef Heap, + typedef Heap< Node, SupplyDemand, typename Graph::template NodeMap, std::greater > 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 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 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::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)