pub fn compute_persistence(
distance_matrix: &[Vec<f64>],
max_dim: usize,
max_epsilon: f64,
) -> Result<Vec<PersistenceDiagram>>Expand description
Compute persistent homology from a precomputed distance matrix.
Returns one PersistenceDiagram per homological dimension (H0, H1, …,
up to max_dim). The filtration is the Vietoris-Rips filtration: a
simplex enters at the maximum pairwise distance among its vertices.
This is equivalent to constructing a nested family of Vietoris-Rips
complexes parameterised by epsilon ∈ [0, max_epsilon].
§Arguments
distance_matrix— symmetric n×n matrix of pairwise distancesmax_dim— maximum homological dimension to compute (typically 1 or 2)max_epsilon— upper bound on the filtration parameter
§Example
use scirs2_transform::tda_ext::compute_persistence;
let dist = vec![
vec![0.0, 1.0, 1.4, 1.0],
vec![1.0, 0.0, 1.0, 1.4],
vec![1.4, 1.0, 0.0, 1.0],
vec![1.0, 1.4, 1.0, 0.0],
];
let diagrams = compute_persistence(&dist, 1, 2.0).expect("should succeed");
assert_eq!(diagrams.len(), 2); // H0 and H1
assert!(!diagrams[0].is_empty()); // at least one H0 feature