cluster_walktrap: Community structure via short random walks

View source: R/community.R

cluster_walktrapR Documentation

Community structure via short random walks


This function tries to find densely connected subgraphs, also called communities in a graph via random walks. The idea is that short random walks tend to stay in the same community.


  weights = NULL,
  steps = 4,
  merges = TRUE,
  modularity = TRUE,
  membership = TRUE



The input graph, edge directions are ignored in directed graphs.


The weights of the edges. It must be a positive numeric vector, NULL or NA. If it is NULL and the input graph has a ‘weight’ edge attribute, then that attribute will be used. If NULL and no such attribute is present, then the edges will have equal weights. Set this to NA if the graph was a ‘weight’ edge attribute, but you don't want to use it for community detection. Larger edge weights increase the probability that an edge is selected by the random walker. In other words, larger edge weights correspond to stronger connections.


The length of the random walks to perform.


Logical scalar, whether to include the merge matrix in the result.


Logical scalar, whether to include the vector of the modularity scores in the result. If the membership argument is true, then it will always be calculated.


Logical scalar, whether to calculate the membership vector for the split corresponding to the highest modularity value.


This function is the implementation of the Walktrap community finding algorithm, see Pascal Pons, Matthieu Latapy: Computing communities in large networks using random walks,


cluster_walktrap() returns a communities() object, please see the communities() manual page for details.


Pascal Pons ( and Gabor Csardi for the R and igraph interface


Pascal Pons, Matthieu Latapy: Computing communities in large networks using random walks,

See Also

See communities() on getting the actual membership vector, merge matrix, modularity score, etc.

modularity() and cluster_fast_greedy(), cluster_spinglass(), cluster_leading_eigen(), cluster_edge_betweenness(), cluster_louvain(), and cluster_leiden() for other community detection methods.

Community detection as_membership(), cluster_edge_betweenness(), cluster_fast_greedy(), cluster_fluid_communities(), cluster_infomap(), cluster_label_prop(), cluster_leading_eigen(), cluster_leiden(), cluster_louvain(), cluster_optimal(), cluster_spinglass(), compare(), groups(), make_clusters(), membership(), modularity.igraph(), plot_dendrogram(), split_join_distance()


g <- make_full_graph(5) %du% make_full_graph(5) %du% make_full_graph(5)
g <- add_edges(g, c(1, 6, 1, 11, 6, 11))

igraph documentation built on Aug. 10, 2023, 9:08 a.m.