COIN-OR::LEMON - Graph Library

Changeset 2242:16523135943d in lemon-0.x for test


Ignore:
Timestamp:
10/14/06 17:26:05 (14 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2991
Message:

New random interface
Switching to the new interface

Location:
test
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • test/all_pairs_shortest_path_test.cc

    r1956 r2242  
    3737
    3838int main(int argc, const char *argv[]) {
    39   srand(time(0));
    4039  typedef SmartGraph Graph;
    4140  typedef Graph::Node Node;
     
    4443  typedef Graph::EdgeIt EdgeIt;
    4544
    46   typedef Graph::EdgeMap<double> LengthMap;
    47   typedef Graph::NodeMap<double> DistMap;
     45  typedef Graph::EdgeMap<int> LengthMap;
     46  typedef Graph::NodeMap<int> DistMap;
    4847
    4948  const int n = argc > 1 ? atoi(argv[1]) : 20;
    5049  const int e = argc > 2 ? atoi(argv[2]) : (int)(n * log((double)n));
    51   const double m = argc > 3 ? (double)atoi(argv[3]) : 100.0;
     50  const int m = argc > 3 ? atoi(argv[3]) : 100;
    5251
    5352  Graph graph;
     
    5958    Node node = graph.addNode();
    6059    nodes.push_back(node);
    61     shift[node] = m * (double)rand() / (RAND_MAX + 1.0);
     60    shift[node] = rnd[m];
    6261  }
    6362
    6463  for (int i = 0; i < e; ++i) {
    65     int s = (int)(n * (double)rand() / (RAND_MAX + 1.0));
    66     int t = (int)(n * (double)rand() / (RAND_MAX + 1.0));
    67     double c = m * (double)rand() / (RAND_MAX + 1.0);
     64    int s = rnd[n];
     65    int t = rnd[n];
    6866    Edge edge = graph.addEdge(nodes[s], nodes[t]);
    69     length[edge] = c - shift[nodes[s]] + shift[nodes[t]];
     67    length[edge] = rnd[m] - shift[nodes[s]] + shift[nodes[t]];
    7068  }
    7169
     
    7775  }
    7876
    79   typedef FibHeap<Node, double, Graph::NodeMap<int> > DoubleFibHeap;
    80   Johnson<Graph, LengthMap>::DefStandardHeap<DoubleFibHeap>
     77  typedef FibHeap<Node, int, Graph::NodeMap<int> > IntFibHeap;
     78  Johnson<Graph, LengthMap>::DefStandardHeap<IntFibHeap>
    8179    ::Create fibJohnson(graph, length);
    8280  {
  • test/arborescence_test.cc

    r2180 r2242  
    4848
    4949int main() {
    50   srand(time(0));
    5150  typedef SmartGraph Graph;
    5251  GRAPH_TYPEDEFS(Graph);
  • test/graph_utils_test.cc

    r2236 r2242  
    117117    for (int i = 0; i < edgeNum; ++i) {
    118118      edges[i] =
    119         graph.addEdge(nodes[urandom(nodeNum)], nodes[urandom(nodeNum)]);
     119        graph.addEdge(nodes[rnd[nodeNum]], nodes[rnd[nodeNum]]);
    120120    }
    121121    for (int i = 0; i < nodeNum; ++i) {
  • test/graph_utils_test.h

    r2229 r2242  
    5757    typename DescriptorMap<Graph, Node>::InverseMap invNodes(nodes);
    5858    for (int i = 0; i < 100; ++i) {
    59       int src = rnd.getInt(invNodes.size());
    60       int trg = rnd.getInt(invNodes.size());
     59      int src = rnd[invNodes.size()];
     60      int trg = rnd[invNodes.size()];
    6161      graph.addEdge(invNodes[src], invNodes[trg]);
    6262    }
  • test/heap_test.h

    r2229 r2242  
    4646
    4747  for (int i = 0; i < n; ++i) {
    48     v[i] = rnd.getInt(1000);
     48    v[i] = rnd[1000];
    4949    heap.push(i, v[i]);
    5050  }
     
    6666
    6767  for (int i = 0; i < n; ++i) {
    68     v[i] = rnd.getInt(1000);
     68    v[i] = rnd[1000];
    6969    heap.push(i, v[i]);
    7070  }
    7171  for (int i = 0; i < n; ++i) {
    72     v[i] += rnd.getInt(1000);
     72    v[i] += rnd[1000];
    7373    heap.increase(i, v[i]);
    7474  }
  • test/matrix_maps_test.cc

    r2039 r2242  
    6868    for (Graph::NodeIt it(graph); it != INVALID; ++it) {
    6969      for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
    70         int val = urandom(100);
     70        int val = rnd[100];
    7171        matrix.set(it, jt, val);
    7272        check(matrix(it, jt) == val, "Wrong assign");
     
    109109    for (Graph::NodeIt it(graph); it != INVALID; ++it) {
    110110      for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
    111         int val = urandom(100);
     111        int val = rnd[100];
    112112        matrix.set(it, jt, val);
    113113        check(matrix(it, jt) == val, "Wrong assign");
     
    155155    for (Graph::NodeIt it(graph1); it != INVALID; ++it) {
    156156      for (Graph::EdgeIt jt(graph2); jt != INVALID; ++jt) {
    157         int val = urandom(100);
     157        int val = rnd[100];
    158158        matrix.set(it, jt, val);
    159159        check(matrix(it, jt) == val, "Wrong assign");
     
    199199    for (Graph::NodeIt it(graph); it != INVALID; ++it) {
    200200      for (Graph::NodeIt jt(graph); jt != INVALID; ++jt) {
    201         int val = urandom(100);
     201        int val = rnd[100];
    202202        matrix.set(it, jt, val);
    203203        check(matrix(it, jt) == val, "Wrong assign");
  • test/radix_sort_test.cc

    r1956 r2242  
    3838    vector<int> data1(n), data2(n);
    3939    for (int i = 0; i < n; ++i) {
    40       data1[i] = data2[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0))) - 500;
     40      data1[i] = data2[i] = rnd[1000] - 500;
    4141    }
    4242    radixSort(data1.begin(), data1.end());
     
    4949    vector<unsigned char> data1(n), data2(n);
    5050    for (int i = 0; i < n; ++i) {
    51       data1[i] = data2[i] = (int)(200 * (rand() / (RAND_MAX + 1.0)));
     51      data1[i] = data2[i] = rnd[(unsigned char)200];
    5252    }
    5353    radixSort(data1.begin(), data1.end());
     
    6565    vector<int> data1(n), data2(n);
    6666    for (int i = 0; i < n; ++i) {
    67       data1[i] = data2[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0))) - 500;
     67      data1[i] = data2[i] = rnd[1000] - 500;
    6868    }
    6969    counterSort(data1.begin(), data1.end());
     
    7676    vector<unsigned char> data1(n), data2(n);
    7777    for (int i = 0; i < n; ++i) {
    78       data1[i] = data2[i] = (int)(200 * (rand() / (RAND_MAX + 1.0)));
     78      data1[i] = data2[i] = rnd[(unsigned char)200];
    7979    }
    8080    counterSort(data1.begin(), data1.end());
     
    107107  vector<Edge> edges;
    108108  for (int i = 0; i < e; ++i) {
    109     int s = (int)(n * (double)rand() / (RAND_MAX + 1.0));
    110     int t = (int)(n * (double)rand() / (RAND_MAX + 1.0));
     109    int s = rnd[n];
     110    int t = rnd[n];
    111111    edges.push_back(graph.addEdge(nodes[s], nodes[t]));
    112112  }
     
    146146  vector<Edge> edges;
    147147  for (int i = 0; i < e; ++i) {
    148     int s = (int)(n * (double)rand() / (RAND_MAX + 1.0));
    149     int t = (int)(n * (double)rand() / (RAND_MAX + 1.0));
     148    int s = rnd[n];
     149    int t = rnd[n];
    150150    edges.push_back(graph.addEdge(nodes[s], nodes[t]));
    151151  }
  • test/simann_test.cc

    r1956 r2242  
    2424public:
    2525  double d, prev_d;
    26   MyEntity() : d(100000.0) { srand48(time(0)); }
     26  MyEntity() : d(100000.0) {}
    2727  double mutate() {
    2828    prev_d = d;
    29     if (drand48() < 0.8) { d += 1.0; }
     29    if (rnd.boolean(0.8)) { d += 1.0; }
    3030    else { d -= 1.0; }
    3131    return d;
  • test/test_tools.h

    r2229 r2242  
    175175   n.outcir.push_back(G.addEdge(n.outer[i],n.outer[(i+1)%5]));
    176176   n.incir.push_back(G.addEdge(n.inner[i],n.inner[(i+2)%5]));
    177   }
     177 }
    178178 return n;
    179179}
    180180
    181 int urandom(int n) {
    182   return rnd.getInt(n);
    183 }
    184 
    185181#endif
Note: See TracChangeset for help on using the changeset viewer.