[英]Detecting communities results in isolated nodes
I am trying to gather some communities form my graph. 我正在尝试从我的图表中收集一些社区。 However, the resulting communities consist of isolated nodes, which contradicts my understanding of communities. 但是,由此产生的社区由孤立的节点组成,这与我对社区的理解相矛盾。 Here is my essential R/igraph-code: 这是我的基本R / igraph代码:
g<-simplify(g)
print("isolates: ")
length(which(degree(g)==0)-1) # says 0
c<-fastgreedy.community(g)
cmem<-community.to.membership(g,c$merges,3081)
w<-which(cmem$membership==0)
sub<-subgraph(g,w)
print("isolates in subgraph: ")
length(which(degree(sub)==0)-1) # says > 0
Did I make a mistake? 我做错了吗? Thank you for your help. 谢谢您的帮助。
You have forgotten to subtract 1 from which(cmem$membership == 0)
, which is required because igraph indexes the nodes from zero, while R uses a 1-based indexing. 您忘记了从which(cmem$membership == 0)
减去1,这是必需的,因为igraph从零开始索引节点,而R使用基于1的索引。 Try it again with w <- which(cmem$membership == 0) - 1
and see if the isolates persist. 使用w <- which(cmem$membership == 0) - 1
再试一次,看隔离是否持久。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.