# HG changeset patch # User jacint # Date 1077010495 0 # Node ID 56e879edcca6be2bd7247b427e0baae84d90b51a # Parent efafe79a88d371b03c2922c2c5f68353864f3d4b after debugging diff -r efafe79a88d3 -r 56e879edcca6 src/work/jacint/preflow_push_hl.h --- a/src/work/jacint/preflow_push_hl.h Tue Feb 17 08:59:49 2004 +0000 +++ b/src/work/jacint/preflow_push_hl.h Tue Feb 17 09:34:55 2004 +0000 @@ -65,12 +65,11 @@ */ void run() { - int i=0;//DELME - typename Graph::NodeMap level(G); - typename Graph::NodeMap excess(G); + typename Graph::NodeMap excess(G); + std::cout <<"excess s:"< 0 ) { NodeIt w=G.head(e); + if ( excess.get(w) == 0 && w!=t && w!=s ) stack[level.get(w)].push(w); flow.set(e, capacity.get(e)); - stack[level.get(w)].push(w); excess.set(w, excess.get(w)+capacity.get(e)); } } - /* End of preprocessing */ @@ -113,10 +109,10 @@ /* - Push/relabel on the highest level active Nodes. + Push/relabel on the highest level active nodes. */ - /*While there exists active Node.*/ + /*While there exists active node.*/ while (b) { /*We decrease the bound if there is no active Node of level b.*/ @@ -124,29 +120,29 @@ --b; } else { - NodeIt w=stack[b].top(); //w is the highest label active Node. - stack[b].pop(); //We delete w from the stack. + NodeIt w=stack[b].top(); //w is a highest label active node. + stack[b].pop(); - int newlevel=2*n-2; //In newlevel we maintain the next level of w. + int newlevel=2*n-2; //In newlevel we bound the next level of w. for(OutEdgeIt e=G.template first(w); e.valid(); ++e) { - NodeIt v=G.head(e); - /*e is the Edge wv.*/ + + if ( flow.get(e) < capacity.get(e) ) { + /*e is an edge of the residual graph */ - if (flow.get(e) level.get(v)+1 ) { std::cout<<"HIBA1!";} //delme + + if( level.get(w) == level.get(v)+1 ) { /*Push is allowed now*/ if (capacity.get(e)-flow.get(e) > excess.get(w)) { /*A nonsaturating push.*/ - if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); + if (excess.get(v)==0 && v != s && v !=t) stack[level.get(v)].push(v); /*v becomes active.*/ - //std::cout<<++i; - flow.set(e, flow.get(e)+excess.get(w)); excess.set(v, excess.get(v)+excess.get(w)); excess.set(w,0); @@ -155,7 +151,7 @@ } else { /*A saturating push.*/ - if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); + if (excess.get(v)==0 && v != s&& v !=t) stack[level.get(v)].push(v); /*v becomes active.*/ excess.set(v, excess.get(v)+capacity.get(e)-flow.get(e)); @@ -193,7 +189,7 @@ if (flow.get(e) > excess.get(w)) { /*A nonsaturating push.*/ - if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); + if (excess.get(v)==0 && v != s&& v !=t) stack[level.get(v)].push(v); /*v becomes active.*/ flow.set(e, flow.get(e)-excess.get(w)); @@ -204,7 +200,7 @@ } else { /*A saturating push.*/ - if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); + if (excess.get(v)==0 && v != s&& v !=t) stack[level.get(v)].push(v); /*v becomes active.*/ excess.set(v, excess.get(v)+flow.get(e));