COMMUNITY DETECTION

Method 1: M. E. J Newman ‘Networks: An Introduction’, page 224 Oxford University Press 2011.

from networkx.algorithms.community import greedy_modularity_communities
G = nx.karate_club_graph()
c = list(greedy_modularity_communities(G))
sorted(c[0])

Find communities in graph using Clauset-Newman-Moore greedy modularity maximization. This method currently supports the Graph class and does not consider edge weights.

Method 2:

j


 

draw networkX graph, from python 学习笔记2 --画图(networkx)

layout functions: 

pos = nx.spring_layout()

建立布局,对图进行布局美化,networkx 提供的布局方式有:
- circular_layout:节点在一个圆环上均匀分布
- random_layout:节点随机分布
- shell_layout:节点在同心圆上分布
- spring_layout: 用Fruchterman-Reingold算法排列节点(这个算法我不了解,样子类似多中心放射状)
- spectral_layout:根据图的拉普拉斯特征向量排列节
布局也可用pos参数指定,例如,nx.draw(G, pos = spring_layout(G)) 这样指定了networkx上以中心放射状分布.

 

posted @ 2019-11-19 19:19  keeps_you_warm  阅读(425)  评论(0编辑  收藏  举报