Graph Neural Networks and 3-Dimensional Topology
We test the efficiency of applying Geometric Deep Learning to the problems in
low-dimensional topology in a certain simple setting. Specifically, we consider
the class of 3-manifolds described by plumbing graphs and use Graph Neural
Networks (GNN) for the problem of deciding whether a pair of graphs give
homeomorphic 3-manifolds. We use supervised learning to train a GNN that
provides the answer to such a question with high accuracy. Moreover, we
consider reinforcement learning by a GNN to find a sequence of Neumann moves
that relates the pair of graphs if the answer is positive. The setting can be
understood as a toy model of the problem of deciding whether a pair of Kirby
diagrams give diffeomorphic 3- or 4-manifolds.
Pavel Putrov, Song Jin Ri
# Graph Neural Networks and 3-Dimensional Topology

###### Abstract

We test the efficiency of applying Geometric Deep Learning to the problems in low-dimensional topology in a certain simple setting. Specifically, we consider the class of 3-manifolds described by plumbing graphs and use Graph Neural Networks (GNN) for the problem of deciding whether a pair of graphs give homeomorphic 3-manifolds. We use supervised learning to train a GNN that provides the answer to such a question with high accuracy. Moreover, we consider reinforcement learning by a GNN to find a sequence of Neumann moves that relates the pair of graphs if the answer is positive. The setting can be understood as a toy model of the problem of deciding whether a pair of Kirby diagrams give diffeomorphic 3- or 4-manifolds.

## 1 Introduction and Summary

Geometric Deep Learning (GDL) [1] is an area of Machine Learning (ML) that has been under very active development during the last few years. It combines various approaches to ML problems involving data that has some underlying geometric structure. The neural networks used in GDL are designed to naturally take into account the symmetries and the locality of the data. It has been successfully applied to problems involving computer vision, molecule properties, social or citation networks, particle physics, etc (see [2] for a survey). It is natural to apply GDL techniques also to mathematical problems in topology. In general, ML has been already used in various problems in low-dimensional topology, knot theory in particular, [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], as well as various physics-related problems in geometry (for a recent survey see [13]). However, the used neural network models were mostly not specific to GDL.

The goal of this paper is to test the efficiency of GDL in a very simple setting in low-dimensional topology. Namely, we consider a special class of 3-manifolds known as plumbed, or graph, 3-manifolds. Those are 3-manifolds that are specified by a choice of a graph with particular features assigned to edges and vertices. Such 3-manifolds are therefore very well suited for analysis by Graph Neural Networks (GNN). GNN is one of the most important and used types of neural networks used in GDL. In general, GNN are designed to process data represented by graphs.

In this paper, we use GNNs for the following problems involving plumbed 3-manifolds. Different (meaning not isomorphic) graphs can correspond to equivalent, i.e. homeomorphic, 3-manifolds. Note that in 3 dimensions (or less) any topological manifold has a unique smooth structure and the notions of homeomorphism and diffeomorphism are equivalent. It is known that a pair of graphs that produce two equivalent 3-manifolds must be related by a sequence of certain _moves_, commonly known as Neumann moves [14]. These moves establish a certain equivalence relation on the graphs (in addition to the standard graph isomorphism). First, we consider a neural network that, as the input has a pair of plumbing graphs, and, as the output gives the decision whether the graphs correspond to homeomorphic 3-manifolds or not, i.e. whether the two graphs are equivalent, or not, in the sense described above. Supervised Learning (SL) is then used to train the network. The training dataset consists of randomly generated graph pairs, for which it is known whether the corresponding 3-manifolds are homeomorphic or not. The trained neural network, up until the very last layer, can be understood to produce an approximate topological invariant of plumbed 3-manifolds.

Second, we consider a neural network for which the input is a plumbing graph and the output is a sequence of Neumann moves that "simplifies" the graph according to a certain criterion. The aim is to build a neural network such that if it is applied to equivalent graphs it simplifies them to the same graph. If the result is successful this can be used to provide an explicit demonstration that a given pair of
For both cases, SL and RL, we consider different architectures of the neural networks and compare their performance.

Note that in principle there is an algorithm for determining whether two plumbing graphs give homeomorphic 3-manifolds or not, which was already presented in [14]. It involves bringing both graphs to a certain normal form (which is, in a sense, similar to the "simplification" process in the RL setup mentioned above) and then checking that normal forms are the same (i.e. isomorphic graphs). However, it is known that just checking isomorphism of graphs already goes beyond polynomial time. The plumbing graphs can be considered as a particular class of more general Kirby diagrams that can be used to describe arbitrary closed oriented 3-manifolds, with Neumann moves being generalized to the so-called Kirby moves. Even in this case, in principle there exists an algorithm of checking whether two Kirby diagrams produce homeomorphic 3-manifolds or not [15]. There is a also of version of Kirby diagrams and moves for smooth 4-manifolds. Moreover, in this case, however, an algorithm for the recognition of diffeomorphic pairs does not exist. In 4 dimensions the notion of diffeomorphism and homeomorphism are not the same. In particular, there exist pairs of manifolds that are homeomorphic but not diffeomorphic. While the classification of 4-manifolds up to homeomorphisms (with certain assumptions on the fundamental group) is relatively not difficult, classification up to diffeomorphisms is an important open question. The setup with plumbed 3-manifolds that we consider in this paper can be understood as a toy model for the problem of recognition of diffeomorphic pairs of general 3- and 4-manifolds, for which one can try to apply neural networks with similar architecture in the future.

The rest of the paper is organized as follows. In Section 2 we review basic preliminaries about plumbed 3-manifolds and Graph Neural Networks needed for the analysis that follows. In Section 3 we consider various GNN architectures for supervised learning of whether a pair of plumbing graphs provide homeomorphic 3-manifolds or not. In Section 4 we consider reinforcement learning of the process of simplification of a plumbing graph representing a fixed (up to a homeomorphism) 3-manifold. Finally, we conclude with Section 5 where we discuss the obtained results and mention possible further directions. The Appendix A contains some basic algorithms that are specific to the problems considered in this paper.

## 2 Preliminaries

### Plumbed 3-manifolds

