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