pub struct SimplicialComplex {
pub simplices: Vec<Vec<usize>>,
pub n_vertices: usize,
}Expand description
A simplicial complex defined by a collection of simplices over a vertex set.
A simplex is a list of vertex indices; e.g., [0,1,2] is a triangle.
The complex automatically includes all faces (sub-simplices) when a simplex
is added.
Fields§
§simplices: Vec<Vec<usize>>All simplices stored as sorted vertex-index lists.
n_vertices: usizeNumber of vertices (0-simplices) in the complex.
Implementations§
Source§impl SimplicialComplex
impl SimplicialComplex
Sourcepub fn new(n_vertices: usize) -> Self
pub fn new(n_vertices: usize) -> Self
Create an empty simplicial complex with n_vertices vertices.
Sourcepub fn add_simplex(&mut self, simplex: &[usize])
pub fn add_simplex(&mut self, simplex: &[usize])
Add a simplex (and all its faces) to the complex.
simplex is a slice of vertex indices. Duplicate simplices are ignored.
Sourcepub fn k_simplices(&self, k: usize) -> Vec<&Vec<usize>>
pub fn k_simplices(&self, k: usize) -> Vec<&Vec<usize>>
Return all k-simplices (simplices of dimension k).
Sourcepub fn boundary_operator(&self, k: usize) -> Vec<Vec<i32>>
pub fn boundary_operator(&self, k: usize) -> Vec<Vec<i32>>
Compute the boundary operator matrix ∂_k as a matrix over ℤ.
Rows index (k-1)-simplices, columns index k-simplices.
Entry [i][j] is ±1 if the i-th (k-1)-simplex is the i-th face
of the j-th k-simplex (with the appropriate sign), or 0 otherwise.
Sourcepub fn betti_numbers(&self) -> Vec<usize>
pub fn betti_numbers(&self) -> Vec<usize>
Compute Betti numbers β_0, β_1, … via Smith normal form over ℤ.
β_k = dim(ker ∂_k) − dim(im ∂_{k+1}).
Sourcepub fn euler_characteristic(&self) -> i32
pub fn euler_characteristic(&self) -> i32
Euler characteristic χ = Σ_k (-1)^k * #(k-simplices).
Sourcepub fn is_manifold(&self) -> bool
pub fn is_manifold(&self) -> bool
Check if the complex is a (combinatorial) manifold.
Every (n-1)-simplex must be shared by exactly 1 or 2 n-simplices,
and the link of every vertex must be a sphere or a ball.
Sourcepub fn skeleton(&self, k: usize) -> Self
pub fn skeleton(&self, k: usize) -> Self
Return the k-skeleton (sub-complex of all simplices of dimension ≤ k).
Trait Implementations§
Source§impl Clone for SimplicialComplex
impl Clone for SimplicialComplex
Source§fn clone(&self) -> SimplicialComplex
fn clone(&self) -> SimplicialComplex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SimplicialComplex
impl RefUnwindSafe for SimplicialComplex
impl Send for SimplicialComplex
impl Sync for SimplicialComplex
impl Unpin for SimplicialComplex
impl UnsafeUnpin for SimplicialComplex
impl UnwindSafe for SimplicialComplex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.