node_redundancy#
- node_redundancy(G, nodes=None)[源代码]#
计算二部图中节点的节点冗余系数
G
.节点的冗余系数
v
是的邻居对的分数v
它们都链接到其他节点。在单模投影中,这些节点将链接在一起,即使v
不在那里。更正式地说,对于任何顶点
v
, the redundancy coefficient of `v` 定义为\[rc(v)=\frac{| \{u,w\}\substeq N(v),\]在哪里?
N(v)
是一组邻居v
在里面G
.- 参数
- G图表
二部图
- nodes列表或可迭代(可选)
计算这些节点的冗余度。默认为G中的所有节点。
- 返回
- redundancy词典
以具有节点冗余值的节点为关键字的字典。
- 加薪
- NetworkXError
如果图(或中)中的任何节点
nodes
,如果指定的话)的(外)度小于2(根据冗余系数的定义,这将导致被零除)。
工具书类
- 1
Latapy、Matthieu、CL_mence Magnien和Nathalie del Vecchio(2008年)。分析大型双模网络的基本概念。社交网络30(1),31-48.
实例
计算图中每个节点的冗余系数:
>>> from networkx.algorithms import bipartite >>> G = nx.cycle_graph(4) >>> rc = bipartite.node_redundancy(G) >>> rc[0] 1.0
计算图表的平均冗余度:
>>> from networkx.algorithms import bipartite >>> G = nx.cycle_graph(4) >>> rc = bipartite.node_redundancy(G) >>> sum(rc.values()) / len(G) 1.0
计算一组节点的平均冗余度:
>>> from networkx.algorithms import bipartite >>> G = nx.cycle_graph(4) >>> rc = bipartite.node_redundancy(G) >>> nodes = [0, 2] >>> sum(rc[n] for n in nodes) / len(nodes) 1.0