Remove unnecessary include headers.
3 // Use a DIMACS max flow file as stdin.
4 // max_flow_demo < dimacs_max_flow_file
10 #include <sage_graph.h>
11 #include <hugo/smart_graph.h>
12 #include <hugo/dimacs.h>
13 #include <hugo/time_measure.h>
14 //#include <graph_wrapper.h>
15 #include <hugo/max_flow.h>
16 #include <augmenting_flow.h>
17 //#include <preflow_res.h>
18 #include <for_each_macros.h>
19 #include <graph_concept.h>
23 int main(int, char **) {
25 typedef SageGraph MutableGraph;
27 //typedef FullFeatureGraphConcept Graph;
28 //typedef SmartGraph Graph;
29 typedef SageGraph Graph;
30 typedef Graph::Node Node;
31 typedef Graph::EdgeIt EdgeIt;
36 Graph::EdgeMap<int> cap(g);
37 //readDimacsMaxFlow(std::cin, g, s, t, cap);
38 readDimacs(std::cin, g, cap, s, t);
40 Graph::EdgeMap<int> flow(g); //0 flow
41 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
42 max_flow_test(g, s, t, cap, flow);
43 AugmentingFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
44 augmenting_flow_test(g, s, t, cap, flow);
46 Graph::NodeMap<bool> cut(g);
49 std::cout << "preflow ..." << std::endl;
52 std::cout << "elapsed time: " << ts << std::endl;
53 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
54 max_flow_test.actMinCut(cut);
56 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
57 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
58 std::cout << "Slackness does not hold!" << std::endl;
59 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
60 std::cout << "Slackness does not hold!" << std::endl;
65 std::cout << "preflow ..." << std::endl;
66 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
68 max_flow_test.preflow(MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >::GEN_FLOW);
69 std::cout << "elapsed time: " << ts << std::endl;
70 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
72 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
73 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
74 std::cout << "Slackness does not hold!" << std::endl;
75 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
76 std::cout << "Slackness does not hold!" << std::endl;
81 // std::cout << "wrapped preflow ..." << std::endl;
82 // FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
84 // pre_flow_res.run();
85 // std::cout << "elapsed time: " << ts << std::endl;
86 // std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl;
90 std::cout << "physical blocking flow augmentation ..." << std::endl;
91 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
94 while (augmenting_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
95 std::cout << "elapsed time: " << ts << std::endl;
96 std::cout << "number of augmentation phases: " << i << std::endl;
97 std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
99 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
100 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
101 std::cout << "Slackness does not hold!" << std::endl;
102 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
103 std::cout << "Slackness does not hold!" << std::endl;
108 std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
109 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
112 while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; }
113 std::cout << "elapsed time: " << ts << std::endl;
114 std::cout << "number of augmentation phases: " << i << std::endl;
115 std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
117 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
118 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
119 std::cout << "Slackness does not hold!" << std::endl;
120 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
121 std::cout << "Slackness does not hold!" << std::endl;
126 std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
127 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
130 while (augmenting_flow_test.augmentOnShortestPath()) { ++i; }
131 std::cout << "elapsed time: " << ts << std::endl;
132 std::cout << "number of augmentation phases: " << i << std::endl;
133 std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
135 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
136 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
137 std::cout << "Slackness does not hold!" << std::endl;
138 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
139 std::cout << "Slackness does not hold!" << std::endl;
144 std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
145 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
148 while (augmenting_flow_test.augmentOnShortestPath2()) { ++i; }
149 std::cout << "elapsed time: " << ts << std::endl;
150 std::cout << "number of augmentation phases: " << i << std::endl;
151 std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
153 FOR_EACH_LOC(Graph::EdgeIt, e, g) {
154 if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
155 std::cout << "Slackness does not hold!" << std::endl;
156 if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
157 std::cout << "Slackness does not hold!" << std::endl;