This class contains member functions for calculate colorings with five and six colors. The six coloring algorithm is a simple greedy coloring on the backward minimum outgoing order of nodes. This order can be computed such way, that in each phase the node with least outgoing edges to unprocessed nodes is choosen. This order guarantees that at the time of coloring of a node it has at most five already colored adjacents. The five coloring algorithm works in the same way, but if the greedy approach fails to color with five color, ie. the node has five already different colored neighbours, it swaps the colors in one connected two colored set with the Kempe recoloring method. #include <lemon/planarity.h>
Public Types | |
typedef UGraph::template NodeMap< int > | IndexMap |
The map type for store color indexes. | |
typedef ComposeMap< Palette, IndexMap > | ColorMap |
The map type for store colors. | |
Public Member Functions | |
PlanarColoring (const UGraph &ugraph) | |
Constructor. | |
IndexMap | colorIndexMap () const |
Returns the NodeMap of color indexes. | |
ColorMap | colorMap () const |
Returns the NodeMap of colors. | |
int | colorIndex (const Node &node) const |
Returns the color index of the node. | |
Color | color (const Node &node) const |
Returns the color of the node. | |
bool | runSixColoring () |
Calculates a coloring with at most six colors. | |
template<typename EmbeddingMap > | |
void | runFiveColoring (const EmbeddingMap &embedding) |
Calculates a coloring with at most five colors. | |
bool | runFiveColoring () |
Calculates a coloring with at most five colors. |
PlanarColoring | ( | const UGraph & | ugraph | ) | [inline] |
Constructor
IndexMap colorIndexMap | ( | ) | const [inline] |
Returns the NodeMap of color indexes. The values are in the range [0..4] or
[0..5] according to the five coloring or six coloring.
ColorMap colorMap | ( | ) | const [inline] |
Returns the NodeMap of colors. The values are five or six distinct colors.
int colorIndex | ( | const Node & | node | ) | const [inline] |
Returns the color index of the node. The values are in the range [0..4] or
[0..5] according to the five coloring or six coloring.
Color color | ( | const Node & | node | ) | const [inline] |
Returns the color of the node. The values are five or six distinct colors.
bool runSixColoring | ( | ) | [inline] |
This function calculates a coloring with at most six colors. The time complexity of this variant is linear in the size of the graph.
void runFiveColoring | ( | const EmbeddingMap & | embedding | ) | [inline] |
This function calculates a coloring with at most five colors. The worst case time complexity of this variant is quadratic in the size of the graph.
bool runFiveColoring | ( | ) | [inline] |
This function calculates a coloring with at most five colors. The worst case time complexity of this variant is quadratic in the size of the graph, but it most cases it does not have to use Kempe recoloring method, in this case it is equivalent with the runSixColoring() algorithm.