Community strucure 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.
walktrap.community(graph, weights = E(graph)$weight, steps = 4, merges = TRUE, modularity = TRUE, labels = TRUE, membership = TRUE)
- The input graph, edge directions are ignored in directed graphs.
- The edge weights.
- 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
membershipargument is true, then it will be always calculated.
- Logical scalar, if
TRUEand the graph has a vertex attribute called
namethen it will be included in the result, in the list member called
- 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, http://arxiv.org/abs/physics/0512106
- A named list with three members:
merges The merges performed by the algorithm will be stored here. Each merge is a row in a two-column matrix and contains the ids of the merged communities. Communities are numbered from zero and cluster number smaller than the number of nodes in the network belong to the individual vertices as singleton communities. In each step a new community is created from two other communities and its id will be one larger than the largest community id so far. This means that before the first merge we have
ncommunities (the number of vertices in the graph) numbered from zero to
n-1. The first merge created community
n, the second community
modularity Numeric vector, the modularity score of the current community structure after each merge operation. labels The labels of the vertices in the graph. The
namevertex attribute will be copied here, if exists.
membership If requested, then the membership vector that belongs to the best split, in terms of highest modularity score.
- Random walk
- Community structure
Pascal Pons, Matthieu Latapy: Computing communities in large networks using random walks, http://arxiv.org/abs/physics/0512106
g <- graph.full(5) %du% graph.full(5) %du% graph.full(5) g <- add.edges(g, c(0,5, 0,10, 5, 10)) walktrap.community(g)