0

I am trying to create a dendrogram of the communities only of a network. The example code below gives me a dendrogram of all the nodes, but as I work with a relatively large dataset, I would like to create a dendrogram of only the comunities,so that I would have a smaller dendrogram with only the communities, is this possible?

library(igraph)
set.seed(1)    
g001 <- erdos.renyi.game(100, 1/10, directed = FALSE)

fc01 <- fastgreedy.community(g001)
colors <- rainbow(max(membership(fc01)))
plot(g001, vertex.size=2, vertex.label=NA, vertex.color=colors[membership(fc01)] )

dendPlot(fc01, mode="phylo", cex=1)

Thank you.

4

1 回答 1

0

dendrogram 类有一个cut函数可以用来在某个高度分割树状图。该community算法似乎根据有多少物体使用高度。因此,鉴于fc01上面的对象,您可以将其拆分为子组

ss01 <- cut(as.dendrogram(fc01), h=length(membership(fc01))-length(fc01))$lower

这为我创建了 5 个组。我们可以绘制整个集合和 5 个子集

layout(matrix(1:6, nrow=2))
dendPlot(fc01, mode="hclust")
lapply(ss01, plot, cex=1)

所以每个子图都在ss01[[1]], ss02[[2]], 等...

于 2014-07-14T03:59:44.547 回答