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"
14 inline int numOfOnes(int n,int dim)
17 for(int i=0;i<dim;i++) {
24 inline int numOfZeros(int n,int dim)
27 for(int i=0;i<dim;i++) {
35 void bfsStlQueue(Graph &G,typename Graph::Node source)
37 GRAPH_TYPEDEF_FACTORY(Graph);
41 typename Graph::NodeMap<bool> visited(G,false);
43 queue<typename Graph::Node> Q;
51 for(OutEdgeIt e(G,n);G.valid(e);G.next(e))
52 if(!visited[m=G.head(e)]) {
60 void bfsOwnQueue(Graph &G,typename Graph::Node source)
62 GRAPH_TYPEDEF_FACTORY(Graph);
66 typename Graph::NodeMap<bool> visited(G,false);
69 vector<typename Graph::Node> Q(N);
75 visited.set(source,true);
79 for(OutEdgeIt e(G,n);G.valid(e);G.next(e))
80 if(!visited[m=G.head(e)]) {
87 int main(int argc, char *argv[])
89 // typedef ListGraph Graph;
90 typedef SmartGraph Graph;
92 ///\bug GRAPH_TYPEDEF_FACTORY(Graph);
93 GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph);
100 cout << "Usage: " << argv[0] << " dim\n";
104 int dim=atoi(argv[1]);
106 // cout << "Creating Hipercube ("<< (1<<dim) << " nodes, "
107 // << dim*(1<<dim) << " edges):";
111 addBiDirHiperCube(G,dim,nodes);
113 PrintTime("GENGRAPH",T);
117 for(int i=0;i<50000;i++)
118 bfsStlQueue(G,nodes[0]);
120 PrintTime("BFS-STL",T);
123 for(int i=0;i<50000;i++)
124 bfsOwnQueue(G,nodes[0]);
126 PrintTime("BFS-OWN",T);