Temporal change: public Edge constructor with given ID.
5 #include <sage_graph.h>
6 #include <hugo/smart_graph.h>
7 #include <hugo/dimacs.h>
8 #include <hugo/time_measure.h>
9 //#include <graph_wrapper.h>
11 //#include <preflow_res.h>
12 #include <hugo/for_each_macros.h>
13 #include <graph_concept.h>
17 // Use a DIMACS max flow file as stdin.
18 // read_dimacs_demo < dimacs_max_flow_file
28 // template <typename B>
36 int main(int, char **) {
38 typedef SageGraph MutableGraph;
40 //typedef FullFeatureGraphConcept Graph;
41 typedef SmartGraph Graph;
42 // typedef SageGraph Graph;
43 typedef Graph::Node Node;
44 typedef Graph::EdgeIt EdgeIt;
50 // typedef Mize Tize[0];
52 // std::cout << &zize << " " << sizeof(mize) << sizeof(Tize) << std::endl;
53 // std::cout << sizeof(bize) << std::endl;
57 // std::cout << sizeof(k) << std::endl;
65 // std::cout << sizeof(Bumm) << std::endl;
71 Graph::EdgeMap<int> cap(g);
72 //readDimacsMaxFlow(std::cin, g, s, t, cap);
73 readDimacs(std::cin, g, cap, s, t);
75 Graph::EdgeMap<int> flow(g); //0 flow
76 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
77 max_flow_test(g, s, t, cap, flow);
78 Graph::NodeMap<bool> cut(g);
81 std::cout << "preflow ..." << std::endl;
84 std::cout << "elapsed time: " << ts << std::endl;
85 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
86 max_flow_test.actMinCut(cut);
88 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
89 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
90 std::cout << "Slackness does not hold!" << std::endl;
91 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
92 std::cout << "Slackness does not hold!" << std::endl;
97 std::cout << "preflow ..." << std::endl;
98 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
100 max_flow_test.preflow(MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >::GEN_FLOW);
101 std::cout << "elapsed time: " << ts << std::endl;
102 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
104 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
105 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
106 std::cout << "Slackness does not hold!" << std::endl;
107 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
108 std::cout << "Slackness does not hold!" << std::endl;
113 // std::cout << "wrapped preflow ..." << std::endl;
114 // FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
116 // pre_flow_res.run();
117 // std::cout << "elapsed time: " << ts << std::endl;
118 // std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl;
122 std::cout << "physical blocking flow augmentation ..." << std::endl;
123 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
126 while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
127 std::cout << "elapsed time: " << ts << std::endl;
128 std::cout << "number of augmentation phases: " << i << std::endl;
129 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
131 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
132 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
133 std::cout << "Slackness does not hold!" << std::endl;
134 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
135 std::cout << "Slackness does not hold!" << std::endl;
140 // std::cout << "faster physical blocking flow augmentation ..." << std::endl;
141 // FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
144 // while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) { ++i; }
145 // std::cout << "elapsed time: " << ts << std::endl;
146 // std::cout << "number of augmentation phases: " << i << std::endl;
147 // std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
151 std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
152 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
155 while (max_flow_test.augmentOnBlockingFlow2()) { ++i; }
156 std::cout << "elapsed time: " << ts << std::endl;
157 std::cout << "number of augmentation phases: " << i << std::endl;
158 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
160 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
161 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
162 std::cout << "Slackness does not hold!" << std::endl;
163 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
164 std::cout << "Slackness does not hold!" << std::endl;
169 std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
170 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
173 while (max_flow_test.augmentOnShortestPath()) { ++i; }
174 std::cout << "elapsed time: " << ts << std::endl;
175 std::cout << "number of augmentation phases: " << i << std::endl;
176 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
178 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
179 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
180 std::cout << "Slackness does not hold!" << std::endl;
181 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
182 std::cout << "Slackness does not hold!" << std::endl;
187 std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
188 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
191 while (max_flow_test.augmentOnShortestPath2()) { ++i; }
192 std::cout << "elapsed time: " << ts << std::endl;
193 std::cout << "number of augmentation phases: " << i << std::endl;
194 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
196 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
197 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
198 std::cout << "Slackness does not hold!" << std::endl;
199 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
200 std::cout << "Slackness does not hold!" << std::endl;