Package org.graph4j.realization
Class HavelHakimiGraphRealization
java.lang.Object
org.graph4j.realization.HavelHakimiGraphRealization
- All Implemented Interfaces:
GraphRealizationAlgorithm
This class provides a method to generate a graph from a given degree
sequence, using the Havel-Hakimi algorithm.
The time complexity is O(n^2 log n), where n is the number of vertices.
- Author:
- Cristian Frăsinaru
-
Constructor Summary
ConstructorsConstructorDescriptionHavelHakimiGraphRealization(int[] degreeSequence) Creates an algorithm for the graph realization problem. -
Method Summary
-
Constructor Details
-
HavelHakimiGraphRealization
public HavelHakimiGraphRealization(int[] degreeSequence) Creates an algorithm for the graph realization problem.- Parameters:
degreeSequence- a degree sequence.
-
-
Method Details
-
isGraphic
public boolean isGraphic()Description copied from interface:GraphRealizationAlgorithmChecks if the degree sequence is graphic.- Specified by:
isGraphicin interfaceGraphRealizationAlgorithm- Returns:
trueif the sequence is graphic,falseotherwise.
-
getGraph
Description copied from interface:GraphRealizationAlgorithmCreates a graph with the specified degree sequence. The vertices of the graph are numbered from 0 to n - 1, where n is the length of the sequence.- Specified by:
getGraphin interfaceGraphRealizationAlgorithm- Returns:
- a graph with the specified degree sequence.
-