我使用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
Run Code Online (Sandbox Code Playgroud)
在此示例中,我想提取社区5以供进一步使用.谢谢!
假设您的社区对象已命名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))
Run Code Online (Sandbox Code Playgroud)