src/work/marci/graph_wrapper_time.cc
author alpar
Mon, 03 Jan 2005 16:23:47 +0000
changeset 1043 52a2201a88e9
parent 849 cc3867a7d380
permissions -rw-r--r--
Several changes in doc
marci@773
     1
// -*- c++ -*-
marci@773
     2
marci@777
     3
// Use a DIMACS max flow file as follows:
marci@777
     4
// graph_wrapper_time dimacs_max_flow_file
marci@777
     5
marci@773
     6
#include <iostream>
marci@773
     7
#include <fstream>
marci@773
     8
#include <string>
marci@773
     9
#include <vector>
alpar@921
    10
#include <lemon/invalid.h>
alpar@921
    11
#include <lemon/time_measure.h>
alpar@921
    12
#include <lemon/graph_wrapper.h>
alpar@921
    13
#include <lemon/preflow.h>
alpar@921
    14
#include <lemon/dimacs.h>
alpar@921
    15
#include <lemon/list_graph.h>
marci@773
    16
alpar@921
    17
using namespace lemon;
marci@773
    18
marci@773
    19
using std::cout;
marci@773
    20
using std::endl;
marci@773
    21
marci@773
    22
template<typename Graph>
marci@773
    23
void timeTest(std::string str, Graph& g) {
marci@773
    24
  g.clear();
marci@773
    25
  typename Graph::Node s;
marci@773
    26
  typename Graph::Node t;
marci@773
    27
  typedef typename Graph::template EdgeMap<int> FlowMap;
marci@773
    28
  FlowMap cap(g);
marci@773
    29
  FlowMap flow(g);
marci@773
    30
  std::ifstream is(str.c_str());
marci@773
    31
  readDimacs(is, g, cap, s, t);
marci@773
    32
  Timer ts;
marci@773
    33
  ts.reset();
marci@777
    34
marci@849
    35
  typedef Preflow<Graph, int, FlowMap, FlowMap> MyPreflow;
marci@849
    36
  MyPreflow max_flow(g, s, t, cap, flow);
marci@849
    37
  max_flow.run(MyPreflow::NO_FLOW);
marci@784
    38
  cout << "flow value: " << max_flow.flowValue() << endl;
marci@773
    39
  cout << ts << endl;
marci@773
    40
}
marci@773
    41
marci@773
    42
int main(int, char** argv) {
marci@773
    43
   std::string in=argv[1];
marci@773
    44
marci@773
    45
  typedef ListGraph Graph; 
marci@773
    46
  Graph g;
marci@773
    47
  timeTest<Graph>(in, g);
marci@773
    48
  typedef GraphWrapper<Graph> Graph1;
marci@773
    49
  Graph1 g1(g);
marci@773
    50
  timeTest<Graph1>(in, g1);
marci@773
    51
  typedef GraphWrapper<Graph1> Graph2;
marci@773
    52
  Graph2 g2(g1);
marci@773
    53
  timeTest<Graph2>(in, g2);
marci@773
    54
  typedef GraphWrapper<Graph2> Graph3;
marci@773
    55
  Graph3 g3(g2);
marci@773
    56
  timeTest<Graph3>(in, g3);
marci@777
    57
  typedef GraphWrapper<Graph3> Graph4;
marci@777
    58
  Graph4 g4(g3);
marci@777
    59
  timeTest<Graph4>(in, g4);
marci@777
    60
  typedef GraphWrapper<Graph4> Graph5;
marci@777
    61
  Graph5 g5(g4);
marci@777
    62
  timeTest<Graph5>(in, g5);
marci@777
    63
  typedef GraphWrapper<Graph5> Graph6;
marci@777
    64
  Graph6 g6(g5);
marci@777
    65
  timeTest<Graph6>(in, g6);  
marci@777
    66
  typedef GraphWrapper<Graph6> Graph7;
marci@777
    67
  Graph7 g7(g6);
marci@777
    68
  timeTest<Graph7>(in, g7);
marci@773
    69
marci@773
    70
  return 0;
marci@773
    71
}