In this section we review basic facts about plumbed 3-manifolds, also known as graph 3-manifolds. For a more detailed exposition we refer to the original paper [14]. First, let us describe how to build a 3-manifold from a _plumbing graph_, or simply a _plumbing_. For convenience, we restrict ourselves to the case when the graph is a tree, i.e., the graph is connected and acyclic. We will also consider the case of genus zero plumbings only. In this setting, apart from the graph itself, the only additional information that one needs to specify is the set of integer _weights_\(w(v)\in\mathbb{Z}\) labeling vertices \(v\in V\) (\(V\) denotes set of all vertices of the graph), also referred to as _framings_ in the context of topology. A typical plumbing graph looks like the one shown in Figure 1. The weights \(w(v)\), together with standard graph data can be naturally encoded in an \(|V|\times|V|\) matrix \(a\) with integral elements \(a_{ij}\) as follows. Outside of the diagonal this matrix coincides with the standard adjacency matrix of the graph (i.e. \(a_{ij}=1\) if \(i\neq j\in V\) are connected by an edge, and \(a_{ij}=0\) otherwise). The diagonal elements are given by the weights: \(a_{ii}=w(i)\).

One can build a 3-manifold corresponding to such a plumbing graph as follows. First, consider a graph containing a single vertex with weight \(p\in\mathbb{Z}\) and no edges. To such a one-vertex graph we associate lens space 3-manifold \(L(|p|,\pm 1)\), where the sign of \(\pm 1\) coincides with the sign of \(p\). It can be described as a

Figure 1: An example of a plumbing graph.
quotient of the standard unit 3-sphere \(S^{3}=\{\left|z_{1}\right|^{2}+\left|z_{2}\right|^{2}=1\left|\left(z_{1},z_{2} \right)\in\mathbb{C}^{2}\right\}\subset\mathbb{R}^{4}\cong\mathbb{C}^{2}\) with respect to the action of cyclic group \(\mathbb{Z}_{\left|p\right|}\) or order \(\left|p\right|\), generated by \(\left(z_{1},z_{2}\right)\rightarrow\left(z_{1}e^{\frac{2\pi i}{\left|p\right|} },z_{2}e^{\frac{2\pi i}{\left|p\right|}}\right)\) transformation. This 3-manifold can be equivalently understood as a circle fibration over \(S^{2}\) base with Euler number \(p\). More explicitly, it can be constructed as follows. Let us start with two copies of \(D^{2}\times S^{1}\) (where \(D^{2}\) denotes 2-dimensional disk), that can be viewed as trivial circle fibrations over \(D^{2}\). We then can glue two \(D^{2}\)'s along the common boundary \(\partial D^{2}\cong S^{1}\) into \(S^{2}\) (so that each \(D^{2}\) can be understood as a hemisphere), with the \(S^{1}\) fibers along the two boundaries being glued with relative rotation specified by a certain map \(f:\partial D^{2}\cong S^{1}\to SO(2)\cong S^{1}\). The homotopy class of such a map is completely determined by the "winding number". The homeomorphism class of the resulting closed 3-manifold only depends on this number. To obtain the lens space \(L(p,1)\) one takes the winding number to be \(p\).

Next, consider a vertex with weight \(p\) being a part of a general tree plumbing (as, for example, the one shown in Figure 1). For each edge coming out of the vertex, we remove a single \(S^{1}\) fiber (over some generic point in the \(S^{2}\) base) of the fibration together with its tubular neighborhood. The neighborhood can be chosen to be the restriction of the fibration to a small disk in the \(S^{2}\) base that contains the chosen point. Such an operation, out of the original lens space \(L(p,1)\), produces a 3-manifold that has a boundary component \(\partial D^{2}\times S^{1}\cong S^{1}\times S^{1}=T^{2}\) for each edge coming out of the vertex. Having an edge between a pair of vertices in the graph then corresponds to gluing two \(T^{2}\) boundary components in the way that the two circles, the fiber \(S^{1}\) and the boundary \(S^{1}\) of the small disk on the base, are swapped (with the orientation of one of the circles reversed, so that the resulting 3-manifold is orientable). Performing such operations to all the vertices and edges of the graph one obtains a 3-manifold that has no boundary components. This is the 3-manifold that one associates to the plumbing graph.

Equivalently, to a plumbing graph one can associate Dehn surgery diagram, in the way that each vertex \(v\in V\) corresponds to an unknot framed by \(w(v)\) and the presence of an edge between two vertices signifies that the corresponding unknots form a Hopf link.

Applying the prescription described above to different graphs may result in homeomorphic 3-manifolds. In [14] it was proved that this happens if and only if the graphs can be related by a sequence of local graph transformations, or _moves_, now commonly known as _Neumann moves_, shown in Figure 2.

### Graph neural networks

Here we provide a brief review on some of GNNs for a later purpose. There are 3 main computational modules to build a typical GNN architecture: propagation modules, sampling modules and pooling modules. Since in this paper we will use only convolution operators, which are one of the most frequently used propagation modules, we focus on some of convolution operators. For a broad review on various modules, we refer the reader to [16].

Convolution operators are motivated by convolutional neural networks (CNN), which have achieved a notable progress in various areas. In general, the role of convolution operators can be described as

\[\mathbf{x}_{i}^{(k)}=\gamma^{(k)}\left(\mathbf{x}_{i}^{(k-1)},\bigoplus_{j\in \mathcal{N}(i)}\phi^{(k)}\left(\mathbf{x}_{i}^{(k-1)},\mathbf{x}_{j}^{(k-1)}, \mathbf{e}_{j,i}\right)\right),\]

where \(\mathbf{x}_{i}^{(k)}\in\mathbb{R}^{F}\) denotes node features of node \(i\) in the \(k\)-th layer and \(\mathbf{e}_{j,i}\in\mathbb{R}^{D}\) denotes edge features

Figure 2: There are 3 different types of Neumann moves, which preserve the resulting 3-manifold up to homeomorphism. Considering the sign, one can count 8 Neumann moves. Among them, there are 5 blow-up moves (by which a new vertex is created) and 3 blow-down moves (by which one or two vertices are annihilated).
of the edge connecting from node \(j\) to node \(i\). We also note that \(\bigoplus\) over a neighborhood \(\mathcal{N}(i)\) of node \(i\) is a differentiable, permutation invariant function such as sum, mean and max, and \(\gamma\) and \(\phi\) denote differentiable functions such as Multi Layer Perceptrons (MLPs).

Among various convolution operators existing in the literature, the following will appear in the next sections.

