4 #include <list_graph.hh>
6 #include <edmonds_karp.hh>
7 #include <time_measure.h>
8 #include <graph_wrapper.h>
12 // Use a DIMACS max flow file as stdin.
13 // read_dimacs_demo < dimacs_max_flow_file
31 int main(int, char **) {
32 typedef ListGraph::NodeIt NodeIt;
33 typedef ListGraph::EachEdgeIt EachEdgeIt;
41 std::cout << &zize << " " << sizeof(mize) << sizeof(Tize) << std::endl;
42 std::cout << sizeof(bize) << std::endl;
46 std::cout << sizeof(k) << std::endl;
54 std::cout << sizeof(Bumm) << std::endl;
59 ListGraph::EdgeMap<int> cap(G);
60 readDimacsMaxFlow(std::cin, G, s, t, cap);
62 typedef TrivGraphWrapper<ListGraph> TGW;
66 std::cout << "p1:" << gw.nodeNum() << std::endl;
68 std::cout << "p2:" << gw.nodeNum() << std::endl;
70 typedef const ListGraph cLG;
71 typedef TrivGraphWrapper<const cLG> CTGW;
75 std::cout << "p1:" << cgw.nodeNum() << std::endl;
77 std::cout << "p2:" << cgw.nodeNum() << std::endl;
81 std::cout << "edmonds karp demo (blocking flow augmentation)..." << std::endl;
82 ListGraph::EdgeMap<int> flow(G); //0 flow
86 //double pre_time=currTime();
87 MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
88 //max_flow_test.augmentWithBlockingFlow<ListGraph>();
90 while (max_flow_test.augmentOnBlockingFlow<ListGraph>()) {
91 // for(EachEdgeIt e=G.template first<EachEdgeIt>(); e.valid(); ++e) {
92 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
94 // std::cout<<std::endl;
97 //double post_time=currTime();
99 //std::cout << "maximum flow: "<< std::endl;
100 //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
101 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
103 //std::cout<<std::endl;
104 std::cout << "elapsed time: " << ts << std::endl;
105 std::cout << "number of augmentation phases: " << i << std::endl;
106 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
110 std::cout << "edmonds karp demo (blocking flow augmentation)..." << std::endl;
111 ListGraph::EdgeMap<int> flow(G); //0 flow
115 //double pre_time=currTime();
116 MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
117 //max_flow_test.augmentWithBlockingFlow<ListGraph>();
119 while (max_flow_test.augmentOnBlockingFlow2()) {
120 // for(EachEdgeIt e=G.template first<EachEdgeIt>(); e.valid(); ++e) {
121 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
123 // std::cout<<std::endl;
126 //double post_time=currTime();
128 //std::cout << "maximum flow: "<< std::endl;
129 //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
130 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
132 //std::cout<<std::endl;
133 std::cout << "elapsed time: " << ts << std::endl;
134 std::cout << "number of augmentation phases: " << i << std::endl;
135 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
139 std::cout << "edmonds karp demo (shortest path augmentation)..." << std::endl;
140 ListGraph::EdgeMap<int> flow(G); //0 flow
144 //double pre_time=currTime();
145 MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
146 //max_flow_test.augmentWithBlockingFlow<ListGraph>();
148 while (max_flow_test.augmentOnShortestPath()) {
149 // for(EachEdgeIt e=G.template first<EachEdgeIt>(); e.valid(); ++e) {
150 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
152 // std::cout<<std::endl;
155 //double post_time=currTime();
157 //std::cout << "maximum flow: "<< std::endl;
158 //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
159 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
161 //std::cout<<std::endl;
162 std::cout << "elapsed time: " << ts << std::endl;
163 std::cout << "number of augmentation phases: " << i << std::endl;
164 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;