
Leiden or Louvain community detection on an igraph
leiden_clustering.RdModularity-based Leiden (Traag et al.) or Louvain (Blondel et al.) community
detection, run in Rust. Mirrors
igraph::cluster_leiden(objective_function = "modularity"), but the result
depends on seed only (not on the global RNG or the number of threads).
Communities are numbered by size, 1 being the largest.
Arguments
- graph
igraph. Undirected. If it has an edge attribute
weight, it is used, otherwise all edges get weight 1.- resolution
Numeric. Modularity resolution parameter. Higher values give more communities.
- algorithm
String. One of
c("leiden", "louvain").- beta
Numeric. Randomness of the Leiden refinement merges. Ignored for Louvain.
- n_iterations
Optional integer. Number of full iterations, each starting from the previous partition. A negative value iterates until the partition is stable. If
NULL,5Lfor Leiden and2Lfor Louvain, which gave the best modularity across synthetic graphs.- min_gain
Numeric. With a negative
n_iterations, also stop once an iteration gains no more than this in modularity.- local_moving
String. One of
c("queue", "coloured")."queue"is Traag's sequential queue."coloured"moves the nodes of one colour class in parallel, which only kicks in on larger levels of the graph.- seed
Integer. Random seed.
Examples
g <- igraph::make_graph("Zachary")
table(leiden_clustering(g))
#>
#> 1 2 3 4
#> 12 11 6 5