1 #ifndef __MINLCA_MINLCA_BASE_HH
2 #define __MINLCA_MINLCA_BASE_HH
4 #include <lemon/core.h>
5 #include <lemon/smart_graph.h>
7 #include <lemon/color.h>
28 template<
typename Graph = lemon::SmartGraph>
32 TEMPLATE_GRAPH_TYPEDEFS(Graph);
65 int oldColour = _c[v];
67 _k = std::max(_k, vColour);
73 for (IncEdgeIt e(_g, v); e != lemon::INVALID; ++e) {
74 Node n = _g.oppositeNode(v, e);
78 if (oldColour != -1) {
79 _lca -= abs(nColour - oldColour);
82 _lca += abs(nColour - vColour);
117 for (NodeIt v(_g); v != lemon::INVALID; ++v) {
169 return abs(_c[_g.u(e)] - _c[_g.v(e)]);
195 for (EdgeIt e(_g); e != lemon::INVALID; ++e) {
196 _lca += std::abs(_c[_g.u(e)] - _c[_g.v(e)]);
MinLCAStatus _s
The status of the solution.
long long lcaValue() const
Value (cost) of the current solution.
virtual void init()
Reset the data structures of the algorithm.
virtual void setColour(const Node &v, int vColour)
Set the colour of a vertex.
MinLCAStatus
Possible status for MinLCA solution.
const Graph & _g
A const reference to the graph we want to arrange.
int _k
Largest index of the colours used.
Colouring _c
The vertex colouring.
Solution has been found after running.
int operator[](const Node &v) const
Colour of a vertex.
Default namespace Default namespace for MinLCA algorithms.
Algorithm has not run yet, or some other status.
Functions for reading graphs and getting graph properties.
int _max_k
Maximum number of colours allowed.
Base class for MinLCA algorithms.
int operator[](const Edge &e) const
Cost of an edge.
int totalColours() const
Total number of colours used.
Solution has not been found after running.
const Colouring & colouring() const
Current colouring.
void setSolutionNotFound()
Auxiliary function to set solution status to not found.
long long recalculateLca()
Force a recalculation of the cost for the current solution.
IntNodeMap Colouring
Type for graph colourings.
MinLCAStatus status() const
Status of the solution.
virtual MinLCAStatus run()
Run the algorithm.
int maxK()
Maximum number of allowed colours.
MinLCA(const Graph &g, int maxK=0)
Constructor for derived classes to use.
long long _lca
Cost of the current solution.
void setSolutionFound()
Auxiliary function to set solution status to found.
int maxDegree(const Graph &g)
Maximum degree of a graph.