V
- the graph vertex typeE
- the graph edge typepublic class GreedyColoring<V,E> extends Object implements VertexColoringAlgorithm<V>
The algorithm iterates over all vertices and assigns the smallest possible color that is not used by any neighbors. Subclasses may provide a different vertex ordering.
VertexColoringAlgorithm.Coloring<V>, VertexColoringAlgorithm.ColoringImpl<V>
Modifier and Type | Field and Description |
---|---|
protected Graph<V,E> |
graph
The input graph
|
protected static String |
SELF_LOOPS_NOT_ALLOWED
Error message if the input graph contains self-loops.
|
Constructor and Description |
---|
GreedyColoring(Graph<V,E> graph)
Construct a new coloring algorithm.
|
Modifier and Type | Method and Description |
---|---|
VertexColoringAlgorithm.Coloring<V> |
getColoring()
Computes a vertex coloring.
|
protected Iterable<V> |
getVertexOrdering()
Get the ordering of the vertices used by the algorithm.
|
protected static final String SELF_LOOPS_NOT_ALLOWED
protected Iterable<V> getVertexOrdering()
public VertexColoringAlgorithm.Coloring<V> getColoring()
getColoring
in interface VertexColoringAlgorithm<V>
Copyright © 2018. All rights reserved.