Changeset 711:b6c56353832c in lemon0.x
 Timestamp:
 07/20/04 11:50:11 (18 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@963
 Location:
 src/benchmark
 Files:

 1 added
 3 edited
Legend:
 Unmodified
 Added
 Removed

src/benchmark/Makefile.am
r708 r711 3 3 noinst_PROGRAMS = graphbench hcube 4 4 5 graph_bench_SOURCES = graphbench.cc 5 graph_bench_SOURCES = graphbench.cc bench_tools.h 6 6 7 hcube_SOURCES = hcube.cc 7 hcube_SOURCES = hcube.cc bench_tools.h 
src/benchmark/graphbench.cc
r708 r711 3 3 #include<hugo/time_measure.h> 4 4 #include<iostream> 5 #include<sage_graph.h> 6 #include <vector>5 6 #include"bench_tools.h" 7 7 8 8 using namespace hugo; 9 10 ///An experimental typedef factory11 #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 primtest21 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 10 ///Makes a full graph by adding and deleting a lot of edges; 
src/benchmark/hcube.cc
r708 r711 7 7 #include<hugo/time_measure.h> 8 8 #include<iostream> 9 #include<../work/jacint/max_flow.h> 9 //#include<../work/jacint/max_flow.h> 10 #include"bench_tools.h" 10 11 11 12 using namespace std; 12 13 using namespace hugo; 13 14 ///An experimental typedef factory15 #define GRAPH_TYPEDEF_FACTORY(Graph) \16 typedef typename Graph:: Node Node;\17 typedef typename Graph:: NodeIt NodeIn;\18 typedef typename Graph:: Edge Edge;\19 typedef typename Graph:: EdgeIt EdgeIt;\20 typedef typename Graph:: InEdgeIt InEdgeIt;\21 typedef typename Graph::OutEdgeIt OutEdgeIt;22 23 #define GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph) \24 typedef Graph:: Node Node;\25 typedef Graph:: NodeIt NodeIn;\26 typedef Graph:: Edge Edge;\27 typedef Graph:: EdgeIt EdgeIt;\28 typedef Graph:: InEdgeIt InEdgeIt;\29 typedef Graph::OutEdgeIt OutEdgeIt;30 31 32 class Primes33 {34 vector<int> primes;35 int n;36 37 bool isPrime(int m)38 {39 for(int i=0;m<primes[i]*primes[i];i++) if(!(m%primes[i])) return false;40 return true;41 }42 public:43 Primes() : n(1) {}44 45 int operator() ()46 {47 if(primes.size()==0) {48 primes.push_back(2);49 return 2;50 }51 else {52 do n+=2; while(!isPrime(n));53 primes.push_back(n);54 return n;55 }56 }57 };58 14 59 15 template<class Graph>
Note: See TracChangeset
for help on using the changeset viewer.