MinLCA algorithms
greedy_clique_graph.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <lemon/smart_graph.h>
4 #include <minlca/greedy.hh>
5 #include <utils/timer.hh>
6 #include <minlca/profiler.hh>
7 using namespace std;
8 using namespace lemon;
9 using namespace minlca;
10 using namespace minlca::utils;
11 
16 
24 int main(int argc, char **argv)
25 {
26  GRAPH_TYPEDEFS(CliqueGraph<>);
27  Timer timer;
28  CliqueGraph<> g(atoi(argv[4]));
29  g.init(atoi(argv[1]), atoi(argv[2]), atof(argv[3])).generate();
30  cout << "Graph generation time: " << timer.elapsed() << endl;
31  cout << endl;
32 
33  int n = countNodes(g);
34  cout << "Total nodes: " << n << endl;
35  cout << "Size of cliques: " << g.cliqueOrder() << endl;
36  cout << "Number of cliques: " << g.cliques() << endl;
37  cout << "Total edges: " << countEdges(g) << endl;
38  cout << "Edge prob.: " << g.p() << endl;
39  cout << "Random seed: " << argv[4] << endl;
40 
41  cout << endl;
42  cout << "Using greedy nearest:" << endl;
43 
45  cout << "Creation elapsed time: " << greedyNearest.creationTime() << endl;
46  greedyNearest.init();
47  cout << "Initialisation elapsed time: " << greedyNearest.initTime() << endl;
48 
49  if (greedyNearest.run() == SOLUTION_FOUND) {
50  cout << "Algorithm running time: " << greedyNearest.runTime() << endl;
51  cout << "Max colours: " << greedyNearest.maxK() << endl;
52  cout << "Colours used: " << greedyNearest.totalColours() << endl;
53  cout << "LCA value: " << greedyNearest.lcaValue() << endl;
54  }
55  else {
56  cout << "Could not find a solution!" << endl;
57  }
58 
59  cout << endl;
60 
61  cout << "Using greedy least cost:" << endl;
62 
64  cout << "Creation elapsed time: " << greedyLeastCost.creationTime() << endl;
65  greedyLeastCost.init();
66  cout << "Initialisation elapsed time: " << greedyLeastCost.initTime() << endl;
67 
68  if (greedyLeastCost.run() == SOLUTION_FOUND) {
69  cout << "Algorithm running time: " << greedyLeastCost.runTime() << endl;
70  cout << "Max colours: " << greedyLeastCost.maxK() << endl;
71  cout << "Colours used: " << greedyLeastCost.totalColours() << endl;
72  cout << "LCA value: " << greedyLeastCost.lcaValue() << endl;
73  }
74  else {
75  cout << "Could not find a solution!" << endl;
76  }
77 }
78 
double runTime()
Retrieve the duration of running the algorithm.
Definition: profiler.hh:62
virtual MinLCAStatus run()
Run the algorithm.
Definition: profiler.hh:50
Contains definition for graphs with cliques.
int cliqueOrder() const
Retrieve the order of each clique.
Definition: cliques.hh:40
virtual Graph & init(int s, int c, double p)
Initialise the generator.
Definition: cliques.hh:140
virtual void generate()
Generate graph.
Definition: cliques.hh:152
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
int cliques() const
Retrieve the number of cliques.
Definition: cliques.hh:47
int main(int argc, char **argv)
Main function.
Class for timing MinLCA algorithms.
Definition: profiler.hh:16
double initTime()
Retrieve the duration of initialising the algorithm.
Definition: profiler.hh:70
Description of Timer.
Simple timing class.
Definition: timer.hh:14
double creationTime()
Retrieve the duration of instantiating the algorithm class.
Definition: profiler.hh:78
Class describing a random graph with cliques.
Definition: cliques.hh:107
Contains the definitions for timing MinLCA algorithms.
double elapsed() const
Retrieve elapsed time.
Definition: timer.cc:20
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