Package org.graph4j.coloring
Class GreedyColoring
java.lang.Object
org.graph4j.SimpleGraphAlgorithm
org.graph4j.coloring.GreedyColoringBase
org.graph4j.coloring.GreedyColoring
- All Implemented Interfaces:
ColoringAlgorithm
- Direct Known Subclasses:
GreedyBandwithColoring,LargestDegreeFirstColoring,RandomGreedyColoring,SmallestDegreeLastColoring
The order in which vertices are colored is either according to their indices in the graph, or can be specified in the constructor.
- Author:
- Cristian Frăsinaru
-
Field Summary
FieldsFields inherited from class org.graph4j.coloring.GreedyColoringBase
colors, numColors, usedFields inherited from class org.graph4j.SimpleGraphAlgorithm
graph -
Constructor Summary
ConstructorsConstructorDescriptionGreedyColoring(Graph graph) The vertices will be colored in the order of their graph indices.GreedyColoring(Graph graph, int[] vertexOrdering) Creates a greedy algorithm that will color the vertices of the graph in the specified order.GreedyColoring(Graph graph, int[] vertexOrdering, boolean validateOrdering) Creates a greedy algorithm that will color the vertices of the graph in the specified order.Validation of the ordering is optional. -
Method Summary
Methods inherited from class org.graph4j.coloring.GreedyColoringBase
findColoring, findColoring, markUsedColor, updateMethods inherited from class org.graph4j.SimpleGraphAlgorithm
getGraphMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.graph4j.coloring.ColoringAlgorithm
getGraph, getHeuristicColoring, getLowerBound, getMaximalClique, isOptimalityEnsured, isSolvingComponents, isStoppingOnFailure, isValid
-
Field Details
-
pos
protected int pos -
vertexOrdering
protected int[] vertexOrdering
-
-
Constructor Details
-
GreedyColoring
The vertices will be colored in the order of their graph indices.- Parameters:
graph- the input graph.
-
GreedyColoring
Creates a greedy algorithm that will color the vertices of the graph in the specified order. Checks if the ordering is valid.- Parameters:
graph- the input graph.vertexOrdering- an ordering of the graph vertices.- Throws:
InvalidVertexOrdering- if the ordering is invalid.
-
GreedyColoring
Creates a greedy algorithm that will color the vertices of the graph in the specified order.Validation of the ordering is optional.- Parameters:
graph- the input graph.vertexOrdering- an ordering of the graph vertices.validateOrdering-trueif the order should be validate,falseotherwise.- Throws:
InvalidVertexOrdering- if the ordering is invalid.
-
-
Method Details
-
init
protected void init()- Overrides:
initin classGreedyColoringBase
-
hasUncoloredVertices
protected boolean hasUncoloredVertices()- Specified by:
hasUncoloredVerticesin classGreedyColoringBase
-
nextUncoloredVertex
protected int nextUncoloredVertex()- Specified by:
nextUncoloredVertexin classGreedyColoringBase
-