* Graph Embedding Network (GEN) [17] GEN is designed for deep graph similarity learning and embeds each graph into a vector, called a graph embedding. More explicitly, it first computes initial node embeddings \(\mathbf{x}_{i}^{(1)}\) from the node features \(\mathbf{x}_{i}^{(0)}\) through MLP \[\mathbf{x}_{i}^{(1)}=\text{MLP}\left(\mathbf{x}_{i}^{(0)}\right),\] then it executes the single message propagation to compute node embeddings \(\mathbf{x}_{i}^{(2)}\) by the information in its local neighbourhood \(\mathcal{N}(i)\)1 Footnote 1: It is also possible to apply a finite number of propagation process iteratively, but we will only consider single propagation here. \[\mathbf{x}_{i}^{(2)}=\text{MLP}\left(\mathbf{x}_{i}^{(1)},\sum_{j\in\mathcal{N }(i)}\text{MLP}\left(\mathbf{x}_{i}^{(1)},\mathbf{x}_{j}^{(1)}\right)\right).\] Once the node embeddings \(\mathbf{x}_{i}^{(2)}\) are computed, an aggregator computes a graph embedding by aggregating the set of node embeddings. In Section 3.1, we describe the details of the aggregator which we will apply not only to GEN but also the other models GCN and GAT.
* Graph Convolutional Network (GCN) GCN is introduced in [18] as a variant of convolutional neural networks for graphs. It operates as the following formula: \[\mathbf{z}_{i}=\boldsymbol{\Theta}^{\intercal}\sum_{j\in\mathcal{N}(i)\cup \{i\}}\frac{1}{\sqrt{\hat{d}_{j}\hat{d}_{i}}}\mathbf{x}_{j},\] where \(\mathbf{z}_{i}\) is the output for the \(i\)-th node, \(\boldsymbol{\Theta}\) is a matrix of filter parameters, and \(\hat{d}_{i}\) is the degree of \(i\)-th node.
* Graph Attention Network (GAT) GAT is proposed in [19], which incorporates the attention mechanism into the message propagation. The mechanism of GAT can be formulated as \[\mathbf{x}_{i}^{\prime}=\alpha_{i,i}\boldsymbol{\Theta}\mathbf{x}_{i}+\sum_{ j\in\mathcal{N}(i)}\alpha_{i,j}\boldsymbol{\Theta}\mathbf{x}_{j}.\] Here the attention coefficients \(\alpha\) are given by \[\alpha_{i,j}=\frac{\exp\left(\text{LeakyReLU}(\mathbf{a}^{\intercal}[ \boldsymbol{\Theta}\mathbf{x}_{i}\|\boldsymbol{\Theta}\mathbf{x}_{j})]\right)} {\sum_{k\in\mathcal{N}(i)\cup\{i\}}\exp\left(\text{LeakyReLU}(\mathbf{a}^{ \intercal}[\boldsymbol{\Theta}\mathbf{x}_{i}\|\boldsymbol{\Theta}\mathbf{x}_{k })]\right)},\] where the attention mechanism \(\mathbf{a}\) is implemented by a single-layer feedoward neural network, and \(\|\) is the concatenation operator.

All the neural networks including GNNs are implemented based on PyTorch [20] and PyTorch Geometric [21]. 2

Footnote 2: Python code is available on Github.

## 3 Supervised Learning

In this section we use supervised learning to decide whether or not two plumbing graphs represent a same plumbed 3-manifold. We build 3 models GEN+GAT, GCN+GCN and GCN+GAT and examine their performance for the task.3
### Models

All the models are designed to have two convolution operators, one aggregation layer and one classification layer. The models are named by concatenating the names of two convolution operators. For a fair comparison, we use the common aggregation layer and the classification layer, and all the layers have the same dimensions for both input and output.

Since we have already reviewed the convolution operators in Section 2.2, let us now elaborate on the common aggregation layer and classification layer. The aggregator computes a graph embedding by aggregating all of its node embeddings, passed from convolution operators. We use the aggregation layer proposed in [22], which is formulated by

\[\mathbf{h}_{G}=\text{MLP}_{G}\left(\sum_{i\in V}\text{Softmax}(\text{MLP}_{ \text{gate}}(\mathbf{x}_{i}))\odot\text{MLP}(\mathbf{x}_{i})\right),\]

where \(\mathbf{h}_{G}\) is a graph-level output and \(\odot\) denotes element-wise multiplication.

The classification layer plays a role to determine, for a given pair of plumbing graphs, whether or not they are equivalent. This layer has the concatenation of two graph embeddings as its input and classifies into two classes, class 0 and class 1. Here class 1 means two plumbing graphs are equivalent while class 0 denotes they are inequivalent. We implement the classification layer by using MLP with two hidden layers.

A detailed information of the architecture for 3 models are presented in Table 1. For each layer in the table, the first element in the bracket followed by a name of model denotes the dimension of input vectors of the layer while the second one denotes the dimension of output embedding.

### Experimental Settings

For training and validation, we put together datasets including 80,000 random pairs of plumbings generated by algorithms presented in Appendix A. More explicitly, the datasets consists of

* 40,000 pairs of equivalent plumbings generated by EquivPair, Algorithm 3, with \(N_{\max}=40\). To generate a pair of equivalent plumbings, the algorithm starts with a random plumbing created by RandomPlumbing, Algorithm 1, and iteratively applies Neumann moves using RandomNeumannMove, Algorithm 2, up to \(N_{\max}\) times, to each plumbing in the pair.
* 30,000 pairs of inequivalent plumbings generated by InequPair, Algorithm 4, with \(N_{\max}=40\). It has a similar process to EquivPair, but it starts with a pair of inequivalent plumbings, each of which is separately generated by RandomPlumbing.4 Footnote 4: We note that two plumbings, generated by running RandomPlumbing twice, could be accidentally equivalent and this might affect the accuracy of models in training. However, we will ignore this since it is statistically insignificant.
* 10,000 pairs of inequivalent plumbings generated by TweaxPair, Algorithm 5, with \(N_{\max}=40\). This algorithm generates a pair of inequivalent plumbings, one of which is obtained by tweaking the other. Here, by tweaking a plumbing, we mean that we make a small change of the weight (or node feature) of a randomly chosen node in the plumbing. Since tweaking is different from Neumann moves, this process creates an inequivalent plumbing to the original one. After tweaking, it also applies RandomNeumannMove iteratively up to \(N_{\max}\). These pairs are added into the datasets in order for the models to make the decision boundary more accurate, since for a pair generated by InequPair, two plumbings might be quiet different due to random generators.

\begin{table}
\begin{tabular}{|c|c|c|} \hline Layers & GEN+GAT & GCN+GAT & GCN+GCN \\ \hline First convolution & GEN(1, 128) & GCN(1, 128) \\ \hline Second convolution & GAT(128, 128) & GCN(128, 128) \\ \hline Aggregation & Aggregator(128, 32) \\ \hline Classification & MLP(64, 2) \\ \hline \end{tabular}
\end{table}
Table 1: The architecture of 3 models with parameter values.
We divide the datasets into training and validation sets by the ratio 8:2. We train our models on training sets containing 64,000 pairs of plumbings up to 150 epochs. For each model, we use cross-entropy loss for a loss function and Adam for an optimizer with the learning rate 0.001.

