4 #include <smart_graph.h>
5 #include <list_graph.h>
8 #include <time_measure.h>
12 // Use a DIMACS max flow file as stdin.
13 // read_dimacs_demo < dimacs_max_flow_file
14 int main(int, char **) {
15 typedef SmartGraph::Node Node;
16 typedef SmartGraph::EdgeIt EdgeIt;
20 SmartGraph::EdgeMap<int> cap(G);
21 readDimacsMaxFlow(std::cin, G, s, t, cap);
23 std::cout << "preflow demo ..." << std::endl;
25 double mintime=1000000;
27 for ( int i=1; i!=11; ++i ) {
28 SmartGraph::EdgeMap<int> flow(G);
29 double pre_time=currTime();
30 Preflow<SmartGraph, int> max_flow_test(G, s, t, cap, flow);
32 double post_time=currTime();
33 if ( mintime > post_time-pre_time ) mintime = post_time-pre_time;
36 SmartGraph::EdgeMap<int> flow(G);
37 Preflow<SmartGraph, int> max_flow_test(G, s, t, cap, flow);
40 SmartGraph::NodeMap<bool> cut(G);
41 max_flow_test.minCut(cut);
44 for(G.first(e); G.valid(e); G.next(e)) {
45 if (cut[G.tail(e)] && !cut[G.head(e)]) min_cut_value+=cap[e];
48 SmartGraph::NodeMap<bool> cut1(G);
49 max_flow_test.minMinCut(cut1);
50 int min_min_cut_value=0;
51 for(G.first(e); G.valid(e); G.next(e)) {
52 if (cut[G.tail(e)] && !cut[G.head(e)])
53 min_min_cut_value+=cap[e];
56 SmartGraph::NodeMap<bool> cut2(G);
57 max_flow_test.maxMinCut(cut2);
58 int max_min_cut_value=0;
59 for(G.first(e); G.valid(e); G.next(e)) {
60 if (cut2[G.tail(e)] && !cut2[G.head(e)])
61 max_min_cut_value+=cap[e];
64 std::cout << "min time of 10 runs: " << mintime << " sec"<< std::endl;
65 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
66 std::cout << "min cut value: "<< min_cut_value << std::endl;
67 std::cout << "min min cut value: "<< min_min_cut_value << std::endl;
68 std::cout << "max min cut value: "<< max_min_cut_value <<
69 std::endl<< std::endl;