Class GraphColoring<N,​E>

  • Type Parameters:
    N - Value type that the graph node stores.
    E - Value type that the graph edge stores.
    Direct Known Subclasses:
    GraphColoring.GreedyGraphColoring

    public abstract class GraphColoring<N,​E>
    extends java.lang.Object
    Annotates the graph with a color in a way that no connected node will have the same color. Nodes of the same color can then be partitioned together and be represented by a super node. This class will merely annotate the nodes with a color using Annotatable.setAnnotation(Annotation) and provide a node to super node mapping with getPartitionSuperNode(Object). The given graph itself will not be modified.

    This algorithm is NOT deterministic by default. Passes that requires deterministic output should provide a Comparator in the constructor as a tie-breaker. This tie-break will be used when deciding which node should be colored first when multiple nodes have the same degree.

    • Field Detail

      • colorToNodeMap

        protected N[] colorToNodeMap
    • Constructor Detail

    • Method Detail

      • getPartitionSuperNode

        public N getPartitionSuperNode​(N node)
        Using the coloring as partitions, finds the node that represents that partition as the super node. The first to retrieve its partition will become the super node.