Graph Isomorphism on graphs of bounded treewidth

The Graph Isomorphism problem is interesting for many reasons, case one being the fact that its complexity status is still unclear - it is probably not NP-complete, mind but not known to be in P either. In the past decades, seek researchers identified a large number of special graph classes for which GI is polynomial-time solvable, including planar graphs, graphs of bounded maximum degree, and graphs excluding a fixed minor, among others.

A closer look at the known algorithms for graphs of bounded degree or graphs excluding a fixed minor reveals that the dependency in the running time bound on the "forbidden pattern" is quite bad: n^{f(Delta)} in the first case or n^{f(H)} in the second case, for some function f. Seeing such dependencies, a natural question is: do there exist fixed-parameter algorithms, parameterized by the "forbidden pattern"? In other words, does the exponent in the polynomial factor in n need to depend on the pattern, on can we obtain an algorithm with running time f(H) cdot n^{O(1)}?

This question remains widely open for all aforementioned cases of bounded degree or excluded minor. In our recent FOCS 2014 paper, we have answered the question affirmatively for the special case of bounded treewidth graphs, proving that isomorphism of two n-vertex graphs of treewidth k can be tested in time 2^{O(k^5 log k)} n^5.

As a starting point, observe that comparing (testing isomorphism) of two graphs together with their given tree decompositions (that is, we want to check if the whole structures consisting of a graph and its decomposition are isomorphic) can be done easily in time polynomial in the size of the graphs, and exponential in the width of the decompositions. This is a relatively standard, but tedious, exercise from the area of designing dynamic programming algorithms on tree decompositions: if you have seen a few of these, I guess you can figure out the details, but if you don't, this is probably one of the worst examples to start with, so just assume it can be done. Alternatively, you may use the recent results of Otachi and Schweitzer that say that one needs only a set of bags for the decomposition, even without the structure of the decomposition tree itself.

With this observation, the task of comparing two bounded-treewidth graphs reduces to the following: given a graph G of treewidth k, we would like to compute in an isomorphic-invariant way a tree decomposition of $G$ of near-optimal width. Here, isomorphic-invariant means that we do not want to make any decisions depending on the representation of the graph in the memory (like, "take arbitrary vertex"), and the output decomposition should be the same (isomorphic) for isomorphic input graphs. Given such an isomorphic-invariant treewidth approximation algorithm, we can now compute the decompositions of both input graphs, and compare given pairs (graph, its tree decomposition), as described in the previous paragraph. Note that for this approach we do not need to output exactly one tree decomposition; we can output, say, n^2 of them, and compare every pair of decompositions for two input graphs for the Graph Isomorphism problem; we only need that the set of output decompositions is isomorphic invariant.

To cope with this new task, let us look at the known treewidth approximation algorithms; in particular, the arguably simplest one - the Robertson-Seymour algorithm. This algorithm provides a constant approximation in 2^{O(k)} cdot n^{O(1)} time, where k is the treewidth of the input n-vertex graph G. It is a recursive procedure that decomposes a part G[A] of the input graph, given a requirement that a set S subseteq A should be contained in the top bag of the output decomposition. Think of S as an interface to the rest of the graph; we will always have N(V(G) setminus A) subseteq S, but for technical reasons the set S could be larger. During the course of the algorithm we maintain an invariant |S| = O(k).