### Results

The comparison of the performance between 3 models is plotted in Figure 3. We find that GEN+GAT model significantly outperforms the other models GCN+GAT and GCN+GCN. The model GCN+GAT seems to outperform GCN+GCN by few percent, but the performance difference is negligible. 5

Footnote 5: For GCN+GAT and GCN+GCN models, we have checked that increasing weight dimensions and longer training phases did not lead to better performance.

We have also tried other models such as GEN+GEN, GEN+GCN and GAT+GAT to figure out which convolution operators has an important role. The model GEN+GCN shows similar performance with GEN+GAT, but slightly underperforms, and the performance of GAT+GAT is somewhere between that of GEN+GAT and GCN+GAT. This means that GEN plays a significant role to evaluate equivalence or inequivalence for a pair of plumbing graphs. However, we found that GEN+GEN does not perform as good as GEN+GAT or GEN+GCN.

We used the following datasets to test our models:

* Test set 1 It contains 5,000 pairs of equivalent plumbing graphs generated by EquivPair with \(N_{\max}=40\) and 5,000 pairs of inequivalent plumbings generated by InequivPair with \(N_{\max}=40\).
* Test set 2 This dataset is similar to Test set 1, but with \(N_{\max}=60\).
* Test set 3 This set is also similar to Test set 1, but with \(N_{\max}=80\).
* Test set 4 It contains 64 pairs of plumbings generated in a manual way such that, for each pair, the determinants of adjacency matrices (with weights on the diagonal) of two plumbings are the same. We use this Test set in order to check that graph embeddings from the models are not just functions of the determinant of the adjacency matrix of a plumbing. All types of Neumann moves have the property that it preserves the determinant of the adjacency matrix of the plumbing, which is the order of the first homology group of the corresponding 3-manifold. We wish graph embeddings to not depend on the determinant only, but be more sophisticated (approximate) invariants of plumbed 3-manifolds.

The results are depicted in Figure 4 and they enlighten us with the following two points. The first point is that the accuracy for Test set 2 and Test set 3 is almost the same level as Test set 1 even though Test set 2 and 3 contain plumbing pairs with larger \(N_{\max}\) than Test set 1. It is perhaps surprising that

Figure 3: Overview of the performance and loss comparison between GEN+GAT, GCN+GAT and GCN+GCN models.
such somewhat counter-intuitive property holds even for GCN+GAT and GCN+GCN models, which show less training accuracy than GEN+GAT. The second point is that GEN+GAT model still outperforms the others for Test set 4 and it can distinguish correctly even inequivalent pairs with the same determinants. Since GEN is designed for graph similarity learning and to have a good generalization, we can see that the model GEN+GAT outperforms significantly the others GCN+GCN and GCN+GAT, designed for general classification problems (with a relatively small number of classes), on various Test sets.

## 4 Reinforcement Learning

In this section, we consider reinforcement learning of a neural network that allows, for a given pair of plumbings, not only to recognize whether they are equivalent or not, but also to find out their simplest representations.

### The environment

#### 4.1.1 State space

In our RL environment, the plumbing graph defines the state and the state space is infinity. In order to handle the start state and terminal stats in an easy way, we set the start state for an episode is set to be a plumbing generated by RandomPlumbing, Algorithm 1, with number of nodes equal to 10, then applying Neumann moves \(N=15\) times.

Between two equivalent plumbings, we define a relation as follows: for two equivalent states \(s_{1}\) and \(s_{2}\), one state is said to be _simpler_ than the other if

\[f(s_{1})<f(s_{2}),\]

where \(f(s)\) for a state \(s\) is defined by

\[f(s):=5|V(s)|+\sum_{v\in V(s)}|w(v)|. \tag{4.1}\]

It is easy to check that this relation is well-defined in a set of all equivalent plumbings.

One might think that number of nodes in a state is enough to decide which state is simpler. The reason why we add the sum of the absolute values of the weights of nodes is to make the simplest state generically

Figure 4: Performance comparison between 3 models, GEN+GAT, GCN+GAT and GCN+GCN on various Test sets. The error bars are not displayed in the figure since the standard errors on Test set 1, 2, and 3 are too small (smaller than 0.7) to notice. The standard errors on Test set 4 are about 2.64, 6.25, and 6.20 for GEN+GAT, GCN+GAT and GCN+GCN models, respectively.
unique6. For example, two plumbings depicted in Figure 5 have same number of nodes and it is easy to check that they are equivalent by applying 2 Neumann moves. In this example, we say that the plumbing on the right-hand side is simpler than the other from (4.1).

Footnote 6: There still could be specific examples with different plumbings in the same equivalence class that minimize \(f(s)\). However, as the results below suggest, such cases are statistically insignificant.

By using this comparison relation, we set the terminal state to be a state equal to or simper than the initial state in the episode. We also terminate each episode after taking 15 time steps.

#### 4.1.2 Action space

An action for the agent in a state is defined to be a Neumann move applied to one of the nodes. There are 8 possible Neumann moves: 5 blow-up moves and 3 blow-down moves. However, blow-down moves are not always available for all nodes and this could raise a problem that there might be too many of such _illegal_ actions. Therefore, we incorporate 3 blow-down moves into one such that it takes an available blow-down if the corresponding node satisfies one of three following conditions:

* the degree of the node is 2 and its weight is equal to \(\pm 1\),
* the degree of the node is 1 and its weight is equal to \(\pm 1\),
* the degree of the node is 1 and its weight is equal to 0.

Then, for a given state, the total number of possible actions is equal to 6 (5 blow-up moves and 1 blow-down move) times number of nodes in the state. If the agent takes an illegal action, then the next state remains the same state as the current state and the agent will be punished with a negative reward, on which we will elaborate soon.

#### 4.1.3 Rewards

Since the goal for the RL agent is to find out the simplest representation for an initial state, it is natural to use \(-f(s^{\prime})\) as a reward (or punishment \(+f(s^{\prime})\)) for taking an action in the current state \(s\), where \(s^{\prime}\) denotes the next state obtained by taking an action to the current state \(s\). Since all the rewards are negative and simpler state is less punished, it helps the agent not only make the current representation as simple as possible, but also do this job as fast as possible. It is also important to note that some states must get a new blow-up node in order to be simplified, which means the agent has to sacrifice the immediate reward at some time steps to maximize the total return. As we have seen previously, there are some illegal actions in the action space for each state. The reward for such illegal actions is set to be equal to \(-2f(s^{\prime})\) for the next state \(s^{\prime}\), which remains the same as the current state \(s\) as we have discussed above.

