R igraph : how to find the largest community?

标签 r igraph

我使用 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 以供进一步使用。
谢谢!

最佳答案

假设您的社区对象名为 community.object , which(membership(community.object) == x)提取社区中顶点的索引x .如果你想要最大的社区,你可以设置xwhich.max(sizes(community.object)) .最后,您可以使用 induced.subgraph将该特定社区提取到单独的图表中:

> x <- which.max(sizes(community.object))
> subg <- induced.subgraph(graph, which(membership(community.object) == x))

关于R igraph : how to find the largest community?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15103744/

相关文章:

r - 从 R 中的列表中获取时的默认值

r - 编辑 strip 大小 ggplot2

r - 如何使用 R 创建包含聚合均值的列?

python - 绘制树状图,根节点在顶部

python - igraph 库出错 - 已弃用的库

r - 一次从矩阵中选择特定元素

r - 使用 Tidyverse 检查该值是否存在于任何其他列中

r - igraph 错误无法创建顶点数为负的空图

r - 在 R 中使用 iGraph 获取路径的权重

graph - 如何一次获取多个rna序列的图特征值?