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