MinLCA algorithms
sa_greedy_random_outerplanar.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 
33 int main(int argc, char **argv)
34 {
35  GRAPH_TYPEDEFS(RandomOuterplanar<>);
36 
37  Timer timer;
38  RandomOuterplanar<> g(atoi(argv[2]));
39  g.init(atoi(argv[1])).generate();
40 
41  cout << "Graph generation time: " << timer.elapsed() << endl;
42  cout << endl;
43 
44  int n = countNodes(g);
45  cout << "Total nodes: " << n << endl;
46  cout << "Total edges: " << countEdges(g) << endl;
47  cout << "Random seed: " << argv[2] << endl;
48 
49  cout << endl;
50  cout << "Using greedy nearest:" << endl;
51 
53  greedyNearest(g, 0, atoi(argv[3]));
54  cout << "Creation elapsed time: " << greedyNearest.creationTime() << endl;
55  greedyNearest.init(atoi(argv[4]), atoi(argv[5]), atoi(argv[6]), atof(argv[7]),
56  atoi(argv[8]));
57  cout << "Initialisation elapsed time: " << greedyNearest.initTime() << endl;
58 
59  if (greedyNearest.run() == SOLUTION_FOUND) {
60  cout << "Algorithm running time: " << greedyNearest.runTime() << endl;
61  cout << "Max colours: " << greedyNearest.maxK() << endl;
62  cout << "Colours used: " << greedyNearest.totalColours() << endl;
63  cout << "LCA value: " << greedyNearest.lcaValue() << endl;
64  }
65  else {
66  cout << "Could not find a solution!" << endl;
67  }
68 }
69 
Contains definition for RandomOuterplanar graphs.
double runTime()
Retrieve the duration of running the algorithm.
Definition: profiler.hh:62
virtual MinLCAStatus run()
Run the algorithm.
Definition: profiler.hh:50
int main(int argc, char **argv)
Main function.
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
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
Class defining random geometric graphs.
Definition: outerplanar.hh:22
virtual void generate()
Generate graph.
Definition: outerplanar.hh:61
void init(Args &&...args)
Reset the data structures of the algorithm.
Definition: profiler.hh:39
Graph & init(int n)
Initialise the generator.
Definition: outerplanar.hh:53
Namespace for util functions and classes.
Definition: binomial.hh:14