Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

networkx.algorithms.graphical.is_graphical

is_graphical(sequence, method='eg')[source]

Returns True if sequence is a valid degree sequence.

A degree sequence is valid if some graph can realize it.

Parameters:
  • sequence (list or iterable container) – A sequence of integer node degrees
  • method (“eg” | “hh”) – The method used to validate the degree sequence. “eg” corresponds to the Erdős-Gallai algorithm, and “hh” to the Havel-Hakimi algorithm.
Returns:

valid – True if the sequence is a valid degree sequence and False if not.

Return type:

bool

Examples

>>> G = nx.path_graph(4)
>>> sequence = (d for n, d in G.degree())
>>> nx.is_graphical(sequence)
True

References

Erdős-Gallai
[EG1960], [choudum1986]
Havel-Hakimi
[havel1955], [hakimi1962], [CL1996]