6 #include <list_graph.h>
7 #include <smart_graph.h>
10 #include <time_measure.h>
11 #include <for_each_macros.h>
15 // Use a DIMACS max flow file as stdin.
16 // read_dimacs_demo dimacs_max_flow_file
18 int main(int, char** argv) {
20 std::string in=argv[1];
21 typedef ListGraph MutableGraph;
24 typedef ListGraph Graph;
25 typedef Graph::Node Node;
26 typedef Graph::EdgeIt EdgeIt;
30 Graph::EdgeMap<int> cap(G);
31 std::ifstream ins(in.c_str());
32 readDimacsMaxFlow(ins, G, s, t, cap);
35 Graph::EdgeMap<int> flow(G); //0 flow
36 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
37 max_flow_test(G, s, t, cap, flow/*, true*/);
39 std::cout << "ListGraph ..." << std::endl;
42 std::cout << "preflow ..." << std::endl;
45 std::cout << "elapsed time: " << ts << std::endl;
46 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
50 std::cout << "physical blocking flow augmentation ..." << std::endl;
51 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
54 while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
55 std::cout << "elapsed time: " << ts << std::endl;
56 std::cout << "number of augmentation phases: " << i << std::endl;
57 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
61 // std::cout << "faster physical blocking flow augmentation ..." << std::endl;
62 // FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
65 // while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) { ++i; }
66 // std::cout << "elapsed time: " << ts << std::endl;
67 // std::cout << "number of augmentation phases: " << i << std::endl;
68 // std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
72 std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
73 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
76 while (max_flow_test.augmentOnBlockingFlow2()) { ++i; }
77 std::cout << "elapsed time: " << ts << std::endl;
78 std::cout << "number of augmentation phases: " << i << std::endl;
79 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
83 std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
84 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
87 while (max_flow_test.augmentOnShortestPath()) { ++i; }
88 std::cout << "elapsed time: " << ts << std::endl;
89 std::cout << "number of augmentation phases: " << i << std::endl;
90 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
96 typedef SmartGraph Graph;
97 typedef Graph::Node Node;
98 typedef Graph::EdgeIt EdgeIt;
102 Graph::EdgeMap<int> cap(G);
103 std::ifstream ins(in.c_str());
104 readDimacsMaxFlow(ins, G, s, t, cap);
107 Graph::EdgeMap<int> flow(G); //0 flow
108 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
109 max_flow_test(G, s, t, cap, flow/*, true*/);
110 // MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
111 // max_flow_test(G, s, t, cap, flow);
113 std::cout << "SmatrGraph ..." << std::endl;
116 std::cout << "preflow ..." << std::endl;
117 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
120 std::cout << "elapsed time: " << ts << std::endl;
121 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
125 std::cout << "physical blocking flow augmentation ..." << std::endl;
126 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
129 while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
130 std::cout << "elapsed time: " << ts << std::endl;
131 std::cout << "number of augmentation phases: " << i << std::endl;
132 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
136 // std::cout << "faster physical blocking flow augmentation ..." << std::endl;
137 // FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
140 // while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) { ++i; }
141 // std::cout << "elapsed time: " << ts << std::endl;
142 // std::cout << "number of augmentation phases: " << i << std::endl;
143 // std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
147 std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
148 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
151 while (max_flow_test.augmentOnBlockingFlow2()) { ++i; }
152 std::cout << "elapsed time: " << ts << std::endl;
153 std::cout << "number of augmentation phases: " << i << std::endl;
154 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
158 std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
159 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
162 while (max_flow_test.augmentOnShortestPath()) { ++i; }
163 std::cout << "elapsed time: " << ts << std::endl;
164 std::cout << "number of augmentation phases: " << i << std::endl;
165 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;