k_shell#

k_shell(G, k=None, core_number=None)[source]#

返回图 G 的 k-shell。

k-shell 是由核心数为 k 的节点诱导的子图。也就是说,k-core 中不在 (k+1)-core 中的节点。

自 3.3 版本弃用:k_shell 在 3.5 版本中将不再接受 MultiGraph 对象。

参数:
GNetworkX graph

图或有向图。

kint, optional

shell 的阶数。如果未指定,则返回外部 shell。

core_numberdictionary, optional

图 G 的预计算核心数。

返回:
GNetworkX graph

k-shell 子图

引发:
NetworkXNotImplemented

k-shell 未实现用于多重图或带有自环的图。

另请参阅

core_number
k_corona

注意

这类似于 k_corona,但在 k_corona 中只考虑 k-core 中的邻居。

对于有向图,节点度定义为入度 + 出度。

图、节点和边的属性将复制到子图。

参考

[1]

使用 k-shell 分解的互联网拓扑模型 Shai Carmi, Shlomo Havlin, Scott Kirkpatrick, Yuval Shavitt, and Eran Shir, PNAS July 3, 2007 vol. 104 no. 27 11150-11154 http://www.pnas.org/content/104/27/11150.full

示例

>>> degrees = [0, 1, 2, 2, 2, 2, 3]
>>> H = nx.havel_hakimi_graph(degrees)
>>> H.degree
DegreeView({0: 1, 1: 2, 2: 2, 3: 2, 4: 2, 5: 3, 6: 0})
>>> nx.k_shell(H, k=1).nodes
NodeView((0, 4))