5 #include <list_graph.hh>
7 #include <edmonds_karp.hh>
15 return double(tv.tv_sec)+double(tv.tv_usec)/1000000.0;
18 // Use a DIMACS max flow file as stdin.
19 // read_dimacs_demo < dimacs_flow_file
20 int main(int, char **) {
21 typedef ListGraph::NodeIt NodeIt;
22 typedef ListGraph::EachEdgeIt EachEdgeIt;
26 ListGraph::EdgeMap<int> cap(G);
27 readDimacsMaxFlow(std::cin, G, s, t, cap);
29 std::cout << "augmenting path flow algorithm demo..." << std::endl;
30 ListGraph::EdgeMap<int> flow(G); //0 flow
32 double preTime=currTime();
33 MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
35 double pushTime=currTime();
36 std::cout << "maximum flow: "<< std::endl;
37 for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
38 std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
41 std::cout << "elapsed time: " << pushTime-preTime << " sec"<< std::endl;
42 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;