# HG changeset patch # User jacint # Date 1082649365 0 # Node ID 0fc9cd9b854a24c3853e13488cfbe29305f5e0e1 # Parent 259ea2d741a21c4b4fb4e31982e0ba254d49c973 diff -r 259ea2d741a2 -r 0fc9cd9b854a src/work/jacint/preflow.cc --- a/src/work/jacint/preflow.cc Thu Apr 22 14:50:24 2004 +0000 +++ b/src/work/jacint/preflow.cc Thu Apr 22 15:56:05 2004 +0000 @@ -24,9 +24,17 @@ std::cout << "preflow demo ..." << std::endl; Graph::EdgeMap flow(G); - Preflow max_flow_test(G, s, t, cap, flow, 1); + Preflow 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 flow2(G); + Preflow 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 cut(G); diff -r 259ea2d741a2 -r 0fc9cd9b854a src/work/jacint/preflowproba.h --- a/src/work/jacint/preflowproba.h Thu Apr 22 14:50:24 2004 +0000 +++ b/src/work/jacint/preflowproba.h Thu Apr 22 15:56:05 2004 +0000 @@ -70,6 +70,7 @@ FlowMap& flow; T value; bool constzero; + bool res; typedef ResGraphWrapper 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; }