src/work/marci/read_dimacs_demo.cc
changeset 71 1d8d806ac8e0
parent 69 24c2c2989e0f
     1.1 --- a/src/work/marci/read_dimacs_demo.cc	Tue Feb 10 13:29:15 2004 +0000
     1.2 +++ b/src/work/marci/read_dimacs_demo.cc	Thu Feb 12 18:11:08 2004 +0000
     1.3 @@ -1,11 +1,20 @@
     1.4 +#include <sys/time.h>
     1.5  #include <iostream>
     1.6  #include <fstream>
     1.7 +
     1.8  #include <list_graph.hh>
     1.9  #include <dimacs.hh>
    1.10  #include <edmonds_karp.hh>
    1.11  
    1.12  using namespace marci;
    1.13  
    1.14 +double currTime() {
    1.15 +  timeval tv;
    1.16 +  //timezone tz;
    1.17 +  gettimeofday(&tv, 0);
    1.18 +  return double(tv.tv_sec)+double(tv.tv_usec)/1000000.0;
    1.19 +}
    1.20 +
    1.21  // Use a DIMACS max flow file as stdin.
    1.22  // read_dimacs_demo < dimacs_flow_file
    1.23  int main(int, char **) {
    1.24 @@ -19,14 +28,17 @@
    1.25  
    1.26    std::cout << "augmenting path flow algorithm demo..." << std::endl;
    1.27    ListGraph::EdgeMap<int> flow(G); //0 flow
    1.28 +
    1.29 +  double preTime=currTime();
    1.30    MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
    1.31    max_flow_test.run();
    1.32 -
    1.33 +  double pushTime=currTime();
    1.34    std::cout << "maximum flow: "<< std::endl;
    1.35    for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
    1.36      std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    1.37    }
    1.38    std::cout<<std::endl;
    1.39 +  std::cout << "elapsed time: " << pushTime-preTime << " sec"<< std::endl; 
    1.40    std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
    1.41  
    1.42    return 0;