src/becnhmark gets in the distro.
I hope it works well.
4 #include<hugo/list_graph.h>
5 #include<hugo/smart_graph.h>
6 #include<hugo/dijkstra.h>
7 #include<hugo/time_measure.h>
9 //#include<../work/jacint/max_flow.h>
10 #include"bench_tools.h"
16 void addHiperCube(Graph &G,int dim,vector<typename Graph::Node> &nodes)
18 GRAPH_TYPEDEF_FACTORY(Graph);
20 vector<int> bits(dim+1);
22 for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
24 for(int i=0;i<bits[dim];i++) {
25 nodes.push_back(G.addNode());
26 for(j=0;j<dim;j++) if(i&bits[j]) G.addEdge(nodes[i-bits[j]],nodes[i]);
31 void addBiDirHiperCube(Graph &G,int dim,vector<typename Graph::Node> &nodes)
33 GRAPH_TYPEDEF_FACTORY(Graph);
35 vector<int> bits(dim+1);
37 for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
39 for(int i=0;i<bits[dim];i++) {
40 nodes.push_back(G.addNode());
41 for(int j=0;j<dim;j++) if(i&bits[j]) {
42 G.addEdge(nodes[i-bits[j]],nodes[i]);
43 G.addEdge(nodes[i],nodes[i-bits[j]]);
49 int main(int argc, char *argv[])
51 // typedef ListGraph Graph;
52 typedef SmartGraph Graph;
54 ///\bug GRAPH_TYPEDEF_FACTORY(Graph);
55 GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph);
62 cout << "Usage: " << argv[0] << " dim\n";
66 int dim=atoi(argv[1]);
68 cout << "Creating Hipercube ("<< (1<<dim) << " nodes, "
69 << dim*(1<<dim) << " edges):";
72 addBiDirHiperCube(G,dim,nodes);
74 cout << "\nGenerating the lengths: ";
76 Graph::EdgeMap<int> map(G);
79 for(int i=0;i<dim*(1<<dim);i++) P();
81 // for(EdgeIt e(G);G.valid(e);G.next(e)) map[e]=P();
82 for(int i=0;i<dim*(1<<dim);i++)
83 // map[Edge(((long long int)(i)*2987)%(dim*(1<<dim)))]=P();
84 map[Edge(((long long int)(i)*93505)%(dim*(1<<dim)))]=P();
88 cout << "\nRunning Dijkstra: ";
91 Dijkstra<Graph> Dij(G,map);
95 // cout << "\nRunning MaxFlow: ";
98 // Graph::EdgeMap<int> flow(G);
100 // MaxFlow<Graph,int> MF(G,nodes[0],nodes[1<<dim-1],map,flow);
101 // MF.run(MF.NO_FLOW);