5 #include <list_graph.h>
6 #include <smart_graph.h>
8 #include <time_measure.h>
9 //#include <graph_wrapper.h>
11 //#include <preflow_res.h>
12 #include <for_each_macros.h>
16 // Use a DIMACS max flow file as stdin.
17 // read_dimacs_demo < dimacs_max_flow_file
27 // template <typename B>
35 int main(int, char **) {
37 typedef ListGraph MutableGraph;
39 typedef SmartGraph Graph;
40 // typedef ListGraph Graph;
41 typedef Graph::Node Node;
42 typedef Graph::EdgeIt EdgeIt;
48 // typedef Mize Tize[0];
50 // std::cout << &zize << " " << sizeof(mize) << sizeof(Tize) << std::endl;
51 // std::cout << sizeof(bize) << std::endl;
55 // std::cout << sizeof(k) << std::endl;
63 // std::cout << sizeof(Bumm) << std::endl;
68 Graph::EdgeMap<int> cap(G);
69 readDimacsMaxFlow(std::cin, G, s, t, cap);
71 Graph::EdgeMap<int> flow(G); //0 flow
72 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
73 max_flow_test(G, s, t, cap, flow);
76 std::cout << "preflow ..." << std::endl;
79 std::cout << "elapsed time: " << ts << std::endl;
80 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
84 std::cout << "preflow ..." << std::endl;
85 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
87 max_flow_test.preflow(MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >::GEN_FLOW);
88 std::cout << "elapsed time: " << ts << std::endl;
89 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
93 // std::cout << "wrapped preflow ..." << std::endl;
94 // FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
96 // pre_flow_res.run();
97 // std::cout << "elapsed time: " << ts << std::endl;
98 // std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl;
102 std::cout << "physical blocking flow augmentation ..." << std::endl;
103 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
106 while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
107 std::cout << "elapsed time: " << ts << std::endl;
108 std::cout << "number of augmentation phases: " << i << std::endl;
109 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
113 // std::cout << "faster physical blocking flow augmentation ..." << std::endl;
114 // FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
117 // while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) { ++i; }
118 // std::cout << "elapsed time: " << ts << std::endl;
119 // std::cout << "number of augmentation phases: " << i << std::endl;
120 // std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
124 std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
125 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
128 while (max_flow_test.augmentOnBlockingFlow2()) { ++i; }
129 std::cout << "elapsed time: " << ts << std::endl;
130 std::cout << "number of augmentation phases: " << i << std::endl;
131 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
135 std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
136 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
139 while (max_flow_test.augmentOnShortestPath()) { ++i; }
140 std::cout << "elapsed time: " << ts << std::endl;
141 std::cout << "number of augmentation phases: " << i << std::endl;
142 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;