edge_betweenness_centrality_subset#
- edge_betweenness_centrality_subset(G, sources, targets, normalized=False, weight=None)[source]#
计算边在节点子集上的介数中心性。
\[c_B(v) =\sum_{s\in S,t \in T} \frac{\sigma(s, t|e)}{\sigma(s, t)}\]其中 \(S\) 是源节点集合,\(T\) 是目标节点集合,\(\sigma(s, t)\) 是最短 \((s, t)\)-路径的数量,\(\sigma(s, t|e)\) 是通过边 \(e\) 的这些路径的数量 [2]。
- 参数:
- G图
一个 networkx 图。
- sources:节点列表
用于计算介数中心性时作为最短路径源节点的列表
- targets:节点列表
用于计算介数中心性时作为最短路径目标节点的列表
- normalizedbool, 可选
如果为 True,则介数中心性值将被归一化。对于无向图,归一化因子为
2/(n(n-1))
;对于有向图,归一化因子为1/(n(n-1))
,其中n
是图 G 中的节点数。- weightNone 或 string, 可选 (默认=None)
如果为 None,则所有边权重视为相等。否则,此参数为用作权重的边属性名称。权重用于计算加权最短路径,因此它们被解释为距离。
- 返回:
- edges字典
一个字典,键为边,值为该边的介数中心性。
另请参阅
betweenness_centrality
edge_load
注意
基本算法来自 [1]。
对于加权图,边的权重必须大于零。零权重的边可能导致节点对之间存在无限多条等长路径。
归一化方式可能看起来有点奇怪,但它与 edge_betweenness_centrality() 中的方式相同,旨在使 edge_betweenness_centrality(G) 的结果与 edge_betweenness_centrality_subset(G,sources=G.nodes(),targets=G.nodes()) 的结果一致。
参考文献
[1]Ulrik Brandes, A Faster Algorithm for Betweenness Centrality. Journal of Mathematical Sociology 25(2):163-177, 2001. https://doi.org/10.1080/0022250X.2001.9990249
[2]Ulrik Brandes: On Variants of Shortest-Path Betweenness Centrality and their Generic Computation. Social Networks 30(2):136-145, 2008. https://doi.org/10.1016/j.socnet.2007.11.001