.
4 #include <list_graph.h>
7 #include <time_measure.h>
11 // Use a DIMACS max flow file as stdin.
12 // read_dimacs_demo < dimacs_max_flow_file
13 int main(int, char **) {
14 typedef ListGraph::Node Node;
15 typedef ListGraph::EdgeIt EdgeIt;
19 ListGraph::EdgeMap<int> cap(G);
20 readDimacsMaxFlow(std::cin, G, s, t, cap);
22 std::cout << "preflow demo ..." << std::endl;
24 double mintime=1000000;
26 for ( int i=1; i!=11; ++i ) {
27 ListGraph::EdgeMap<int> flow(G);
28 double pre_time=currTime();
29 Preflow<ListGraph, int> max_flow_test(G, s, t, cap, flow);
31 double post_time=currTime();
32 if ( mintime > post_time-pre_time ) mintime = post_time-pre_time;
35 ListGraph::EdgeMap<int> flow(G);
36 Preflow<ListGraph, int> max_flow_test(G, s, t, cap, flow);
39 ListGraph::NodeMap<bool> cut(G);
40 max_flow_test.minCut(cut);
43 for(G.first(e); G.valid(e); G.next(e)) {
44 if (cut.get(G.tail(e)) && !cut.get(G.head(e))) min_cut_value+=cap.get(e);
47 ListGraph::NodeMap<bool> cut1(G);
48 max_flow_test.minMinCut(cut1);
49 int min_min_cut_value=0;
50 for(G.first(e); G.valid(e); G.next(e)) {
51 if (cut.get(G.tail(e)) && !cut.get(G.head(e)))
52 min_min_cut_value+=cap.get(e);
55 ListGraph::NodeMap<bool> cut2(G);
56 max_flow_test.maxMinCut(cut2);
57 int max_min_cut_value=0;
58 for(G.first(e); G.valid(e); G.next(e)) {
59 if (cut2.get(G.tail(e)) && !cut2.get(G.head(e)))
60 max_min_cut_value+=cap.get(e);
63 std::cout << "min time of 10 runs: " << mintime << " sec"<< std::endl;
64 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
65 std::cout << "min cut value: "<< min_cut_value << std::endl;
66 std::cout << "min min cut value: "<< min_min_cut_value << std::endl;
67 std::cout << "max min cut value: "<< max_min_cut_value <<
68 std::endl<< std::endl;