jacint@109: #include jacint@109: jacint@220: #include jacint@211: #include jacint@211: #include jacint@372: #include jacint@109: #include jacint@109: jacint@109: using namespace hugo; jacint@109: jacint@109: int main(int, char **) { jacint@372: jacint@372: typedef SmartGraph Graph; jacint@372: jacint@372: typedef Graph::Node Node; jacint@372: typedef Graph::EdgeIt EdgeIt; jacint@109: jacint@372: Graph G; jacint@211: Node s, t; jacint@372: Graph::EdgeMap cap(G); jacint@109: readDimacsMaxFlow(std::cin, G, s, t, cap); jacint@372: Timer ts; jacint@372: jacint@109: std::cout << "preflow demo ..." << std::endl; jacint@109: jacint@372: Graph::EdgeMap flow(G); jacint@374: Preflow max_flow_test(G, s, t, cap, flow, 1,1); jacint@372: ts.reset(); jacint@211: max_flow_test.run(); jacint@374: std::cout << "elapsed time with res: " << ts << std::endl; jacint@374: jacint@374: std::cout << "preflow demo ..." << std::endl; jacint@374: jacint@374: Graph::EdgeMap flow2(G); jacint@375: Preflow max_flow_test2(G, s, t, cap, flow2, 1,0); jacint@374: ts.reset(); jacint@374: max_flow_test2.run(); jacint@375: std::cout << "elapsed time without res: " << ts << std::endl; jacint@211: jacint@372: Graph::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@220: if (cut[G.tail(e)] && !cut[G.head(e)]) min_cut_value+=cap[e]; jacint@109: } jacint@109: jacint@372: Graph::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@220: if (cut[G.tail(e)] && !cut[G.head(e)]) jacint@220: min_min_cut_value+=cap[e]; jacint@109: } jacint@109: jacint@372: Graph::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@220: if (cut2[G.tail(e)] && !cut2[G.head(e)]) jacint@220: max_min_cut_value+=cap[e]; jacint@109: } jacint@109: 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: }