src/benchmark/graph-bench.cc
changeset 711 b6c56353832c
parent 708 429dfcbbf47d
child 718 75d36edc6bc4
equal deleted inserted replaced
1:7699f01a167e 2:1c2c4edb0ed3
     1 #include<math.h>
     1 #include<math.h>
     2 #include<hugo/list_graph.h>
     2 #include<hugo/list_graph.h>
     3 #include<hugo/time_measure.h>
     3 #include<hugo/time_measure.h>
     4 #include<iostream>
     4 #include<iostream>
     5 #include<sage_graph.h>
     5 
     6 #include<vector>
     6 #include"bench_tools.h"
     7 
     7 
     8 using namespace hugo;
     8 using namespace hugo;
     9 
       
    10 ///An experimental typedef factory
       
    11 #define GRAPH_TYPEDEF_FACTORY(Graph) \
       
    12    typedef typename Graph::   Node      Node;\
       
    13    typedef typename Graph::   NodeIt    NodeIn;\
       
    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 
       
    20 ///A primitive primtest
       
    21 bool isPrim(int n)
       
    22 {
       
    23   if(n%2) {
       
    24     for(int k=3;n/k>=k;k+=2)
       
    25       if(!(n%k)) return false;
       
    26     return true;
       
    27   }
       
    28   return false;
       
    29 }
       
    30 
       
    31 ///Finds the smallest prime not less then \c n.
       
    32 int nextPrim(int n)
       
    33 {
       
    34   for(n+=!(n%2);!isPrim(n);n+=2) ;
       
    35   return n;
       
    36 }
       
    37 
     9 
    38 ///Makes a full graph by adding and deleting a lot of edges;
    10 ///Makes a full graph by adding and deleting a lot of edges;
    39 
    11 
    40 ///\param n Number of nodes.
    12 ///\param n Number of nodes.
    41 ///\param rat The funcion will make \f$rat\timesn^2\f$ edge addition and
    13 ///\param rat The funcion will make \f$rat\timesn^2\f$ edge addition and