使用igraph在python中绘制图形
我的代码的格式如下所示。如何在图形中输出communities对象?我尝试使用plot(communities),但我得到的不支持plot使用igraph在python中绘制图形,python,plot,graph,igraph,Python,Plot,Graph,Igraph,我的代码的格式如下所示。如何在图形中输出communities对象?我尝试使用plot(communities),但我得到的不支持plot import igraph as ig from edgeboost.EdgeBoost import CommunityEdgeBoost G = ig.Graph.Erdos_Renyi(200,0.1) #creates EdgeBoost object ... edgeBooster = CommunityEdgeBoost(lambda
import igraph as ig
from edgeboost.EdgeBoost import CommunityEdgeBoost
G = ig.Graph.Erdos_Renyi(200,0.1)
#creates EdgeBoost object
... edgeBooster = CommunityEdgeBoost(lambda
x:x.community_multilevel(),"common_neighbors",numIterations = 10)
#detect communities
... communities = edgeBooster.detect_communities(G)
print communities
[[0, 34, 55, 57, 94, 136, 191, 105, 116, 124, 170], [1, 24, 36, 98,
100, 142, 150, 173, 38, 43, 44, 51, 66, 69, 84, 97, 141, 155, 185],
[2, 74, 83, 6, 31, 48, 109, 113, 121, 127, 160, 163, 174, 175],
.....]
这很容易。使用此选项:
import igraph as ig
from edgeboost.EdgeBoost import CommunityEdgeBoost
G = ig.Graph.Erdos_Renyi(200,0.1)
#creates EdgeBoost object
edgeBooster = CommunityEdgeBoost(lambda x:x.community_multilevel(),"common_neighbors",numIterations = 10)
#detect communities
communities = edgeBooster.detect_communities(G)
下面是诀窍:
对您想要的社区重复上述操作。
另请参见:查看我的答案并让我知道
# Define the community/subgraph/subnetwork
community_0 = G.subgraph(communities[0])
#plot it
ig.plot(community_0)