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