COIN-OR::LEMON - Graph Library

Changeset 742:235fd36336b7 in lemon-0.x for src/benchmark/hcube.cc


Ignore:
Timestamp:
07/27/04 18:09:42 (17 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@999
Message:
  • bfs-bench added
  • hypercube generators moved to bench-tools.h
  • new benchmark script
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/hcube.cc

    r729 r742  
    1111using namespace std;
    1212using namespace hugo;
    13 
    14 template<class Graph>
    15 void addHiperCube(Graph &G,int dim,vector<typename Graph::Node> &nodes)
    16 {
    17   GRAPH_TYPEDEF_FACTORY(Graph);
    18  
    19   vector<int> bits(dim+1);
    20   bits[0]=1;
    21   for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
    22  
    23   for(int i=0;i<bits[dim];i++) {
    24     nodes.push_back(G.addNode());
    25     for(int j=0;j<dim;j++) if(i&bits[j]) G.addEdge(nodes[i-bits[j]],nodes[i]);
    26   }
    27 }
    28 
    29 template<class Graph>
    30 void addBiDirHiperCube(Graph &G,int dim,vector<typename Graph::Node> &nodes)
    31 {
    32   GRAPH_TYPEDEF_FACTORY(Graph);
    33  
    34   vector<int> bits(dim+1);
    35   bits[0]=1;
    36   for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
    37  
    38   for(int i=0;i<bits[dim];i++) {
    39     nodes.push_back(G.addNode());
    40     for(int j=0;j<dim;j++) if(i&bits[j]) {
    41       G.addEdge(nodes[i-bits[j]],nodes[i]);
    42       G.addEdge(nodes[i],nodes[i-bits[j]]);
    43     }
    44    
    45   }
    46 }
    4713
    4814inline int numOfOnes(int n,int dim)
Note: See TracChangeset for help on using the changeset viewer.