source:lemon-0.x/benchmark/graph-bench.cc@2592:f1fb0c31f952

Last change on this file since 2592:f1fb0c31f952 was 2592:f1fb0c31f952, checked in by Akos Ladanyi, 16 years ago

Revert to long long int since currently I don't know a better solution.

File size: 2.0 KB
Line
1/* -*- C++ -*-
2 *
3 * This file is a part of LEMON, a generic C++ optimization library
4 *
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 *
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
12 *
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
15 * purpose.
16 *
17 */
18
19#include<lemon/list_graph.h>
20
21#include"bench_tools.h"
22
23using namespace lemon;
24
25///Makes a full graph by adding and deleting a lot of edges;
26
27///\param n Number of nodes.
28///\param rat The funcion will make \f\$rat\timesn^2\f\$ edge addition and
29///\f\$(rat-1)\timesn^2\f\$ deletion.
30///\param p Tuning parameters.
31///\warning \c rat, \c p, and \c n must be pairwise relative primes.
32template <class Graph>
33void makeFullGraph(int n, int rat, int p)
34{
35  GRAPH_TYPEDEFS(typename Graph);
36
37  Graph G;
38
39  //  Node nodes[n];
40  std::vector<Node> nodes(n);
42
43  //Edge equ[rat];
44  std::vector<Edge> equ(rat);
45
46  /// \bug There is no long long int type in C++98.
47  long long int count;
48
49  for(count=0;count<rat;count++) {
51                                  nodes[int((count*p/n)%n)]);
52  }
53  for(;(count%rat)||((count*p)%n)||((count*p/n)%n);count++) {
54    //    if(!(count%1000000)) fprintf(stderr,"%d\r",count);
55    if(count%rat) G.erase(equ[count%rat]);
57                                  nodes[int((count*p/n)%n)]);
58  }
59//   std::cout << "Added " << count
60//          << " ( " << n << "^2 * " << rat << " ) edges\n";
61
62
63  //  for(int i=0;1;i++) ;
64}
65
66int main()
67{
68  lemon::Timer T;
69  makeFullGraph<ListGraph>(nextPrim(1000),nextPrim(300),nextPrim(100));
70
71  PrintTime("BIG",T);
72  T.restart();
73  makeFullGraph<ListGraph>(nextPrim(100),nextPrim(30000),nextPrim(150));
74
75  PrintTime("SMALL",T);
76}
Note: See TracBrowser for help on using the repository browser.