Skip to main content

sdivi_detection/
lib.rs

1//! Native Leiden community detection for sdivi-rust.
2//!
3//! Provides a fully deterministic, native Rust port of the Leiden algorithm
4//! (Traag et al. 2019) with Modularity and CPM quality functions.
5//!
6//! # Quick Start
7//!
8//! ```rust
9//! use sdivi_detection::leiden::run_leiden;
10//! use sdivi_detection::partition::{LeidenConfig, LeidenPartition};
11//! use sdivi_graph::dependency_graph::build_dependency_graph_from_edges;
12//!
13//! let dg = build_dependency_graph_from_edges(&[], &[]);
14//! let cfg = LeidenConfig::default();
15//! let partition = run_leiden(&dg, &cfg, None);
16//! assert_eq!(partition.community_count(), 0);
17//! ```
18
19pub mod leiden;
20pub mod partition;
21pub mod warm_start;
22
23pub use leiden::run_leiden;
24pub use leiden::run_leiden_with_weights;
25pub use partition::{LeidenConfig, LeidenPartition, QualityFunction};
26pub use warm_start::{initial_assignment_from_cache, CACHE_FILENAME};
27
28/// Internal test helpers — **not stable API**.
29///
30/// These re-exports exist solely for integration-test plumbing (e.g.
31/// `tests/aggregate_invariance.rs`).  They may be removed or renamed at any
32/// time; do not use them in production code.
33#[doc(hidden)]
34pub mod internal {
35    pub use crate::leiden::aggregate::{aggregate_network, AggregateResult};
36    pub use crate::leiden::graph::LeidenGraph;
37    pub use crate::leiden::quality::compute_modularity;
38    pub use crate::leiden::refine::{refine_partition, well_connected, RefinementState};
39}