Topological regularization of Karate network embedding

In this notebook, we show how a topological loss can be combined with a graph embedding procedure, as to regularize the embedding and better reflect the topological---in this case disconnected---prior.

We start by setting the working directory and importing the necessary libraries.

Load and plot graph

We now load and plot the Karate network.

Regular graph embedding

We first take a look at a regular embedding of this graph without topological regularization.

Apply topological regularization to the embedding

We now show how we can bias a graph embedding using a loss function that captures our topological prior. As a topological loss, we will use the persistence of the second most prominent component in our embedding (one will always be infinite). It is important to multiply this by a factor $\lambda_{\mathrm{top}} <0$, since we want this persistence to be high. To obtain this loss, we require an additional layer that constructs the alpha complex from the embedding, from which subsequently persistent homology is computed.

The topological loss is computed from a small sample in the embedding each time. This prevents the same point to be selected and moved away from the rest during each iteration, encouraging more natural communities, while simultaneously increasing computational efficiency.

We can now conduct the topologically regularized graph embedding as follows.

Compare with ordinary topological optimization

For comparison, we also conduct the same topological optimization procedure directly on the ordinary graph embedding.

We observe that the graph embedding benefits most from combining both losses.

Quantitative evaluation

First, we evaluate the different losses (embedding and topological) for all final embeddings.

Finally, we compare if the topologically regularized embedding improves on the ordinary graph embedding for predicting data point labels.