src/work/marci/const_map_time.cc
changeset 890 3a48bc350e0f
child 921 818510fa3d99
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/work/marci/const_map_time.cc	Mon Sep 20 17:53:33 2004 +0000
     1.3 @@ -0,0 +1,46 @@
     1.4 +// Use a DIMACS max flow file as stdin.
     1.5 +// const_map_time < dimacs_max_flow_file
     1.6 +
     1.7 +#include <iostream>
     1.8 +
     1.9 +#include <hugo/maps.h>
    1.10 +#include <hugo/smart_graph.h>
    1.11 +#include <hugo/time_measure.h>
    1.12 +#include <hugo/dimacs.h>
    1.13 +#include <hugo/graph_wrapper.h>
    1.14 +
    1.15 +using namespace hugo;
    1.16 +
    1.17 +int main() {
    1.18 +
    1.19 +  typedef SmartGraph Graph;
    1.20 +  typedef Graph::Node Node;
    1.21 +  typedef Graph::Edge Edge;
    1.22 +  typedef Graph::EdgeIt EdgeIt;
    1.23 +
    1.24 +  Graph g;
    1.25 +
    1.26 +  Node s, t;
    1.27 +  NullMap<Edge, int> cap;
    1.28 +  readDimacs(std::cin, g, cap, s, t);
    1.29 +  //typedef ConstMap<Node, Bool<true> > CN1; CN1 cn1;
    1.30 +  typedef ConstMap<Node, True> CN1; CN1 cn1;
    1.31 +  typedef ConstMap<Node, bool> CN2; CN2 cn2(true);
    1.32 +  // typedef ConstMap<Edge, Bool<true> > CE1; CE1 ce1;
    1.33 +  typedef ConstMap<Edge, True> CE1; CE1 ce1;
    1.34 +  typedef ConstMap<Edge, bool> CE2; CE2 ce2(true);
    1.35 +  typedef SubGraphWrapper<Graph, CN1, CE1> SB1; SB1 sb1(g, cn1, ce1);
    1.36 +  typedef SubGraphWrapper<Graph, CN2, CE2> SB2; SB2 sb2(g, cn2, ce2);
    1.37 +  Timer ts;
    1.38 +  cout << "specialized (compile-time) const map time:" << endl;
    1.39 +  ts.reset();
    1.40 +  for (SB1::NodeIt n(sb1); n!=INVALID; ++n)
    1.41 +    for (SB1::EdgeIt e(sb1); e!=INVALID; ++e) { }
    1.42 +  cout << ts << endl;
    1.43 +  ts.reset();
    1.44 +  cout << "generic const map time:" << endl;
    1.45 +  for (SB2::NodeIt n(sb2); n!=INVALID; ++n) 
    1.46 +    for (SB2::EdgeIt e(sb2); e!=INVALID; ++e) { }
    1.47 +  cout << ts << endl;
    1.48 +  return 0;
    1.49 +}