We set the discount factor as \(\gamma=0.99\), very close to 1.

### The deep RL algorithm

We remind that the RL task is to obtain the simplest representation from a given initial state by using Neumann moves. To accomplish this task, we used Asynchronous Advantage Actor-Critic (A3C) [23] as an RL algorithm, which is the asynchronous version of Actor-Critic (AC) [24], with feedforward GNNs. A3C executes multiple local AC agents asynchronously in parallel to decorrelate the local agent's data into

Figure 5: Two plumbings are equivalent and they have same number of nodes. The right-hand side plumbing is simpler than the left one in the sense of (4.1).
a more stationary process. It also provides practical benefits of being able to use only multi-core CPU, not having to rely on specialized hardware such as GPUs.

The Actor network defines the policy function \(\pi(a|s)\), whose output shows the probability of taking action \(a\) in state \(s\), while the Critic network is to approximate the value function \(V^{\pi}(s)\), which represents the expected return from state \(s\). Since the inputs of the Actor and Critic are plumbing graphs, in the context of GNNs, the Actor network can be thought as the GNNs for node-level action-selection problem and the Critic is for graph-level estimation problem. The architecture of the Actor is designed by using two graph convolutional layers GCN+GCN and one single-layer feedforward neural network. The Critic has a similar structure, but it has an extra aggregation layer, for which we used a simple mean function. We have also tried GEN+GAT and GEN+GCN for the convolutional layers in the Actor and Critic networks. They seemed to perform well, but it takes a bit longer time for training than GCN+GCN. Since the results with GCN+GCN were already pretty good, we ended up using GCN+GCN.

We trained the agents for \(8\times 10^{4}\) episodes using 8 CPU cores and no GPU, which takes around 8 hours. We used Adam optimizer with learning rate \(5\times 10^{-4}\). For a comparison, we have also implemented Deep Q-Network (DQN) [25] with feedforward GNNs GCN+GCN with the same settings as those for A3C.

### Results

Our RL agents can be used to find the simplest representative in the equivalence class of a given plumbing graph. Furthermore, it also can be used to check whether a pair of plumbing graphs represents the same 3-manifold or not. For the latter purpose, we run the RL agents on a pair of plumbings to get the simplest representations for two plumbings, then we compare those to decide whether two equivalent plumbings are isomorphic or not. This process provides us with another advantage that, given two equivalent plumbings, we can get a sequence of Neumann moves that change one plumbing into the other, even though such sequence of Neumann moves is not necessarily the optimal one between two plumbings. From this perspective, we are going to check the performance of the RL agents by running them on pairs of plumbings that represent the same 3-manifolds.

For the initial inputs of the agents, we generate 10,000 random pairs of plumbings by EQUIVPAIR, Algorithm 3, but with a fixed number of Neumann moves \(N\in\{20,40,60,80,100\}\). At each time step, the agents choose a Neumann move and apply it to each plumbing in a pair, then we get another pair of plumbings as the next input for the agents. After taking each action, we compare two plumbings and check if they are isomorphic. If yes, we consider it as the success of finding out a sequence of Neumann moves connecting two plumbings in the initial pair. Otherwise, we move on to the next step and we repeat the process until the number of time steps exceeds \(5N\). We define the accuracy of the performance as the ratio the number of successes divided by the number of total episodes. An example of a pair of equivalent graphs with the successful result by the A3C trained agent is shown in Figure 9.

The results of the RL agents is presented in Figure 6. The plot on the left in Figure 6 shows the accuracy comparison between A3C and DQN. The accuracy for A3C tends to slightly decrease as \(N\) gets larger, but it's around 93% for all pairs of plumbings. However, the accuracy for DQN drops significantly from around 86% to 42% when \(N\) increases from \(N=20\) to \(N=100\).

On the right in Figure 6, we show the average number of actions that the agent takes until obtaining a pair of exactly same two plumbings from an initial pair of equivalent plumbings. For A3C agent, the

Figure 6: Performance comparison between A3C and DQN algorithms.
average numbers of actions do not exceed around 1.35 times \(N\), which means the trained A3C agent has a good efficiency to make a plumbing simpler. The DQN agent needs similar number of actions to the A3C for \(N=20\) and \(N=40\). However, it takes almost twice as many number of actions as A3C for larger \(N\).

We have also studied the distribution of Neumann moves (or actions) that the A3C agent performs before and after training to simplify plumbings generated with \(N=100\). In Figure 7, we plot the number of each Neumann move taken by the agent divided by \(N\). In the plot, moves 1-5 denote blow-up moves and moves 6-8 denote blow-down moves.

It is natural to observe that all blue dots in Figure 7 lay on the line \(y=0.125\), because the untrained agent takes each action equally often from a uniform distribution. On the other hand, red dots for trained agent show that the agent takes blow-down moves (moves 6-8) with a probability of around 75% and takes blow-up moves (moves 1-5) with the remaining probability. This makes sense from the fact that blow-down moves can actually make the plumbing simpler and get a less punishment than blow-up moves. Especially, we see that the move 7, blow-down move of type (b), is the most frequent action and the move 1, blow-up move of type (a), is the least frequent action. This is explained by the fact that the move 1 is not helpful for the agent to get a simpler plumbing.

Before we jump into the conclusion, it is interesting to check whether or not the trained A3C agent is indeed maximizing the total return instead of immediate rewards by a simple example depicted in 8. The left plumbing in Figure 8 is a standard representation that realizes a 3-manifold known as a Brieskorn 3-sphere \(\overline{\Sigma(2,3,5)}\), while the plumbing on the right represents a homeomorphic 3-manifold which can also be considered as the boundary of the \(E_{8}\) manifold. As one can see immediately, the plumbing on the right in Figure 8 does not have nodes available for blow-down moves. Therefore, in order to get the left plumbing from the right one, the RL agent should take appropriate blow-up moves first, then taking available blow-down moves. This is why we take this example for the test. We notice that 6 actions are needed to turn one plumbing into the other in an optimal way.

The trained A3C agent successfully simplify the \(E_{8}\) plumbing to the plumbing \(\overline{\Sigma(2,3,5)}\) by taking 16 actions, while the trained DQN does not find a solution until the number of actions exceeds 50. This test ensures that the A3C agent indeed pursues not short-term rewards, but its maximal long-term return.

