src/work/marci/graph_wrapper_time.cc
author marci
Tue, 31 Aug 2004 11:26:59 +0000
changeset 775 e46a1f0623a0
child 777 a82713ed19f3
permissions -rw-r--r--
ResGraphWrapper<Graph> is done, so does dimacs.h.
marci@773
     1
// -*- c++ -*-
marci@773
     2
marci@773
     3
#include <iostream>
marci@773
     4
#include <fstream>
marci@773
     5
#include <string>
marci@773
     6
#include <vector>
marci@773
     7
#include <hugo/invalid.h>
marci@773
     8
#include <hugo/time_measure.h>
marci@773
     9
#include <hugo/graph_wrapper.h>
marci@773
    10
#include <hugo/max_flow.h>
marci@773
    11
#include <hugo/dimacs.h>
marci@773
    12
#include <hugo/list_graph.h>
marci@773
    13
marci@773
    14
using namespace hugo;
marci@773
    15
marci@773
    16
using std::cout;
marci@773
    17
using std::endl;
marci@773
    18
marci@773
    19
template<typename Graph>
marci@773
    20
void timeTest(std::string str, Graph& g) {
marci@773
    21
  g.clear();
marci@773
    22
  typename Graph::Node s;
marci@773
    23
  typename Graph::Node t;
marci@773
    24
  typedef typename Graph::template EdgeMap<int> FlowMap;
marci@773
    25
  FlowMap cap(g);
marci@773
    26
  FlowMap flow(g);
marci@773
    27
  std::ifstream is(str.c_str());
marci@773
    28
  readDimacs(is, g, cap, s, t);
marci@773
    29
  Timer ts;
marci@773
    30
  ts.reset();
marci@773
    31
  cout << g.nodeNum() << endl;
marci@773
    32
  cout << g.edgeNum() << endl;
marci@773
    33
  typedef MaxFlow<Graph, int, FlowMap, FlowMap> MyMaxFlow;
marci@773
    34
  MyMaxFlow max_flow(g, s, t, cap, flow);
marci@773
    35
  max_flow.run(MyMaxFlow::NO_FLOW);
marci@773
    36
  cout << ts << endl;
marci@773
    37
}
marci@773
    38
marci@773
    39
int main(int, char** argv) {
marci@773
    40
   std::string in=argv[1];
marci@773
    41
marci@773
    42
  typedef ListGraph Graph; 
marci@773
    43
  Graph g;
marci@773
    44
//   cout << g.id(g.addNode()) << endl;
marci@773
    45
//   cout << g.id(g.addNode()) << endl;
marci@773
    46
//   cout << g.nodeNum() << endl;
marci@773
    47
  timeTest<Graph>(in, g);
marci@773
    48
  typedef GraphWrapper<Graph> Graph1;
marci@773
    49
  Graph1 g1(g);
marci@773
    50
//   g1.clear();
marci@773
    51
//   cout << g.id(g1.addNode()) << endl;
marci@773
    52
//   cout << g.id(g1.addNode()) << endl;
marci@773
    53
//   cout << g1.nodeNum() << endl;
marci@773
    54
//   g1.clear();
marci@773
    55
  timeTest<Graph1>(in, g1);
marci@773
    56
  typedef GraphWrapper<Graph1> Graph2;
marci@773
    57
  Graph2 g2(g1);
marci@773
    58
  timeTest<Graph2>(in, g2);
marci@773
    59
  typedef GraphWrapper<Graph2> Graph3;
marci@773
    60
  Graph3 g3(g2);
marci@773
    61
  timeTest<Graph3>(in, g3);
marci@773
    62
//   typedef GraphWrapper<Graph3> Graph4;
marci@773
    63
//   Graph4 g4(g3);
marci@773
    64
//   timeTest<Graph4>(in, g4);
marci@773
    65
//   typedef GraphWrapper<Graph4> Graph5;
marci@773
    66
//   Graph5 g5(g4);
marci@773
    67
//   timeTest<Graph5>(in, g5);
marci@773
    68
//   typedef GraphWrapper<Graph5> Graph6;
marci@773
    69
//   Graph6 g6(g5);
marci@773
    70
//   timeTest<Graph6>(in, g6);  
marci@773
    71
//   typedef GraphWrapper<Graph6> Graph7;
marci@773
    72
//   Graph7 g7(g6);
marci@773
    73
//   timeTest<Graph7>(in, g7);
marci@773
    74
marci@773
    75
  return 0;
marci@773
    76
}