5 #include <list_graph.h>
6 #include <smart_graph.h>
8 #include <edmonds_karp.h>
9 #include <time_measure.h>
10 //#include <graph_wrapper.h>
14 template<typename T> int get(T) const {return 1;}
19 // Use a DIMACS max flow file as stdin.
20 // read_dimacs_demo < dimacs_max_flow_file
30 // template <typename B>
38 int main(int, char **) {
40 typedef ListGraph MutableGraph;
42 typedef SmartGraph Graph;
43 //typedef ListGraph Graph;
44 typedef Graph::Node Node;
45 typedef Graph::EdgeIt EdgeIt;
51 // typedef Mize Tize[0];
53 // std::cout << &zize << " " << sizeof(mize) << sizeof(Tize) << std::endl;
54 // std::cout << sizeof(bize) << std::endl;
58 // std::cout << sizeof(k) << std::endl;
66 // std::cout << sizeof(Bumm) << std::endl;
71 Graph::EdgeMap<int> cap(G);
72 readDimacsMaxFlow(std::cin, G, s, t, cap);
74 // typedef TrivGraphWrapper<Graph> TGW;
77 // gw./*getF*/first(sw);
78 // std::cout << "p1:" << gw.nodeNum() << std::endl;
80 // std::cout << "p2:" << gw.nodeNum() << std::endl;
82 // typedef const Graph cLG;
83 // typedef TrivGraphWrapper<const cLG> CTGW;
86 // cgw./*getF*/first(csw);
87 // std::cout << "p1:" << cgw.nodeNum() << std::endl;
89 // std::cout << "p2:" << cgw.nodeNum() << std::endl;
93 std::cout << "edmonds karp demo (physical blocking flow augmentation)..." << std::endl;
94 Graph::EdgeMap<int> flow(G); //0 flow
99 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
100 max_flow_test(G, s, t, flow, cap);
102 while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) {
103 // for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
104 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
106 // std::cout<<std::endl;
110 // std::cout << "maximum flow: "<< std::endl;
111 // for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
112 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
114 // std::cout<<std::endl;
115 std::cout << "elapsed time: " << ts << std::endl;
116 std::cout << "number of augmentation phases: " << i << std::endl;
117 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
121 std::cout << "edmonds karp demo (physical blocking flow 1 augmentation)..." << std::endl;
122 Graph::EdgeMap<int> flow(G); //0 flow
127 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
128 max_flow_test(G, s, t, flow, cap);
130 while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
131 // for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
132 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
134 // std::cout<<std::endl;
138 // std::cout << "maximum flow: "<< std::endl;
139 // for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
140 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
142 // std::cout<<std::endl;
143 std::cout << "elapsed time: " << ts << std::endl;
144 std::cout << "number of augmentation phases: " << i << std::endl;
145 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
149 std::cout << "edmonds karp demo (on-the-fly blocking flow augmentation)..." << std::endl;
150 Graph::EdgeMap<int> flow(G); //0 flow
155 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
156 max_flow_test(G, s, t, flow, cap);
158 while (max_flow_test.augmentOnBlockingFlow2()) {
159 // for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
160 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
162 // std::cout<<std::endl;
166 // std::cout << "maximum flow: "<< std::endl;
167 // for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
168 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
170 // std::cout<<std::endl;
171 std::cout << "elapsed time: " << ts << std::endl;
172 std::cout << "number of augmentation phases: " << i << std::endl;
173 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
177 std::cout << "edmonds karp demo (on-the-fly shortest path augmentation)..." << std::endl;
178 Graph::EdgeMap<int> flow(G); //0 flow
183 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
184 max_flow_test(G, s, t, flow, cap);
186 while (max_flow_test.augmentOnShortestPath()) {
187 // for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
188 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
190 // std::cout<<std::endl;
194 // std::cout << "maximum flow: "<< std::endl;
195 // for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
196 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
198 // std::cout<<std::endl;
199 std::cout << "elapsed time: " << ts << std::endl;
200 std::cout << "number of augmentation phases: " << i << std::endl;
201 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;