# HG changeset patch # User marci # Date 1091121835 0 # Node ID a0e497db23ee95cdb960c0ae263f6f12fb17e382 # Parent be163d94c109b5fdd9b97655997226f2fecb20db diff -r be163d94c109 -r a0e497db23ee src/work/jacint/makefile --- a/src/work/jacint/makefile Thu Jul 29 17:20:51 2004 +0000 +++ b/src/work/jacint/makefile Thu Jul 29 17:23:55 2004 +0000 @@ -1,3 +1,3 @@ -BINARIES = max_flow_test +BINARIES = max_flow_bug INCLUDEDIRS= -I../../include -I../.. -I.. -I../{klao,marci,jacint,alpar,johanna,akos} include ../makefile diff -r be163d94c109 -r a0e497db23ee src/work/jacint/max_flow_bug.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/jacint/max_flow_bug.cc Thu Jul 29 17:23:55 2004 +0000 @@ -0,0 +1,163 @@ +#include + +//#include +#include +#include +#include +//#include +#include + +using namespace hugo; + +int main(int, char **) { + +// typedef ListGraph Graph; + typedef SageGraph Graph; + + typedef Graph::Node Node; + typedef Graph::EdgeIt EdgeIt; + + Graph G; + Node s, t; + Graph::EdgeMap cap(G); + Graph::EdgeMap flow(G,0); + + readDimacs(std::cin, G, cap, s, t, flow); + Timer ts; + + std::cout << + "\n Running max_flow.h on a graph with " << + G.nodeNum() << " nodes and " << G.edgeNum() << " edges..." + << std::endl< max_flow_test_no_stack(G, s, t, cap, flow); + ts.reset(); + max_flow_test_no_stack.preflowPhase1(MaxFlow::PRE_FLOW); + std::cout << "Elapsed time of run() without stack: " << std::endl + < mincut(G); + max_flow_test_no_stack.minMinCut(mincut); + int min_min_cut_value=0; + EdgeIt e; + for(G.first(e); G.valid(e); G.next(e)) { + if (mincut[G.tail(e)] && !mincut[G.head(e)]) min_min_cut_value+=cap[e]; + } + + Graph::NodeMap cut(G); + max_flow_test_no_stack.minCut(cut); + int min_cut_value=0; + for(G.first(e); G.valid(e); G.next(e)) { + if (cut[G.tail(e)] && !cut[G.head(e)]) + min_cut_value+=cap[e]; + } + + Graph::NodeMap maxcut(G); + max_flow_test_no_stack.maxMinCut(maxcut); + int max_min_cut_value=0; + for(G.first(e); G.valid(e); G.next(e)) { + if (maxcut[G.tail(e)] && !maxcut[G.head(e)]) + max_min_cut_value+=cap[e]; + } + + std::cout << "\n Checking the result without stack: " < flow2(G,0); + std::cout << "Calling resetFlow() " << std::endl + << ts << std::endl; + max_flow_test.resetFlow(flow2); + ts.reset(); + max_flow_test.preflow(max_flow_test.PRE_FLOW); + std::cout << "Elapsed time of preflow(PRE_FLOW) starting from the zero flow: " << std::endl + << ts << std::endl; + + Graph::NodeMap mincut2(G); + max_flow_test.minMinCut(mincut2); + int min_min_cut_value2=0; + for(G.first(e); G.valid(e); G.next(e)) { + if (mincut2[G.tail(e)] && !mincut2[G.head(e)]) min_min_cut_value2+=cap[e]; + } + + Graph::NodeMap cut2(G); + max_flow_test.minCut(cut2); + int min_cut_value2=0; + for(G.first(e); G.valid(e); G.next(e)) { + if (cut2[G.tail(e)] && !cut2[G.head(e)]) + min_cut_value2+=cap[e]; + } + + Graph::NodeMap maxcut2(G); + max_flow_test.maxMinCut(maxcut2); + int max_min_cut_value2=0; + for(G.first(e); G.valid(e); G.next(e)) { + if (maxcut2[G.tail(e)] && !maxcut2[G.head(e)]) + max_min_cut_value2+=cap[e]; + } + + std::cout << "\n Checking the result: " < max_flow_test3(G, s, t, cap, flow2); + max_flow_test3.run(max_flow_test3.GEN_FLOW); + std::cout << "Calling run(GEN_FLOW) from the max flow found before. " < mincut3(G); + max_flow_test3.minMinCut(mincut3); + int min_min_cut_value3=0; + for(G.first(e); G.valid(e); G.next(e)) { + if (mincut3[G.tail(e)] && !mincut3[G.head(e)]) min_min_cut_value3+=cap[e]; + } + + Graph::NodeMap cut3(G); + max_flow_test3.minCut(cut3); + int min_cut_value3=0; + for(G.first(e); G.valid(e); G.next(e)) { + if (cut3[G.tail(e)] && !cut3[G.head(e)]) + min_cut_value3+=cap[e]; + } + + Graph::NodeMap maxcut3(G); + max_flow_test3.maxMinCut(maxcut3); + int max_min_cut_value3=0; + for(G.first(e); G.valid(e); G.next(e)) { + if (maxcut3[G.tail(e)] && !maxcut3[G.head(e)]) + max_min_cut_value3+=cap[e]; + } + + std::cout << "\n Checking the result: " <