Skip to content

mtsch/Ripserer.jl

Repository files navigation

Ripserer.jl

Flexible and efficient persistent homology computation.

Coverage Status Build Status Documentation status

Introduction

Ripserer is a pure Julia implementation of the Ripser algorithm for computing persistent homology. Its aims are to be easy to use, generic, and fast.

See the documentation for more information and usage examples.

If you're looking for persistence diagram-related functionality such as Wasserstein or bottleneck distances, persistence images, or persistence curves, please see PersistenceDiagrams.jl.

Quick start

This package is registered. To install it, run the following.

julia> using Pkg
julia> Pkg.add("Ripserer")

Now, generate some data.

julia> data = [(rand(), rand(), rand()) for _ in 1:200]

The main exported function in this package is ripserer. By default, it computes Vietoris-Rips persistent homology on point cloud data and distance matrices.

julia> ripserer(data)
# 2-element Vector{PersistenceDiagrams.PersistenceDiagram}:
#  200-element 0-dimensional PersistenceDiagram
#  84-element 1-dimensional PersistenceDiagram

Several other filtration types are supported. We tell ripserer to use them by passing them as the first argument.

julia> ripserer(EdgeCollapsedRips, data)
# 2-element Vector{PersistenceDiagrams.PersistenceDiagram}:
#  200-element 0-dimensional PersistenceDiagram
#  84-element 1-dimensional PersistenceDiagram

Sometimes you may want to initialize a filtration in advance.

julia> rips = EdgeCollapsedRips(data, threshold=1)
# EdgeCollapsedRips{Int64, Float64}(nv=200)
julia> ripserer(rips, dim_max=2)
# 3-element Vector{PersistenceDiagrams.PersistenceDiagram}:
#  200-element 0-dimensional PersistenceDiagram
#  84-element 1-dimensional PersistenceDiagram
#  16-element 2-dimensional PersistenceDiagram

Ripserer supports plotting with Plots.jl. Experimental Makie.jl support is also available here.

Plotting persistence diagrams and barcodes is straightforward:

using Plots
result = ripserer(data, dim_max=2)
plot(plot(result), barcode(result)

barcode(result)