我使用fastgreedy.community生成一个社区对象,其中包含15个社区。但是,我如何提取这15个社区中最大的社区呢?
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以供进一步使用。谢谢!
发布于 2013-02-27 17:33:47
假设您的社区对象名为community.object,which(membership(community.object) == x)将提取社区x中顶点的索引。如果你想要最大的社区,你可以将x设置为which.max(sizes(community.object))。最后,您可以使用induced.subgraph将特定的社区提取到一个单独的图中:
> x <- which.max(sizes(community.object))
> subg <- induced.subgraph(graph, which(membership(community.object) == x))https://stackoverflow.com/questions/15103744
复制相似问题