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@773
|
38 |
cout << ts << endl;
|
marci@773
|
39 |
}
|
marci@773
|
40 |
|
marci@773
|
41 |
int main(int, char** argv) {
|
marci@773
|
42 |
std::string in=argv[1];
|
marci@773
|
43 |
|
marci@773
|
44 |
typedef ListGraph Graph;
|
marci@773
|
45 |
Graph g;
|
marci@773
|
46 |
timeTest<Graph>(in, g);
|
marci@773
|
47 |
typedef GraphWrapper<Graph> Graph1;
|
marci@773
|
48 |
Graph1 g1(g);
|
marci@773
|
49 |
timeTest<Graph1>(in, g1);
|
marci@773
|
50 |
typedef GraphWrapper<Graph1> Graph2;
|
marci@773
|
51 |
Graph2 g2(g1);
|
marci@773
|
52 |
timeTest<Graph2>(in, g2);
|
marci@773
|
53 |
typedef GraphWrapper<Graph2> Graph3;
|
marci@773
|
54 |
Graph3 g3(g2);
|
marci@773
|
55 |
timeTest<Graph3>(in, g3);
|
marci@777
|
56 |
typedef GraphWrapper<Graph3> Graph4;
|
marci@777
|
57 |
Graph4 g4(g3);
|
marci@777
|
58 |
timeTest<Graph4>(in, g4);
|
marci@777
|
59 |
typedef GraphWrapper<Graph4> Graph5;
|
marci@777
|
60 |
Graph5 g5(g4);
|
marci@777
|
61 |
timeTest<Graph5>(in, g5);
|
marci@777
|
62 |
typedef GraphWrapper<Graph5> Graph6;
|
marci@777
|
63 |
Graph6 g6(g5);
|
marci@777
|
64 |
timeTest<Graph6>(in, g6);
|
marci@777
|
65 |
typedef GraphWrapper<Graph6> Graph7;
|
marci@777
|
66 |
Graph7 g7(g6);
|
marci@777
|
67 |
timeTest<Graph7>(in, g7);
|
marci@773
|
68 |
|
marci@773
|
69 |
return 0;
|
marci@773
|
70 |
}
|