MinLCA algorithms
greedy_clique_cycle.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 
12 
17 
23 int main(int argc, char **argv)
24 {
25  GRAPH_TYPEDEFS(CliqueCycle<>);
26  Timer timer;
27  CliqueCycle<> g;
28  g.init(atoi(argv[1]), atoi(argv[2])).generate();
29  cout << "Graph generation time: " << timer.elapsed() << endl;
30  cout << endl;
31 
32  int n = countNodes(g);
33  cout << "Total nodes: " << n << endl;
34  cout << "Size of cliques: " << g.cliqueOrder() << endl;
35  cout << "Number of cliques: " << g.cliques() << endl;
36  cout << "Total edges: " << countEdges(g) << endl;
37 
38  cout << endl;
39  cout << "Using greedy nearest:" << endl;
40 
42  cout << "Creation elapsed time: " << greedyNearest.creationTime() << endl;
43  greedyNearest.init();
44  cout << "Initialisation elapsed time: " << greedyNearest.initTime() << endl;
45 
46  if (greedyNearest.run() == SOLUTION_FOUND) {
47  cout << "Algorithm running time: " << greedyNearest.runTime() << endl;
48  cout << "Max colours: " << greedyNearest.maxK() << endl;
49  cout << "Colours used: " << greedyNearest.totalColours() << endl;
50  cout << "LCA value: " << greedyNearest.lcaValue() << endl;
51  }
52  else {
53  cout << "Could not find a solution!" << endl;
54  }
55 
56  cout << endl;
57 
58  cout << "Using greedy least cost:" << endl;
59 
61  cout << "Creation elapsed time: " << greedyLeastCost.creationTime() << endl;
62  greedyLeastCost.init();
63  cout << "Initialisation elapsed time: " << greedyLeastCost.initTime() << endl;
64 
65  if (greedyLeastCost.run() == SOLUTION_FOUND) {
66  cout << "Algorithm running time: " << greedyLeastCost.runTime() << endl;
67  cout << "Max colours: " << greedyLeastCost.maxK() << endl;
68  cout << "Colours used: " << greedyLeastCost.totalColours() << endl;
69  cout << "LCA value: " << greedyLeastCost.lcaValue() << endl;
70  }
71  else {
72  cout << "Could not find a solution!" << endl;
73  }
74 }
75 
76 
Class describing a cycle of cliques.
Definition: cliques.hh:74
double runTime()
Retrieve the duration of running the algorithm.
Definition: profiler.hh:62
int main(int argc, char **argv)
Main function.
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)
Initialise the generator.
Definition: cliques.hh:83
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
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
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