社区度
import communityfrom community import community_louvainimport matplotlib.pyplot as pltimport networkx as nx # 画图'''社区发现'''G = nx.Graph()G.add_weighted_edges_from([(1,2,1),(1,9,1),(2,3,1),(2,5,1),(2,6,1),(3,5,1),(3,6,1),(3,9,1),(4,6,1),(4,7,1),(4,8,1),(5,6,1),(5,8,1),(7,8,1)])partition = community_louvain.best_partition(G)print(partition)
