In this section we show that graph canonisation, and thus graph isomorphism, is \(\mathsf {FPT}\) parameterized by elimination distance to bounded degree. The algorithm is based on Lindell’s algorithm [13] that decides isomorphism of trees by establishing an ordering on them. We extend a version of this algorithm used by Bouland et al. [2] to decide isomorphism on graphs of bounded tree-depth.
The central idea is to define a pre-order \(\sqsubseteq \) on graphs \((G,{\le })\) equipped with an elimination order to degree d, with the property that \((G,{\le }) \sqsubseteq (G',{\le '})\) and \((G',{\le }) \sqsubseteq (G,{\le '})\) if, and only if, \((G,{\le })\) is isomorphic to \((G',{\le '})\). We then exhibit an algorithm that constructs, given a graph G, the elimination order to degree d on G that makes \((G,{\le })\)
\(\sqsubseteq \)-minimal. This serves as a canonical representative of G. Before defining \(\sqsubseteq \) formally, we need some additional terminology.
Definition 6.1
Let G be a graph and let \(\le \) be a tree order for G. The level of a vertex \(v \in V(G)\) is the length of the chain \(\{w \in V(G) \mid w \le v\}\). We denote the level of v by \( level _<(v)\).
Definition 6.2
Let G be a graph. We denote the number of connected components of G by \(\#G\).
The definition of \(\sqsubseteq \) is by induction on the height of the order \(\le \). Inductively, we need to consider coloured graphs and so formally, \(\sqsubseteq _k\) is a pre-order on triples \((G,\chi ,{\le })\) where \(\chi : V(G) \rightarrow X\) is a colouring of G and \(\le \) is an elimination order to degree d of G. We always assume that the set of colours X is an initial segment of the natural numbers and so, in particular, linearly ordered.
Definition 6.3
For a graph G, with a colouring \(\chi : V(G) \rightarrow X\) and a vertex \(v \in V(G)\), we write \(\chi _v\) for the colouring of \(G{\setminus } v\) given by \(\chi _v: V(G{\setminus } v) \rightarrow X \times \{0,1\}\) where \(\chi _v(u) = (\chi (u),1)\) if \((u,v) \in E(G)\) and \(\chi _v(u) = (\chi (u),0)\) if \((u,v) \not \in E(G)\).
By Theorem 2.4 we can find a canonical form of each coloured graph Z of degree at most d in polynomial time, and thus a pre-order \(\sqsubseteq _0\) such that for every pair of \(Z,Z'\) of such graphs, either \(Z \sqsubseteq _0 Z'\) or \(Z' \sqsubseteq _0 Z\) and \(Z \cong Z'\) if, and only if, both \(Z \sqsubseteq _0 Z'\) and \(Z' \sqsubseteq _0 Z\).
In the following definition we extend this to a pre-order \(\sqsubseteq \) on coloured graphs with an elimination order to degree d by induction on the height of the order.
Definition 6.4
Let \(G, G'\) be graphs with colourings \(\chi \) and \(\chi '\) and respective elimination orders \(\le , \le '\) to degree d. We say that \((G, \chi , {\le }) \sqsubseteq (G', \chi ', {\le '})\) if one of the following holds:
-
1.
\(\mathrm {height}(\le ) < \mathrm {height}(\le ')\);
-
2.
\(\mathrm {height}(\le ) = \mathrm {height}(\le ') = 0\) and \((G, \chi ) \sqsubseteq _0 (G', \chi ')\);
-
3.
\(\mathrm {height}(\le ) = \mathrm {height}(\le ') > 0\) and \(\#G < \#{G'}\);
-
4.
\(\mathrm {height}(\le ) = \mathrm {height}(\le ') > 0\), \(\#G = \#{G'} = 1\) and \(\chi (v) < \chi '(v')\) where \(v, v'\) are minimal elements of \(G, G'\) with respect to \({\le }, {\le '}\) respectively;
-
5.
\(\mathrm {height}(\le ) = \mathrm {height}(\le ') > 0\), \(\#G = \#{G'} = 1\) and
$$\begin{aligned} (G {\setminus } v,\chi _v, {\le }) \sqsubseteq (G' {\setminus } v', \chi '_{v'},{\le '}), \end{aligned}$$
where \(v, v'\) are minimal elements of \(G, G'\) with respect to \({\le }, {\le '}\) respectively;
-
6.
\(\mathrm {height}(\le ) = \mathrm {height}(\le ') > 0\), \(s = \#G = \#{G'} > 1\), and there is an enumeration \(G_1, \dots , G_s\) of the components of G and \(G_1', \dots , G_s'\) of the components of \(G'\) such that
-
(a)
whenever \(i \le j\), \((G_i,\chi ,{\le }) \sqsubseteq (G_j, \chi ,{\le })\) and \((G_i', \chi ',{\le '}) \sqsubseteq (G_j', \chi ',{\le '})\); and
-
(b)
if for any i, \((G_i,\chi ,{\le }) \not \sqsubseteq (G_i', \chi ',{\le '})\), then there is a \(j < i\) such that \((G_j', \chi ',{\le '}) \not \sqsubseteq (G_j, \chi ,{\le })\).
To see that this inductive definition is well-founded, note that the recursive use of \(\sqsubseteq \) is on graphs either equipped with an elimination order to degree d of strictly smaller height [clause (5)] or with strictly fewer components [clause (6)]. The next two propositions are aimed at showing that this definition establishes a linear pre-order on coloured graphs with an elimination order that classifies them up to isomorphism
Proposition 6.5
For any pair \((G,\chi , {\le })\), \((G', \chi ', {\le '})\) of coloured graphs with an elimination order to degree d, at least one of \((G,\chi , {\le }) \sqsubseteq (G', \chi ', {\le '})\) or \((G',\chi ', {\le '}) \sqsubseteq (G, \chi , {\le })\) holds.
Proof
The proof is by induction on the height k of \(\le \) and for a fixed k, by induction on the number of components. If \(k=0\), then either \(\mathrm {height}(\le ') > 0\) and \((G,\chi , {\le }) \sqsubseteq (G', \chi ', {\le '})\) by clause (1) of the definition, or \(\mathrm {height}(\le ') = 0\) and at least one of \((G,\chi , {\le }) \sqsubseteq (G', \chi ', {\le '})\) or \((G',\chi ', {\le '}) \sqsubseteq (G, \chi , {\le })\) must hold by clause (2) and the definition of \(\sqsubseteq _0\).
Now suppose \(k > 0\). If one of the first four conditions of Definition 6.4 is satisfied, we are done. So suppose they fail and suppose \(\#G = \#{G'} = 1\). Then, if v and \(v'\) are the minimal elements of \(G, G'\) with respect to \({\le }, {\le '}\), the height of these orders on \(G {\setminus } v\) and \(G' {\setminus } v'\) is strictly less than k. By induction hypothesis, either \((G {\setminus } v,\chi _v, {\le }) \sqsubseteq (G' {\setminus } v', \chi '_{v'},{\le '})\) or \((G' {\setminus } v',\chi _{v'}, {\le '}) \sqsubseteq (G {\setminus } v, \chi _{v},{\le })\), so the claim follows.
Finally, suppose \(\mathrm {height}(\le ) = \mathrm {height}(\le ') > 0\) and \(s = \#G = \#{G'} > 1\) and we argue that in all such cases, clause (6) ensures the result. By the induction hypothesis and the previous case, for any pair of components \(G_i\) and \(G_j\) of G, one of \((G_i,\chi ,{\le }) \sqsubseteq (G_j, \chi ,{\le })\) or \((G_j,\chi ,{\le }) \sqsubseteq (G_i, \chi ,{\le })\) must hold and similarly for the components of \(G'\). Thus, the components of each can be ordered so that whenever \(i \le j\), \((G_i,\chi ,{\le }) \sqsubseteq (G_j, \chi ,{\le })\) and \((G_i', \chi ',{\le '}) \sqsubseteq (G_j', \chi ',{\le '})\). Also, by the induction hypothesis, we have for each i, either \((G_i,\chi ,{\le }) \sqsubseteq (G_i', \chi ',{\le '})\) or \((G_i',\chi ',{\le '}) \sqsubseteq (G_i, \chi ,{\le })\). If the first case holds for all i, then \((G,\chi , {\le }) \sqsubseteq (G', \chi ', {\le '})\). If the second case holds for all i, then \((G',\chi ', {\le '}) \sqsubseteq (G, \chi , {\le })\). If neither holds for all i, consider the least i such that either \((G_i,\chi ,{\le }) \not \sqsubseteq (G_i', \chi ',{\le '})\) or \((G_i',\chi ',{\le '}) \not \sqsubseteq (G_i, \chi ,{\le })\). In the former case, we have \((G',\chi ', {\le '}) \sqsubseteq (G, \chi , {\le })\) and in the latter \((G_i,\chi ,{\le }) \sqsubseteq (G_i', \chi ',{\le '})\). In all cases, the proposition is established.
This proposition implies that it is always possible to enumerate the components \(G_1, \dots , G_s\) of G in \(\sqsubseteq \)-order. The next proposition shows that this order is, essentially, unique.
Proposition 6.6
Let \(G, G'\) be graphs with colourings \(\chi \) and \(\chi '\) and let \({\le }, {\le '}\) be elimination orders to degree d on \(G, G'\) respectively.
Then both \((G,\chi , {\le }) \sqsubseteq (G', \chi ', {\le '})\) and \((G', \chi ', {\le '}) \sqsubseteq (G, \chi , {\le })\) if, and only if, \((G, \chi , {\le }) \cong (G', \chi , {\le '})\).
Proof
Suppose \((G, \chi , {\le }) \cong (G', \chi , {\le '})\) and suppose, without loss of generality that \((G,\chi , {\le }) \sqsubseteq (G', \chi ', {\le '})\). We aim to show that also \((G', \chi ', {\le '}) \sqsubseteq (G, \chi , {\le })\), and we do this by induction on the height k of \(\le \) and for a fixed k, by cases on the number of components. If \(k = 0\) then since \((G,\chi ) \cong (G',\chi ')\), the conclusion follows from the definition of \(\sqsubseteq _0\) and clause (2) of Definition 6.4. If \(k > 0\) and \(\# G = 1\) then the induction hypothesis and the fact that \((G {\setminus } v,\chi _v, {\le }) \cong (G' {\setminus } v', \chi '_{v'},{\le '})\) together imply that \((G {\setminus } v,\chi _v, {\le }) \sqsubseteq (G' {\setminus } v', \chi '_{v'},{\le '})\) and \((G' {\setminus } v',\chi '_{v'}, {\le '}) \sqsubseteq (G {\setminus } v, \chi _{v},{\le })\), so the proposition holds by clause (4) of Definition 6.4. Finally, suppose that \(k > 0\) and \(\# G > 1\) and let \(G_1,\ldots ,G_s\) enumerate the components of G in \(\sqsubseteq \) order. By the isomorphism between \((G,\chi , {\le })\) and \((G', \chi ', {\le '})\) and the induction hypothesis, it follows that for the corresponding enumeration \(G_1',\ldots ,G_s'\) of components of \(G'\) in \(\sqsubseteq \) order, we have that \((G_i, \chi , {\le }) \cong (G_i', \chi , {\le '})\) for each i. Then by clause (6) of Definition 6.4, both \((G,\chi , {\le }) \sqsubseteq (G', \chi ', {\le '})\) and \((G', \chi ', {\le '}) \sqsubseteq (G, \chi , {\le })\) hold.
For the other direction, suppose \((G,\chi , {\le }) \sqsubseteq (G', \chi ', {\le '})\) and \((G', \chi ', {\le '}) \sqsubseteq (G, \chi , {\le })\) If \(\mathrm {height}(\le ) < \mathrm {height}(\le ')\), then \((G', \chi ', {\le '}) \not \sqsubseteq (G, \chi , {\le })\), so assume that \(\mathrm {height}(\le ) = \mathrm {height}(\le ') = k\) and we proceed by induction on k. If \(k=0\), we have by clause (2) that \((G, \chi ) \sqsubseteq _0 (G', \chi ')\) and \((G',\chi ') \sqsubseteq _0 (G, \chi )\) which, by definition of \(\sqsubseteq _0\) means that \((G, \chi ) \cong (G', \chi )\), and the two orders are both trivial.
Suppose then that \(k > 0\) and assume first that G and \(G'\) are both connected. Then both \(G, G'\) have minimal elements \(v, v'\) with respect to \({\le }, {\le '}\). By the induction hypothesis we have \((G {\setminus } v, \chi _v {\le }) \cong (G' {\setminus } v', \chi _{v'},{\le '})\), so let \(\sigma : V(G {\setminus } v) \rightarrow V(G' {\setminus } v')\) be an isomorphism witnessing this. Extend this to \(\hat{\sigma } : V(G) \rightarrow V(G')\) by setting \(\hat{\sigma }(v) = v'\) and we claim that this is an isomorphism between \((G,\chi , {\le })\) and \((G',\chi ', {\le '})\). It is clear that \(\hat{\sigma }\) takes the order \(\le \) to \(\le '\) since v and \(v'\) are minimal for these respective orders. Also, \(\hat{\sigma }\) preserves colours since the colourings \(\chi _v\) and \(\chi _{v'}\) refine the colourings \(\chi \) and \(\chi '\) respectively and by clause (4) we have \(\chi (v) = \chi '(v')\). Finally, we need to verify that \(\hat{\sigma }\) preserves the edge relation. Since \(\sigma \) preserves all edges, we only need to verify that \(uv \in E(G)\) if, and only if, \(\hat{\sigma }(u)v' \in E(G')\). But, this follows from the fact that \(\chi _v(u) = \chi '_{v'}(\sigma (u))\).
Now, if G and \(G'\) have different number of connected components, then we cannot have both \((G,\chi , {\le }) \sqsubseteq (G', \chi ', {\le '})\) and \((G', \chi ', {\le '}) \sqsubseteq (G, \chi , {\le })\). So, we are left with the case where \(\#G = \#G' = s > 1\). Let \(G_1 \sqsubseteq \cdots \sqsubseteq G_s\) be the connected components of G and let \(G_1' \sqsubseteq \cdots \sqsubseteq G_s'\) be the connected components of \(G'\). Then by definition of \(\sqsubseteq \) we have that both \((G_i,\chi ,{\le }) \sqsubseteq (G_i',\chi ',{\le '})\) and \((G_i',\chi ',{\le '}) \sqsubseteq (G_i,\chi ,{\le })\) for each \(i \le s\). By the argument for connected graphs above, we have \((G_i,\chi ,{\le }) \cong (G_i',\chi ',{\le '})\) for each i and we are done.
In order to define an algorithm for constructing a minimal elimination order to degree d, we need one further ingredient. For a graph G of tree-depth k, we say that a vertex v is a potential root of a minimal elimination order on G if \(\mathop {td}(G {\setminus } v) < k\). We know from Bouland et al. [2] that there is a computable function f such that the number of potential roots in any graph of tree-depth k is at most f(k). Moreover, the set of all such vertices can be found by an algorithm running in time \(f(k)n^3\) where n is the number of vertices in G. This now allows us to define Algorithm 1 which computes a minimal elimination order to degree d. The algorithm is started with the graph G, its d-degree torso C, the level \(\ell \) initially set to 0 and the degree d. It then recursively chooses a potential root and returns the order that is minimal with respect to \(\sqsubseteq \).
With this, we are able to establish our main result.
Theorem 6.7
Graph Canonisation is \(\mathsf {FPT}\) parameterized by elimination distance to bounded degree.
Proof
Suppose we are given a graph G with \(|V(G)| = n\). We first compute the d-degree torso C of G in \(O(n^4)\) time. Using Algorithm 1 we compute a \(\sqsubseteq \)-minimal elimination order \(<\) to degree d on G. By the analysis from Bouland et al. [2, Theorem 11], this takes time \(O(h(k)n^3log(n))\) for some computable function h. Note for the base case that we can compute the canonical representation of a component Z with \(\Delta (Z) \le d\) by Theorem 2.4 in polynomial time (where the degree of the polynomial depends on d).
Note that the order \(\sqsubseteq \) also induces a natural order on the vertices of G and we can thus enumerate the vertices of G in a canonical way in linear time.
Corollary 6.8
Graph Isomorphism is \(\mathsf {FPT}\) parameterized by elimination distance to bounded degree.