is_graphical#

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

如果序列是一个有效的度序列,则返回 True。

度序列是有效的,如果某些图可以实现它。

Parameters:
sequence列表或可迭代容器

一个整数节点度的序列

method“eg” | “hh” (默认:’eg’)

用于验证度序列的方法。 “eg” 对应于 Erdős-Gallai 算法 [EG1960], [choudum1986],以及 “hh” 对应于 Havel-Hakimi 算法 [havel1955], [hakimi1962], [CL1996]

Returns:
validbool

如果序列是有效的度序列,则为 True,否则为 False。

References

[EG1960]

Erdős 和 Gallai, Mat. Lapok 11 264, 1960.

[choudum1986]

S.A. Choudum. “A simple proof of the Erdős-Gallai theorem on graph sequences.” Bulletin of the Australian Mathematical Society, 33, pp 67-70, 1986. https://doi.org/10.1017/S0004972700002872

[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 和 L. Lesniak, “Graphs and Digraphs”, Chapman and Hall/CRC, 1996.

Examples

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

测试一个非图形序列: >>> sequence_list = [d for n, d in G.degree()] >>> sequence_list[-1] += 1 >>> nx.is_graphical(sequence_list) False