Figure 7: Comparison of the number of Neumann moves taken by a trained A3C agent and an untrained A3C agent to simplify plumbing. The values shown are the total number of Neumann moves of a given type divided by the total number of actions performed, aggregated over multiple examples.
## 5 Conclusion and Future Work

### Conclusion

In this paper we have examined the GNN approach to the problems in 3-dimensional topology, which ask whether two given plumbing graphs represent a same 3-manifold or not, and whether or not it is possible to find out the sequence of Neumann moves that connects two plumbings if they are equivalent.

In Section 3, we used supervised learning to solve the binary classification of whether or not a pair of plumbings is equivalent. We built 3 models by combining graph convolution operators GEN, GCN and GAT, together with a certain graph aggregation module and an MLP as a classifier. We found that GEN + GAT model outperformed GCN + GCN and GCN + GAT models on randomly generated training datasets with maximal number \(N_{\max}=40\) of applied Neumann moves. GEN + GAT achieved about 95% accuracy while accuracy for the others is below 80%. We also tested those 3 models on randomly generated testsets with larger \(N_{\max}=60\) and \(N_{\max}=80\). Even though those models were trained by a training sets with \(N_{\max}=40\), it is an interesting point that, on such testsets, they still performed on a similar level to their training performance.

In Section 4, we utilized reinforcement learning to find out the sequence of Neumann moves that relates to a given pair of equivalent plumbings. We trained the agent such that it could find the simplest representation of a plumbing by using Neumann moves as its actions. We define the simplicity as a certain linear combination of number of nodes and sum of the absolute value of node features. We ran the trained agent on each of two equivalent plumbings until it arrived at two isomorphic plumbings. In this way, we can construct a sequence of Neumann moves connecting two equivalent plumbings. Using A3C algorithm, we see that the agent can find a sequence of Neumann moves in over 90% of randomly generated equivalent plumbing pairs even with \(N_{max}=100\). This outperforms the DQN agent by a factor of around 1.5 when \(N=60\), and by more than a factor of 2 when \(N=100\).

### Future work

In this paper we have used Geometric Deep Learning, GNN in particular, in the problem of classification of 3-manifolds up to homeomorphisms. We restricted to a special simple class of 3-manifolds corresponding to tree plumbing graphs. We hope to apply similar neural network models for more general 3-manifolds and also 4-manifolds in the future. One direct generalization would be considering 3-manifolds corresponding to general plumbing graphs described in [14], possibly disconnected, with loops, and with non-trivial genera assigned to the vertices7. This, in particular, would involve considering extra features associated to the vertices and also to the edges of graphs, as well as additional set of moves relating equivalent graphs. A more interesting generalization would be considering general Kirby diagrams for 3-manifolds. A Kirby diagram of a 3-manifold is a planar diagram of a link with an integer framing number assigned to each link component. The 3-manifold corresponding to the diagram is then obtained by performing Dehn surgery on this framed link. Two diagrams produce homeomorphic 3-manifolds if and only if they can be related by a sequence of Reidemeister moves (that do not change the isotopy class of the link) together with the so-called Kirby, or equivalently, Fenn-Rourke moves that do change the link but not the

Figure 8: Two equivalent representations of a plumbed 3-manifold \(\overline{\Sigma(2,3,5)}\).
resulting 3-manifold (up to homeomorphism). Such a diagram can be understood as a 4-regular plane graph with additional data specifying the types of crossings in the link diagram and the framings of the link components. Alternatively, one can consider Tait graph associated to a checkboard coloring of the link diagram. For practical purposes, this presentation most likely will be more efficient. The Reidemeister, as well as Kirby/Fenn-Rourke moves then can be understood again as certain local operations on graphs associated with Kirby diagrams. The main new challenge would be incorporating the structure of the planar embedding of the graph in GNN. This can be done, for example, by specifying the cyclic order of edges at each vertex, or cyclic order of edges for each face of the plane graph. This additional structure should be taken into account in the layers of the network. This is not considered in most standard GNN architectures. A further step would be the problem of recognizing whether a pair of Kirby diagrams for 4-manifolds produces a diffeomorphic pair. Such Kirby diagrams are again framed link diagrams that also contain special "dotted" link components. There is a corresponding set of local Kirby moves that relate diagrams realizing diffeomorphic 4-manifold. For a comprehensive reference about the Kirby diagrams of 3- and 4-manifold we refer to [26].

## Acknowledgements

We would like to thank Sergei Gukov for the useful comments and suggestions on the draft of the paper. We would also like to thank the anonymous referees who provided insightful and detailed comments and suggestions on a earlier version of the paper.

## Appendix A Algorithms

In this section, we provide details of the algorithms which have been used to generate datasets for training and testing both SL and RL models in Section 3 and Section 4.

* RandomPlumbing This algorithm generates a random plumbing tree by creating a random array for node features and building an adjacency matrix. It starts to choose a random integer as a number of nodes between 1 and 25. In general, there are \(N^{N-2}\) different plumbing trees with \(N\) nodes if we don't consider node features. Therefore, the upper limit 25 is large enough to generate around \(10^{6}\) random plumbing tess with statistically insignificant overlapping plumbings. The array of node feature is also created by randomly choosing an integer in the interval \((-20,20)\) for each node. Then we define the adjacency matrix for the plumbing tree, and the algorithm returns a pair of node feature array and adjacency matrix as data for the output plumbing. Note that all random process is done by using a uniform distribution.
* RandomNeumannMove The role of this algorithm is to apply a randomly chosen Neumann move to a random node of the input plumbing, then returns the resulting plumbing. A random Neumann move is characterized by 3 variables, i.e., \(type\), \(updown\), and \(sign\). Here \(type\in\{1,2,3\}\) denotes 3 types of Neumann moves depicted in Figure 2, \(updown\in\{1,-1\}\) points out blow-up (\(updown=1\)) or blow-down (\(updown=-1\)), and \(sign\in\{1,-1\}\) denotes the sign of the new vertex for blow-up Neumann moves of type (b) and (c). Notice that other moves does not require \(sign\). The algorithm first takes a random node of the input and fixes a random tuple \((type,updown,sign)\) from a uniform distribution. Then it builds new node feature array and adjacency matrix for the plumbing obtained by applying the Neumann move to the chosen node. If the Neumann move determined by a tuple \((type,updown,sign)\) is an illegal move, the output plumbing is the same as the input. The algorithm also returns another variable \(done\in\{\textsc{True},\textsc{False}\}\), which makes it possible to notice whether the Neumann move to be applied is legal (\(done=\textsc{True}\)) or illegal (\(done=\textsc{False}\)). This variable \(done\) will be used to decide the rewards of actions in Section 4.
* EquivPair and InequPair These are used to generate an equivalent plumbing pair (EquivPair) or an inequivalent plumbing pair (InequivPair). At the first step, EquivPair generates an initial pair of isomorphic plumbings, while InequPair generates two inequivalent plumbings, by using RandomPlumbing. Then they
have the same process, in which they apply Neumann moves iteratively up to \(N_{\max}\) times to each plumbing in the initial pair. Then they return the resulting pair as well as a variable, named \(label\), which will be used for classification problem in Section 3. Notice that \(label=1\) for EquivPair and \(label=-1\) for InequPair.
* TweakPair This algorithm generates an inequivalent pair of plumbings, but with the same graph structure. One plumbing is generated by RandomPlumbing, and the other is obtained by tweaking a copy of the first plumbing, i.e., by making a small change to a feature of a randomly chosen node. These two plumbings form an initial pair. Since the adjacency matrices of two plumbings are same, they have the same graph structure. However, due to the small change, two plumbings are inequivalent. Then the algorithm has the same structure as in EquivPair and InequPair to apply random Neumann moves iteratively to each plumbing in the initial pair.

