src/work/alpar/f_ed_ka_demo.cc
author alpar
Fri, 20 Feb 2004 21:45:07 +0000
changeset 105 a3c73e9b9b2e
parent 95 3322fbf254d2
child 108 0351b00fd283
permissions -rw-r--r--
marci -> hugo replacements
resize -> update replacements
     1 #include <iostream>
     2 #include <fstream>
     3 
     4 #include "smart_graph.h"
     5 
     6 #include "../list_graph.hh"
     7 #include "../marci/dimacs.hh"
     8 #include "f_ed_ka.h"
     9 #include "../marci/time_measure.h"
    10 
    11 using namespace marci;
    12 
    13 // Use a DIMACS max flow file as stdin.
    14 // read_dimacs_demo < dimacs_max_flow_file
    15 
    16 int main(int, char **) {
    17   //  typedef SmartGraph Graph;
    18   typedef ListGraph Graph;
    19 
    20   typedef Graph::NodeIt NodeIt;
    21   typedef Graph::EachNodeIt EachNodeIt;
    22   typedef Graph::EachEdgeIt EachEdgeIt;
    23 
    24   Graph G;
    25   NodeIt s, t;
    26   Graph::EdgeMap<int> cap(G);
    27   readDimacsMaxFlow(std::cin, G, s, t, cap);
    28 
    29   std::cout << "edmonds karp demo..." << std::endl;
    30   Graph::EdgeMap<int> flow(G); //0 flow
    31   
    32   int ret;
    33   double pre_time=currTime();
    34   ret = maxFlow(G,flow,cap,s,t);
    35   double post_time=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)<<") ";
    39   //}
    40   //std::cout<<std::endl;
    41   std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; 
    42   std::cout << "flow value: "<< ret << std::endl;
    43 
    44   return 0;
    45 }