is_valid_degree_sequence_havel_hakimi#

is_valid_degree_sequence_havel_hakimi(deg_sequence)[source]#

Returns True if deg_sequence can be realized by a simple graph.

The validation proceeds using the Havel-Hakimi theorem [havel1955], [hakimi1962], [CL1996]. Worst-case run time is \(O(s)\) where \(s\) is the sum of the sequence.

Parameters:
deg_sequencelist

A list of integers where each element specifies the degree of a node in a graph.

Returns:
validbool

True if deg_sequence is graphical and False if not.

Notes

The ZZ condition says that for the sequence d if

\[|d| >= \frac{(\max(d) + \min(d) + 1)^2}{4*\min(d)}\]

then d is graphical. This was shown in Theorem 6 in [1].

References

[1]

I.E. Zverovich and V.E. Zverovich. “Contributions to the theory of graphic sequences”, Discrete Mathematics, 105, pp. 292-303 (1992).

[havel1955]

Havel, V. “A Remark on the Existence of Finite Graphs” Casopis Pest. Mat. 80, 477-480, 1955.

[hakimi1962]

Hakimi, S. “On the Realizability of a Set of Integers as Degrees of the Vertices of a Graph.” SIAM J. Appl. Math. 10, 496-506, 1962.

[CL1996]

G. Chartrand and L. Lesniak, “Graphs and Digraphs”, Chapman and Hall/CRC, 1996.

Examples

>>> G = nx.Graph([(1, 2), (1, 3), (2, 3), (3, 4), (4, 2), (5, 1), (5, 4)])
>>> sequence = (d for _, d in G.degree())
>>> nx.is_valid_degree_sequence_havel_hakimi(sequence)
True

To test a non-valid sequence: >>> sequence_list = [d for _, d in G.degree()] >>> sequence_list[-1] += 1 >>> nx.is_valid_degree_sequence_havel_hakimi(sequence_list) False