jacint@388: /* jacint@388: The only difference between preflow.h and preflow_res.h is that the latter jacint@388: uses the ResGraphWrapper, while the first does not. (Bfs is implemented by jacint@388: hand in both.) This test program runs Preflow and PreflowRes on the same jacint@388: graph, tests the result of these implementations and writes the running time jacint@388: of them. */ jacint@388: #include jacint@388: jacint@388: #include jacint@388: #include jacint@388: #include jacint@388: #include jacint@388: #include jacint@388: jacint@388: using namespace hugo; jacint@388: jacint@388: int main(int, char **) { jacint@388: jacint@388: typedef SmartGraph Graph; jacint@388: jacint@388: typedef Graph::Node Node; jacint@388: typedef Graph::EdgeIt EdgeIt; jacint@388: jacint@388: Graph G; jacint@388: Node s, t; jacint@388: Graph::EdgeMap cap(G); jacint@388: readDimacsMaxFlow(std::cin, G, s, t, cap); jacint@388: Timer ts; jacint@388: jacint@388: std::cout << jacint@388: "\n In which way are we faster: using ResGraphWrapper or not?" jacint@388: < flow(G,0); jacint@388: Preflow max_flow_test(G, s, t, cap, flow, 1); jacint@388: ts.reset(); jacint@388: max_flow_test.run(); jacint@388: std::cout << "Elapsed time NOT using the ResGraphWrapper: " << std::endl jacint@388: < mincut(G); jacint@388: max_flow_test.minMinCut(mincut); jacint@388: int min_min_cut_value=0; jacint@388: EdgeIt e; jacint@388: for(G.first(e); G.valid(e); G.next(e)) { jacint@388: if (mincut[G.tail(e)] && !mincut[G.head(e)]) min_min_cut_value+=cap[e]; jacint@388: } jacint@388: jacint@388: Graph::NodeMap cut(G); jacint@388: max_flow_test.minCut(cut); jacint@388: int min_cut_value=0; jacint@388: for(G.first(e); G.valid(e); G.next(e)) { jacint@388: if (cut[G.tail(e)] && !cut[G.head(e)]) jacint@388: min_cut_value+=cap[e]; jacint@388: } jacint@388: jacint@388: Graph::NodeMap maxcut(G); jacint@388: max_flow_test.maxMinCut(maxcut); jacint@388: int max_min_cut_value=0; jacint@388: for(G.first(e); G.valid(e); G.next(e)) { jacint@388: if (maxcut[G.tail(e)] && !maxcut[G.head(e)]) jacint@388: max_min_cut_value+=cap[e]; jacint@388: } jacint@388: jacint@388: std::cout << "\n Checking the result: " < flow2(G,0); jacint@388: PreflowRes max_flow_test2(G, s, t, cap, flow2, 1); jacint@388: ts.reset(); jacint@388: max_flow_test2.run(); jacint@388: std::cout << "Elapsed time using the ResGraphWrapper: " << std::endl jacint@388: << ts << std::endl; jacint@388: jacint@388: Graph::NodeMap mincut2(G); jacint@388: max_flow_test2.minMinCut(mincut2); jacint@388: int min_min_cut_value2=0; jacint@388: for(G.first(e); G.valid(e); G.next(e)) { jacint@388: if (mincut2[G.tail(e)] && !mincut2[G.head(e)]) min_min_cut_value2+=cap[e]; jacint@388: } jacint@388: jacint@388: Graph::NodeMap cut2(G); jacint@388: max_flow_test2.minCut(cut2); jacint@388: int min_cut_value2=0; jacint@388: for(G.first(e); G.valid(e); G.next(e)) { jacint@388: if (cut2[G.tail(e)] && !cut2[G.head(e)]) jacint@388: min_cut_value2+=cap[e]; jacint@388: } jacint@388: jacint@388: Graph::NodeMap maxcut2(G); jacint@388: max_flow_test2.maxMinCut(maxcut2); jacint@388: int max_min_cut_value2=0; jacint@388: for(G.first(e); G.valid(e); G.next(e)) { jacint@388: if (maxcut2[G.tail(e)] && !maxcut2[G.head(e)]) jacint@388: max_min_cut_value2+=cap[e]; jacint@388: } jacint@388: jacint@388: std::cout << "\n Checking the result: " <