COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
10/14/06 17:26:05 (18 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

File:
1 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  {
Note: See TracChangeset for help on using the changeset viewer.