Learn R Programming

cograph (version 2.0.0)

community_walktrap: Walktrap Community Detection

Description

Detects communities via random walks. Nodes within the same community tend to have short random walk distances.

Usage

community_walktrap(
  x,
  weights = NULL,
  steps = 4,
  merges = TRUE,
  modularity = TRUE,
  membership = TRUE,
  ...
)

com_wt( x, weights = NULL, steps = 4, merges = TRUE, modularity = TRUE, membership = TRUE, ... )

Value

A cograph_communities object

A cograph_communities object. See detect_communities.

Arguments

x

Network input

weights

Edge weights. NULL uses network weights, NA for unweighted.

steps

Number of random walk steps. Default 4.

merges

Logical; return merge matrix? Default TRUE.

modularity

Logical; return modularity scores? Default TRUE.

membership

Logical; return membership vector? Default TRUE.

...

Additional arguments passed to to_igraph

References

Pons, P., & Latapy, M. (2006). Computing communities in large networks using random walks. Journal of Graph Algorithms and Applications, 10(2), 191-218.

Examples

Run this code
if (requireNamespace("igraph", quietly = TRUE)) {
  g <- igraph::make_graph("Zachary")

  # Default 4 steps
  comm <- community_walktrap(g)

  # More steps for larger communities
  comm2 <- community_walktrap(g, steps = 8)
}

Run the code above in your browser using DataLab