Class GraphColoring<N,E>
java.lang.Object
com.google.javascript.jscomp.graph.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
Annotates the graph with a color in a way that no connected node will have
the same color. Nodes of the same color cab 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
give 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classGreedily assign nodes with high degree unique colors. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract intcolor()Annotates the graph withGraphColoring.Colorobjects usingAnnotatable.setAnnotation(Annotation).getGraph()getPartitionSuperNode(N node) Using the coloring as partitions, finds the node that represents that partition as the super node.
-
Field Details
-
colorToNodeMap
-
graph
-
-
Constructor Details
-
GraphColoring
-
-
Method Details
-
color
public abstract int color()Annotates the graph withGraphColoring.Colorobjects usingAnnotatable.setAnnotation(Annotation).- Returns:
- The number of unique colors need.
-
getPartitionSuperNode
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. -
getGraph
-