```
\(n\leftarrow\) random integer between \(1\) and \(25\)\(\triangleright\) number of nodes \(\mathbf{x}\leftarrow\) array of \(n\) random integers between \(-20\) and \(20\)\(\triangleright\) node features \(\mathbf{a}\gets n\times n\) matrix of zeros \(\triangleright\) initialize the adjacency matrix for\(i=2\) to \(n\)do\(\triangleright\) construct the adjacency matrix \(j\leftarrow\) random integer between \(1\) and \(i-1\) \(\mathbf{a}_{i,j},\mathbf{a}_{j,i}\gets 1\) endfor \(G\leftarrow(\mathbf{x},\mathbf{a})\)\(\triangleright\)\(G\) defines the plumbing return\(G\)
```

**Algorithm 1**RandomPlumbing

```
\(\mathbf{Require:}\) a plumbing \(G\)\(v\leftarrow\) a random node of \(G\)\(type\leftarrow\) a random choice in \(\{1,2,3\}\)\(updown\leftarrow\) a random choice in \(\{1,-1\}\) if\(updown=1\)then\(\triangleright\) blow-up move if\(type=1\)then\(G^{\prime}\leftarrow\) a plumbing applied a blow-up move of type (a) to the node \(v\) else\(sign\leftarrow\) a random choice in \(\{1,-1\}\)\(G^{\prime}\leftarrow\) a plumbing applied a blow-up move determined by \((type,sign)\) endif \(done\leftarrow\) True else\(\triangleright\) blow-down move if\(v\) can be removed by a blow-down move then\(G^{\prime}\leftarrow\) a plumbing applied a blow-down move to the node \(v\) \(done\leftarrow\) True else\(G^{\prime}\gets G\)\(\triangleright\) returns the input plumbing for a forbidden move \(done\leftarrow\) False endif endif endif return\((done,G^{\prime})\)
```

**Algorithm 2**RandomNeumannMove

```
\(\mathbf{x}\leftarrow\) array of \(n\) random integers between \(-20\) and \(20\)\(\triangleright\) initialize the adjacency matrix for\(i=2\) to \(n\)do\(\triangleright\) construct the adjacency matrix \(j\leftarrow\) random integer between \(1\) and \(i-1\)\(\mathbf{a}_{i,j},\mathbf{a}_{j,i}\gets 1\) endfor \(G\leftarrow(\mathbf{x},\mathbf{a})\)return\(G\)
```

**Algorithm 3**RandomPlumbing

```
\(\mathbf{Require:}\) a plumbing \(G\)\(v\leftarrow\) a random node of \(G\)\(type\leftarrow\) a random choice in \(\{1,2,3\}\)\(updown\leftarrow\) a random choice in \(\{1,-1\}\) if\(updown=1\)then\(\triangleright\) blow-up move if\(type=1\)then\(G^{\prime}\leftarrow\) a plumbing applied a blow-up move of type (a) to the node \(v\) else\(sign\leftarrow\) a random choice in \(\{1,-1\}\)\(G^{\prime}\leftarrow\) a plumbing applied a blow-up move determined by \((type,sign)\) endif \(done\leftarrow\) True else\(\triangleright\) blow-down move if\(v\) can be removed by a blow-down move then\(G^{\prime}\leftarrow\) a plumbing applied a blow-down move to the node \(v\) \(done\leftarrow\) True else\(G^{\prime}\gets G\)\(\triangleright\) returns the input plumbing for a forbidden move \(done\leftarrow\) False endif endif endif return\((done,G^{\prime})\)
```

**Algorithm 4**RandomPlumbing

```
\(\mathbf{x}\leftarrow\) array of \(n\) random integers between \(-20\) and \(20\)\(\triangleright\) initialize the adjacency matrix for\(i=2\) to \(n\)do\(\triangleright\) construct the adjacency matrix \(j\leftarrow\) random integer between \(1\) and \(i-1\)\(\mathbf{a}_{i,j},\mathbf{a}_{j,i}\gets 1\) endfor \(G\leftarrow(\mathbf{x},\mathbf{a})\)return\(G\)
```

**Algorithm 5**RandomPlumbing

```
\(\mathbf{Require:}\) a plumbing \(G\)\(v\leftarrow\) a random node of \(G\)\(type\leftarrow\) a random choice in \(\{1,2,3\}\)\(updown\leftarrow\) a random choice in \(\{1,-1\}\)\(updown=1\)then\(\triangleright\) blow-up move if\(type=1\)then\(G^{\prime}\leftarrow\) a plumbing applied a blow-up move of type (a) to the node \(v\) else\(sign\leftarrow\) a random choice in \(\{1,-1\}\)\(G^{\prime}\leftarrow\) a plumbing applied a blow-up move determined by \((type,sign)\) endif \(done\leftarrow\) True else\(\triangleright\) blow-down move if\(v\) can be removed by a blow-down move then\(G^{\prime}\leftarrow\) a plumbing applied a blow-down move to the node \(v\) \(done\leftarrow\) True else\(G^{\prime}\gets G\)\(\triangleright\) returns the input plumbing for a forbidden move \(done\leftarrow\) False endif endif endif return\((done,G^{\prime})\)
```

**Algorithm 5**RandomPlumbing

