Topological regularization of Harry Potter 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 circular---prior.

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

Load and plot graph

We now load and plot the Harry Potter network. We will only include edges that represent friendly relationships between the characters, and restrict to the largest connected component. We will annotate text labels for the characters also visualized in

[1] Robin Vandaele, Yvan Saeys, Tijl De Bie. Mining Topological Structurein Graphs through Forest Representations. Journal of Machine Learning Research, 21(215):1–68, 2020.

Note that this circular model will not be used to derive our embedding, nor is it derived from our embedding in this notebook.

Regular graph embedding

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

The graph embedding, along with the circular model presented in [1], is now visualized as follows.

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 most prominent cycle in our embedding. 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.

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

The topologically regularized deepwalk embedding, along with the circular model presented in [1], is now visualized as follows.

Compare with ordinary topological optimization

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

The topologically optimized deepwalk embedding, along with the circular model presented in [1], is now visualized as follows.

Quantitative evaluation

We evaluate the different losses (embedding and topological) for all final embeddings.