edge_betweenness_partition#
- edge_betweenness_partition(G, number_of_sets, *, weight=None)[source]#
由迭代移除具有最高边介数的边创建的分区。
该算法通过计算所有边的边介数并移除具有最高值的边来工作。然后确定图是否已被分解为至少
number_of_sets
个连通分量。如果没有,则重复该过程。- Parameters:
- GNetworkX 图、有向图或多图
要分区的图
- number_of_setsint
图的期望分区中的集合数量
- weight键, 可选, 默认=None
如果使用边介数计算的权重,则使用的键
- Returns:
- C集合列表
G的节点分区
- Raises:
- NetworkXError
如果number_of_sets <= 0或number_of_sets > len(G)
Notes
该算法相当慢,因为连通分量和边介数的计算都依赖于所有对最短路径算法。它们有可能被结合起来以减少总体计算时间。
References
[1]Santo Fortunato ‘Community Detection in Graphs’ Physical Reports Volume 486, Issue 3-5 p. 75-174 http://arxiv.org/abs/0906.0612
Examples
>>> G = nx.karate_club_graph() >>> part = nx.community.edge_betweenness_partition(G, 2) >>> {0, 1, 3, 4, 5, 6, 7, 10, 11, 12, 13, 16, 17, 19, 21} in part True >>> { ... 2, ... 8, ... 9, ... 14, ... 15, ... 18, ... 20, ... 22, ... 23, ... 24, ... 25, ... 26, ... 27, ... 28, ... 29, ... 30, ... 31, ... 32, ... 33, ... } in part True