Lab 3 — Comparing simplicial-complex constructions¶

Goal. On the same point cloud, compute persistence with Vietoris-Rips, Čech (via alpha approximation), and alpha complexes. Compare diagrams and compute time.

What you ship. Notebook with three diagrams overlaid, plus a table of computation times and a 200-word discussion of when the differences matter.

Setup¶

Install the dependencies (one-time).

In [ ]:
# !pip install ripser gudhi persim matplotlib numpy
In [ ]:
import time
import numpy as np
import matplotlib.pyplot as plt
from ripser import ripser
import gudhi
from persim import plot_diagrams

rng = np.random.default_rng(42)

A point cloud with one prominent H_1 feature¶

In [ ]:
n = 400
theta = rng.uniform(0, 2*np.pi, n)
X = np.column_stack([np.cos(theta), np.sin(theta)])
X += 0.07 * rng.normal(size=X.shape)
print('cloud:', X.shape)

Exercise 1 — Vietoris-Rips via ripser¶

In [ ]:
t0 = time.time()
rips = ripser(X, maxdim=1)
t_rips = time.time() - t0
print(f'Rips: {t_rips:.2f}s')

Exercise 2 — Alpha complex via GUDHI¶

In [ ]:
# YOUR TURN
# Use gudhi.AlphaComplex(points=X) and compute persistence with maxdim=1.
# Record the time.

Exercise 3 — Čech approximation¶

In [ ]:
# YOUR TURN
# Use gudhi.CechComplex (approximate) or a witness complex.
# Compare the resulting diagram to Rips and Alpha.

Exercise 4 — Time comparison¶

In [ ]:
# YOUR TURN
# Print a table of complex name, computation time, number of simplices,
# and number of H_1 features above persistence 0.1.

Done?¶

Submit per the cohort schedule. Peer review pairing announced the following Monday.