A pure python implementation of persistent homology algorithm.
APACHE-2.0 License
This simple project provides a pure python (optimized with numpy tensor operation as much as possible) implementation of the whole pipeline for Persistent Homology algorithm as described in TDs of Ecole polytechnique professor M. Steve Oudot which includes
In the step 2, I first build the sparse boundary matrix, then reduce it using Gaussian elimination algorithm under the field Z/pZ where p is a prime number (the current implementation only support p=2, but it's not complicated to adapt it to the general cases).
For the pratical research of development, please use the python package dionysus (2.0) or GUDHI developed by Inria (France) instead. However, this pure python implementation may offer non-C++ developer a better way to understand algorithm.
A simple example illustrates the persistent homology algorithm.
The data filtration (aka complex) is described as [Time(aka value), dim_of_homology, vertex_0, vertex_1, ..., vertex_dim].
From left to right are respectively time 1, 2, 3 From left to right are respectively time 4, 5, 6
The barcode (aka persistent diagram) is as follows (with format [dim_of_homology, time_start, time_end]):
Therefore, we know that the Betti's number is \beta_0 = 1, \beta_1 = 1.
The following barcode and persistent diagram come from the 2D sphere function (x,y) -> x+y. Note that the sphere function is different from the sphere object. We have here \beta_0 = 1 and \beta_1 = 0. (For a sphere object S^n with n>0, we have \beta_0 = \beta_n= 1 and \beta_k = 0 for the other k)