```
\(\mathbf{x}\leftarrow\) array of \(n\) random integers between \(-20\) and \(20\)\(\triangleright\) initialize the adjacency matrix for\(i=2\) to \(n\)do\(\triangleright\) construct the adjacency matrix for\(i=2\) to \(n\)do\(\triangleright\) construct the adjacency matrix \(j\leftarrow\) random integer between \(1\) and \(i-1\)\(\mathbf{a}_{i,j},\mathbf{a}_{j,i}\gets 1\) endfor \(G\leftarrow(\mathbf{x},\mathbf{a})\)return\(G\)
```

**Algorithm 6**RandomPlumbing

```
\(\mathbf{Require:}\) a plumbing \(G\)\(v\leftarrow\) a random node of \(G\)\(type\leftarrow\) a random choice in \(\{1,2,3\}\)\(updown\leftarrow\) a random choice in \(\{1,-1\}\)\(updown=1\)then\(\triangleright\) blow-up move if\(type=1\)then\(G^{\prime}\leftarrow\) a plumbing applied a blow-up move of type (a) to the node \(v\) else\(sign\leftarrow\) a random choice in \(\{1,-1\}\)\(G^{\prime}\leftarrow\) a plumbing applied a blow-up move determined by \((type,sign)\) endif \(done\leftarrow\) True else\(\triangleright\) blow-down move if\(v\) can be removed by a blow-down move then\(G^{\prime}\leftarrow\) a plumbing applied a blow-down move to the node \(v\) \(done\leftarrow\) True else\(G^{\prime}\gets G\)\(\triangleright\) returns the input plumbing for a forbidden move \(done\leftarrow\) False endif endif endif return\((done,G^{\prime})\)
```

**Algorithm 6**RandomPlumbing

```
\(\mathbf{x}\leftarrow\) array of \(n\) random integers between \(-20\) and \(20\)\(\triangleright\) initialize the adjacency matrix for\(i=2\) to \(n\)do\(\triangleright\) construct the adjacency matrix for\(i=2\) to \(n\)do\(\triangleright\) construct the adjacency matrix for\(j=\) random integer between \(1\) and \(i-1\)\(\mathbf{a}_{i,j},\mathbf{a}_{j,i}\gets 1\) endfor \(G\leftarrow(\mathbf{x},\mathbf{a})\)return\(G\)
```

**Algorithm 7**RandomPlumbing

``` \(\mathbf{Require:}\) a plumbing \(G\)\(v\leftarrow\) a random node of \(G\)\(type\leftarrow\) a random choice in \(\{1,2,3\}\)\(updown\leftarrow\) a random choice in \(\{1,-1\}\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(updown=1\)\(down=down=1\)\(updown=1\)\(down=1\)\(down=down=1\)\(down=1\)\(down=down=1\)\(down=down=1\)\(down=down=1\)\(down=down=1\)\(down=down=1\)\(down=down=1\)\(down=down=1\)\(down=down=down=1\)\(down=down=1\)\(down=down=down=1\)\(down=down=1\)\(down=down=down=1\)\(down=down=down=1\)\(down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=1\)\(down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=1\)\(down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=down=1\)\(down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=down=1\)\(down=down=down=
```
Require:\(N_{\max}\in\mathbb{Z}^{+}\) \(G\leftarrow\) a plumbing by RandomPlumbing \(G_{1}\gets G\) \(n_{1}\leftarrow\) a random integer between 1 and \(N_{\max}\) for\(i=1\) to \(n_{1}\)do\(G_{1}\leftarrow\) RandomNeumannMove\((G_{1})\) endfor \(G_{2}\gets G\) \(n_{2}\leftarrow\) a random integer between 1 and \(N_{\max}\) for\(j=1\) to \(n_{2}\)do\(G_{2}\leftarrow\) RandomNeumannMove\((G_{2})\) endfor \(label\gets 1\) return\(G_{1},G_{2},label\)
```

**Algorithm 3** EQUIVPAIR

```
Require:\(N_{\max}\in\mathbb{Z}^{+}\) \(G_{1}\leftarrow\) a plumbing by RandomPlumbing \(G_{2}\leftarrow G_{1}\) \(v\leftarrow\) a random node in \(G_{2}\) \(t\leftarrow\) a random integer between -3 and 3, not 0. \(\mathbf{x}\leftarrow\) node feature of \(G_{2}\) \(\mathbf{a}\leftarrow\) adjacency matrix of \(G_{2}\) \(\mathbf{x}_{v}\leftarrow\mathbf{x}_{v}+t\) \(G_{2}\leftarrow\) a plumbing with \((\mathbf{x},\mathbf{a})\) \(n_{1}\leftarrow\) a random integer between 1 and \(N_{\max}\) for\(i=1\) to \(n_{1}\)do\(G_{1}\leftarrow\) RandomNeumannMove\((G_{1})\) endfor \(n_{2}\leftarrow\) a random integer between 1 and \(N_{\max}\) for\(i=1\) to \(n_{2}\)do\(G_{2}\leftarrow\) RandomNeumannMove\((G_{2})\) endfor \(label\gets-1\) return\(G_{1},G_{2},label\)
```

**Algorithm 4** INEQUIVPAIR

```
Require:\(N_{\max}\in\mathbb{Z}^{+}\) \(G_{1}\leftarrow\) a plumbing by RandomPlumbing \(G_{2}\leftarrow G_{1}\) \(v\leftarrow\) a random node in \(G_{2}\) \(t\leftarrow\) a random integer between -3 and 3, not 0. \(\mathbf{x}\leftarrow\) node feature of \(G_{2}\) \(\mathbf{a}\leftarrow\) adjacency matrix of \(G_{2}\) \(\mathbf{x}_{v}\leftarrow\mathbf{x}_{v}+t\) \(G_{2}\leftarrow\) a plumbing with \((\mathbf{x},\mathbf{a})\) \(n_{1}\leftarrow\) a random integer between 1 and \(N_{\max}\) for\(i=1\) to \(n_{1}\)do\(G_{1}\leftarrow\) RandomNeumannMove\((G_{1})\) endfor \(n_{2}\leftarrow\) a random integer between 1 and \(N_{\max}\) for\(i=1\) to \(n_{2}\)do\(G_{2}\leftarrow\) RandomNeumannMove\((G_{2})\) endfor \(label\gets-1\) return\(G_{1},G_{2},label\)
```

**Algorithm 5** TweakPair
Figure 9: An example of a pair of equivalent plumbing graphs generated by EQUIVPAIR with the number of Neumann moves fixed to \(N=40\). The graphs are successfully recognized as equivalent both by the RL agent trained by A3C algorithm considered in Section 4 and the GEN+GAT neural network considered in Section 3.