[74] | 1 | #include <iostream> |
---|
| 2 | #include <fstream> |
---|
| 3 | |
---|
[103] | 4 | #include "smart_graph.h" |
---|
| 5 | |
---|
[74] | 6 | #include "../list_graph.hh" |
---|
| 7 | #include "../marci/dimacs.hh" |
---|
| 8 | #include "f_ed_ka.h" |
---|
| 9 | #include "../marci/time_measure.h" |
---|
| 10 | |
---|
[108] | 11 | using namespace hugo; |
---|
[74] | 12 | |
---|
| 13 | // Use a DIMACS max flow file as stdin. |
---|
| 14 | // read_dimacs_demo < dimacs_max_flow_file |
---|
| 15 | |
---|
| 16 | int main(int, char **) { |
---|
[108] | 17 | typedef SmartGraph Graph; |
---|
| 18 | //typedef ListGraph Graph; |
---|
[74] | 19 | |
---|
[103] | 20 | typedef Graph::NodeIt NodeIt; |
---|
| 21 | typedef Graph::EachNodeIt EachNodeIt; |
---|
| 22 | typedef Graph::EachEdgeIt EachEdgeIt; |
---|
| 23 | |
---|
| 24 | Graph G; |
---|
[95] | 25 | NodeIt s, t; |
---|
[108] | 26 | Graph::DynEdgeMap<int> cap(G); |
---|
[74] | 27 | readDimacsMaxFlow(std::cin, G, s, t, cap); |
---|
| 28 | |
---|
| 29 | std::cout << "edmonds karp demo..." << std::endl; |
---|
[108] | 30 | Graph::DynEdgeMap<int> flow(G); //0 flow |
---|
[74] | 31 | |
---|
| 32 | int ret; |
---|
| 33 | double pre_time=currTime(); |
---|
[117] | 34 | Timer ts; |
---|
| 35 | |
---|
[74] | 36 | ret = maxFlow(G,flow,cap,s,t); |
---|
| 37 | double post_time=currTime(); |
---|
[117] | 38 | std::cout << "ellapsed time:" << ts << std::endl; |
---|
| 39 | |
---|
[74] | 40 | //std::cout << "maximum flow: "<< std::endl; |
---|
| 41 | //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { |
---|
| 42 | // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") "; |
---|
| 43 | //} |
---|
| 44 | //std::cout<<std::endl; |
---|
| 45 | std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; |
---|
| 46 | std::cout << "flow value: "<< ret << std::endl; |
---|
| 47 | |
---|
| 48 | return 0; |
---|
| 49 | } |
---|