Learn R Programming

cograph (version 2.0.0)

community_louvain: Louvain Community Detection

Description

Multi-level modularity optimization using the Louvain algorithm. Fast and widely used for large networks.

Usage

community_louvain(x, weights = NULL, resolution = 1, seed = NULL, ...)

com_lv(x, weights = NULL, resolution = 1, seed = NULL, ...)

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.

resolution

Resolution parameter. Higher values = more communities. Default 1 (standard modularity).

seed

Random seed for reproducibility. Default NULL.

...

Additional arguments passed to to_igraph

References

Blondel, V.D., Guillaume, J.L., Lambiotte, R., & Lefebvre, E. (2008). Fast unfolding of communities in large networks. Journal of Statistical Mechanics, P10008.

Examples

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

  # Reproducible result with seed
  comm1 <- community_louvain(g, seed = 42)
  comm2 <- community_louvain(g, seed = 42)
  identical(igraph::membership(comm1), igraph::membership(comm2))
}

Run the code above in your browser using DataLab