4 #include<hugo/list_graph.h> |
4 #include<hugo/list_graph.h> |
5 #include<hugo/smart_graph.h> |
5 #include<hugo/smart_graph.h> |
6 #include<hugo/dijkstra.h> |
6 #include<hugo/dijkstra.h> |
7 #include<hugo/time_measure.h> |
7 #include<hugo/time_measure.h> |
8 #include<iostream> |
8 #include<iostream> |
9 #include<../work/jacint/max_flow.h> |
9 //#include<../work/jacint/max_flow.h> |
|
10 #include"bench_tools.h" |
10 |
11 |
11 using namespace std; |
12 using namespace std; |
12 using namespace hugo; |
13 using namespace hugo; |
13 |
|
14 ///An experimental typedef factory |
|
15 #define GRAPH_TYPEDEF_FACTORY(Graph) \ |
|
16 typedef typename Graph:: Node Node;\ |
|
17 typedef typename Graph:: NodeIt NodeIn;\ |
|
18 typedef typename Graph:: Edge Edge;\ |
|
19 typedef typename Graph:: EdgeIt EdgeIt;\ |
|
20 typedef typename Graph:: InEdgeIt InEdgeIt;\ |
|
21 typedef typename Graph::OutEdgeIt OutEdgeIt; |
|
22 |
|
23 #define GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph) \ |
|
24 typedef Graph:: Node Node;\ |
|
25 typedef Graph:: NodeIt NodeIn;\ |
|
26 typedef Graph:: Edge Edge;\ |
|
27 typedef Graph:: EdgeIt EdgeIt;\ |
|
28 typedef Graph:: InEdgeIt InEdgeIt;\ |
|
29 typedef Graph::OutEdgeIt OutEdgeIt; |
|
30 |
|
31 |
|
32 class Primes |
|
33 { |
|
34 vector<int> primes; |
|
35 int n; |
|
36 |
|
37 bool isPrime(int m) |
|
38 { |
|
39 for(int i=0;m<primes[i]*primes[i];i++) if(!(m%primes[i])) return false; |
|
40 return true; |
|
41 } |
|
42 public: |
|
43 Primes() : n(1) {} |
|
44 |
|
45 int operator() () |
|
46 { |
|
47 if(primes.size()==0) { |
|
48 primes.push_back(2); |
|
49 return 2; |
|
50 } |
|
51 else { |
|
52 do n+=2; while(!isPrime(n)); |
|
53 primes.push_back(n); |
|
54 return n; |
|
55 } |
|
56 } |
|
57 }; |
|
58 |
14 |
59 template<class Graph> |
15 template<class Graph> |
60 void addHiperCube(Graph &G,int dim,vector<typename Graph::Node> &nodes) |
16 void addHiperCube(Graph &G,int dim,vector<typename Graph::Node> &nodes) |
61 { |
17 { |
62 GRAPH_TYPEDEF_FACTORY(Graph); |
18 GRAPH_TYPEDEF_FACTORY(Graph); |