python库-networkx模块(二)
networkx模块(二)
1 算法
# 引入算法模块
from networkx.algorithms import community
1.1 communities 社区发现算法
# GN算法
G = nx.barbell_graph(5, 1)
communities_generator = community.girvan_newman(G)
top_level_communities = next(communities_generator)
next_level_communities = next(communities_generator)
sorted(map(sorted, next_level_communities)