benchmark/bench_tools.h
changeset 1933 a876a3d6a4c7
parent 1689 f1795dafe42c
child 1956 a055123339d5
equal deleted inserted replaced
1:e5decafed5f7 2:fcd9e9225694
     3 #define LEMON_BENCH_TEST_H
     3 #define LEMON_BENCH_TEST_H
     4 
     4 
     5 #include<vector>
     5 #include<vector>
     6 #include<iostream>
     6 #include<iostream>
     7 
     7 
       
     8 #include<lemon/graph_utils.h>
     8 #include<lemon/time_measure.h>
     9 #include<lemon/time_measure.h>
     9 
       
    10 ///An experimental typedef factory
       
    11 #define GRAPH_TYPEDEF_FACTORY(Graph) \
       
    12    typedef typename Graph::   Node      Node;\
       
    13    typedef typename Graph::   NodeIt    NodeIt;\
       
    14    typedef typename Graph::   Edge      Edge;\
       
    15    typedef typename Graph::   EdgeIt    EdgeIt;\
       
    16    typedef typename Graph:: InEdgeIt  InEdgeIt;\
       
    17    typedef typename Graph::OutEdgeIt OutEdgeIt;
       
    18 
       
    19 #define GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph) \
       
    20    typedef Graph::   Node      Node;\
       
    21    typedef Graph::   NodeIt    NodeIt;\
       
    22    typedef Graph::   Edge      Edge;\
       
    23    typedef Graph::   EdgeIt    EdgeIt;\
       
    24    typedef Graph:: InEdgeIt  InEdgeIt;\
       
    25    typedef Graph::OutEdgeIt OutEdgeIt;
       
    26  
       
    27 
    10 
    28 ///A primitive primtest
    11 ///A primitive primtest
    29 
    12 
    30 ///\bug 2 is not a prime according to this function!
    13 ///\bug 2 is not a prime according to this function!
    31 ///
    14 ///
    91 
    74 
    92 ///
    75 ///
    93 template<class Graph>
    76 template<class Graph>
    94 void addHyperCube(Graph &G,int dim,std::vector<typename Graph::Node> &nodes)
    77 void addHyperCube(Graph &G,int dim,std::vector<typename Graph::Node> &nodes)
    95 {
    78 {
    96   GRAPH_TYPEDEF_FACTORY(Graph);
    79   GRAPH_TYPEDEFS(typename Graph);
    97   
    80   
    98   std::vector<int> bits(dim+1);
    81   std::vector<int> bits(dim+1);
    99   bits[0]=1;
    82   bits[0]=1;
   100   for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
    83   for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
   101   
    84   
   107 
    90 
   108 ///
    91 ///
   109 template<class Graph>
    92 template<class Graph>
   110 void addBiDirHyperCube(Graph &G,int dim,std::vector<typename Graph::Node>&nodes)
    93 void addBiDirHyperCube(Graph &G,int dim,std::vector<typename Graph::Node>&nodes)
   111 {
    94 {
   112   GRAPH_TYPEDEF_FACTORY(Graph);
    95   GRAPH_TYPEDEFS(typename Graph);
   113   
    96   
   114   std::vector<int> bits(dim+1);
    97   std::vector<int> bits(dim+1);
   115   bits[0]=1;
    98   bits[0]=1;
   116   for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
    99   for(int i=1;i<=dim;i++) bits[i]=2*bits[i-1];
   117   
   100