Class 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 Detail

      • VertexColorizerKempe6

        public VertexColorizerKempe6()
    • 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.

        1. a vertex that was not assigned a valid color.
        2. a pair of adjacent vertices assigned the same color
        At this time, there are no known conditions under which the color-assignment algorithm fails.
        Parameters:
        tin - a valid instance
        ps - 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.