In the leaves of the recursion we have A = S, and we output a single bag A. If S is small, say, |S| < 100k, then we can add an arbitrary vertex to S and recurse. The interesting things happen when S grows beyond the threshold 100k. As the graph is of treewidth k, but |S| geq 100k, in an optimal decomposition of G the set S is spread across many bags. A simple argument shows that there exists a bag X, |X| leq k+1, such that every component of G[A setminus X] contains at most |S|/2 vertices of S. The algorithm takes S cup X as a root bag (note that |S|+|X| = O(k)), and recurses on every connected component of G[A setminus (S cup X)]; formally, for every connected component C of G[A setminus (S cup X)], we recurse on A = N[C] with S = N(C). Since every component of G[A setminus X] contains at most |S|/2 vertices of S, in every recursive call the new set S is of size at most |S|/2 + |X| < |S|. In the above algorithm, there are two steps that are very deeply not isomorphic-invariant: "take an arbitrary vertex to S" in the case of small S, and "take any such X" in the case of large S. We start fixing the algorithm in the second, more interesting case. Before we start, let us think how we can find such a set X - the argument provided two paragraphs ago only asserted its existence. One of the ways to do it is to iterate through all disjoint sets P,Q subseteq S of size exactly k+2 each, and check if the minimum separator between P and Q in G[A] is of size at most k+1 (such a separator can contain vertices of P or Q, these are deletable as well). If such a separator is found, it is a good candidate for the set X - it does not necessarily have the property that every connected component of G[A setminus X] contains at most half of the vertices of S, but the claim that in the recursive calls the size of the set S decreased is still true. Of course, in this approach we have two not isomorphic-invariant choices: the choice of P and Q, and the choice of the minimum separator X. Luckily, an (almost) isomorphic-invariant way to make the second choice has already been well understood: by submodularity of cuts, there exists a well-defined notion of the minimum cut closest to P, and the one closest to Q. But how about the choice of P and Q? The surprising answer is: it works just fine if we just throw into the constructed bag all separators for every choice of P and Q. That is, we start with the tentative bag B=S, we iterate over all such (ordered) pairs (P,Q), and throw into the constructed bag B the minimum cut between P and Q that is closest to P, as long as it has size at most k+1. We recurse on all connected components of G[A setminus B] as before; the surprising fact is that the sizes of the sets S in the recursive calls did not grow. To prove this fact, we analyse what happens to the components of G[A setminus B] when you add P-Q cuts one-by-one; a single step of this induction turns out to be an elementary application of submodularity. Furthermore, note that if the size of S is bounded in terms of k, so is the set of the bag B: |B| leq (k+1)|S|^{2k+4}.

Having made isomorphic-invariant the "more interesting" case of the Robertson-Seymour approximation algorithm, let us briefly discuss the case of the small set S: we need to develop an isomorphic-invariant way to grow this set. Here, we need some preprocessing: by known tricks, we can assume that (a) the input graph does not contain any clique separators, and (b) if uv<br />
otin E(G), then the minimum cut between u and v is of size at most k. Furthermore, observe that in our algorithm, contrary to the original Robertson-Seymour algorithm, we always maintain the invariant that S = N(V(G) setminus A) and G[A setminus S] is connected. Thus, S is never a clique in G, and, if |S| < 100k, we can throw into a bag the minimum cut between u and v that is closest to u, for every ordered pair (u,v) where u,v in S, uv 
otin E(G). In this way, the lack of clique separators ensures that we always make a progress in the algorithm, by "eating" at least one vertex of A setminus S. The bound on the size of minimum cut between two nonadjacent vertices ensures that the bag created in this way is of size O(k^3), and so are the sets S in the recursive calls. Consequently, our algorithm computes in an isomorphic-invariant way a tree decomposition with adhesions of size O(k^3) and bags of size 2^{O(k log k)}. Well, there is one small catch - neither of the aforementioned steps is good to start the algorithm, to provide the initial call of the recursion; the Robertson-Seymour approximation starts with just A = V(G) and S = emptyset. Here, we can start with A = V(G) and S = {u,v} for every pair {u,v} of nonadjacent vertices, as in this call the step with the small set S will work fine. But this produces not a single isomorphic-invariant tree decomposition, but a family of O(n^2) decompositions - which is still fine for the isomorphism test.

A cautious reader would also notice that the described algorithm results in a double-exponential dependency on the parameter k in the running time, contrary to the claim of the 2^{O(k^5 log k)} term. Getting down to this dependency requires a bit more technical work; we refer to the full version of our paper for details.