问题描述
我使用fastgreedy.community生成一个社区对象,其中包含15个社区.但是如何提取这15个社区中最大的社区?
I use fastgreedy.community to generate a community object, which contains 15 communities. But how can I extract the largest community among these 15 communities?
Community sizes
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1862 1708 763 974 2321 1164 649 1046 2 2 2 2 2 2
15
2
在此示例中,我想提取社区5以便进一步使用.谢谢!
In this example, I want to extract the community 5 for further use.Thanks!
推荐答案
假定您的社区对象命名为 community.object
, which(membership(community.object)== x)
提取社区 x
中顶点的索引.如果需要最大的社区,可以将 x
设置为 which.max(sizes(community.object))
.最后,您可以使用 ductive.subgraph
将特定社区提取到单独的图形中:
Assuming that your community object is named community.object
, which(membership(community.object) == x)
extracts the indices of the vertices in community x
. If you want the largest, community, you can set x
to which.max(sizes(community.object))
. Finally, you can use induced.subgraph
to extract that particular community into a separate graph:
> x <- which.max(sizes(community.object))
> subg <- induced.subgraph(graph, which(membership(community.object) == x))
这篇关于人物:如何找到最大的社区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!