src/benchmark/bench_tools.h
changeset 742 235fd36336b7
parent 718 75d36edc6bc4
child 750 2713723d2210
     1.1 --- a/src/benchmark/bench_tools.h	Tue Jul 27 16:04:21 2004 +0000
     1.2 +++ b/src/benchmark/bench_tools.h	Tue Jul 27 16:09:42 2004 +0000
     1.3 @@ -81,6 +81,42 @@
     1.4  	    << S.getSystemTime() << ' ' << S.getRealTime() << std::endl;
     1.5  }
     1.6  
     1.7 +
     1.8 +
     1.9 +///
    1.10 +template<class Graph>
    1.11 +void addHiperCube(Graph &G,int dim,std::vector<typename Graph::Node> &nodes)
    1.12 +{
    1.13 +  GRAPH_TYPEDEF_FACTORY(Graph);
    1.14    
    1.15 +  std::vector<int> bits(dim+1);
    1.16 +  bits[0]=1;
    1.17 +  for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
    1.18 +  
    1.19 +  for(int i=0;i<bits[dim];i++) {
    1.20 +    nodes.push_back(G.addNode());
    1.21 +    for(int j=0;j<dim;j++) if(i&bits[j]) G.addEdge(nodes[i-bits[j]],nodes[i]);
    1.22 +  }
    1.23 +}
    1.24 +
    1.25 +///
    1.26 +template<class Graph>
    1.27 +void addBiDirHiperCube(Graph &G,int dim,std::vector<typename Graph::Node>&nodes)
    1.28 +{
    1.29 +  GRAPH_TYPEDEF_FACTORY(Graph);
    1.30 +  
    1.31 +  std::vector<int> bits(dim+1);
    1.32 +  bits[0]=1;
    1.33 +  for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
    1.34 +  
    1.35 +  for(int i=0;i<bits[dim];i++) {
    1.36 +    nodes.push_back(G.addNode());
    1.37 +    for(int j=0;j<dim;j++) if(i&bits[j]) {
    1.38 +      G.addEdge(nodes[i-bits[j]],nodes[i]);
    1.39 +      G.addEdge(nodes[i],nodes[i-bits[j]]);
    1.40 +    }
    1.41 +    
    1.42 +  }
    1.43 +}  
    1.44  
    1.45  #endif