[82] | 1 | #include <iostream> |
---|

| 2 | #include <fstream> |
---|

| 3 | |
---|

[522] | 4 | #include <list_graph.h> |
---|

| 5 | #include <dimacs.h> |
---|

[82] | 6 | #include <preflow_push.hh> |
---|

| 7 | #include <time_measure.h> |
---|

| 8 | |
---|

[921] | 9 | using namespace lemon; |
---|

[82] | 10 | |
---|

| 11 | // Use a DIMACS max flow file as stdin. |
---|

| 12 | // read_dimacs_demo < dimacs_max_flow_file |
---|

| 13 | int main(int, char **) { |
---|

[522] | 14 | typedef ListGraph::Node Node; |
---|

| 15 | //typedef ListGraph::EachEdgeIt EachEdgeIt; |
---|

[82] | 16 | |
---|

| 17 | ListGraph G; |
---|

[522] | 18 | Node s, t; |
---|

[82] | 19 | ListGraph::EdgeMap<int> cap(G); |
---|

| 20 | readDimacsMaxFlow(std::cin, G, s, t, cap); |
---|

| 21 | |
---|

| 22 | std::cout << "preflow demo (ATHOS)..." << std::endl; |
---|

| 23 | //ListGraph::EdgeMap<int> flow(G); //0 flow |
---|

| 24 | |
---|

| 25 | double pre_time=currTime(); |
---|

| 26 | preflow_push<ListGraph, int> max_flow_test(G, s, t, cap); |
---|

| 27 | int flow_value=max_flow_test.run(); |
---|

| 28 | //ListGraph::NodeMap<bool> cut=max_flow_test.mincut(); |
---|

| 29 | //int cut_value=0; |
---|

| 30 | //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { |
---|

[986] | 31 | // if (cut.get(G.source(e)) && !cut.get(G.target(e))) cut_value+=cap.get(e); |
---|

[82] | 32 | //} |
---|

| 33 | double post_time=currTime(); |
---|

| 34 | //std::cout << "maximum flow: "<< std::endl; |
---|

| 35 | //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { |
---|

[986] | 36 | // std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") "; |
---|

[82] | 37 | //} |
---|

| 38 | //std::cout<<std::endl; |
---|

| 39 | std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; |
---|

| 40 | std::cout << "flow value: "<< flow_value << std::endl; |
---|

| 41 | //std::cout << "cut value: "<< cut_value << std::endl; |
---|

| 42 | |
---|

| 43 | return 0; |
---|

| 44 | } |
---|