src/work/marci/graph_wrapper_time.cc
author deba
Wed, 08 Sep 2004 12:06:45 +0000 (2004-09-08)
changeset 822 88226d9fe821
parent 777 a82713ed19f3
child 849 cc3867a7d380
permissions -rw-r--r--
The MapFactories have been removed from the code because
if we use macros then they increases only the complexity.

The pair iterators of the maps are separeted from the maps.

Some macros and comments has been changed.
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>
marci@773
    10
#include <hugo/invalid.h>
marci@773
    11
#include <hugo/time_measure.h>
marci@773
    12
#include <hugo/graph_wrapper.h>
marci@773
    13
#include <hugo/max_flow.h>
marci@773
    14
#include <hugo/dimacs.h>
marci@773
    15
#include <hugo/list_graph.h>
marci@773
    16
marci@773
    17
using namespace hugo;
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@773
    35
  typedef MaxFlow<Graph, int, FlowMap, FlowMap> MyMaxFlow;
marci@773
    36
  MyMaxFlow max_flow(g, s, t, cap, flow);
marci@773
    37
  max_flow.run(MyMaxFlow::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
}