diff -r 625de6f1e766 -r 59f8d173968e src/benchmark/graph-bench.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/benchmark/graph-bench.cc Tue Jul 13 07:19:34 2004 +0000 @@ -0,0 +1,83 @@ +#include +#include +#include +#include +#include + +using namespace hugo; + +///An experimental typedef factory +#define GRAPH_TYPEDEF_FACTORY(Graph) \ + typedef typename Graph:: Node Node;\ + typedef typename Graph:: NodeIt NodeIn;\ + typedef typename Graph:: Edge Edge;\ + typedef typename Graph:: EdgeIt EdgeIt;\ + typedef typename Graph:: InEdgeIt InEdgeIt;\ + typedef typename Graph::OutEdgeIt OutEdgeIt; + + +///A primitive primtest +bool isPrim(int n) +{ + if(n%2) { + for(int k=3;n/k>=k;k+=2) + if(!(n%k)) return false; + return true; + } + return false; +} + +///Finds the smallest prime not less then \c n. +int nextPrim(int n) +{ + for(n+=!(n%2);!isPrim(n);n+=2) ; + return n; +} + +///Makes a full graph by adding and deleting a lot of edges; + +///\param n Number of nodes. +///\param rat The funcion will make \f$rat\timesn^2\f$ edge addition and +///\f$(rat-1)\timesn^2\f$ deletion. +///\param p Tuning parameters. +///\warning \c rat, \c p, and \c n must be pairwise relative primes. +template +void makeFullGraph(int n, int rat, int p) +{ + GRAPH_TYPEDEF_FACTORY(Graph); + + Graph G; + + Node nodes[n]; + for(int i=0;i