In this notebook we will demonstrate how Polymake can be used to compute a Vietoris Rips complex and its homology on a random two dimensional point cloud. To read up on these concepts we suggest to take a look at: Computational Topology: An Introduction by Herbert Edelsbrunner and John Harer.
We will begin by checking on our system by calling versioninfo()
. We can see the version of our Julia Kernel and some system specs.
versioninfo()
Then we check the status of our package manager and tell Julia which packages to use.
using Pkg
Pkg.status()
using Polymake
using Plots
using Distances
With this our setup is complete. We will begin by generating a random set of points via some of Julia's basic functionality. Then we will plot these points using the "Plots" package.
points = rand(Float64, (16,2))
scatter(points[:,1],points[:,2],xlabel="x-coordinate",ylabel="y-coordinate",legend=false,aspect_ratio =:equal)
Polymake requires a distance matrix to compute the Vietoris rips complex. Here we use the "Distances" package to compute a $n imes n$ matrix of pairwise distances, where $n$ is the number of points. We can specify which metric we want to use and choose the Euclidean metric.
Setting dims = 1
specifies that we want the pairwise distances of the rows of our matrix points
.
distances = Distances.pairwise(Distances.Euclidean(),points,dims = 1)
Now we can use Polymake's topaz library to generate the VR complex from our distance matrix. We also have to pass a float, indicating the maximum pairwise distance of vertices, such that they become a face of our abstract simplicial complex. Depending on our point set and the value we choose here, we get a higher or lower dimensional abstract simplicial complex. Note that if we'd choose a value of $1$ the generated abstract simplicial complex would contain all faces of the $n-$simplex.
vr = topaz.vietoris_rips_complex(distances, 0.33)
vr.FACETS
Above we can see the facets, encoded by sets of labeled vertices. Below we see a visualization of the VR complex provided by Polymake.
Polymake.display_svg(vr)
Finally we use another Polymake function to print the reduced homology of our complex. Each line corresponds to one dimension, starting with dimension $0$. The torsion coefficients are displayed in the curly brackets, which are empty if there is no torsion. The number after the curly brackets is the reduced Betti number.
vr.HOMOLOGY