MinLCA algorithms
sa_greedy_random_geometric.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <lemon/smart_graph.h>
3 #include <utils/graph_utils.hh>
6 #include <utils/timer.hh>
7 #include <minlca/profiler.hh>
8 #include <minlca/greedy.hh>
9 using namespace std;
10 using namespace lemon;
11 using namespace minlca;
12 using namespace minlca::utils;
13 
19 
34 int main(int argc, char **argv)
35 {
36  GRAPH_TYPEDEFS(RandomGeometric<>);
37 
38  Timer timer;
39  RandomGeometric<> g(atoi(argv[3]));
40  g.init(atoi(argv[1]), atof(argv[2])).generate();
41 
42  cout << "Graph generation time: " << timer.elapsed() << endl;
43  cout << endl;
44 
45  int n = countNodes(g);
46  cout << "Total nodes: " << n << endl;
47  cout << "Total edges: " << countEdges(g) << endl;
48  cout << "Radius squared: " << atof(argv[2]) << endl;
49  cout << "Random seed: " << argv[3] << endl;
50 
51  cout << endl;
52  cout << "Using greedy nearest:" << endl;
53 
55  greedyNearest(g, 0, atoi(argv[4]));
56  cout << "Creation elapsed time: " << greedyNearest.creationTime() << endl;
57  greedyNearest.init(atoi(argv[5]), atoi(argv[6]), atoi(argv[7]), atof(argv[8]),
58  atoi(argv[9]));
59  cout << "Initialisation elapsed time: " << greedyNearest.initTime() << endl;
60 
61  if (greedyNearest.run() == SOLUTION_FOUND) {
62  cout << "Algorithm running time: " << greedyNearest.runTime() << endl;
63  cout << "Max colours: " << greedyNearest.maxK() << endl;
64  cout << "Colours used: " << greedyNearest.totalColours() << endl;
65  cout << "LCA value: " << greedyNearest.lcaValue() << endl;
66  }
67  else {
68  cout << "Could not find a solution!" << endl;
69  }
70 }
71 
virtual void generate()
Generate graph.
Definition: geometric.hh:65
double runTime()
Retrieve the duration of running the algorithm.
Definition: profiler.hh:62
Class defining random geometric graphs.
Definition: geometric.hh:21
virtual MinLCAStatus run()
Run the algorithm.
Definition: profiler.hh:50
Contains definition for RandomGeometric graphs.
Solution has been found after running.
Definition: base.hh:22
LEMON namespace.
Definition: grb.cc:29
Default namespace Default namespace for MinLCA algorithms.
Definition: base.hh:15
Graph & init(int n, double radSq)
Initialise the generator.
Definition: geometric.hh:54
Class for timing MinLCA algorithms.
Definition: profiler.hh:16
Functions for reading graphs and getting graph properties.
double initTime()
Retrieve the duration of initialising the algorithm.
Definition: profiler.hh:70
Definitions for simulated annealing using greedy recolourings.
Description of Timer.
Simple timing class.
Definition: timer.hh:14
double creationTime()
Retrieve the duration of instantiating the algorithm class.
Definition: profiler.hh:78
Contains the definitions for timing MinLCA algorithms.
double elapsed() const
Retrieve elapsed time.
Definition: timer.cc:20
int main(int argc, char **argv)
Main function.
void init(Args &&...args)
Reset the data structures of the algorithm.
Definition: profiler.hh:39
Namespace for util functions and classes.
Definition: binomial.hh:14