Edge creation is available.
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_TYPEDEF_FACTORY(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_TYPEDEF_FACTORY(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_TYPEDEF_FACTORY(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 ///\bug GRAPH_TYPEDEF_FACTORY(Graph);
101 GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph);
108 cout << "Usage: " << argv[0] << " dim mul\n";
112 int dim=atoi(argv[1]);
113 int mul=atoi(argv[2]);
115 // cout << "Creating Hipercube ("<< (1<<dim) << " nodes, "
116 // << dim*(1<<dim) << " edges):";
120 addBiDirHiperCube(G,dim,nodes);
122 PrintTime("GENGRAPH",T);
126 for(int i=0;i<mul;i++)
127 bfsStlQueue(G,nodes[0]);
129 PrintTime("BFS-STL",T);
132 for(int i=0;i<mul;i++)
133 bfsOwnQueue(G,nodes[0]);
135 PrintTime("BFS-OWN",T);
138 for(int i=0;i<mul;i++)
141 PrintTime("ITERATE",T);