Package org.tinfour.utils
Class VertexColorizerKempe6
- java.lang.Object
-
- org.tinfour.utils.VertexColorizerKempe6
-
public class VertexColorizerKempe6 extends Object
Assign vertices color index values so that no two connected vertices have the same color. The algorithm used for the assignment is based on Alfred Kempe's 6-color colorization scheme. Vertices will be assigned color indices in the range 0 to 5. These can be applied by rendering applications as required.This implementation runs in O(n^2) time.
A 5-color algorithm for color-coding vertices also exists and has similar time-complexity as this implementation. It is more complicated than this routine, but not unreasonably so. Therefore, the Tinfour project may consider the 5-color algorithm for future implementations.
-
-
Constructor Summary
Constructors Constructor Description VertexColorizerKempe6()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassignColorsToVertices(IIncrementalTin tin)Assign color index values to vertices.booleanverifyAssignments(IIncrementalTin tin, PrintStream ps)A test utility for verifying the results from the assignColorsToVertices method.
-
-
-
Method Detail
-
assignColorsToVertices
public void assignColorsToVertices(IIncrementalTin tin)
Assign color index values to vertices.- Parameters:
tin- a valid instance
-
verifyAssignments
public boolean verifyAssignments(IIncrementalTin tin, PrintStream ps)
A test utility for verifying the results from the assignColorsToVertices method. This method is intended for debugging and development purposes only.This method tests for two potential failure conditions.
- a vertex that was not assigned a valid color.
- a pair of adjacent vertices assigned the same color
- Parameters:
tin- a valid instanceps- a optional print source, or a null if no output is desired.- Returns:
- true if the color indices for the vertices in the TIN are successfully assigned; otherwise, false.
-
-