src/work/marci/const_map_time.cc
author alpar
Wed, 29 Sep 2004 15:30:04 +0000
changeset 921 818510fa3d99
parent 890 3a48bc350e0f
permissions -rw-r--r--
hugo -> lemon
marci@890
     1
// Use a DIMACS max flow file as stdin.
marci@890
     2
// const_map_time < dimacs_max_flow_file
marci@890
     3
marci@890
     4
#include <iostream>
marci@890
     5
alpar@921
     6
#include <lemon/maps.h>
alpar@921
     7
#include <lemon/smart_graph.h>
alpar@921
     8
#include <lemon/time_measure.h>
alpar@921
     9
#include <lemon/dimacs.h>
alpar@921
    10
#include <lemon/graph_wrapper.h>
marci@890
    11
alpar@921
    12
using namespace lemon;
marci@890
    13
marci@890
    14
int main() {
marci@890
    15
marci@890
    16
  typedef SmartGraph Graph;
marci@890
    17
  typedef Graph::Node Node;
marci@890
    18
  typedef Graph::Edge Edge;
marci@890
    19
  typedef Graph::EdgeIt EdgeIt;
marci@890
    20
marci@890
    21
  Graph g;
marci@890
    22
marci@890
    23
  Node s, t;
marci@890
    24
  NullMap<Edge, int> cap;
marci@890
    25
  readDimacs(std::cin, g, cap, s, t);
marci@890
    26
  //typedef ConstMap<Node, Bool<true> > CN1; CN1 cn1;
marci@890
    27
  typedef ConstMap<Node, True> CN1; CN1 cn1;
marci@890
    28
  typedef ConstMap<Node, bool> CN2; CN2 cn2(true);
marci@890
    29
  // typedef ConstMap<Edge, Bool<true> > CE1; CE1 ce1;
marci@890
    30
  typedef ConstMap<Edge, True> CE1; CE1 ce1;
marci@890
    31
  typedef ConstMap<Edge, bool> CE2; CE2 ce2(true);
marci@890
    32
  typedef SubGraphWrapper<Graph, CN1, CE1> SB1; SB1 sb1(g, cn1, ce1);
marci@890
    33
  typedef SubGraphWrapper<Graph, CN2, CE2> SB2; SB2 sb2(g, cn2, ce2);
marci@890
    34
  Timer ts;
marci@890
    35
  cout << "specialized (compile-time) const map time:" << endl;
marci@890
    36
  ts.reset();
marci@890
    37
  for (SB1::NodeIt n(sb1); n!=INVALID; ++n)
marci@890
    38
    for (SB1::EdgeIt e(sb1); e!=INVALID; ++e) { }
marci@890
    39
  cout << ts << endl;
marci@890
    40
  ts.reset();
marci@890
    41
  cout << "generic const map time:" << endl;
marci@890
    42
  for (SB2::NodeIt n(sb2); n!=INVALID; ++n) 
marci@890
    43
    for (SB2::EdgeIt e(sb2); e!=INVALID; ++e) { }
marci@890
    44
  cout << ts << endl;
marci@890
    45
  return 0;
marci@890
    46
}