Check StaticGraphSkeleton, as well.
4 #include<hugo/list_graph.h>
5 #include<hugo/smart_graph.h>
6 #include<hugo/dijkstra.h>
7 #include<hugo/max_flow.h>
9 #include"bench_tools.h"
15 void addHiperCube(Graph &G,int dim,vector<typename Graph::Node> &nodes)
17 GRAPH_TYPEDEF_FACTORY(Graph);
19 vector<int> bits(dim+1);
21 for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
23 for(int i=0;i<bits[dim];i++) {
24 nodes.push_back(G.addNode());
25 for(int j=0;j<dim;j++) if(i&bits[j]) G.addEdge(nodes[i-bits[j]],nodes[i]);
30 void addBiDirHiperCube(Graph &G,int dim,vector<typename Graph::Node> &nodes)
32 GRAPH_TYPEDEF_FACTORY(Graph);
34 vector<int> bits(dim+1);
36 for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
38 for(int i=0;i<bits[dim];i++) {
39 nodes.push_back(G.addNode());
40 for(int j=0;j<dim;j++) if(i&bits[j]) {
41 G.addEdge(nodes[i-bits[j]],nodes[i]);
42 G.addEdge(nodes[i],nodes[i-bits[j]]);
48 inline int numOfOnes(int n,int dim)
51 for(int i=0;i<dim;i++) {
58 inline int numOfZeros(int n,int dim)
61 for(int i=0;i<dim;i++) {
68 int main(int argc, char *argv[])
70 // typedef ListGraph Graph;
71 typedef SmartGraph Graph;
73 ///\bug GRAPH_TYPEDEF_FACTORY(Graph);
74 GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph);
81 cout << "Usage: " << argv[0] << " dim\n";
85 int dim=atoi(argv[1]);
87 // cout << "Creating Hipercube ("<< (1<<dim) << " nodes, "
88 // << dim*(1<<dim) << " edges):";
92 addBiDirHiperCube(G,dim,nodes);
94 PrintTime("GENGRAPH",T);
97 Graph::EdgeMap<int> map(G);
98 for(int i=0;i<5;i++) {
100 for(int i=0;i<dim*(1<<dim);i++) P();
102 // for(EdgeIt e(G);G.valid(e);G.next(e)) map[e]=P();
103 for(int i=0;i<dim*(1<<dim);i++)
104 // map[Edge(((long long int)(i)*2987)%(dim*(1<<dim)))]=P();
105 map[Edge(((long long int)(i)*93505)%(dim*(1<<dim)))]=P();
107 // for(int i=0;i<(1<<dim);i++) {
108 // int mul= (1<<(numOfZeros(i,dim)/4));
109 // for(OutEdgeIt e(G,nodes[i]);G.valid(e);G.next(e))
114 PrintTime("GENLENGTHS",T);
118 Dijkstra<Graph> Dij(G,map);
119 for(int i=0;i<10;i++)
122 PrintTime("DIJKSTRA",T);
126 Graph::EdgeMap<int> flow(G);
128 MaxFlow<Graph,int> MF(G,nodes[0],nodes[1<<dim-1],map,flow);
129 for(int i=0;i<10;i++)
132 PrintTime("PREFLOW",T);