简体   繁体   English

R,igraph walktrap.community在完全连接的图的情况下拆分所有节点

[英]R, igraph walktrap.community splits all nodes in the case of a fully connected graph

Using the walktrap.community approach for defining communities within my graph works great - of all the algorithms I tested it performs the best. 使用walktrap.community方法在图形中定义社区非常有效-在我测试过的所有算法中,效果最佳。 The caveat is that in the case of a fully connected graph with no self linkages (every node connects to each other node, but not itself) each node is assigned its own community. 需要注意的是,在没有自我链接的完全连接图的情况下(每个节点都彼此连接,但不是自身连接),每个节点都被分配了自己的社区。

I am not experienced in network analysis but this seems like an interesting case and its certainly not desired behavior. 我没有网络分析方面的经验,但这似乎是一个有趣的案例,并且它当然不是所希望的行为。 How can I avoid this splitting in my actual data? 如何避免在实际数据中出现这种分裂?

library(igraph)
match.mat = matrix(T, nrow=8, ncol=8)

diag(match.mat)[1:8] = T
topology = which(match.mat, arr.ind=T)
g = graph.data.frame(topology, directed=F)
cm = walktrap.community(g)
membership(cm)

# 2 3 4 5 6 7 8 1 
# 1 1 1 1 1 1 1 1 

plot(cm, g)

分组网络

diag(match.mat)[1:8] = F
topology = which(match.mat, arr.ind=T)
g = graph.data.frame(topology, directed=F)
cm = walktrap.community(g)
membership(cm)

#2 3 4 5 6 7 8 1 
#1 2 3 4 5 6 7 8 

plot(cm, g)

分割网络

Conceptually I'm not sure how the lack of self linkages would lead to every node being split - maybe possible communities are all tied and therefore split? 从概念上讲,我不确定缺少自我链接会如何导致每个节点被拆分-可能所有社区都被捆绑在一起并因此分裂了? But the case of all self linkages would seem equivalent in that regard. 但是,在这方面,所有自我联系的情况似乎是等效的。

Thanks! 谢谢!

http://www-rp.lip6.fr/~latapy/Publis/communities.pdf http://www-rp.lip6.fr/~latapy/Publis/communities.pdf

If you have read the paper carefully, you will note that the Walktrap builds a node distance measure based on the random walk transition matrix. 如果您已仔细阅读本文,您将注意到Walktrap基于随机行走过渡矩阵构建节点距离度量。 However, this transition matrix needs to be ergodic, therefore its underlying adjacency matrix needs to be connected and non-bipartite. 但是,此转换矩阵需要是遍历遍历的,因此其底层邻接矩阵需要是连通的且不可分割。 Non-bipartiteness is achieved by adding self loops to the nodes. 通过将自环添加到节点来实现非双向性。 Therefore, you need to add self loops to each node in your graph. 因此,您需要将自循环添加到图形中的每个节点。 Maybe it will be a good idea for the future to include this correction in the igraph package, but as far as I know they are using the C implementation of Latapy and Pons and for this one the graph needs to have self loops. 将来在igraph程序包中包含此更正可能是一个好主意,但据我所知,他们正在使用Latapy和Pons的C实现,为此,该图需要具有自循环。 Hope this answers your question! 希望这能回答您的问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM