How to find measures after community detection in igraph (R)?

馋奶兔 提交于 2019-11-30 04:25:43

Well, we can just adapt your code to loop over the different subgroups

karate <- graph.famous("Zachary")
wckarate <- walktrap.community(karate) #any algorithm
sapply(unique(membership(wckarate)), function(g) {
    subg1<-induced.subgraph(karate, which(membership(wckarate)==g)) #membership id differs for each cluster
    ecount(subg1)/ecount(karate)
})

and as far as getting the edges between the communities, you could do

#get all combinations of communities
cs <- data.frame(combn(unique(membership(wckarate)),2))
cx <- sapply(cs, function(x) {
    es<-E(karate)[V(karate)[membership(wckarate)==x[1]] %--% 
              V(karate)[membership(wckarate)==x[2]]]    
    length(es)
})
cbind(t(cs),cx)

Also you can plot the communities to make sure that looks reasonable

plot.communities(wckarate, karate)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!