Class ColoringGreedy
- All Implemented Interfaces:
ColoringAlgo
,RandomizedAlgorithm
The algorithm examine the vertices in a random order and assign for each vertex the minimum (integer) color which is not used by its neighbors.
The algorithm runs in linear time, assuming the number of colors is constant.
For deterministic behavior, set the seed using setSeed(long)
.
Note that the result is an approximation for the minimum number of colors, as finding an optimal coloring is an NP-hard problem.
- Author:
- Barak Ugav
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
setSeed
(long seed) Sets the seed for the random number generator.Methods inherited from class com.jgalgo.alg.color.ColoringAlgoAbstract
computeColoring
-
Constructor Details
-
ColoringGreedy
public ColoringGreedy()Create a new coloring algorithm object.Please prefer using
ColoringAlgo.newInstance()
to get a default implementation for theColoringAlgo
interface.
-
-
Method Details
-
setSeed
public void setSeed(long seed) Description copied from interface:RandomizedAlgorithm
Sets the seed for the random number generator.The algorithm will use the same seed for the random number generator, in order to perform deterministically. Note that if methods of the algorithm are called multiple times, the seed should be set before each call.
- Specified by:
setSeed
in interfaceRandomizedAlgorithm
- Parameters:
seed
- the seed for the random number generator.
-