Distribute xml.h too.
5 #include<lemon/smart_graph.h>
6 #include"bench_tools.h"
11 inline int numOfOnes(int n,int dim)
14 for(int i=0;i<dim;i++) {
21 inline int numOfZeros(int n,int dim)
24 for(int i=0;i<dim;i++) {
32 void bfsStlQueue(Graph &G,typename Graph::Node source)
34 GRAPH_TYPEDEFS(typename Graph);
38 typename Graph::template NodeMap<bool> visited(G,false);
40 queue<typename Graph::Node> Q;
48 for(OutEdgeIt e(G,n);e!=INVALID;++e)
49 if(!visited[m=G.target(e)]) {
57 void bfsOwnQueue(Graph &G,typename Graph::Node source)
59 GRAPH_TYPEDEFS(typename Graph);
63 typename Graph::template NodeMap<bool> visited(G,false);
66 vector<typename Graph::Node> Q(N);
72 visited.set(source,true);
76 for(OutEdgeIt e(G,n);e!=INVALID;++e)
77 if(!visited[m=G.target(e)]) {
85 void iteratorBench(Graph &G)
87 GRAPH_TYPEDEFS(typename Graph);
91 for(NodeIt n(G);n!=INVALID;++n)
92 for(OutEdgeIt e(G,n);e!=INVALID;++e)
96 int main(int argc, char *argv[])
98 typedef SmartGraph Graph;
100 GRAPH_TYPEDEFS(Graph);
107 cout << "Usage: " << argv[0] << " dim mul\n";
111 int dim=atoi(argv[1]);
112 int mul=atoi(argv[2]);
114 // cout << "Creating Hipercube ("<< (1<<dim) << " nodes, "
115 // << dim*(1<<dim) << " edges):";
119 addBiDirHyperCube(G,dim,nodes);
121 PrintTime("GENGRAPH",T);
125 for(int i=0;i<mul;i++)
126 bfsStlQueue(G,nodes[0]);
128 PrintTime("BFS-STL",T);
131 for(int i=0;i<mul;i++)
132 bfsOwnQueue(G,nodes[0]);
134 PrintTime("BFS-OWN",T);
137 for(int i=0;i<mul;i++)
140 PrintTime("ITERATE",T);