onion_layers#
- onion_layers(G)[source]#
返回图中洋葱分解中每个顶点的层。
洋葱分解通过提供关于每个k-壳内部组织的信息来细化k-核分解。它通常与
core numbers
一起使用。- 参数:
- GNetworkX 图
无自环的无向图。
- 返回:
- od_layers字典
一个字典,键为节点,值为其洋葱层。层是起始于 1 的连续整数。
- 引发:
- NetworkXNotImplemented
如果
G
是多重图或有向图,或者包含自环。
另请参阅
参考文献
[1]Multi-scale structure and topological anomaly detection via a new network statistic: The onion decomposition L. Hébert-Dufresne, J. A. Grochow, and A. Allard Scientific Reports 6, 31708 (2016) http://doi.org/10.1038/srep31708
[2]Percolation and the effective structure of complex networks A. Allard and L. Hébert-Dufresne Physical Review X 9, 011023 (2019) http://doi.org/10.1103/PhysRevX.9.011023
示例
>>> 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.onion_layers(H) {6: 1, 0: 2, 4: 3, 1: 4, 2: 4, 3: 4, 5: 4}