edge_betweenness_partition#
- edge_betweenness_partition(G, number_of_sets, *, weight=None)[source]#
通过迭代移除边介数最高的边创建的划分。
此算法通过计算所有边的边介数并移除值最高的边来工作。然后确定图是否已分解为至少
number_of_sets
个连通分量。如果不是,则重复此过程。- 参数:
- GNetworkX Graph, DiGraph 或 MultiGraph
待划分的图
- number_of_setsint
图期望划分中的集合数量
- weight键,可选,默认值=None
如果使用权重计算边介数,则使用的键
- 返回值:
- C集合列表
G 节点的划分
- 引发:
- NetworkXError
如果 number_of_sets <= 0 或 number_of_sets > len(G)
注意
此算法相当慢,因为连通分量和边介数的计算都依赖于所有节点对最短路径算法。它们有可能可以结合起来以减少总体计算时间。
参考文献
[1]Santo Fortunato ‘图中的社区检测’ Physical Reports Volume 486, Issue 3-5 p. 75-174 http://arxiv.org/abs/0906.0612
示例
>>> 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