src/work/marci/edmonds_karp_demo.cc
author marci
Mon, 16 Feb 2004 18:15:31 +0000
changeset 82 4d6a48fc0a2d
child 100 f1de2ab64e1c
permissions -rw-r--r--
Can you test more preflow algs?
     1 #include <iostream>
     2 #include <fstream>
     3 
     4 #include <list_graph.hh>
     5 #include <dimacs.hh>
     6 #include <edmonds_karp.hh>
     7 #include <time_measure.h>
     8 
     9 using namespace marci;
    10 
    11 // Use a DIMACS max flow file as stdin.
    12 // read_dimacs_demo < dimacs_max_flow_file
    13 int main(int, char **) {
    14   typedef ListGraph::NodeIt NodeIt;
    15   typedef ListGraph::EachEdgeIt EachEdgeIt;
    16 
    17   ListGraph G;
    18   NodeIt s, t;
    19   ListGraph::EdgeMap<int> cap(G);
    20   readDimacsMaxFlow(std::cin, G, s, t, cap);
    21 
    22   std::cout << "edmonds karp demo..." << std::endl;
    23   ListGraph::EdgeMap<int> flow(G); //0 flow
    24 
    25   double pre_time=currTime();
    26   MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
    27   max_flow_test.run();
    28   double post_time=currTime();
    29   //std::cout << "maximum flow: "<< std::endl;
    30   //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
    31   //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    32   //}
    33   //std::cout<<std::endl;
    34   std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; 
    35   std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
    36 
    37   return 0;
    38 }