Skip to main content

Module community

Module community 

Source
Expand description

Community-detection algorithms (ALGO-CO-*). Phase 1: modularity (Newman-Girvan modularity of a partition). Phase 4: louvain multilevel community detection, leiden (Traag-Waltman-van Eck 2019), label_propagation (Raghavan-Albert-Kumara 2007 + Traag-Šubelj 2023 fast variant), fluid_communities (Parés et al. 2017), edge_betweenness_community (Girvan-Newman 2002), fast_greedy_modularity (Clauset-Newman-Moore 2004), walktrap (Pons-Latapy 2005), leading_eigenvector (Newman 2006), infomap (Rosvall-Bergstrom 2008), spinglass (Reichardt-Bornholdt 2006). Helpers: community_to_membership (cut a dendrogram at k merges), reindex_membership (densify a membership vector to 0..k-1 by first occurrence).

Structs§

CommunityToMembershipResult
Result of community_to_membership: per-vertex cluster ids densified to 0..k, plus the size of each cluster in the same order.
CommunityVoronoiResult
Result of community_voronoi.
EdgeBetweennessResult
Result of edge_betweenness_community.
FastGreedyResult
Result of fast_greedy_modularity / fast_greedy_modularity_weighted.
FluidOptions
Full option bag for fluid_communities_with_options.
FluidResult
Result of fluid_communities / fluid_communities_with_options.
InfomapResult
Result of an Infomap run.
LeadingEigenvectorResult
Result of the leading eigenvector community detection.
LeidenOptions
Full set of options for leiden_with_options. Construct via LeidenOptions::default() and then mutate the fields you care about, mirroring the way upstream C exposes per-parameter defaults.
LeidenResult
Result of a Leiden run.
LouvainResult
Result of a Louvain run.
LpaOptions
Full option bag for label_propagation_with_options.
LpaResult
Result of a label-propagation run.
ReindexMembershipResult
Result of reindex_membership: a densified membership vector [0, k), the old cluster id behind each new id (so new_to_old[i] is the original id that now maps to i), and the number of distinct clusters k = new_to_old.len().
SpinglassOptions
Options for spinglass community detection.
SpinglassResult
Result of spinglass community detection.
SplitJoinDistance
Asymmetric split-join distances between two community partitions.
WalktrapOptions
Tuning knobs for walktrap_with_options.
WalktrapResult
Result of walktrap / walktrap_weighted / walktrap_with_options.

Enums§

CommunityComparison
Which partition-comparison measure compare_communities returns.
LeidenObjective
Quality function (objective) that Leiden optimises. Mirrors igraph_leiden_objective_t.
LpaVariant
Which variant of label propagation to run. Mirrors igraph_lpa_variant_t.
SpinglassUpdateRule
Update rule for the spinglass null model.

Constants§

FLUID_DEFAULT_MAX_ITERATIONS
Default safety cap on outer iterations for fluid_communities / fluid_communities_with_options.
LEIDEN_DEFAULT_BETA
Default randomness used in the refinement step — same default as upstream igraph_community_leiden_simple (β = 0.01).
LEIDEN_DEFAULT_ITERATIONS
Default number of outer iterations. The reference paper and upstream both note that two iterations are usually enough.
SPINGLASS_DEFAULT_SPINS
Default number of spins for spinglass.
WALKTRAP_DEFAULT_STEPS
Default random-walk length matching the igraph reference (steps = 4).

Functions§

community_to_membership
Cut a binary dendrogram at steps merges, returning the resulting membership and cluster-size vectors.
community_voronoi
Voronoi-based community detection.
compare_communities
Compare two community membership vectors over the same vertex set.
edge_betweenness_community
Run edge-betweenness community detection on graph.
edge_betweenness_community_weighted
Run weighted edge-betweenness community detection on graph with per-edge weights.
fast_greedy_modularity
Run fast greedy modularity community detection on graph (unweighted).
fast_greedy_modularity_weighted
Run fast greedy modularity community detection on graph with edge weights.
fluid_communities
Run Fluid Communities with default options (seed = 0, max_iterations = FLUID_DEFAULT_MAX_ITERATIONS).
fluid_communities_with_options
Run Fluid Communities with full option control.
infomap
Run Infomap with the default options (unweighted, 1 trial).
infomap_weighted
Run Infomap with per-edge weights (1 trial).
infomap_with_options
Run Infomap with full control over parameters.
label_propagation
Run label propagation with the default options (LpaVariant::Fast, no initial labels, no fixed vertices, seed 0).
label_propagation_weighted
Run label propagation with per-edge weights (default variant, no initial labels, no fixed vertices, seed 0).
label_propagation_with_options
Run label propagation with the full option bag.
le_community_to_membership
Cut an incomplete dendrogram after steps merges, starting from an initial (non-singleton) cluster assignment.
leading_eigenvector
Detect communities using Newman’s leading eigenvector method.
leading_eigenvector_weighted
Weighted leading eigenvector community detection (convenience wrapper).
leiden
Run Leiden with the default modularity objective, γ = 1, β = 0.01, two iterations, seed 0.
leiden_weighted
Run Leiden with per-edge weights (modularity objective, γ = 1, β = 0.01, two iterations, seed 0).
leiden_with_options
Run Leiden with the full set of options.
louvain
Run Louvain with the default options (γ = 1, unweighted, deterministic seed 0).
louvain_weighted
Run Louvain with per-edge weights (γ = 1, deterministic seed 0).
louvain_with_options
Run Louvain with the full set of options.
modularity
Modularity of graph with respect to community assignment membership.
modularity_directed
Directed modularity (Leicht-Newman, ALGO-CO-001b).
modularity_matrix
Compute the modularity matrix B of a graph.
modularity_weighted
Weighted modularity (ALGO-CO-001c).
reindex_membership
Relabel a membership vector so cluster ids run contiguously over 0..k, where k is the number of distinct clusters. The partition is unchanged: two vertices share a cluster in the output iff they shared one in the input. New ids are assigned in first-occurrence order — the first cluster id you encounter when sweeping left to right becomes 0, the next new one becomes 1, and so on.
spinglass
Spinglass community detection with default options.
spinglass_weighted
Spinglass community detection with edge weights.
spinglass_with_options
Spinglass community detection with full options.
split_join_distance
Compute the two asymmetric projection distances between comm1 and comm2.
walktrap
Run Walktrap on an unweighted, undirected graph with default steps = 4.
walktrap_weighted
Run Walktrap on a weighted, undirected graph with default steps = 4.
walktrap_with_options
Run Walktrap with a custom WalktrapOptions.