COIN-OR::LEMON - Graph Library

Changeset 711:b6c56353832c in lemon-0.x for src


Ignore:
Timestamp:
07/20/04 11:50:11 (16 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@963
Message:

Some tools of common usage was put to bench_tool.h

Location:
src/benchmark
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/Makefile.am

    r708 r711  
    33noinst_PROGRAMS = graph-bench hcube
    44
    5 graph_bench_SOURCES = graph-bench.cc
     5graph_bench_SOURCES = graph-bench.cc bench_tools.h
    66
    7 hcube_SOURCES = hcube.cc
     7hcube_SOURCES = hcube.cc bench_tools.h
  • src/benchmark/graph-bench.cc

    r708 r711  
    33#include<hugo/time_measure.h>
    44#include<iostream>
    5 #include<sage_graph.h>
    6 #include<vector>
     5
     6#include"bench_tools.h"
    77
    88using 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 }
    379
    3810///Makes a full graph by adding and deleting a lot of edges;
  • src/benchmark/hcube.cc

    r708 r711  
    77#include<hugo/time_measure.h>
    88#include<iostream>
    9 #include<../work/jacint/max_flow.h>
     9//#include<../work/jacint/max_flow.h>
     10#include"bench_tools.h"
    1011
    1112using namespace std;
    1213using namespace hugo;
    13 
    14 ///An experimental typedef factory
    15 #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 Primes
    33 {
    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 };
    5814
    5915template<class Graph>
Note: See TracChangeset for help on using the changeset viewer.