jacint@109: #include jacint@109: #include jacint@109: jacint@211: #include jacint@211: #include jacint@109: #include jacint@109: #include jacint@109: jacint@109: using namespace hugo; jacint@109: jacint@109: // Use a DIMACS max flow file as stdin. jacint@109: // read_dimacs_demo < dimacs_max_flow_file jacint@109: int main(int, char **) { jacint@211: typedef ListGraph::Node Node; jacint@211: typedef ListGraph::EdgeIt EdgeIt; jacint@109: jacint@109: ListGraph G; jacint@211: Node s, t; jacint@109: ListGraph::EdgeMap cap(G); jacint@109: readDimacsMaxFlow(std::cin, G, s, t, cap); jacint@109: jacint@109: std::cout << "preflow demo ..." << std::endl; jacint@109: jacint@109: double mintime=1000000; jacint@109: jacint@109: for ( int i=1; i!=11; ++i ) { jacint@211: ListGraph::EdgeMap flow(G); jacint@109: double pre_time=currTime(); jacint@211: Preflow max_flow_test(G, s, t, cap, flow); jacint@211: max_flow_test.run(); jacint@109: double post_time=currTime(); jacint@109: if ( mintime > post_time-pre_time ) mintime = post_time-pre_time; jacint@109: } jacint@109: jacint@211: ListGraph::EdgeMap flow(G); jacint@211: Preflow max_flow_test(G, s, t, cap, flow); jacint@211: max_flow_test.run(); jacint@211: jacint@109: ListGraph::NodeMap cut(G); jacint@109: max_flow_test.minCut(cut); jacint@109: int min_cut_value=0; jacint@211: EdgeIt e; jacint@211: for(G.first(e); G.valid(e); G.next(e)) { jacint@109: if (cut.get(G.tail(e)) && !cut.get(G.head(e))) min_cut_value+=cap.get(e); jacint@109: } jacint@109: jacint@109: ListGraph::NodeMap cut1(G); jacint@109: max_flow_test.minMinCut(cut1); jacint@109: int min_min_cut_value=0; jacint@211: for(G.first(e); G.valid(e); G.next(e)) { jacint@109: if (cut.get(G.tail(e)) && !cut.get(G.head(e))) jacint@109: min_min_cut_value+=cap.get(e); jacint@109: } jacint@109: jacint@109: ListGraph::NodeMap cut2(G); jacint@109: max_flow_test.maxMinCut(cut2); jacint@109: int max_min_cut_value=0; jacint@211: for(G.first(e); G.valid(e); G.next(e)) { jacint@109: if (cut2.get(G.tail(e)) && !cut2.get(G.head(e))) jacint@109: max_min_cut_value+=cap.get(e); jacint@109: } jacint@109: jacint@109: std::cout << "min time of 10 runs: " << mintime << " sec"<< std::endl; jacint@211: std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl; jacint@109: std::cout << "min cut value: "<< min_cut_value << std::endl; jacint@109: std::cout << "min min cut value: "<< min_min_cut_value << std::endl; jacint@109: std::cout << "max min cut value: "<< max_min_cut_value << jacint@109: std::endl<< std::endl; jacint@109: jacint@109: return 0; jacint@109: }