24 ListGraph::EdgeMap<int> flow(G); //0 flow |
24 ListGraph::EdgeMap<int> flow(G); //0 flow |
25 |
25 |
26 double pre_time=currTime(); |
26 double pre_time=currTime(); |
27 MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap); |
27 MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap); |
28 //max_flow_test.augmentWithBlockingFlow<ListGraph>(); |
28 //max_flow_test.augmentWithBlockingFlow<ListGraph>(); |
29 max_flow_test.run<ListGraph>(); |
29 int i=0; |
|
30 while (max_flow_test.augmentOnBlockingFlow<ListGraph>()) { ++i; } |
30 double post_time=currTime(); |
31 double post_time=currTime(); |
31 |
32 |
32 //std::cout << "maximum flow: "<< std::endl; |
33 //std::cout << "maximum flow: "<< std::endl; |
33 //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { |
34 //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { |
34 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") "; |
35 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") "; |
35 //} |
36 //} |
36 //std::cout<<std::endl; |
37 //std::cout<<std::endl; |
37 std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; |
38 std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; |
|
39 std::cout << "number of augmentation phases: " << i << std::endl; |
38 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl; |
40 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl; |
39 } |
41 } |
40 |
42 |
41 { |
43 { |
42 std::cout << "edmonds karp demo (shortest path augmentation)..." << std::endl; |
44 std::cout << "edmonds karp demo (shortest path augmentation)..." << std::endl; |
43 ListGraph::EdgeMap<int> flow(G); //0 flow |
45 ListGraph::EdgeMap<int> flow(G); //0 flow |
44 |
46 |
45 double pre_time=currTime(); |
47 double pre_time=currTime(); |
46 MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap); |
48 MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap); |
47 //max_flow_test.augmentWithBlockingFlow<ListGraph>(); |
49 //max_flow_test.augmentWithBlockingFlow<ListGraph>(); |
48 max_flow_test.run(); |
50 int i=0; |
|
51 while (max_flow_test.augmentOnShortestPath()) { ++i; } |
49 double post_time=currTime(); |
52 double post_time=currTime(); |
50 |
53 |
51 //std::cout << "maximum flow: "<< std::endl; |
54 //std::cout << "maximum flow: "<< std::endl; |
52 //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { |
55 //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { |
53 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") "; |
56 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") "; |
54 //} |
57 //} |
55 //std::cout<<std::endl; |
58 //std::cout<<std::endl; |
56 std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; |
59 std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; |
|
60 std::cout << "number of augmentation phases: " << i << std::endl; |
57 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl; |
61 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl; |
58 } |
62 } |
59 |
63 |
60 return 0; |
64 return 0; |
61 } |
65 } |