简体   繁体   中英

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. 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

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. 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. Hope this answers your question!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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