COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/marci/graph_wrapper_time.cc @ 777:a82713ed19f3

Last change on this file since 777:a82713ed19f3 was 777:a82713ed19f3, checked in by marci, 20 years ago

graph_wrapper.h is ready for hugo 0.2

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