介数中心性#

betweenness_centrality(G, nodes)[source]#

计算二分网络中节点的介数中心性。

节点的介数中心性 v 是通过 v 的所有节点对最短路径的比例总和。

介数值通过最大可能值进行归一化,对于二分图,最大可能值受两个节点集相对大小的限制 [1]

n 为节点集 U 中的节点数,m 为节点集 V 中的节点数,则 U 中的节点通过除以以下值进行归一化:

\[\frac{1}{2} [m^2 (s + 1)^2 + m (s + 1)(2t - s - 1) - t (2s - t + 3)] ,\]

其中

\[s = (n - 1) \div m , t = (n - 1) \mod m ,\]

V 中的节点通过除以以下值进行归一化:

\[\frac{1}{2} [n^2 (p + 1)^2 + n (p + 1)(2r - p - 1) - r (2p - r + 3)] ,\]

其中,

\[p = (m - 1) \div n , r = (m - 1) \mod n .\]
参数:
G

一个二分图

nodes列表或容器

包含其中一个二分节点集中所有节点的容器。

返回:
betweenness字典

字典,以节点为键,对应的二分介数中心性为值。

注释

nodes 输入参数必须包含其中一个二分节点集中的所有节点,但返回的字典包含来自两个节点集的所有节点。有关 NetworkX 如何处理二分图的更多详细信息,请参阅 bipartite documentation

参考文献

[1]

Borgatti, S.P. and Halgin, D. In press. “Analyzing Affiliation Networks”. In Carrington, P. and Scott, J. (eds) The Sage Handbook of Social Network Analysis. Sage Publications. https://dx.doi.org/10.4135/9781446294413.n28

示例

>>> G = nx.cycle_graph(4)
>>> top_nodes = {1, 2}
>>> nx.bipartite.betweenness_centrality(G, nodes=top_nodes)
{0: 0.25, 1: 0.25, 2: 0.25, 3: 0.25}