jacint@588: #include jacint@588: jacint@715: #include jacint@715: #include jacint@588: #include jacint@715: #include jacint@715: #include jacint@588: jacint@588: using namespace hugo; jacint@588: jacint@588: int main(int, char **) { jacint@588: jacint@588: typedef ListGraph Graph; jacint@588: jacint@588: typedef Graph::Node Node; jacint@588: typedef Graph::EdgeIt EdgeIt; jacint@588: jacint@588: Graph G; jacint@588: Node s, t; jacint@588: Graph::EdgeMap cap(G); jacint@588: readDimacs(std::cin, G, cap, s, t); jacint@588: Timer ts; jacint@588: jacint@588: std::cout << jacint@588: "\n Running max_flow.h on a graph with " << jacint@588: G.nodeNum() << " nodes and " << G.edgeNum() << " edges..." jacint@588: << std::endl< flowstack(G,0); jacint@715: MaxFlow max_flow_test(G, s, t, cap, flowstack); jacint@588: ts.reset(); jacint@588: max_flow_test.run(); jacint@715: std::cout << "Elapsed time of run() with stl stack: " << std::endl jacint@715: < flow(G,0); jacint@715: MaxFlowNoStack max_flow_test_no_stack(G, s, t, cap, flow); jacint@715: ts.reset(); jacint@715: max_flow_test_no_stack.run(); jacint@715: std::cout << "Elapsed time of run() without stack: " << std::endl jacint@588: < mincut(G); jacint@715: max_flow_test_no_stack.minMinCut(mincut); jacint@588: int min_min_cut_value=0; jacint@588: EdgeIt e; jacint@588: for(G.first(e); G.valid(e); G.next(e)) { jacint@588: if (mincut[G.tail(e)] && !mincut[G.head(e)]) min_min_cut_value+=cap[e]; jacint@588: } jacint@588: jacint@588: Graph::NodeMap cut(G); jacint@715: max_flow_test_no_stack.minCut(cut); jacint@588: int min_cut_value=0; jacint@588: for(G.first(e); G.valid(e); G.next(e)) { jacint@588: if (cut[G.tail(e)] && !cut[G.head(e)]) jacint@588: min_cut_value+=cap[e]; jacint@588: } jacint@588: jacint@588: Graph::NodeMap maxcut(G); jacint@715: max_flow_test_no_stack.maxMinCut(maxcut); jacint@588: int max_min_cut_value=0; jacint@588: for(G.first(e); G.valid(e); G.next(e)) { jacint@588: if (maxcut[G.tail(e)] && !maxcut[G.head(e)]) jacint@588: max_min_cut_value+=cap[e]; jacint@588: } jacint@588: jacint@715: std::cout << "\n Checking the result without stack: " < flow2(G,0); jacint@588: std::cout << "Calling resetFlow() " << std::endl jacint@588: << ts << std::endl; alpar@757: max_flow_test.setFlow(flow2); jacint@588: ts.reset(); jacint@588: max_flow_test.preflow(max_flow_test.PRE_FLOW); jacint@588: std::cout << "Elapsed time of preflow(PRE_FLOW) starting from the zero flow: " << std::endl jacint@588: << ts << std::endl; jacint@588: jacint@588: Graph::NodeMap mincut2(G); jacint@588: max_flow_test.minMinCut(mincut2); jacint@588: int min_min_cut_value2=0; jacint@588: for(G.first(e); G.valid(e); G.next(e)) { jacint@588: if (mincut2[G.tail(e)] && !mincut2[G.head(e)]) min_min_cut_value2+=cap[e]; jacint@588: } jacint@588: jacint@588: Graph::NodeMap cut2(G); jacint@588: max_flow_test.minCut(cut2); jacint@588: int min_cut_value2=0; jacint@588: for(G.first(e); G.valid(e); G.next(e)) { jacint@588: if (cut2[G.tail(e)] && !cut2[G.head(e)]) jacint@588: min_cut_value2+=cap[e]; jacint@588: } jacint@588: jacint@588: Graph::NodeMap maxcut2(G); jacint@588: max_flow_test.maxMinCut(maxcut2); jacint@588: int max_min_cut_value2=0; jacint@588: for(G.first(e); G.valid(e); G.next(e)) { jacint@588: if (maxcut2[G.tail(e)] && !maxcut2[G.head(e)]) jacint@588: max_min_cut_value2+=cap[e]; jacint@588: } jacint@588: jacint@588: std::cout << "\n Checking the result: " < max_flow_test3(G, s, t, cap, flow2); jacint@588: max_flow_test3.run(max_flow_test3.GEN_FLOW); jacint@588: std::cout << "Calling run(GEN_FLOW) from the max flow found before. " < mincut3(G); jacint@588: max_flow_test3.minMinCut(mincut3); jacint@588: int min_min_cut_value3=0; jacint@588: for(G.first(e); G.valid(e); G.next(e)) { jacint@588: if (mincut3[G.tail(e)] && !mincut3[G.head(e)]) min_min_cut_value3+=cap[e]; jacint@588: } jacint@588: jacint@588: Graph::NodeMap cut3(G); jacint@588: max_flow_test3.minCut(cut3); jacint@588: int min_cut_value3=0; jacint@588: for(G.first(e); G.valid(e); G.next(e)) { jacint@588: if (cut3[G.tail(e)] && !cut3[G.head(e)]) jacint@588: min_cut_value3+=cap[e]; jacint@588: } jacint@588: jacint@588: Graph::NodeMap maxcut3(G); jacint@588: max_flow_test3.maxMinCut(maxcut3); jacint@588: int max_min_cut_value3=0; jacint@588: for(G.first(e); G.valid(e); G.next(e)) { jacint@588: if (maxcut3[G.tail(e)] && !maxcut3[G.head(e)]) jacint@588: max_min_cut_value3+=cap[e]; jacint@588: } jacint@588: jacint@588: std::cout << "\n Checking the result: " <