检测社区导致孤立节点
我正在尝试从我的图表中收集一些社区。然而,由此产生的社区由孤立的节点组成,这与我对社区的理解相矛盾。 这是我的基本 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
我犯错了吗?感谢您的帮助。
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:
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您忘记了从
which(cmem$membership == 0)
中减去 1,这是必需的,因为 igraph 从零开始索引节点,而 R 使用基于 1 的索引。使用w <- which(cmem$membership == 0) - 1
再次尝试,看看隔离是否仍然存在。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. Try it again withw <- which(cmem$membership == 0) - 1
and see if the isolates persist.