| Title: | Topological Data Analysis: Simplicial Complex |
|---|---|
| Description: | Provides an implementation of simplicial complexes for Topological Data Analysis (TDA). The package includes functions to compute faces, boundary operators, Betti numbers, Euler characteristic, and to construct simplicial complexes. It also implements persistent homology, from building filtrations to computing persistence diagrams, with the aim of helping readers understand the core concepts of computational topology. Methods are based on standard references in persistent homology such as Zomorodian and Carlsson (2005) <doi:10.1007/s00454-004-1146-y> and Chazal and Michel (2021) <doi:10.3389/frai.2021.667963>. |
| Authors: | ChiChien Wang [aut, cre, trl] |
| Maintainer: | ChiChien Wang <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-13 08:04:46 UTC |
| Source: | https://github.com/tda-r/simplicialcomplex |
Compute Euler characteristic for an abstract simplicial complex
abstract_simplicial_complex(simplices, dimension, tol = NULL)abstract_simplicial_complex(simplices, dimension, tol = NULL)
simplices |
A list of simplices (each a numeric vector). |
dimension |
Optional max dimension to compute up to. |
tol |
Optional numerical tolerance to pass to |
The Euler characteristic .
simplices <- list(c(1, 2), c(3, 4), c(2, 1, 3), c(4, 2)) abstract_simplicial_complex(simplices, 2)simplices <- list(c(1, 2), c(3, 4), c(2, 1, 3), c(4, 2)) abstract_simplicial_complex(simplices, 2)
Compute the boundary operator for a simplicial complex
boundary(simplices, bound_dim)boundary(simplices, bound_dim)
simplices |
A list of simplices (each a numeric vector). |
bound_dim |
The dimension k of the boundary operator |
A sparse matrix representing .
simplices <- list(c(1, 2), c(3, 4), c(2, 1, 3), c(4, 2)) boundary(simplices, 0)simplices <- list(c(1, 2), c(3, 4), c(2, 1, 3), c(4, 2)) boundary(simplices, 0)
Get the boundary matrix and its reduction information in matrix form
boundary_info(filist)boundary_info(filist)
filist |
Filtration list, each element includes simplex and time. |
A list containing the boundary matrix, the last boundary row, and the pivot owner for persistence extraction.
points <- matrix(c(0, 1, 1, 0, 0, 0, 1, 1), ncol = 2) filtration <- build_vr_filtration(points, eps_max=1.2) res <- boundary_info(filtration)points <- matrix(c(0, 1, 1, 0, 0, 0, 1, 1), ncol = 2) filtration <- build_vr_filtration(points, eps_max=1.2) res <- boundary_info(filtration)
Vietoris-Rips Filtration: Get the boundary matrix and its reduction information in matrix form
build_vr_filtration(points, eps_max)build_vr_filtration(points, eps_max)
points |
Data point input. |
eps_max |
Maximum scale (epsilon). |
A list of simplices with their information.
points <- matrix(c(0, 1, 1, 0, 0, 0, 1, 1), ncol = 2) filtration <- build_vr_filtration(points, eps_max=1.2)points <- matrix(c(0, 1, 1, 0, 0, 0, 1, 1), ncol = 2) filtration <- build_vr_filtration(points, eps_max=1.2)
of a simplicial complexCompute the Euler characteristic of a simplicial complex
euler_characteristic(simplices, tol)euler_characteristic(simplices, tol)
simplices |
A list of simplices (each a numeric vector). |
tol |
Optional numerical tolerance to pass to |
The Euler characteristic is computed as:
where is the th Betti number, and is the highest dimension of any simplex in the complex.
Interpretation of values:
: Sphere-like surfaces
: Disk-like spaces
: Torus-like or circle-like spaces
: Surfaces with multiple handles or genus
An integer representing the Euler characteristic .
simplices <- list(c(1, 2), c(3, 4), c(2, 1, 3), c(4, 2)) euler_characteristic(simplices, tol=0.1)simplices <- list(c(1, 2), c(3, 4), c(2, 1, 3), c(4, 2)) euler_characteristic(simplices, tol=0.1)
This function extracts the persistence from combining the boundary matrix and its filtration
extract_persistence_pairs(filist, last_1, pivot_owner)extract_persistence_pairs(filist, last_1, pivot_owner)
filist |
Filtration list, each element includes simplex and time. |
last_1 |
The last 1 row index for each column in boundary matrix. |
pivot_owner |
The column index owning the pivot row. |
A data frame with columns: dimension, birth, and death.
points <- matrix(c(0, 1, 1, 0, 0, 0, 1, 1), ncol = 2) filtration <- build_vr_filtration(points, eps_max=1.2) res <- boundary_info(filtration) pairs <- extract_persistence_pairs(filtration, res$last_1, res$pivot_owner)points <- matrix(c(0, 1, 1, 0, 0, 0, 1, 1), ncol = 2) filtration <- build_vr_filtration(points, eps_max=1.2) res <- boundary_info(filtration) pairs <- extract_persistence_pairs(filtration, res$last_1, res$pivot_owner)
Generate all unique faces of a given dimension from simplices
faces(simplices, target_dim)faces(simplices, target_dim)
simplices |
A list of simplices (each a numeric vector). |
target_dim |
The target dimension |
The function generates all possible subsets (combinations) of each simplex, removes duplicates,
and filters them to only include those of length target_dim + 1.
For example, a 2-simplex c(1, 2, 3) has three 1-dimensional faces (edges):
c(1,2), c(1,3), and c(2,3), and three 0-dimensional faces (vertices):
1, 2, and 3.
A list of faces (each a numeric vector) of dimension target_dim.
simplices <- list(c(1, 2), c(3, 4), c(2, 1, 3), c(4, 2)) faces(simplices, target_dim=0)simplices <- list(c(1, 2), c(3, 4), c(2, 1, 3), c(4, 2)) faces(simplices, target_dim=0)
Plot Persistence Diagram
plot_persistence(df)plot_persistence(df)
df |
Dataframe from plot_persistence. |
A ggplot2 object representing the persistence diagram.
points <- matrix(c(0, 1, 1, 0, 0, 0, 1, 1), ncol = 2) filtration <- build_vr_filtration(points, eps_max=1.2) res <- boundary_info(filtration) pairs <- extract_persistence_pairs(filtration, res$last_1, res$pivot_owner) plot_persistence(pairs)points <- matrix(c(0, 1, 1, 0, 0, 0, 1, 1), ncol = 2) filtration <- build_vr_filtration(points, eps_max=1.2) res <- boundary_info(filtration) pairs <- extract_persistence_pairs(filtration, res$last_1, res$pivot_owner) plot_persistence(pairs)
Construct a Vietoris–Rips Complex (1-skeleton + maximal simplices)
VietorisRipsComplex(points, epsilon)VietorisRipsComplex(points, epsilon)
points |
A numeric matrix or data.frame with one point per row (columns are coordinates). |
epsilon |
A positive numeric threshold; connect points with distance < |
The Vietoris–Rips complex at scale includes a simplex for every
finite set of points with pairwise distances < . This function
constructs the 1-skeleton (edges only) and then uses maximal cliques in that
graph as the maximal simplices.
A list with:
An igraph object representing the 1-skeleton.
A list of integer vectors, each the vertex indices of a maximal simplex.
points <- matrix(c(0, 1, 1, 0, 0, 0, 1, 1), ncol = 2) epsilon <- 1.5 vr_complex <- VietorisRipsComplex(points, epsilon)points <- matrix(c(0, 1, 1, 0, 0, 0, 1, 1), ncol = 2) epsilon <- 1.5 vr_complex <- VietorisRipsComplex(points, epsilon)