Skip to main content

holos_tda/persistent_class_artifact/
model.rs

1use crate::{CriticalPair, PersistentClass, SparseDistanceMatrix};
2
3/// One nonzero coefficient on an oriented edge of a geometric persistence
4/// cycle.
5#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
6pub struct PersistenceCycleTerm {
7    /// Lower endpoint of the edge.
8    pub u: usize,
9    /// Higher endpoint of the edge.
10    pub v: usize,
11    /// Coefficient in the declared prime field.
12    pub coefficient: u32,
13}
14
15/// One nonzero coefficient on an oriented triangle of a finite death chain.
16#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
17pub struct PersistenceTriangleTerm {
18    /// Triangle vertices in ascending order.
19    pub vertices: [usize; 3],
20    /// Coefficient in the declared prime field.
21    pub coefficient: u32,
22}
23
24/// A persistent H1 class with a geometric cycle witness.
25///
26/// The source graph, threshold, class, critical pair, and geometric terms
27/// are private so callers cannot construct a claim without the producer
28/// checks. Use [`Self::build`](crate::PersistentClassArtifact::build).
29#[derive(Debug, Clone)]
30pub struct PersistentClassArtifact {
31    pub(super) source: SparseDistanceMatrix,
32    pub(super) threshold: Option<f64>,
33    pub(super) class: PersistentClass,
34    pub(super) critical_pair: CriticalPair,
35    pub(super) cycle: Vec<PersistenceCycleTerm>,
36    pub(super) bounding_chain: Vec<PersistenceTriangleTerm>,
37}
38
39impl PersistentClassArtifact {
40    /// The complete weighted source graph bound to this artifact.
41    pub fn source(&self) -> &SparseDistanceMatrix {
42        &self.source
43    }
44
45    /// The declared filtration threshold.
46    pub fn threshold(&self) -> Option<f64> {
47        self.threshold
48    }
49
50    /// The selected canonical persistent class.
51    pub fn class(&self) -> &PersistentClass {
52        &self.class
53    }
54
55    /// The critical pair selected from the class interval group.
56    pub fn critical_pair(&self) -> &CriticalPair {
57        &self.critical_pair
58    }
59
60    /// The normalized geometric cycle in ascending edge order.
61    pub fn cycle(&self) -> &[PersistenceCycleTerm] {
62        &self.cycle
63    }
64
65    /// The finite-death bounding chain in ascending triangle order.
66    pub fn bounding_chain(&self) -> &[PersistenceTriangleTerm] {
67        &self.bounding_chain
68    }
69}