Towards an Isomorphism Dichotomy for Hereditary Graph Classes

In this paper we resolve the complexity of the isomorphism problem on all but finitely many of the graph classes characterized by two forbidden induced subgraphs. To this end we develop new techniques applicable for the structural and algorithmic analysis of graphs. First, we develop a methodology to show isomorphism completeness of the isomorphism problem on graph classes by providing a general framework unifying various reduction techniques. Second, we generalize the concept of the modular decomposition to colored graphs, allowing for non-standard decompositions. We show that, given a suitable decomposition functor, the graph isomorphism problem reduces to checking isomorphism of colored prime graphs. Third, we extend the techniques of bounded color valence and hypergraph isomorphism on hypergraphs of bounded color class size as follows. We say a colored graph has generalized color valence at most k if, after removing all vertices in color classes of size at most k, for each color class C every vertex has at most k neighbors in C or at most k non-neighbors in C. We show that isomorphism of graphs of bounded generalized color valence can be solved in polynomial time.


Introduction
Given two graphs G 1 and G 2 , the graph isomorphism problem asks whether there exists a bijection from the vertices of G 1 to the vertices of G 2 that preserves adjacency and non-adjacency. In this paper we continue the systematic investigation of the complexity of graph isomorphism on hereditary graph classes with a focus on classes characterized by finitely many forbidden induced subgraphs as initiated in [24] (see also [25]).
Given a set of finite graphs H 1 , . . . , H t we define (H 1 , . . . , H t )-free to be the class of all graphs that do not contain any H i as an induced subgraph. In the light of the unknown complexity status of the graph isomorphism problem, the goal in this context is typically to classify the complexity for the various graph classes into being polynomial time solvable or isomorphism complete (i.e., polynomially equivalent to graph isomorphism). Recently, in [30] it is shown that, assuming that graph isomorphism is not polynomial time solvable in general, there exist graph classes closed under taking (not necessarily induced) subgraphs which are of intermediate complexity. Trivially this implies the same conditional existence of hereditary graph classes (i.e., graph classes characterized by forbidden induced subgraphs) of intermediate complexity.
However, the construction in [30] intrinsically requires the use of infinitely many forbidden subgraphs. In contrast to this, in [30] it is also shown that there are no intermediate graph classes characterized by finitely many forbidden subgraphs. However, this statement does not carry over to forbidden induced subgraphs and the question of the existence of intermediate graph classes characterized by finitely many forbidden induced subgraphs remains open. A more precise statement of the dichotomy result in [30] is that a graph class characterized by finitely many forbidden subgraphs has a polynomial time solvable graph isomorphism problem if one of the forbidden graphs is a union of subdivided stars, and is graph isomorphism complete otherwise. These graphs, the forests of subdivided stars, also play a central role in the complexity of hereditary graph classes.
With respect to classes defined by forbidden induced subgraphs, there is a dichotomy for the isomorphism problem on (H 1 )-free graphs into polynomially solvable and isomorphism complete cases. In [24] the complexity of the isomorphism problem on (H 1 , H 2 )-free graphs is determined for various pairs (H 1 , H 2 ) and the results also follow the "polynomially solvable versus isomorphism complete" dichotomy. The crucial cases that were not resolved are those where either H 1 or H 2 is a complete graph. More specifically, except for finitely many cases, the unresolved cases were shown to be polynomially equivalent to a class where one of the graphs is a complete graph.
In the light of all of these results we conjecture the following: . . , H t )-free is a graph class defined by the finite set of forbidden induced subgraphs H 1 , . . . , H t then graph isomorphism of graphs in C is polynomial time solvable or isomorphism complete.
In this paper we continue the investigation of the complexity of the isomorphism problem on the graph classes focusing on the case of two forbidden subgraphs, where one of the graphs is complete. As mentioned above these are the crucial cases that were not resolved. For the resolution of those classes, techniques beyond those that were developed in [24] are required. These techniques are presented in this paper leading to the following theorem: Theorem 2. On all but finitely many classes of the form (H 1 , H 2 )-free the graph isomorphism problem is polynomial time solvable or isomorphism-complete.
Contribution. In order to prove the theorem, in this paper three new techniques for the structural and algorithmic analysis of graphs are developed.
Firstly, we develop a methodology to show isomorphism completeness of the isomorphism problem on graph classes by providing a unifying framework for various reductions typically used for that purpose. The advantage of this framework is that it allows a streamlined abstract way to argue why some class is isomorphism complete which boils down to a algorithmically checkable argument.
Secondly, we generalize the modular decomposition to colored graphs and define the concept of a colored modular decomposition with respect to a decomposition functor. This not only allows us to show that the graph isomorphism problem reduces to colored isomorphism of prime graphs but it also allows us to decompose graphs that are prime with respect to the classical modular decomposition. To show this reduction we also describe how to remodel an algorithm that has access to an oracle producing a complete invariant for a graph class into an algorithm that only has access to an isomorphism test of the graph class.
Thirdly, we extend the techniques of bounded color valence and hypergraph isomorphism on hypergraphs of bounded color class size as follows. We say a colored graph has generalized color valence at most k if, after removing all vertices in color classes of size at most k, for each color class C every vertex has at most k neighbors in C or at most k non-neighbors in C. We show that isomorphism of graphs of bounded generalized color valence can be solved in polynomial time. This generalization allows us to perform isomorphism tests for graphs whose automorphism group cannot be forced into having bounded size composition factors even when using finitely many individualization steps. Since for such graphs alternating groups of unbounded size can appear among the composition factors, it seems that the standard group theoretic techniques cannot be directly applied. This shows that indeed new techniques were required to solve the particular cases.
We apply the three mentioned techniques to resolve the complexity of isomorphism on all but finitely many of the graph classes characterized by two forbidden induced subgraphs. For the resolved classes we either provide a reduction from the general problem or a polynomial time algorithm. The applications of the techniques include for example showing that bipartite graphs that are free from a fixed forbidden double star refine into graphs of bounded generalized color valence. This can be used to show that isomorphism of graphs of bounded clique number with a fixed forbidden double star can be solved in polynomial time. We in turn apply this in conjunction with the colored modular decomposition technique to solve isomorphism for graphs of bounded clique number which do not contain P 5 (a path of length 4) as an induced subgraph. We apply the general reductions to show that classes of graphs without cliques of size 4 and certain unions of paths are extensive enough to have an isomorphism problem that is isomorphism complete. Furthermore we apply the modular decomposition techniques in conjunction with the bounded generalized color valence to analyze the structure of various graph classes of bounded clique number with certain forbidden forests of subdivided stars.
Related work. We refer the reader to [3,21,32] for an introduction to the diverse complexitytheoretic results related to the isomorphism problem. There are numerous results known on the complexity of graph isomorphism of hereditary graph classes. A collection showing the problem for many classes to be equivalent to the general problem is given by Booth and Colbourn [7]. In that paper the complexity of classes characterized by one forbidden subgraph H is shown to depend on whether the graph H is an induced subgraph of P 4 (the path on 4 vertices). The systematic study of classes characterized by two forbidden subgraphs was initiated in [24].
With regard to algorithms, a recent very general result, implying many results devised earlier on more special graph classes, is a theorem of Grohe and Marx [16] that shows that isomorphism of graph classes defined by a forbidden topological minor can be solved in polynomial time.
There are several applications of modules (sometimes called homogeneous sets) or some form of modular decomposition in the context of graph isomorphism. For example Goldberg's plain exponential algorithm [14] uses the concept of sections, which can be seen as colored modules. Furthermore Junttila and Kaski [20] define nonuniform components within the individualizationrefinement approach that also constitute colored modules. As described below, Rao [31] also exploits the classical modular decomposition to devise an isomorphism algorithm for gem and co-gem free graphs (i.e., (P 4∪ K 1 , P 4∪ K 1 )-free graphs). His technique can be seen as a special case of the techniques using colored modular decompositions described in this paper. Other hereditary graph classes, for which graph isomorphism algorithms make use of modular decomposition, are for example subclasses of circular-arc graphs (see [10]).
In the early stages of the discovery of the group theoretic technique for the isomorphism problem, Luks [27] applied it to show that isomorphism of graphs of bounded maximum degree can be solved in polynomial time. Babai [2] applied the notion of bounded color valence in his algorithm for the general isomorphism problem. Miller (see [28]) applied this technique in a series of papers to perform isomorphism tests of k-separable and k-contactable graphs as well as isomorphism of hypergraphs of bounded color class size (see also [1], [4] and [33]). In our generalization in this paper, only the subgraph induced by the color classes that are not of bounded size is required to exhibit bounded color valence.
Concerning dichotomies for problems on graph classes characterized by forbidden induced subgraphs there have been several studies aiming at dichotomy results for computational problem. For example for two forbidden subgraphs this has been done for the computation of the chromatic number [23], dominating sets [26] and coloring [12], and list coloring [15].
Moreover there are numerous results analyzing whether the clique width of a graph class characterized by forbidden subgraphs is bounded (see [11] for an extensive list of references).
Structure of the paper. We mainly apply the three techniques developed in this paper to classes characterized by two forbidden induced subgraphs. However, the intention behind their presentation is to allow them to be applicable in a broader sense to practical and theoretical algorithms for isomorphism of general graphs or maybe for the classes of bounded clique-width. The paper first presents the techniques and the second part, mostly contained in the appendix, explains how to apply them to various classes of two forbidden subgraphs.
In the first part of the paper we provide preliminaries such as introducing notation and recalling basic tools (Section 2). We then devise a methodology to prove isomorphism completeness results (Section 3) and briefly describe how to simulate a complete invariant given only an isomorphism algorithm (Section 5). After this we turn to techniques for isomorphism testing using modular decompositions (Section 6) and devise a polynomial time algorithm for graphs of bounded generalized color valence (Section 7).
The reduction techniques are applied to show the isomorphism completeness of various graph classes characterized by forbidden induced subgraphs (Section 4). The algorithmic techniques are then applied to graph classes with forbidden double stars (Section 8) and graph classes of graphs without induced paths of length 4 (Section 9). The techniques are also applied to analyze specific triangle-free graphs (Section 10) and specific graphs of bounded clique number (Section 11). We conclude by showing that together with the theorems in [24] this resolves the complexity of all but finitely many graph classes defined by two forbidden induced subgraphs (Section 12).

Preliminaries
In this paper all graphs are finite, simple, undirected graphs. For a graph G, by V (G) and E(G) we denote the vertex set and the edge set, respectively. By N G (S) = N (S) we denote the neighborhood of a set S, i.e., the vertices in V (G) \ S adjacent to some vertex in S. By id we always denote the identity map. The bipartite complement of a bipartite graph G with bipartition classes A and B is obtained by replacing E(G) with {{a, b} | a ∈ A, b ∈ B} \ E(G).
We write H ≤ G if the graph G contains a graph H as an induced subgraph. A graph G is H-free if H G. It is (H 1 , . . . , H k )-free, if it is H i -free for all i. A graph class C is H-free (respectively (H 1 , . . . , H k )-free) if this is true for all G ∈ C. A graph class C is hereditary if it is closed under taking induced subgraphs. The class (H 1 , . . . , H k )-free is the class of all (H 1 , . . . , H k )-free graphs. Note that each class (H 1 , . . . , H k )-free is hereditary. We say a graph G contains a graph H (as an induced subgraph) if an induced subgraph of G is isomorphic to H.
By I t , K t , P t , and C t we denote the independent set, the clique, the path, and the cycle on t vertices, respectively. The clique number of a graph G is the largest integer t such that G contains K t . By H∪ H ′ we denote the disjoint union of H and H ′ ; we use tH for the disjoint union of t copies of the graph H. By G we denote the (edge) complement of G. The graph K 2∪ I 2 , i.e., the graph obtained from K 4 by deleting an edge, is called the diamond.
A star is a graph isomorphic to the complete bipartite graph K 1,t for some positive integer t. A subdivided star is a possibly repeated subdivision of a star. Since any subdivided star is a tree, we call the disjoint union of subdivided stars a forest of subdivided stars.If a subdivided star has a vertex of degree at least 3 then this vertex is unique and called the center. For nonnegative integers a 0 , . . . , a t with a t > 0, we define the graph H(a t , . . . , a 1 , a 0 ) to be the disjoint union of an independent set of size a 0 with the following subdivided star H. The star H is the subdivided star that for i ∈ {1, . . . , t} has exactly a i leaves at distance i from the center and no   other leaves. (If t i=1 (a i ) < 3 the center of H is defined so that the graph H is a path whose two leaves have suitable distances from that center.) Examples of such graphs are depicted in Figure 1.
In [24] it is shown that isomorphism of (H 1 , . . . , H t )-free graphs is isomorphism complete unless one of the forbidden graphs is a forest of subdivided stars.
In this paper a colored graph is a vertex colored graph whose coloring does not need to be proper (i.e., adjacent vertices can have the same color). Isomorphisms between colored graphs are required to respect the colors, that is, they must map vertices to vertices of the same color. A singleton is a vertex with a unique color. The naive vertex refinement algorithm, or 1-dimensional Weisfeiler-Lehman algorithm, is a standard technique of repeatedly recoloring the vertices, refining the partition induced by the colors by using the multiplicity of colors appearing among the neighbors of a vertex (see for example [32]). It has the property that after the refinement, the number of neighbors a vertex v has in a color class C only depends on the colors of v and C. A graph has color valence at most k if for every vertex v and every color class C there are at most k neighbors of v in C or there are at most k non-neighbors of v in C.

Reductions
In this section we develop a systematic approach to proving isomorphism invariant reductions. This provides general means to construct isomorphism-complete graph classes. Standard reductions like subdividing, taking complements, and adding isolated vertices fall into this framework. Likewise, most reductions performed in [24] and also various reductions in [7] fall into this framework. Definition 1. Let J be a finite set and L : J ×J → {A, N } be a labeling assigning every ordered pair of vertices the label A for adjacent or N for non-adjacent. Moreover let L N : J × J → N ∪ {∞} be a labeling assigning every ordered pair of vertices an integer or infinity.
A graph G belongs to the class encoded by the labeled graph (J, L, L N ) if there exists a map φ : V (G) → J such that the following hold: In this definition, the triple (J, L, L N ) should be thought of as a generalized graph. The graph class encoded by (J, L, L N ) then contains graphs that can be obtained by replacing the elements of J with sets of vertices. In some contexts, this is referred to as blowing-up the elements of J. Adjacency of the new vertices is essentially governed by the adjacency of the original graph. However, the values of L N control the number of exceptions to this rule that are allowed per vertex.
The definition captures various constructions that are used in graph theory. A first class of examples form the complete multipartite graphs, which turn out to be graphs modeled with the function L satisfying L(x, y) = N if and only if x = y and the function L N being the constant function evaluating to 0.
A second, more general class of examples modeled by the definition is the graphs of bounded color valence, which are graphs that frequently appear in the context of graph isomorphism. Such graphs are obtained whenever L N is a bounded function. The coloring corresponds to the map φ.
A third example is the class of graphs that map homomorphically onto a finite graph H. Of interest to us is the complexity of the isomorphism problem of graph classes encoded by a triple (J, L, L N ). It turns out that when L N is a bounded function then isomorphism can be solved in polynomial time. Proof. We show the statement by induction on |J|. However, we show a statement that is slightly stronger. Namely, we show that there exists an algorithm that solves the isomorphism problem for input pairs where only one of the graphs is required to be encoded by (J, L, L N ). Moreover we require that the algorithm does not produce any incorrect answers when queried with a pair of graphs both of which are not encoded by (J, L, L N ). That is, when both graphs are not encoded by (J, L, L N ) the algorithm either correctly determines whether the graphs are isomorphic or states that the answer was not determined.
For |J| = 1 the encoded graphs have bounded degree or bounded co-degree, so isomorphism can be solved in polynomial time [27]. Let (J, L, L N ) be an encoding with |J| > 1. We first describe a reduction rule. Suppose there are j 1 , j 2 ∈ J such that for all j ∈ J we have L(j 1 , j) = L(j 2 , j) and L(j, j 1 ) = L(j, j 2 ). We now argue that in this case we can replace J by a smaller set at the expense of increasing the values in L N . To this end, let π be the projection that maps j 2 to j 1 , i.e., the map that satisfies π(j) = j if j = j 2 and π(j 2 ) = j 1 . We claim that every graph encoded by (J, L, L N ) is also encoded by (J ′ , L ′ , L ′ N ) where J ′ = J \ {j 2 }, L| J\{j 2 } is the restriction of L to J ′ , and L ′ (j, j ′ ) = 2 · max{L(ℓ, ℓ ′ ) | ℓ ∈ π −1 (j), ℓ ′ ∈ π −1 (j ′ )}. Indeed, if for a graph G a map φ : V (G) → J is an encoding by (J, L, L N ) then the map π • φ is an encoding by (J ′ , L ′ , L ′ N ). By induction we can solve isomorphism for graphs encoded by (J ′ , L ′ , L ′ N ) in polynomial time.
Suppose now that the above situation does not arise. We can assume that for every map that encodes one of the input graphs by (J, L, L N ), the map to J is surjective. Otherwise we can solve the isomorphism problem on a smaller encoding by induction.
We will now guess an encoding φ 1 of the input graph G 1 . For each j in J we guess a vertex v ∈ V (G 1 ) with φ 1 (v) = j. Let M be the set of guessed vertices. We now guess all vertices that form an exception with a vertex in M . That is, we guess all vertices u for which there exists a v ∈ M such that L(φ 1 (v), φ 1 (u)) = A but u and v are not adjacent or such that L(φ 1 (v), φ 1 (u)) = N but u and v are adjacent. Since L N is bounded, the possible number of vertices that form an exception with a vertex in M is bounded. For all these vertices we guess their image under φ 1 . By the reduction described above, for all non-exceptional vertices not in M there is only one choice for their image under φ 1 not violating the encoding or making them an exception. Thus φ 1 is completely determined by the guesses we have performed. The process of guessing an image under φ 1 is performed only for a bounded number of vertices. Thus, there are only polynomially many options.
Similarly for G 2 there are only polynomially many options for suitable encodings. We can also check validity of an encoding in polynomial time. Once an encoding is determined, the graphs have bounded color valence and isomorphism can be checked in polynomial time.
The theorem implicitly shows that isomorphism of graphs that have bounded color valence for some coloring that uses a bounded number of color classes can be solved in polynomial time, even if the color classes are not given.

Corollary 4.
For every positive integer c, graph isomorphism of graphs whose vertices can be partitioned into c color classes such that the graph has color-valence at most c can be solved in polynomial time.
Proof. Every graph that can be partitioned into c color classes such that the graph has colorvalence at most c can be encoded by a triple (J, L, L N ) with |J| ≤ c and a function L N bounded by c. There are only finitely many encodings of this type. For each of these we can apply the algorithm from the proof of the theorem. The input graphs are isomorphic if and only if at least one of the calls to the algorithm claims them to be isomorphic.
While encodings can be used to show polynomial time solvability of certain graph classes, they can also be used to show hardness results as follows.
Definition 2. An encoding (J, L, L N ) is a simple path encoding in case L is symmetric (i.e., if L(j, j ′ ) = L(j ′ , j) holds) and there is a sequence of vertices (p 1 , . . . , p t ) of length at least 2 in J such that L N (p 1 , p 2 ) = ∞, L N (p t , p t−1 ) ≥ 2 and for all k we have L N (p k , p k+1 ) ≥ 1 and L N (p k+1 , p k ) ≥ 1.
Intuitively, a simple path encoding allows enough freedom to encode bipartite graphs with one bipartition having vertices of degree two. We can formally prove this statement in the form of a reduction.
Theorem 5. The class of graphs encoded by a simple path encoding is graph isomorphism complete.
Proof. First we describe a reduction and then show it is isomorphism invariant. Let (J, L, L N ) be a simple path encoding with the path P = (p 1 , . . . , p t ). Let G = (V, E) be a graph. We now describe a reduction that transforms G into a graph G ′ that can be encoded by (J, L, L N ). The vertex set of We define a map φ : V (G ′ ) → J such that for all v ∈ V (G) we have φ(v) = p 1 and for all e ∈ E(G) and i ∈ {2, . . . , t − 1} we have φ(e) = p t and φ({e, i}) = p i . The edge set E(G ′ ) will be formed as a symmetric difference as follows: • In the case t > 2 we define E 3 to be the set of pairs {v, • If t = 2 we set E 3 as {v, {v, v ′ }} and E 4 is the empty set.
where △ denotes the symmetric difference. By following the construction, given a graph G, the graph G ′ can be constructed in polynomial time. The map φ is an encoding and shows that the graph G can be encoded by the triple (J, L, L N ). Since all steps of the construction are isomorphism invariant, given two isomorphic graphs G 1 and G 2 the respective graphs produced by the construction to each of them are isomorphic as well.
To finish the proof we need to show the following: there is a graph isomorphism complete class of graphs C such that for any two non-isomorphic graphs in C the construction produces two non-isomorphic graphs.
For this let C be the class of graphs that have the following properties: the number of edges is at least 5n. The minimum degree and the maximum co-degree are at least 4. This class can be seen to be isomorphism complete by using the operation that adds 6 non-adjacent vertices to a graph and making them adjacent to every other vertex. There are various other reductions showing that this is an isomorphism complete class, for example the class of self-complementary graphs fulfills these properties, which is an isomorphism complete class [9].
To show that the construction described above maps non-isomorphic graphs from C to non-isomorphic graphs it suffices to reconstruct the labeling. To show that the labeling is reconstructible, we use a degree argument. The degree of a vertex with label p 1 is d+k 1 n−ε+k 2 m where d is the degree of the vertex in G, the variables k 1 , ε ∈ {0, 1} depend on the value of L(p 1 , p 1 ), and k 2 ∈ {0, . . . , |J|} is a constant that depends on the values of L(p 1 , p i ).
The degree of a vertex with a label p i different from p 1 is k 1 n + k 2 m + k 3 , where again k 1 , k 2 and k 3 depend on the labeling L. More precisely, k 1 ∈ {0, 1} depends on L(p i , p 1 ), k 2 depends on the values of L(p i , p i ′ ) and k 3 is an integer with an absolute value that is bounded above by 2 arising from exceptions allowed by L N .
Since m ≥ 5n the degree of vertices with label p 1 cannot be expressed as a sum with constraints of the latter kind (i.e., as k 1 n + k 2 m + k 3 ). Likewise the degree of vertices with a label different from p 1 cannot be expressed with constraints of the former kind (i.e., as d + k 1 n − ε + k 2 m). This implies that the set of vertices with label p 1 is reconstructible. Since for i > 1 the set of vertices with label p i contains exactly the vertices that have a neighbor and a non-neighbor among the vertices with label p i−1 , we can reconstruct φ and thus the partition. Once the partition is reconstructed, the edge sets E i can be reconstructed, and thus the original graph can be reconstructed. This shows that the reduction preserves isomorphism for graphs in C and finishes the proof.
In the next section, we give examples of reductions that apply the theorem. We require these results later to resolve the complexity of various hereditary graph classes of bounded clique number.

Isomorphism-complete classes
The reduction techniques of the previous sectionprovide a systematic approach to show isomorphism completeness results for graphs characterized by finitely many forbidden induced subgraphs. The following examples show how to apply the techniques in a mechanical way to show isomorphism completeness of graph classes characterized by forbidden induced subgraphs. Theorem 6. The graph isomorphism problem on the class of (2K 2∪ K 1 , K 4 )-free graphs, of (P 6 , P 4∪ P 2 , K 4 )-free graphs, and of (H(1, 0, 3, 0), K 4 )-free graphs is graph isomorphism complete.
(c) An encoding that is suitable for (H(1, 0, 3, 0), K4)-free graphs. Proof. We first show the statement for the class of (2K 2∪ K 1 , K 4 )-free graphs. For this, let ({p 1 , p 2 , p 3 }, L, L N ) be the encoding given by setting This encoding is depicted in Figure 2a. By Theorem 5 it suffices to show that graphs encoded by ({p 1 , p 2 , p 3 }, L, L N ) are (2K 2∪ K 1 )-free and (K 4 )-free. This is equivalent to showing that neither 2K 2∪ K 1 nor K 4 can be encoded. For K 4 this is obvious since all encoded graphs are tripartite. For 2K 2∪ K 1 we conduct a case distinction. First note that, under a tentative encoding, it cannot be the case that all elements of {p 1 , p 2 , p 3 } are in the image of the encoding, as otherwise two non-adjacent vertices would be mapped to p 1 and p 3 each. If the isolated vertex is mapped to p 1 (respectively p 3 ) then all other vertices must be mapped to p 2 or p 3 (respectively p 2 or p 3 ). Since end points of edges cannot be mapped to the same element of {p 1 , p 2 , p 3 }, two vertices are mapped to p 2 . This implies that some vertex mapped to p 2 has two non-neighbors mapped to p 1 (respectively p 3 ) contradicting that L N (p 2 , p 1 ) = 1 (respectively L N (p 2 , p 3 ) = 1). In the case where the isolated vertex is mapped to p 2 there are two vertices mapped to p 1 or two vertices mapped to p 3 which similarly leads to a contradiction. To show the second part of the theorem for (P 6 , P 4∪ P 2 , K 4 )-free graphs we use the encod- and only if v = v ′ (and the same function L N as in the first part of the proof). This encoding is depicted in Figure 2b. Analogously to the first part, it suffices for us to show that the graphs P 6 , P 4 ∪ P 2 and K 4 cannot be encoded. Again, the encoded graphs are tripartite so K 4 cannot be encoded.
We first note that for any encoding of P 4 , some vertex is mapped to p 1 and some vertex is mapped to p 3 . Indeed, otherwise, some vertex is mapped to p 2 , two neighbors are mapped to p 1 , or two neighbors mapped to p 3 .
Suppose there is an encoding of P 6 . Since P 4 ≤ P 6 , some vertex is mapped to p 1 and some vertex is mapped to p 3 . Since every non-empty complete bipartite graph on 4 vertices contains a vertex of degree 3 or a cycle, this implies that in any encoding at most 3 vertices can be mapped to p 1 or p 3 . Thus 3 vertices must be mapped to p 2 . The path P 6 only has two independent sets of size 3. The vertices not mapped to p 2 also form an independent set, so they must be all mapped to p 1 or all mapped to p 3 which contradicts the observation about encodings of P 4 .
Suppose now that there is an encoding of P 4∪ P 2 . We already know that some vertex of P 4 is mapped to p 1 and some vertex is mapped to p 3 . However, some vertex of P 2 must also be mapped to p 1 or p 3 and this vertex would thus have to be adjacent to a vertex of P 4 .
To show the third part of the theorem for (H(1, 0, 3, 0), K 4 )-free graphs we use the encod- (and the same function L N as above). This encoding is depicted in Figure 2c. By the same arguments as before K 4 cannot be encoded, so it suffices to show that H(1, 0, 3, 0) cannot be encoded. Let h be the vertex of degree 4 in the graph H(1, 0, 3, 0) and let x 1 , x 2 and x 3 be the vertices on the path from h to the leaf of distance 3 from the center. Suppose h is mapped to p 1 . In this case x 1 could not be mapped to p 2 since x 2 would have to be mapped to p 3 , which contradicts that x 2 is not adjacent to h. Thus x 1 would have to be mapped to p 3 . Then x 2 is mapped to p 1 , since otherwise x 3 cannot be mapped anywhere. This implies that all leaves are mapped to p 2 . However, then x 1 , which is mapped to p 3 , has 3 non-neighbors which are mapped to p 2 contradicting the requirements of the encoding. Supposing next that h is mapped to p 2 , then at least one, and thus all of its neighbors are mapped to p 3 . Since x 2 must then be mapped to p 2 this would mean that x 2 has 2 non-neighbors that are mapped to p 3 contradicting the encoding. Finally suppose h is mapped to p 3 . This implies that one of the vertices x 2 and x 3 is mapped to p 2 while the other is mapped to p 3 . This in turn implies that all leaf vertices adjacent to h are mapped to p 2 which shows that some vertex in {x 2 , x 3 } is mapped to p 3 but has 3 non-neighbors that are mapped to p 2 which yields a contradiction.
As can been seen in the proof of the previous theorem, given an encoding, checking whether no H-free graph can be encoded amounts to checking whether H itself can be encoded, which is a finite computation that can in fact be fully automated. We consider another example concerned with bipartite graphs.
Proof. Let ({p 1 , p 2 , p 3 , p 4 }, L, L N ) be the encoding depicted in Figure 3 For every encoding of a graph the pre-images of {p 1 , p 3 } and {p 2 , p 4 } must be independent sets and thus the encoded graphs are bipartite. Let π be an encoding of 2P 3∪ K 1 and consider the bipartition induced by the pre-images just considered. We first observe that no independent set of 2P 3∪ K 1 can be partitioned such that there are 2 vertices in each bipartition class. Indeed, if this were the case, then two vertices are mapped to p 2 or one pair of endpoints is mapped to p 3 . Due to the requirements of the encoding this implies that the other pair is mapped to p 1 or p 4 , which again gives a contradiction to the requirements of the encoding. Figure 3: An encoding that is suitable for bipartite (2P 3∪ K 1 )-free graphs. Figure 4: An encoding that is suitable for bipartite (2P 3∪ K 1 )-free graphs.
Since P 3 is connected, the endpoints of each P 3 are contained in the same bipartition class. Thus by our observation about independent sets of size 4, all end points of the paths are mapped to the same bipartition class. Furthermore, by the same reason, the isolated vertex must be mapped to the same bipartition class. This means the other two vertices have 3 non-neighbors in the other bipartition class. Thus they are mapped to p 1 . This implies that all other vertices are mapped to p 2 giving a contradiction to L(p 2 , p 1 ) for the isolated vertex.
On a more intuitive level, one can also interpret the proof as an argument showing that 2P 3∪ K 1 cannot be partitioned into two parts such that its bipartite complement is a forest of subdivided stars.
Finally, we conclude with one more example-application of the reduction technique.
Proof. Let ({p 1 , p 2 , p 3 , p 4 }, L, L N ) be the encoding depicted in Figure 4 with If the set {x 2 , x 3 } is mapped to {p 2 , p 3 } then the 3 vertices that are neither adjacent to x 2 nor x 3 must all be mapped to p 2 or p 3 . In any case, two of these vertices are mapped to the same vertex in {p 2 , p 3 } and there is a vertex in {x 2 , x 3 } non-adjacent to both of them and not mapped to the same vertex in {p 2 , p 3 } contradicting the encoding. We now assume that The case where the set is mapped to {x 3 , x 4 } is symmetric. This implies that all vertices except possibly x 1 are mapped to p 1 or p 2 . Since vertices that are mapped to p 2 can have at most one neighbor mapped to p 1 we conclude that h is mapped to p 1 and the leaves adjacent to h are mapped to p 2 . Since vertices mapped to p 3 cannot have two non-neighbors mapped to p 2 we conclude that x 1 is mapped to p 2 . This implies that x 2 is mapped to p 1 which is a contradiction since x 1 cannot have two neighbors mapped to p 1 .
In the appendix in Section 4, we apply the theorem to show that various classes (namely the classes (2K 2∪ K 1 , K 4 )-free, (P 6 , P 4∪ P 2 , K 4 )-free, (H(1, 0, 3, 0), K 4 )-free, bipartite (2P 3∪ K 1 )-free, (H(1, 0, 2, 0), K 5 )-free) are isomorphism complete. This in turn implies that various classes (H 1 , H 2 )-free that are superclasses of one of these are isomorphism complete (such as (K 3 , 2P 3∪ K 1 )-free). The graph classes characterized by encodings as described in this section contain many classes useful to show isomorphism-completeness of various hereditary graph classes. These results are sufficient for the purpose of this paper, proving Theorem 2. However, we remark that there are several completeness results for classes of the form (H 1 , H 2 )-free where further restrictions on the encoded graphs become necessary. For example when excluding the diamond , it is beneficial to require that there is only one encoded path between vertices mapped to p 1 and p t . Furthermore, there are some reductions that do not seem to fit into the reduction scheme of this section, even with further restrictions. Among those are in particular the line graph reductions (see [24]).

Isomorphism, Invariants and Canonical Labeling
We recall the concept of a complete invariant and the related concept of a canonical labeling.A complete graph invariant for a graph class C is a map Inv : C → D into some class D such that for graphs G 1 and G 2 in C we have Inv(G 1 ) = Inv(G 2 ) if and only if G 1 and G 2 are isomorphic. A canonical labeling is a map that assigns to every graph G a graph C(G) with vertex set V (C(G)) = {1, . . . , |G|} and an isomorphism φ : G → C(G) such that the map assigning C(G) to G is a complete invariant.
There are relatively general techniques with which one can turn a complete invariant into a canonical labeling algorithm [17,18,22]. These techniques are typically only applicable when dealing with invariants for graph classes that have additional properties, for example the ability to attach gadgets to vertices in order to encode information or having balanced separators of bounded size. However, in our situation we can employ colors to achieve this.
Intuitively the technique finds the first vertex of the canonical labeling by individualizing each vertex one by one and choosing the vertex which yields lexicographically the smallest invariant. By repeating the process, having already individualized the first vertex, then individualizing each possible second vertex and applying the invariant, the second vertex is found. Iterating this procedure yields the canonical labeling.
In this paper, we are mainly interested in isomorphism algorithms, as opposed to canonical labeling algorithms or complete invariants. We will therefore require a tool to simulate an invariant within one execution of our algorithm, given only an algorithm that performs isomorphism checks. The key difference between having an invariant and an isomorphism algorithm is that the invariant must be consistent across different executions of an algorithm.Our simulated invariant will not be consistent across different calls of the same algorithm.
Theorem 9. Let A be an polynomial time algorithm with access a complete invariant O for a graph class C given as oracle. Suppose the outputs of A are independent of the choice of the invariant O. If isomorphism of graphs in C can be solved in polynomial time then there is a polynomial-time algorithm B whose outputs coincide with those of A which does not require access to an oracle.
Proof. We simulate an algorithm that has access to a complete invariant as follows. We maintain a list of graphs that contains the first graph of each isomorphism class which has been used as input to the oracle so far. Whenever a new oracle call is made with a graph G, we check, using Iso, whether G is isomorphic to a graph that was already used as input to the oracle. If so, the returned invariant is the graph in the database isomorphic to G. Otherwise G is added to the list and returned as invariant. Concerning the running time, checking whether a graph already has an isomorphic copy in the list requires a number of calls to Iso equal to the number of graphs already added to the list. The total number of calls to Iso is thus at most quadratic in the number of oracle calls.
We will use the theorem to replace an invariant with a isomorphism algorithm in the next section when dealing with modular decompositions (more precisely to prove Theorem 12).
The reason why the technique described in the proof of 9 not viable in practical applications of isomorphism algorithms is two-fold. Firstly, the algorithm suffers from a polynomial increase in particular in the space required and secondly, the technique makes the algorithm inherently sequential, whereas the advantage of canonization is its parallelizability. Another way of stating this is that the values of the invariant are not compatible across different executions of the algorithm.

Colored modular decomposition
In this section we are concerned with modular decompositions and their application to the isomorphism problem. We will work with colored graphs since this is convenient in the graph isomorphism context. However, we will also generalize the concept of a module to that of a colored module, since this is required by our later applications. Since we do not require previous knowledge about the uncolored modular decomposition, we will not define it. We refer the reader to the survey by Habib and Paul [19] for more information on the uncolored decomposition and its algorithmic applications. For the colors, we will assume that there is a linear order on the colors. In algorithmic applications such a linear order can always be obtained by comparing the bit-strings corresponding to the colors lexicographically.
are of the same color then either v is adjacent to both vertices x and x ′ or to neither x nor x ′ .
A module M is non-trivial if it contains at least two vertices that cannot be distinguished by vertices outside of the module. That is, M is non-trivial if there are x, y ∈ M such that for all v ∈ V (G) \ M the vertex v is adjacent to x if and only if it is adjacent to y. Note that every module that contains two vertices of the same color is non-trivial.

Definition 4.
A map assigning to every graph G a subset of the vertices M (G) is said to be isomorphism invariant if for every isomorphism φ : A map that assigns to every graph G a partition of a subset of the vertices Definition 5. A decomposition functor is a "map" assigning to every graph G a partition of a subset of the vertices into modules which is isomorphism invariant.
We elaborate briefly on the choice of terminology "decomposition functor". A decomposition functor can be seen as a covariant functor in the sense that every homomorphism between graphs induces a homomorphism between the subgraphs induced by the modules. Moreover it induces a homomorphism between the quotient graphs defined below. Similarly, color refinements can be seen as functors (see [32,Page 22] for more information on this). Note that a decomposition functor assigns to every graph a decomposition. It is thus not simply a decomposition of just a single graph. This is what the word functor expresses, rather than talking about just having a decomposition for graphs. The crux is that these decompositions must be consistent across isomorphism classes.
Technically a decomposition functor is not a set-theoretic map since the class of all graphs is not a set. However, these category theoretic hurdles will not be important in the rest of this paper. In any case it does not seem that the word "invariant decomposition map" would express the concept really well.
A graph G is prime with respect to a decomposition functor Mod if Mod(G) does not contain non-trivial modules. While there is a standard decomposition functor for the uncolored case, for the colored case it is in general not clear whether we can find a useful functor to decompose the graphs, and we have to find such a functor for a given graph class first, in order to decompose the graphs.
We illustrate that colored modules allow us to decompose graphs that are prime as uncolored graphs. Consider a connected, bipartite graph with bipartition classes A and B of different colors. Let A ′ ⊂ A and B ′ ⊂ B be sets such that A ′ ∪ B ′ induces a matching between the vertices in A ′ and the vertices in B ′ and such that all vertices of A ′ are adjacent to all vertices of B \ B ′ and all vertices of B ′ are adjacent to all vertices of A \ A ′ . Then A ′ ∪ B ′ forms a colored module, but no vertex of A ′ ∪ B ′ is contained in a non-trivial classical (uncolored) module.
In the remainder of this section, we argue for certain decomposition functors that graph isomorphism for a hereditary graph class can be solved in polynomial time if the isomorphism problem for colored prime graphs in the class can be solved in polynomial time. To facilitate the proof we can assume that we are given a complete invariant for the prime graphs in the hereditary graph class and then apply Theorem 9.
Our next goal is to define the concept of the quotient graph. In the uncolored case, the quotient graph is obtained by replacing each module with a single vertex whose adjacency to the rest of the graph is the same as that of every vertex of the module. However, for the colored case, the adjacency to the rest of the graph depends on the color of the vertex in the module. This means that for every adjacency type we need to retain a vertex that has the same adjacency type with respect to vertices outside the module.
A replacement operator is an isomorphism invariant map that assigns every non-trivial module M in a decomposition of a graph G an induced subgraph of M in which the vertices are possibly recolored. We require that for every adjacency type of vertices in M at least one vertex of M is maintained. Let Inv(M ) be a complete graph invariant. Given a family of modules {M 1 , . . . , M k } that partitions the graph, the quotient graph is obtained by simultaneously replacing all modules using the replacement operator and then recoloring every vertex v as the triple (χ(v), L, Inv(M v )), where χ(v) is the color of v after the replacement, L is a list of the colors of vertices with the same adjacency type as v, and Inv(M v ) is the invariant of the module containing v.Intuitively the goal of this coloring is to provide information how to reconstruct the original graph. However We say that the decomposition functor is simple with respect to a replacement operator if for every complete invariant every quotient graph is prime. Intuitively this means that the decomposition functor provides us with maximal modules. Definition 6. Given a decomposition functor, we say a replacement operator is reversible if the following holds: two graphs G 1 and G 2 are isomorphic if and only if their colored quotient graphs with respect to the decomposition functor and the replacement operator are isomorphic.
Note that reversibility does not depend on the complete invariant that is used for the recoloring of the quotient graph.
We remark that for uncolored graphs the definitions of module, primality and the quotient graph coincide with the usual definition from the literature (see [19]). In that context, the decomposition functor is typically chosen to partition the graph into components, components of the complement graph or maximal modules. The replacement operator simply replaces the entire module by one vertex. However, for the applications we have in mind, we require the more general concept of colored modules. There are certain situations where is it immediate that a replacement operator is reversible.
Lemma 10. A replacement operator is reversible in the following situations.
1. There is only one trivial module, 2. all replacements contain only one vertex, or 3. non-trivial modules induce connected graphs, but the non-trivial modules are pairwise nonadjacent.
Proof. To reconstruct the original graph we need to replace each set M ′ that is a replacement for module M by the original module M . We also need to determine the adjacency of the vertices in M to vertices outside of M . This adjacency information is encoded in the coloring of the vertices of M ′ by definition. However, it is not possible for all replacements to determine the sets M ′ that are replacements of modules. However, in each of the three cases in the lemma, it is possible to reconstruct the sets of vertices M ′ that originated from the same module. This is obvious for the first two cases. In the third case the sets M ′ originating form non-trivial modules are the maximal connected subgraphs consisting of vertices whose third entry in the color, which is Inv(M v ) by definition of the quotient graph, is the same.
The reason is that in each of these cases it is possible to reconstruct which replacement vertices originate from the same module.
A reversible simple decomposition functor can be used to test isomorphism by considering only isomorphisms between quotient graphs and modules. Iterating this, we will now develop an algorithm that performsan isomorphism test for decomposable graphs if one has access to a complete invariant for prime graphs.
(Description of Algorithm 1) Given a reversible, simple decomposition functor Mod and an algorithm Inv p that computes a complete invariant for graphs in a graph class C that are prime with respect to Mod, Algorithm 1 constitutes a complete invariant for graphs in C. The algorithm applies the functor Mod. If this application yields non-trivial modules, the algorithm recursively computes the invariant of the modules and forms the quotient graph. The invariant of the input is the invariant of this prime graph.
Lemma 11. Let C be a hereditary graph class and Mod a simple polynomial time computable decomposition functor for C with polynomial-time computable reversible replacement operator R. Given a complete invariant Inv p for colored prime graphs in C, Algorithm 1 constitutes a complete invariant for all graphs in C. If the total running time for query calls to Inv p is polynomially bounded, then Algorithm 1 runs in polynomial time.
Proof. (Correctness) First note that whenever a recursive call is performed in Line 8, the module M , which is the new input graph, has less vertices than the original graph. Thus the algorithm terminates. Suppose G 1 and G 2 are isomorphic graphs to which the algorithm is applied. By definition, the decomposition functor is invariant, and thus, by induction, the recursive calls compute the same invariant for corresponding modules. Since decomposition functors are isomorphism invariant, the quotient graphs are isomorphic. These observations show that the invariants computed for G 1 and G 2 are the same. Suppose now that two nonisomorphic graphs G 1 and G 2 are given to Algorithm 1. By induction we can assume that the Algorithm 1 Inv: A complete invariant for a hereditary class C with decomposition functor.
Input: (G, Mod, R, Inv p ): A graph G in C, a simple decomposition functor Mod, a reversible replacement operator R, and an algorithm Inv p that computes a complete invariant for graphs in C which are colored and prime with respect to Mod. Output: Inv(G): The value of G with respect to a complete invariant Inv for C.

4:
for all non-trivial M ∈ Mod(G) do 5: if M is prime then 6: Compute Inv p (M ).  Compute the quotient graph Q ′ of G with respect to Mod, R, and the computed invariants Inv p (M ).

12:
Q ← Q ′ 13: end if 14: return Inv p (Q) invariants for the modules form a complete invariant for the modules. Therefore, the correctness of the algorithm follows from the assumption that R is reversible.
(Running time) We show that, given a complete invariant for prime graphs that runs in polynomial time, Algorithm 1 also runs in polynomial time. Consider the recursion tree of a call to Algorithm 1 for a graph G of size n. Since all steps can be performed in polynomial time, it suffices to polynomially bound the number of nodes in the tree. The number of vertices for each node is smaller than the number of vertices of the parent. This bounds the height of the recursion tree, and thus it suffices for us to bound the number of leaves of the tree. With the possible exception of the root, for each recursive call corresponding to a leaf, the input graph is a non-trivial module M of some coloring of G and thus in particular contains two indistinguishable vertices. Since at least one of these vertices is not present in any quotient graph that has a module that contains M , this pair of vertices cannot be a pair of indistinguishable vertices in any other call corresponding to a leaf. The number of leaves is thus bounded by the number of pairs of vertices.
Using Theorem 9 we can replace the requirement for a complete invariant by an isomorphism algorithm.
Theorem 12. Let C be a hereditary graph class and Mod a simple polynomial time computable decomposition functor with polynomial-time computable, reversible replacement operator R for colored graphs in C. If the isomorphism problem for colored prime graphs in C can be solved in polynomial time then the isomorphism problem of all graphs in C can be solved in polynomial time.
Proof. The theorem follows by combining Lemma 11 and Theorem 9. However, there is an issue with the length of the encoding of colors. In particular, if the calculated invariants are repeatedly applied to recolor the graphs then, even with a polynomial number of iterations, the encoding of the colors may become super-polynomial. To avoid this, we apply the standard technique of hashing colors. More precisely, we maintain a numbered list of colors. Every time a new color is encountered, the next unused number is assigned to this color. When an oracle call is performed by Algorithm 1, and consequentially according to Theorem 9 the algorithm for prime graphs is invoked to simulate this oracle call, then the graph will be given in encoded form with short descriptions for the colors. Since only polynomially many colors can appear during the execution of the algorithm, this shows that the entire algorithm runs in polynomial time.
The theorem in particular applies to the standard uncolored modular decomposition. This decomposition is associated with a simple decomposition functor with polynomial-time computable, reversible replacement. In his diploma thesis, Fuhlbrück [13] also describes a reduction for the standard uncolored decomposition factor. Already when trying to solve the isomorphism problem for uncolored graphs in a graph class C with the described method, the fact that the quotient graph needs to be colored implies that we require an isomorphism algorithm for colored prime graphs. In [31], Rao describes a special case of the theorem for the uncolored modular decomposition, essentially considering hereditary graph classes in which every prime graph is of bounded size. In principle the algorithm described in Rao's paper is a special case of the algorithm described here, but this is disguised slightly by the fact that in Rao's description the algorithm simultaneously performs the computation of the (uncolored) modular decomposition, the invariant for the possible prime graphs, and the hashing of colors.Moreover, in the isomorphism context, the bi-join decomposition, also described in [31], can also be treated by using colored modules. In different terminology, the graph classes considered by Rao are sometimes called graphs of bounded composition-width or modular width. However, we caution the reader that there are two unrelated definitions of composition width for groups and graphs, respectively, both appearing in the context of isomorphism (see [4]).
Together with the observation that vertices of degree 1 can be removed in an isomorphism invariant fashion by recoloring their neighbors, the previous theorem also provides means of solving isomorphism of distance hereditary graphs. Indeed, by a theorem of Bandelt and Mulder [6] every prime distance hereditary graph has a vertex of degree at most 1. However, there is a faster, tailored algorithm for distance hereditary graphs running in linear time [29].
In our applications of the Theorem 12 we also use another unrelated technique of dealing with small color classes that we describe next.

Bounded generalized color valence
In this section we show that isomorphism of graphs of bounded generalized color valence can be solved in polynomial time. However, the proofs of the lemmas and theorems within the section require familiarity with the computational group theoretic methods that have been developed within the context of the isomorphism problem. For example, when computing automorphism groups, cosets, and sets of isomorphisms between two combinatorial objects, we use a succinct representation by generators and a representative. We also use the set stabilizer theorem [27] for groups with composition factors of bounded size (see also [1,4,28]), which implies that for a permutation group with composition factors of bounded size acting faithfully on a set, we can compute the stabilizer of any given subset in polynomial time. For a good overview over the various computational group theoretic techniques, we refer the reader to [33].
Before we solve their isomorphism problem, let us consider some examples of graphs of bounded generalized color valence. Hypergraphs on sets of bounded color class size can directly be encoded as graphs by adding a vertex for every hyper edge which is adjacent to the elements of the hyper edge. Thus, a polynomial time algorithm for bounded generalized color valence also gives rise to a polynomial time algorithm for hypergraphs of bounded color class size. However, there are examples that are not captured by this. Consider a graph of maximum degree at most c consisting of a large number of components such that there is only a small number of isomorphism types among these components. Now add an arbitrary finite number of new vertices colored with new colors such that the added vertices form color classes of size at most c. The new vertices are connected via edges in an arbitrary way to the original vertices. The resulting graph has bounded generalized color valence. However, its automorphism group may contain composition factors of arbitrarily large size. The isomorphism algorithm for graphs of bounded degree exploits the fact that at least for components it is possible, by individualizing one vertex, to obtain a group with bounded composition factor. However in the example graphs just described it is not clear how the standard group theoretic arguments can be applied.
Nevertheless, our goal is to prove that graph isomorphism of graphs with bounded generalized color valence can be solved in polynomial time. Note that the classes of bounded generalized color valence are closed under refinement operations such as individualization and naive vertex refinement.
To solve the isomorphism problem, we need to deal with the small color classes. If there are only a bounded number of them, we can apply individualization to all vertices in small color classes. However, the number of small color classes can be linear in the number of vertices.
To remedy this problem, we exploit the existence of certain colored modules and use group theoretic techniques.
We first define a decomposition functor that works well with graphs of bounded generalized color valence that have been refined with naive vertex refinement. Given a subset S of vertices, we say a vertex v ′ / ∈ S contained in the color class C ′ is of degree dependence at most d Intuitively this definition says that there is a vertex v ∈ S such that individualization of this vertex followed by refinement with respect to adjacency towards v produces a set of size at most d within which v ′ can be found.

Definition 7.
A non-empty subset S is a d-degree dependence module, if no vertex outside S has degree dependence at most d with respect to S. Lemma 13. Let G be a graph of color valence at most c which is stable under naive vertex refinement. If G does not contain color classes of size at most 2c then the minimal c-degree dependence modules partition G. Moreover, the map assigning every such graph the family of minimal c-degree dependence modules is a polynomial time computable decomposition functor.
Proof. To show the first part of the lemma it suffices to show that the following holds in G: if v and v ′ are vertices in the color classes C and C ′ respectively then We only show the first equivalence, the second one follows by considering the complement graph. For the first equivalence, by symmetry, it suffices to show one direction. Thus we assume |(N (v) ∩ C ′ )| ≤ c. If it is not the case that |(N (v ′ ) ∩ C)| ≤ c then |C \ (N (v ′ ))| ≤ c since the graph has color valence at most c. We count the number of edges and non-edges between C and C ′ . There are at most |C|c edges and at most |C ′ |c non-edges. This implies that |C||C ′ | ≤ |C|c + |C ′ |c which shows that one of the color classes has size at most 2c.
The fact that the minimal c-degree dependence modules are isomorphism invariant follows from the fact that the definition of the modules is isomorphism invariant. They form colored modules since the color valence of the graph is assumed to be at most c. To compute the modules in polynomial time one can, for every vertex, compute its module by repeatedly adding vertices that have color dependence at most c with respect to the set created so far.
In Lemma 13, using naive vertex refinement is essential. Indeed, consider a wheel, i.e., a cycle with an added center adjacent to every other vertex. In this graph, there is only one non-trivial 3-degree dependence module, namely the set that contains only the center of the wheel. Thus the 3-degree dependence modules do not partition the graph.
We show now that the set of isomorphisms between subgraphs induced by certain c-degree dependence modules can be computed in polynomial time. Proof. For i ∈ {1, 2}, by iterating over all vertices in M i , we can find all vertices v i such that M i is minimal among all c-degree dependence modules containing v i . Since there are only quadratically many pairs of such vertices, it thus suffices to be able to compute all isomorphisms from M 1 to M 2 mapping v 1 to v 2 assuming that v 1 and v 2 are given. We individualize v i in each graph (with the same color in both graphs) and apply naive vertex refinement. We now consider the graphs G 1 [M 1 ] and G 2 [M 2 ]. If the color classes that appear are not the same then there is no isomorphism from G 1 [M 1 ] and G 2 [M 2 ], so we assume otherwise. Note that we can order the color classes in a canonical way to C 1 . . . , C t such that C 1 = {v 1 , v 2 } and such that for i ∈ {2, . . . , t} and for vertices in C i there is a color class C j with j < i such that each vertex in C j has at most c neighbors or at most c non-neighbors in C i . This enables us to compute the set of isomorphisms between the graphs induced by the first i color classes on the basis of the isomorphisms between the graphs induced by the first i − 1 color classes. Indeed, this shows that the graphs have automorphism groups that have composition factors that are subgroups of S c , the symmetric group of degree c. Therefore we can apply the known techniques based on group theoretic isomorphism algorithms. For example we can apply techniques by Babai and Luks [4] or Miller [28]. We refer the reader to [4,Section 4.2] for an explanation of all these options.
We next provide a corollary of Lemmalem:iso:of:dep:modules that will facilitate its application in our main theorem.
Corollary 15. Let G 1 and G 2 be graphs of generalized color valence at most c. Let V 1 and V 2 be the set of vertices contained in a color class of size at most 2c in G 1 and G 2 respectively. Let M 1 and M ′ 1 be minimal c-degree dependence modules of G 1 \ V 1 and let M 2 be a minimal c-degree dependence module of G 2 \ V 2 . We can compute in polynomial time the automorphism group of G[M 1 ∪M ′ 1 ∪V ] and the automorphism group of Proof. The corollary follows from Lemma 14 by observing that M 1 ∪ V 1 , M ′ 1 ∪ V 1 and M 2 ∪ V 2 are contained in minimal 2c-degree dependence modules of their respective graphs.
In the following we will be working on two graphs simultaneously. Note that when performing naive vertex refinement on two graphs separately, it may be the case that the color degrees differ in the two graphs even within the same color class. To avoid this, we perform a joint refinement, by performing the refinement on the disjoint union of the two graphs.
Lemma 16. Let G 1 and G 2 be colored graphs, stable under the joint vertex refinement, which are of color valence at most c and which do not contain any color class of size at most 2c. If φ is a map from V (G 1 ) to V (G 2 ) that maps the c-degree dependence modules of G 1 isomorphically to the c-degree dependence modules of G 2 then φ is an isomorphism.
Proof. It suffices to show the following: if two vertices v and v ′ of G 1 which are not contained in the same c-degree dependence module are adjacent (non-adjacent) then φ(v) and φ(v ′ ) are adjacent (non-adjacent). Let C be the color class of v ′ . Since G 1 has color valence at most c the vertex v has at most c neighbors in C or at most c non-neighbors in C. In the former case all neighbors of v of color C are in the same c-degree dependence module as v. In the latter case all non-neighbors of v are in the same c-degree dependence module as v. This implies that all vertices of C that are not in the same c-degree dependence module have the same adjacency type towards v. This is also the case in G 2 and this adjacency type is the same in the graphs G 1 and G 2 , since they have been jointly refined. This shows that φ is an isomorphism.
The previous proof implicitly shows that for graphs of color valence at most c that are stable under naive vertex refinement which do not contain color classes of size at most 2c the cdegree dependence modules are in fact colored modules in the sense of the previous section, also providing the motivation for the terminology.
A frequent observation in the graph isomorphism context is that the isomorphism problem between two graphs reduces to computation of the automorphism group of a combination of the two graphs. We will also take this route, since it drastically streamlines our proof. However, this comes at the expense of increased running time. Note that in our case, for the reduction, we cannot simply take the usual path of forming the disjoint union of two graphs and compute its automorphism group, since this union might not have bounded generalized color valence as can be seen when forming the disjoint union of two large cliques.
Lemma 17. The isomorphism problem of graphs of generalized bounded color valence at most c polynomial time reduces to the computation of the automorphism group of a graph of generalized color valence at most 2c.
Proof. Let G 1 and G 2 be colored graphs of generalized color valence at most c. To each graph G i , we add a vertex v i adjacent to all vertices of this graph. The two added vertices obtain a color that neither appears in G 1 nor on G 2 . Next, we run the joint naive vertex refinement on each of the augmented graphs to obtain the graphs G ′ 1 and G ′ 2 . If the obtained graphs do not contain the same color classes with the same multiplicities we reject the graphs as non-isomorphic.
We form their disjoint union. Let C and C ′ be color classes each of multiplicity more than 2c in each of the graphs G ′ 1 and G ′ 2 . We now determine whether we should add all edges between vertices of these colors which are in different graphs or none. If within the graphs G ′ 1 and G ′ 2 vertices in C have more than c neighbors in C ′ then we add all edges between vertices of colors C and C ′ if they lie in different graphs. Note that in this case, by arguments similar to those performed in the proof of Lemma 13, vertices in C ′ symmetrically then also have more than c neighbors in C. If this operation is performed across all pairs of color classes which are larger than 2c, we obtain a graph G of bounded color valence at most 2c. Since we added the universal vertices v 1 and v 2 to each of the graphs, any automorphism of the final graph must respect V (G 1 ) and V (G 2 ) as blocks. Thus, G contains an automorphism that swaps v 1 and v 2 if and only if G 1 and G 2 are isomorphic.
The lemma allows us to focus on computing the automorphism group of a single graph. Proof. Let G be a colored graph of generalized color valence at most c. Since refinement does not increase generalized color valence, we can assume that the coloring of the graph is stable under naive vertex refinement. Let U be the set of vertices contained in a color class of size at most 2c. Let V be the set of minimal c-degree dependence modules of G − U . Let S be a union of color classes in U . By Aut S we denote the following automorphism group: we consider all permutations of S. Such a permutation φ is in Aut S if there exists a permutation π of the c-degree dependence modules of G − U such that the following holds for all M ∈ V: if π(M ) = M ′ then there exists an isomorphism from G[M ∪ U ] to G[M ′ ∪ U ] which, when restricted to S, agrees with φ.
We will first show how to compute Aut U and then explain how to compute the automorphism group of G from Aut U . Note that Aut {} is the trivial group. Consequently, to compute Aut U , it suffices for us to show the following claim for an arbitrary color class C in U not contained in S.
Claim. Given Aut S we can in polynomial time compute Aut S∪C . Every element of ψ ′ ∈ Aut S gives rise to exactly one permutation ψ ′ of the equivalence classes induced by ∼ (S,U \S) . This gives rise to an action of Aut S on the equivalence classes. We first compute a subgroup Aut ′ S of Aut S that respects a certain coloring of these equivalence classes. For this consider the equivalence classes induced by ∼ (S∪C,U \(S∪C)) . They form a refinement of the classes induced by ∼ (S,U \S) . We label each equivalence class M under ∼ (S,U \S) by the multiset of block-sizes that arise when M is partitioned according to ∼ (S∪C,U \(S∪C)) .
We now define Aut ′ S to be the subgroup of Aut S that stabilizes the labels. This subgroup can be computed in polynomial time since the involved groups have composition factors of bounded size (see [4]).
Our strategy now for computing Aut S∪C on the basis of Aut ′ S is to find a set on which a supergroup of Aut ′ S acts such that Aut S∪C can be observed to be a stabilizer of a computable subset. Let M be the sets of equivalence classes in V with respect to ∼ (S∪C,U \(S∪C)) . We define an action of the group Sym(C) × Aut ′ S on these equivalence classes of pairs. The element (ψ, ψ ′ ) maps the congruence class of (φ, [M ] ∼ (S∪C,U \(S∪C)) ) to the congruence class of (ψφf, which is equal to f −1 and ψ ′ on C and S, respectively. We need to argue that this action is well defined. First, observe that since Aut ′ S is obtained by stabilizing the labeling as defined above, an M ′ fulfilling the requirements exists. Suppose now that M ′′ and f ′′ also satisfy the required properties. Then there exists an isomorphism from G[M ′ ∪ U ] to G[M ′′ ∪ U ] that is equal to ψ ′ (ψ ′−1 ) = id on S and equal to f ′′−1 f = (ψφf ′′ ) −1 (ψφf ) on C. Thus the pairs (πψφ, [M ′ ] ∼ (S∪C,U \(S∪C)) ) and (π ′ ψφ, [M ′′ ] ∼ (S∪C,U \(S∪C)) ) are congruent. We also need to show that we have defined an action. Suppose the pair (ψ, ψ ′ ) maps the congruence class of (ψφf, [M ′ ] ∼ (S∪C,U \(S∪C)) ) to the congruence class of (ψψφf f , [M ] ∼ (S∪C,U \(S∪C)) ) with M and π satisfying the requirements as above. Since there is an isomorphism from G[M ∪ U ] to G[M ′ ∪ U ] which is equal to πψ and ψ ′ on C and S respectively and there is an isomorphism from G[M ′ ∪U ] to G[M ∪U ] which is equal to πψ and ψ ′ on C and S respectively, there is an isomorphism from G[M ∪ U ] to G[M ∪ U ] which is equal to πψπψ and ψ ′ ψ ′ on C and S respectively. It also follows from the definition that the neutral element of Sym(C) × Aut ′ S fixes all pairs (φ, [M ] ∼ (S∪C,U \(S∪C)) ). Thus, we have defined an action.
Abusing notation, we can consider the group of color preserving permutations of Sym(S ∪C) as a subgroup of Sym(S) × Sym(C). In this sense, we claim that the group Aut S∪C is the subgroup of Sym(C) × Aut ′ S that stabilizes the image of M under the above-mentioned embedding [M ] ∼ (S∪C,U \(S∪C)) → (id, [M ] ∼ (S∪C,U \(S∪C)) ). Suppose first that (ψ, ψ ′ ) is an element of this stabilizer subgroup. We use the action on the congruence classes to show that (ψ, ψ ′ ) ∈ Aut S∪C . We define a bijection on the c-degree dependence modules contained in ) under (ψ, ψ ′ ). Since M and M ′ are arbitrary, it suffices now to observe that there is an isomorphism from M to M ′ which is equal to ψ and ψ ′ on C and S respectively. Conversely, if (ψ, ψ ′ ) is an element of Aut S∪C then ψ ′ is an element of Aut S by definition of the groups Aut S and Aut S∪C . Since it must respect multiplicities it is thus also an element of Aut ′ S . Let M be an arbitrary c-degree dependence module in V. By definition of Aut S∪C there is an M ′ ∈ V and an isomorphism from ). This shows that elements of Aut S∪C stabilize the image of M under the embedding described above. We want to compute this stabilizer. To achieve that the action is faithful, we additionally let the group act on the set A ∪ C. Since the group has bounded composition factors, the stabilizer can be computed in polynomial time. This proves the claim.
It remains to explain how to compute the automorphism group of G from the group Aut U . Consider the homomorphism π : Aut(G) → Sym(U ) that is obtained by restricting the permutations in Aut(G) to the set U . We first argue that π(Aut(G)) ≤ Aut U . To see this consider an automorphism α of G. Since the c-degree dependence modules of G − U are isomorphism invariant, the automorphism α maps every such module M to a module M ′ such that there is an isomorphism from G[M ∪ U ] to G[M ′ ∪ U ] that is equal to π(α) when restricted to U , showing π(Aut(G)) ≤ Aut U . We next argue that π is surjective. Let ψ be an element of Aut U . By definition of Aut U there is a bijection from V to V such that if M is mapped to M ′ then there is an isomorphism from G[M ∪ U ] to G[M ′ ∪ U ] that is equal to ψ when restricted to U . By Lemma 16, combining all these mappings gives an automorphism of G that is equal to ψ when restricted to U . This shows that π is surjective. It also shows how to compute a lift of ψ to Aut(G) such that this lift projects to ψ under Aut(G). Using Corollary 15 such a lift can be computed in polynomial time. By the first isomorphism theorem, it now suffices to compute a lift for each generator in a generating set of Aut U and to compute the kernel of the map π. The kernel of π is by definition the point-wise stabilizer of U . This is equal to the automorphism group of a graph obtained from G by individualizing all elements of S. Refining such a graph with naive vertex refinement yields a graph of bounded color valence, for which we already know how to compute the automorphism group in polynomial time.
By defining a faithful group action of the automorphism group of a graph on the c-degree dependence modules it possible to gradually compute the automorphism group, yielding also an isomorphism test for such graphs.
Theorem 19. Graph isomorphism for colored graphs of generalized color valence at most c can be solved in polynomial time.
Proof. This follows directly from the previous theorem and Lemma 17. In Appendices 8-11, we apply the theorem together with Theorem 12 to show that the classes (K 1,s∪ K 1,s , K t )-free, (P 5 , K t )-free, (H(1, 0, b, 1), K 3 )-free and (H(1, b, 0), K s )-free have a polynomial-time solvable isomorphism problem. These classes include various subcases for which the complexity of the isomorphism problem was also previously not resolved.

Color refinement and forbidden double stars
In this section we are concerned with graphs which do not contain double stars. More precisely we consider classes of graphs that, for some positive integer s, do not contain the disjoint union of two stars K 1,s∪ K 1,s as induced subgraphs. Our first lemma shows that bipartite graphs without double stars refine to graphs of bounded color valence under the naive vertex refinement.
Theorem 20. In a bipartite (K 1,s∪ K 1,s )-free graph in which the vertices are colored according to a bipartition, the naive vertex refinement produces a graph of bounded color valence. Moreover, the conclusion remains true if we only forbid double stars whose centers are in the same bipartition class.
Proof. Let G be a bipartite graph without a K 1,s∪ K 1,s subgraph that has the centers in the same bipartition class. We apply the naive vertex refinement to the graph G. We now show that if C and C ′ are two color classes then the color valence of every vertex v in C towards vertices in C ′ is less than R = 2s. Suppose otherwise. Let v be a vertex in C and let N be the neighbors of v in C ′ . By our assumption |N | ≥ R and |C ′ | − |N | ≥ R. Since the original graph was colored according to a bipartition and the new coloring is a refinement, the vertices in C are not adjacent to v. Since G is (K 1,s∪ K 1,s )-free, the neighborhood of a vertex in C differs from the neighborhood of v by s or more vertices. Thus, there are more than |C|(R − s) edges between C and N . This implies that every vertex of N is incident with more than |C|/2 edges. However, since neighborhoods cannot differ by more than s vertices, there are at most |C|s edges between C and C ′ \ N . This implies that a vertex in C ′ \ N is incident with at most |C|s/(|C ′ |−|N |) ≤ |C|s/R ≤ |C|/2 edges, which gives a contradiction.
In later sections we repeatedly apply the theorem to show that isomorphism of graphs in various hereditary graph classes, among them for example (P 5 , K t )-free graphs, can be solved in polynomial time. However, for some classes we also require a slight variant of Theorem 20 that also holds when the parts of the graphs are of bounded degree, as opposed to being independent sets.
Theorem 21. For every pair of positive integers s, t there exists integers c, d ∈ N such that the following holds. In every (K 1,s∪ K 1,s , K t )-free graph, there is a set S of size at most d, individualization of which, followed by naive vertex refinement, produces a graph of generalized color valence at most c.
Proof. If the graph G does not contain a star of large size, then by an easy Ramsey argument, the graph has bounded degree implying the claim of the lemma (see the introduction of [24] for details). Otherwise, we color the vertices of G according to adjacency type to some large star in G. Note that each color class is either of bounded degree or (K t−1 )-free. Since the number of color classes is bounded, by induction on t we thus see that there is a set S ′ of bounded size, such that coloring the vertices by adjacency type to S ′ produces color classes of bounded degree. We apply the naive vertex refinement to the graph colored in this way.
We now show that if C and C ′ are two sufficiently large color classes then the color valence of every vertex v in C towards vertices in C ′ is bounded by some constant R. Suppose otherwise.
Let v be a vertex in C and let N be the neighbors of c in C ′ . By our assumption |N | > R. There are |C| − d − 1 vertices in C that are not adjacent to v. Since G is (K 1,s∪ K 1,s )-free, there are at least (|C| − d)(R − s) edges between C and N . If we assume that R is larger than ks this implies that every vertex of N is incident with at least (|C|− d)(k − 1)/k edges with an endpoint in C. However, there are at most (|C| − d)s + dR edges between C and C ′ \ N . This implies that a vertex in If k and |C| are sufficiently large, this gives a contradiction.
Note that the theorem and its proof are similar to Theorem 20 and its proof. However, since we are not be able to decompose our graph into color classes that are independent sets, we can only reason about color valence between large color classes.
Corollary 22. Graph isomorphism for (K 1,s∪ K 1,s , K t )-free graphs can be solved in polynomial time.
Proof. The corollary follows by combining Theorem 21 and Corollary 19.

P 5 -free graphs of bounded clique number
In this section we analyze the structure of (P 5 , K t )-free graphs developing means to solve the isomorphism problem for such a class. We will need a theorem by Bacsó and Tuza [5] that says that every connected P 5 -free graph has a dominating P 3 or a dominating clique. Recall that a dominating set is a set of vertices S such that every vertex has a neighbor in S.
An instructive class of examples to have in mind are graphs obtained from disjoint unions of bipartite graphs to which a (P 5 , K t−3 )-free graph is joined. In this class it is easy to see that even when allowing individualization of a bounded number of vertices, the naive vertex refinement does not produce graphs of bounded color valence. In the following we employ modules to circumvent this problem.
If G is a colored graph and S a set of vertices then a refinement of G by adjacency towards S is a coloring obtained by refining the coloring of G such that the vertices of S are singleton color classes and two vertices v and v ′ outside of S are in the same color class if and only if they have the same color in the original coloring of G and for every vertex of s ∈ S either both v and v ′ are adjacent to s or both are non-adjacent to s. Lemma 23. For all positive integers t and d, there exists a positive integer ℓ such that refining an uncolored, connected (P 5 , K t )-free graph G by adjacency towards a dominating set of size d yields color classes for which the following holds: for each color C, among the components in the graph induced by the color class C, there are at most ℓ components that do not form a colored module in the entire graph.
Proof. Let S be a dominating set in an uncolored, connected graph G which is (P 5 , K t )-free and let C be a color class in the graph obtained from G by refining towards adjacency. Let C be a component of the graph induced by vertices of color C. If C is not a module then there exists a vertex v C / ∈ C and vertices u C , u ′ C ∈ C such that v C is adjacent to u C but not adjacent to u ′ C . Since C is connected we can choose u C and u ′ C to be adjacent. We call the vertex v C a distinguishing vertex for C. We first claim that a vertex v / ∈ C cannot be a distinguishing vertex for two distinct components C and C ′ at the same time (i.e., if C = C ′ then v C = v C ′ ). Indeed, otherwise the vertices u C , u ′ C , v C , u C ′ , u ′ C ′ would form a P 5 . Since there is only a bounded number of color classes (at most 2 d + d), it suffices to show for each color class D that the number of components C in a color class C that have a distinguishing vertex of color D is bounded. Since G is K t -free, it suffices to show that for distinct components C and C ′ within the graph induced by C, the vertices v C and v C ′ are adjacent if they have the same color. Suppose this is not the case. Since v and v ′ have the same color, D say, and the coloring is by adjacency towards S, there is a vertex s in S that distinguishes vertices in D from those in C. If v C is not adjacent to u C ′ and v C ′ is not adjacent to u C then v C , u C ′ , v C ′ , u C and s induce a P 5 , which is a contradiction. Without loss of generality we can thus assume that v C is adjacent to u C ′ . Since v C cannot distinguish vertices in two different components, v C is also adjacent to u ′ C ′ . Since the set {v C ′ , u C ′ , v C , u C , u ′ C } cannot induce a P 5 , v C ′ must be adjacent to a vertex in C and thus all vertices in C. However, in this case v C , u ′ C ′ , v C ′ , u ′ C and s would induced a P 5 , which shows that our assumption was false and thus v C and v C ′ are adjacent.
We strengthen the lemma to show that we can choose the dominating set so that the clique number in the non-module components becomes arbitrarily small.

Lemma 24.
For n ∈ N \ {0} and i ∈ {1, . . . , t} there exists an integer d such that in every connected (P 5 , K t )-free graph there is a dominating set S of size at most d such that refining by adjacency towards S yields color classes for which the following holds: for each color C, every component in the graph induced by the color class C is a module or K i -free.
Proof. Suppose n ∈ N \ {0}, i ∈ {1, . . . , t} and let G be a connected graph that is (P 5 , K n )-free. We show the statement by downward induction on k. For i = t there is nothing to show, since the graph G is K t -free by assumption. Suppose now that i < t. By induction we may assume that for i + 1 we have already shown the statement.
Suppose S is a dominating set such that refining by adjacency towards S produces colors within which the components are modules or K t+1 -free. By the induction hypothesis we can choose this set to be of bounded size. By Lemma 23 there is only a bounded number of components in the graphs induced by the color classes that do not form modules. For each such component we pick a dominating set of smallest size. By the theorem of Bacsó and Tuza [5] this dominating set has bounded size. Let S ′ be the union of S and all dominating sets picked for the components in the color classes. The size of S ′ is bounded by a function of t and i. We claim that refining by adjacency produces color classes which are K i -free or modules. To see this, note that in general when refining by adjacency towards vertices outside of a module M , the set M remains a module. For all components C that were not a module, the set S ′ used to refine by adjacency includes a dominating set within the graph induced by C. Thus, for all vertices in the new non-singleton color classes which C splits into, there is a common neighbor in the dominating set S ′ . Thus, since the component C was previously K i+1 -free, the new color classes are now K i -free.
The lemma shows in fact that there is a set of bounded size such that the resulting components are all modules.
Corollary 25. For every positive integer t there exists an integer d such that in every connected (P 5 , K t )-free graph there is a dominating set S of size at most d such that refining by adjacency towards S yields color classes for which the following holds: for each color C, all components in the graph induced by the color class C form a colored module in the entire graph.
Proof. Since every K 1 -free graph is empty, the corollary is a reformulation of the previous lemma for the case i = 1.
The corollary provides us with a mechanism to decompose a P 5 -free graph into modules which a have smaller clique number.
Theorem 26. For every positive integer t, graph isomorphism of (P 5 , K t )-free graphs can be solved in polynomial time.
Proof. We show the statement by induction on t. Let G 1 and G 2 be (P 5 , K t )-free graphs. By the previous corollary, we can guess in both graphs corresponding dominating sets S of bounded size such that refinement by adjacency produces color classes in which the components are modules. These modules are K t−1 -free since S is dominating. By induction we can compute the isomorphism type of each such module. Since the classical replacement operation is reversible, we can replace each module by a suitably colored single vertex and it suffices to solve isomorphism of the two quotient graphs that are obtained. Observe that the color classes in the quotient graph are independent sets. We now argue that if C and C ′ are color classes in the quotient then there is no 2K 1 in C ∪ C ′ . Supposing otherwise, for this to happen neither C nor C ′ can be contained in S since vertices in S are singletons. However, since colors are obtained by refining by adjacency towards S, there is a vertex s ∈ S that is adjacent to all vertices in one of the color classes and adjacent to no vertex of the other color class. This vertex together with the alleged copy of 2K 1 would form a P 5 yielding a contradiction. Consequently, by Theorem 20, the naive vertex refinement refines the graphs G 1 and G 2 to bounded color valence.
At this point we would like to caution the reader that for each particular graph class treated in the theorem, the modular decomposition is formed only a bounded number of times. The fact that vertices are individualized before the modules are formed prevents us from applying the Theorem 12 directly.

Specific classes of triangle-free graphs
We now analyze certain classes of triangle-free graphs and in doing so apply the techniques developed in the previous sections of this paper. Our ultimate goal is to show that isomorphism of triangle-free H(1, 0, b, 1)-free graphs (see Figure 1b) can be solved in polynomial time. However, only little is known about isomorphism of these classes and even their structurally simpler subclasses. This forces us to use a form of bootstrapping by showing various structural properties and developing algorithms step by step.
Lemma 27. For every integer b, the isomorphism problem of graphs that are colored, bipartite H(1, 0, b, 0)-free can be solved in polynomial time.
Proof. We analyze the structure of a connected, bipartite, H(1, 0, b, 0)-free, colored graph G. Let A and B be the bipartition classes of G. We apply the naive vertex refinement to G. By possibly having individualized one vertex before the refinement, we can assume that vertices in different bipartition classes have different colors. If G does not contain 2K 1,2b−1 with centers in the same bipartition class, then by Theorem 20 the naive vertex refinement produces a graph of bounded color valence. Thus for such graphs, we can solve isomorphism in polynomial time. We assume therefore that in G there is an induced subgraph isomorphic to 2K 1,2b−1 with centers in A say.
For a vertex v in A we define the set N c [v] as the set of vertices of A obtained by exhaustively applying the following operation: we start by setting S = {v}. If there is a vertex v ′ in A such that the neighborhoods of S and v ′ in B intersect, and the set of neighbors of S in B is not properly contained in the set of non-neighbors of v ′ in B, then we add v ′ to S. In this process the final set obtained is independent of the order in which the vertices are added.
We can use the algorithm for the bipartite case to develop an algorithm for all graph that (H(1, 0, b, 0))-free and do not contain triangles. (H(1, 0, b, 0), K 3 )-free graphs can be solved in polynomial time.

Lemma 28. Isomorphism of
Proof. Let G be a colored, connected (H(1, 0, b, 0), K 3 )-free graph. If the maximum degree of G is at most 6b we can solve isomorphism in polynomial time. Thus, let v be a vertex of G of degree at least d > 6b whose neighborhood is maximal, i.e., the neighborhood of no other vertex properly contains the neighborhood of v. Let N 0 be the set of vertices whose neighborhood is the same as the neighborhood of v. Let N i be the set of vertices that have distance i from N 0 . Note that N 1 forms an independent set since G is triangle free. We partition N 2 into three groups depending on the number of neighbors in N 1 being high, low or medium as follows: let N h 2 , and N l 2 be the sets of vertices in N 2 which have at most c 1 = 3b non-neighbors and at most c 2 = b neighbors in N 1 respectively. The set N m 2 is the set of vertices in N 2 neither in N h 2 nor N l 2 . Since c 1 + c 2 ≤ d these three sets partition N 2 . We first argue that the set N h 2 forms an independent set. Indeed, two vertices in N h 2 have a common neighbor in N 1 , since each such vertex has at most c 1 non-neighbors in N 1 , but there are at least d > 2c 1 vertices in N 1 .
Claim. We claim that if a vertex u 1 in N 2 has a neighbor u 2 that is not in N 1 , then the set of neighbors of u 1 in N 1 and the set of neighbors of u 2 in N 1 form disjoint sets which contain all but at most b − 1 vertices of N 1 .
The fact that the neighbor sets in N 1 are disjoint follows from the triangle-freeness of the graph. If there were b or more vertices in N 1 not adjacent to u 1 and not adjacent to u 2 , we could construct the forbidden subgraph H(1, 0, b, 0) by choosing the two vertices u 1 and u 2 , a vertex in N 1 adjacent to u 2 (consequently not adjacent to u 1 ), one vertex in N 0 and b vertices in N 1 neither adjacent to u 1 nor to u 2 . This proves the claim.
From the claim it follows that no vertex u 1 in N 3 ∪ N l 2 has a neighbor u 2 in N l 2 ∪ N m 2 . Indeed since b + (c 1 − c 2 ) ≤ d there are at least b vertices in N 1 not contained in the union of the neighborhoods of u 1 and u 2 .
We next argue that the bipartite graph with partition classes N h 2 and N l 2 does not contain the double star 2K 1,(c 1 +1)b with the centers in the same class. The centers of such an alleged double star J cannot be in N h 2 since such vertices have a common neighbor in N 1 , which, together with a subgraph of J isomorphic to K 1,b∪ K 2 , would result in the forbidden subgraph. We now assume that the centers of J are in N l 2 . Symmetrically to the other case, the centers cannot have a common neighbor in N 1 . Suppose w is one of the centers and there is a vertex u in N 1 adjacent to w such that at least one vertex y of J in N h 2 is adjacent to u. Then we find a forbidden subgraph with a vertex set consisting of y, u, the two centers and b vertices of J in N h 2 adjacent to w. Supposing otherwise, let u be a neighbor of w in N 1 which is not adjacent to any vertex of J in N h 2 . Note that among any (c 1 + 1)b vertices in N h 2 , there is a set T of b vertices that has a common neighbor in N 1 . Thus in J we can choose a set of T vertices adjacent to a common vertex x in N 1 but such that all vertices in T are not adjacent to u. The vertices in T together with x, v, u and w induce a forbidden subgraph. By Theorem 20, the absence of double stars that we just argued implies that the naive vertex refinement produces bounded color valence in the graph induced by N h 2 ∪ N l 2 . Suppose N m 2 is non-empty. We distinguish two cases according to the existence of an edge running within N m 2 ∪ N h 2 . Suppose first there exists an edge. Let N h 2 be the set of vertices in N h 2 that have a neighbor in N m 2 . We now show that N m 2 ∪ N h 2 is a complete bipartite graph. Let x 1 and x 2 be adjacent vertices of N m 2 ∪ N h 2 . Consider a third vertex x 3 in N m 2 . It suffices to show that x 3 is adjacent to x 1 or x 2 . Supposing otherwise, using the claim, we see that less than b vertices of N 1 are neither adjacent to x 1 nor to x 2 . Since x 3 ∈ N m 2 is adjacent to at least c 2 = b vertices in N 1 , this shows that x 3 has a common neighbor in N 1 with x 1 or x 2 . Due to the forbidden subgraph, this implies that for i ∈ {1, 2} the number of neighbors of x i which are not neighbors of x 3 is less than b. This implies that the number of vertices in N 1 to which x 3 is not adjacent is less than c 1 = 3b, which contradicts x 3 ∈ N m 2 . By the claim, the N 1 -neighborhoods of adjacent vertices in N 2 are complementary with respect to N 1 , with the exception of less than b vertices. Thus in the case that there is an edge x 1 , x 2 in N m 2 then individualizing x 1 and x 2 and refining by adjacency yields a graph for which every vertex has bounded color valence to color classes contained in N 1 .
Suppose now that there is no edge within N m 2 ∪ N h 2 . Due to the forbidden subgraph, there cannot be a double star isomorphic to K 1,b∪ K 2 in the graph induced by N 1 ∪ N 2 with centers in N 1 . We show that if there is a double star J isomorphic to 2K 1,2b between N m 2 and N 1 with centers in N m 2 then the graph is not prime with respect to a certain polynomial time computable decomposition functor. Let x 1 and x 2 be the centers in N m 2 . Suppose a vertex x in N 2 has a common neighbor with both x 1 and x 2 . Note that this vertex is neither adjacent to x 1 nor to x 2 . This implies it must be adjacent to all but b − 1 neighbors of x 1 and all but b − 1 neighbors of x 2 . This in turn implies that it must be adjacent to all neighbors of x 1 and all neighbors of x 2 since otherwise the forbidden subgraph is formed by x 1 , x 2 , x, and suitable neighbors of x 1 and x 2 . Due to the forbidden subgraph, if a vertex from N l 2 has a common neighbor with x 1 then its neighborhood in N 1 is a subset of the neighborhood of x 1 in N 1 . Moreover it cannot be adjacent to a vertex in N h 2 . The argument shows that the set of vertices which have a common neighbor with x 1 but not with x 2 , together with their neighbors in N 1 , form a colored module. The union of all such modules is also a module containing only vertices from N 1 , N m 2 and N h 2 . This module is a bipartite graph which is isomorphism invariant for the graph in which v has been individualized and can be computed in polynomial time. By Lemma 27 we can determine the isomorphism type of the module. Replacing it by an edge is reversible. Since it contains all double stars of the describes type, the associated decomposition functor is simple. For the entire graph G, note that, when all vertices of this module except the endpoints of one edge are removed, then the graph remains connected.
We next show for every i > 2 that for every vertex v ∈ N i the number of neighbors of v in N i ∪ N i+1 is at most b − 1. Indeed, suppose z 0 is a vertex in N i which has a set T of b neighbors in N i ∪ N i+1 . Using T and z 0 we can construct the forbidden subgraph H(1, 0, b, 0) by starting with z 0 and repeatedly choosing a neighbor in the level that is one closer to the root. More precisely, let z 1 be a neighbor of z 0 in N i−1 , let z 2 be a neighbor of z 1 in N i−2 and let z 3 be a neighbor of z 2 in N i−3 . The set T ∪ {z 0 , z 1 , z 2 , z 3 } induces the forbidden subgraph.
Using a very similar argument, we also show that for i = 2 the analogous statement holds, i.e, for every vertex v ∈ N 2 the number of neighbors of v in N 2 ∪ N 3 is bounded: let z 0 be a vertex in N 2 which has a set T of b neighbors in N 2 ∪ N 3 . Since N 2 is an independent set, T is in fact contained in N 3 . We construct the forbidden subgraph by adding a vertex z 1 from N 1 adjacent to z 0 , a vertex z 2 from N 0 and a vertex z 3 from N 1 not adjacent to z 0 . This vertex exists since, due to the neighborhood of v ∈ N 0 being maximal, the neighborhood of z 0 cannot contain all of N 1 .
We summarize what we have achieved up to this point: by choosing an initial vertex v with maximal neighborhood we partition the graph into level sets N i . By either removing a bipartite module in N 1 ∪ N m 2 ∪ N l 2 or individualizing an edge in N m 2 we obtain a colored, connected graph for which the naive vertex refinement produces a coloring in which every vertex has bounded color valence to every color class that is not contained in N h 2 . However, between the vertices in N h 2 and N 3 the same situation could arise as between N 1 and N 2 . We cannot easily apply the previous technique to separate N 3 into N h 3 , N m 3 and N l since the adjacency of N h 2 towards N 1 is not uniform in the same way in which the adjacency of N 1 is uniform to N 0 .
We remedy this by reapplying the entire procedure for a bounded number of iterations using different root sets N 0 . Intuitively, in each iteration we force some of the vertices previously in N h 2 to be somewhere outside of what is going to be the new level set of distance 2 from the root. For this, first note that in N 1 for every set S ′ of size c 1 + 1, every vertex in N h 2 has a neighbor in S ′ . For every vertex w ∈ S ′ we can choose some maximal vertex w ′ whose neighborhood contains the entire neighborhood of w. Choosing w ′ and its twins to become the level set N 0 implies that vertices adjacent to w will be in the new level set N 1 and in particular not in the new N h 2 . Repeating this for all vertices in S ′ ensures that for each vertex there is at least one execution during which the vertex is not contained in N h 2 . If the degree of w ′ is not sufficiently large, i.e., it is not larger than 6b, we cannot apply the arguments given above. However, in this case individualizing all neighbors of w ′ and refining by adjacency already achieves that adjacency for all vertices towards neighbors of w is of bounded color valence. This shows that the graph we obtain has bounded color valence. In total only a bounded number of vertices is being individualized.
By applying the colored module isomorphism theorem (Theorem 12) this proves the lemma, since the modules are bipartite graphs (for which isomorphism can be solved by the previous lemma).
The previous theorems are concerned with forbidding the graph H(1, 0, b, 0) which is obtained from H(1, 0, b, 1) by deleting the isolated vertex. We now study the classes obtained by deleting another vertex from H(1, 0, b, 1) and forbidding the resulting graph.
Lemma 29. Let s be an integer. Graph isomorphism of colored, bipartite graphs which do not contain an induced subgraph isomorphic to K 1,s∪ K 2∪ K 1 such that the center of K 1,s and the isolated vertex are in different bipartition classes can be solved in polynomial time.
Proof. If G is a connected bipartite graph then G does not contain K 1,s∪ K 2∪ K 1 with the center and the isolated vertex in different bipartition classes if and only if the bipartite complement of G is H(1, 0, s, 0)-free. Isomorphism of such graphs can thus by solved in polynomial time due to Lemma 27 by taking the bipartite complement.
Corollary 30. Isomorphism of connected, bipartite H(1, 0, b, 1)-free graphs for which every pair of vertices in the same bipartition class has a common neighbor can be solved in polynomial time.
Proof. If a connected, bipartite graph is H(1, 0, b, 1)-free and every pair of vertices in the same bipartition class has a common neighbor then the graph does not contain an induced subgraph isomorphic to K 1,b∪ K 2∪ K 1 such that the center of K 1,b and the isolated vertex are in different bipartition classes. We can thus apply the previous lemma.
Despite being able to solve isomorphism of bipartite H(1, 0, b, 1)-free graphs with the corollary, we still require more detailed structural knowledge on these graph classes for our overall goal.
Lemma 31. Let G be a bipartite graph colored according to a bipartition which does not contain an induced subgraph isomorphic to K 1,s∪ K 2∪ K 1 such that the center of K 1,s and the isolated vertex are in different bipartition classes. If G does not contain the bipartite complement of 3K 1,s with centers in the same bipartition class, then by individualizing a set of bounded size and applying the naive vertex refinement, the graph can be turned into a graph of bounded color valence.
Proof. If the graph has no 2K 1,s with centers on the same side, then by Theorem 20 the naive vertex refinement produces a graph of bounded color valence. Otherwise, we individualize the vertices of a copy J 1 of 2K 1,s with centers on the same side. If in the new color classes there is no 2K 1,s with centers on the same side, we can apply Theorem 20 again. Otherwise, we individualize one new copy J 2 of 2K 1,s such that prior to individualization vertices in J 2 that lie in the same bipartition class had the same color. Note that the vertex sets of J 1 and J 2 are disjoint. By possibly repeating the argument, we conclude that we can choose J 1 and J 2 such that all centers are in the same bipartition class. Since J 2 was chosen after the vertices were refined by adjacency to J 1 , to every vertex of J 1 the centers of J 2 are either both adjacent or neither of them is adjacent. This implies that both centers of J 2 must be adjacent to the non-centers of J 1 , otherwise we find the forbidden subgraph since the centers of J 2 would have a common non-neighbor in the other bipartition class. Similarly, there cannot be a non-center of J 2 to which both centers of J 1 are non-adjacent. This implies that one of the centers of J 1 is adjacent to all non-centers of J 2 . This center and its non-adjacent non-center vertices in J 1 together with the vertices of J 2 form the bipartite complement of 3K 1,s .
We assemble the structural analysis of the subcases performed in this section to develop an algorithm deciding isomorphism of triangle-free H(1, 0, b, 1)-free graphs.
Proof. Without loss of generality we assume b ≥ 3. If one of the input graphs to a given instance of the graph isomorphism problem is (H(1, 0, b, 0), K 3 )-free, then we can solve isomorphism using Lemma 28.
We thus discuss the structure of a (H(1, 0, b, 1), K 3 )-free graph G that contains an induced subgraph K isomorphic to H (1, 0, b, 0). Note that every vertex of G is adjacent to at least one vertex of K, i.e., K is dominating. For i ∈ {0, . . . , 4} we define the sets N i to be set of vertices of distance i from the leaf in K that is adjacent to a vertex of degree 2. By individualizing the vertices in K and recoloring the vertices of G according to adjacency towards K we obtain a coloring of the graph into independent sets.
Let C and C ′ be two color classes which contain adjacent vertices. Let T be the set of neighbors in K of a vertex (and thus any vertex) in C and let T ′ be the set of neighbors in K of a vertex in C ′ . This implies that T and T ′ form disjoint non-empty independent sets of K. We want to achieve that the graph induced by two color classes C and C ′ has bounded color valence when refined with the naive vertex refinement. Note that the subgraph induced by C and C ′ does not contain K 1,2b+1∪ K 2∪ K 1 such that the center of K 1,2b+1 and the isolated vertex are in different bipartition classes: Otherwise, by adding an appropriate vertex of K, we could construct the forbidden subgraph H (1, 0, b, 1). Thus, if the graph induced by the two colors does not contain the bipartite of complement 3K 1,2b+1 with centers in the same bipartition class, we can, by Lemma 31, individualize a set of bounded size such that the refinement yields bounded color valence. Since the bipartite complement of 3K 1,2b+1 in particular contains the graph H (1, 0, b, 0), the graph induced by C and C ′ can only contain the bipartite complement of 3K 1,2b+1 if T ∪ T ′ contains every vertex of K.
In the following we thus assume that one of the sets T and T ′ is N 0 ∪ N 2 ∪ N 4 while the other one is N 1 ∪ N 3 . We also assume that the graph induced by C and C ′ contains the bipartite of complement 3K 1,2b+1 with centers in the same bipartition class. Let J be an isomorphic copy of this graph. Without loss of generality we assume that the centers are in the color class C.
We claim that G is a bipartite graph such that each pair of vertices in one of the bipartition classes has a common neighbor. To show this, we first show that for each vertex v not in C, for two of the three stars in J, v is adjacent to more than half the vertices of color C or to more than half the vertices of color C ′ . Thus let v be a vertex that is not of color C, its color being C ′′ say. Let T v be the vertices in K to which v is adjacent. Recall that T is a maximal independent set of K. Thus, since T v is different from T , there is a vertex x in K such that x is adjacent to the vertices in C but neither adjacent to the vertices in C ′ nor the vertices in C ′′ . This implies, due to forbidden subgraph H (1, 0, b, 1), that v is adjacent to at least two centers of J or for two of the stars in J, v is adjacent to more than half of the vertices in C ′ . Since T v is non-empty, there is no edge between v and C or there is no edge between v and C ′ .
Let A be the set of vertices that have a neighbor in C and let B be the other vertices. We claim that this is a bipartition of G. Indeed, every vertex that has a neighbor in C is adjacent to two of the tree centers. Thus all vertices in A have a common neighbor and A is an independent set. All vertices in B which are not in C are adjacent to more than half of the vertices of color C ′ in two of the stars. It remains to show that vertices in C have a common neighbor with all vertices in B. However, each vertex in B is adjacent to a vertex in T which in turn is adjacent to every vertex in C. Thus vertices in B have a common neighbor and B is an independent set.
This proves that G is bipartite such that each pair of vertices in one of the bipartition classes has a common neighbor. Isomorphism of such graphs can be solved using Corollary 30.

Specific classes of bounded clique number
In this section we show that isomorphism of (H (1, b, 0), K s )-free graphs can be solved in polynomial time (see Figure 1a). To do so, we start with a structural lemma concerning such graphs. Proof. Suppose otherwise that v has a neighbor in H and M and a non-neighbor in M . Since M is connected, v has a neighbor x in M and a non-neighbor y in M such that x and y are adjacent.
If v is adjacent to at least b leaf vertices of H then {y, x, v} together with these b leaves induces the forbidden subgraph. Otherwise v is non-adjacent to b leaves of H. If v is adjacent to the center h of H then the set {x, v, h} together with b leaves non-adjacent to v induce a forbidden subgraph. If however v is non-adjacent to the center, then by assumption there is a leaf ℓ to which v is adjacent. In this case v, ℓ, h and b leaves non-adjacent to v induce a forbidden subgraph.
Theorem 34. Graph isomorphism for colored (H(1, b, 0), K s )-free graphs can be solved in polynomial time.
Proof. Let G 1 and G 2 be (H(1, b, 0), K s )-free graphs. Recall that by Corollary 22 we can solve isomorphism of G 1 and G 2 in polynomial time if one of the graphs is (K 1,2b−1∪ K 1,2b−1 )-free.
We now argue that for graphs that do contain K 1,2b−1∪ K 1,2b−1 , we can use the standard modular decomposition functor for uncolored graphs to decompose the graphs. That is, if the graphs are not connected, we take the connected components as the modules. Analogously, if their complements are not connected we take the connected components of the complements as modules. In any other case, we decompose the graph into the maximal modules. These partition the vertices and can be computed in polynomial time (see [19]). We show that if a H(1, b, 0)-free graph contains an induced double star (K 1,2b−1∪ K 1,2b−1 )-free then there is a non-trivial module. For this it suffices to show that the minimal modules containing each K 1,2b−1 are disjoint. Call the stars H 1 and H 2 . Suppose the minimal module containing H 1 contains a vertex from H 2 . The minimal module containing H 1 is obtained by starting with S 0 = V (H 1 ) and repeatedly increasing this set by adding vertices. More precisely S i+1 = S i ∪ {v} for some vertex v that has a neighbor and a non-neighbor in S i . Note that by induction all S i are connected. By our assumptions, in some step a vertex must be added which is not in V (H 2 ) but has a neighbor in H 2 . Let i be the first step in which this happens and suppose u is the vertex that is added. Then u has a neighbor and a non-neighbor in the set S i which induces a connected graph and a neighbor in H 2 , which is a contradiction to Lemma 33.
Since we can solve isomorphism of colored prime graphs in polynomial time, this concludes the proof using Theorem 12 with the classical decomposition functor.

Comprehensiveness of the case distinction
In this section we argue that the theorems developed throughout this paper together with the theorems from [24], with the exception of finitely many cases, resolve the complexity of graph isomorphism for (H 1 , H 2 )-free graphs. In fact, said theorems also either provide a polynomial time algorithm or a reduction from the general isomorphism problem to the respective classes.
Proof of Theorem 2. Let (H 1 , H 2 )-free be the graph class for which we want to determine the complexity. By the results in [24], we may assume that one of the graphs, H 2 say, is a complete graph. Since graph isomorphism for K 2 -free graphs is polynomial-time solvable, we further assume that H 2 has at least 3 vertices. By [24, Lemma 2] we may consequently assume that H 1 is a forest of subdivided stars, since the problem is graph isomorphism complete otherwise.
If H 1 contains 3 non-trivial components, then H 1 contains 3K 2 and the problem is isomorphism complete [24,Lemma 5]. In the following we can thus assume that H 1 has at most 2 non-trivial components. If H 1 does not contain a vertex of degree 3 then if H 1 is sufficiently large, it is either of the form P i∪ I t with i ≤ 3 or it contains the graph 2K 2∪ I 2 . In the former case graph isomorphism is polynomial-time solvable by Theorem 32. In the latter case the isomorphism problem is graph isomorphism complete [24, Lemma 5].
(The case H 2 = K 3 ). Suppose H 2 is the graph K 3 . Since H 2 is fixed, we can assume that H 1 is sufficiently large and we can thus assume by the observation above that H 1 contains a vertex of degree 3. If H 1 does not contain a P 4 then H 1 is a union of at most two stars plus isolated vertices. If there is at most one star, the problem is polynomial-time solvable by Theorem 32 (or by [24,Theorem 4]). Assuming there are two stars, if there is more than one isolated vertex then H 1 contains 2K 2∪ 2K 1 and the problem is isomorphism complete by [24,Lemma 5]. If neither of the stars is only a single edge then if there exists an isolated vertex in H 1 the problem is isomorphism complete by Theorem 7 and if there is no isolated vertex in H 1 it is polynomial-time solvable by Corollary 22. Finally, if one of the stars is only an edge then by Theorem 32 the problem is in polynomial-time solvable.
If H 1 contains a P 4 and there are two non-adjacent vertices not in the same connected component as the P 4 then H 1 contains P 4∪ 2K 1 and the problem is graph isomorphism complete [24,Lemma 5]. Assuming this is not the case implies that the vertex of degree 3 is in the same component as the P 4 . Since isomorphism of (2K 2∪ 2K 1 )-free triangle-free graphs is isomorphism complete [24,Lemma 5], by assuming that H 1 is sufficiently large, we may further assume there is at most one additional vertex not in the connected component of the P 4 . If there is only one degree 1 vertex non-adjacent to the vertex h of degree at least 3, and this vertex has distance 2 from h, then H 1 is an induced subgraph of H(1, 0, b, 1) for some positive integer b and the problem is in polynomial-time solvable by Theorem 32. If H 1 contains two leaves of distance at least 3 from the center, then if H 1 is sufficiently large it also contains 2K 2∪ 2K 1 . If H 1 contains a leaf of distance at least 4 then H 1 contains P 4∪ 2K 2 . In both cases the problem is graph isomorphism complete by [24,Lemma 5].
(The case H 2 = K n with n > 3). Suppose now H 2 is the graph K n for some n ≥ 4. Suppose first, H 1 contains two non-trivial components. If it contains an isolated vertex, then in contains 2K 2∪ K 1 and the problem is isomorphism complete by Theorem 6. If one of the components contains P 4 and the graph is not connected, then the graph contains P 4∪ K 1 and the problem is isomorphism complete by [24,Theorem 3]. Otherwise the two components form a double star and the problem is polynomial-time solvable by Corollary 22.
Thus we may assume now that there is only one non-trivial component. If there is no P 4 in H 1 , the problem is solvable by [24,Theorem 4]. Otherwise, by [24,Theorem 3], we can assume that H 1 is connected. If H 1 is isomorphic to P 5 , the problem is solvable by Theorem 26. If H 1 is isomorphic to P 6 the problem is isomorphism complete by Theorem 6. We can thus assume that H 1 contains a vertex of degree at least 3, which we call the center. If there is only one leaf not adjacent to the center and this leaf has distance 2 from the center, then the problem is polynomial-time solvable by Theorem 34. If there are two leaves not adjacent to the center then H 1 contains P 4∪ K 1 and the problem is isomorphism complete by [24,Theorem 3].
If there is a leaf of distance at least 3 from the center and the center has degree 4 then the problem is graph isomorphism complete by Theorem 6. We can thus assume that the center has degree 3. Under these conditions, if H 2 = K 4 and H 1 is sufficiently large, then H 1 contains P 6 and the problem is isomorphism complete by Theorem 6. In the remaining cases H 2 = K n with n ≥ 5 and H 1 has a leaf of distance at least 2 from the center. In this case the problem is isomorphism complete by Theorem 8.

Conclusion
There is an intricate relationship between the boundedness of the clique width on a graph class and polynomial-time solvability of the isomorphism problem. While there are classes of unbounded clique width the isomorphism problem of which is solvable in polynomial time (for example the graphs of bounded degree or the graphs characterized by a forbidden star and a forbidden clique (see [24])), there are no classes known to be isomorphism-complete and known to have bounded clique width. It is conceivable, but open, that isomorphism on graphs of bounded clique-width is solvable in polynomial time. In fact, it seems that typically an isomorphism reduction to a graph class C yields a proof for the unboundedness of the clique width. It is easy to see that every class of graphs encoded by a simple path encoding has unbounded clique width. The reason is that if G ′ is the graph produced from a graph G by the reduction detailed in the proof of Theorem 5 then G can be obtained from G ′ by a finite application of edge complementations between two sets, followed by an unbounded number of local complementations and vertex removals. This shows that the clique width of G is bounded by a function of the clique width of G ′ . Thus, if G has large clique width then G ′ has large clique width.
Corollary 35. The graphs encoded by a simple path encoding have unbounded clique width.
This implies that many classes (H 1 , H 2 )-free have unbounded clique width. In particular the class (P 4 ∪ K 1 , K 4 )-free has unbounded clique width, which is an open case in the list of [11]. Conversely, when a graph class is shown to be polynomial-time solvable, often this is due to some structural insight that actually amounts to showing that the clique width of the class is bounded. On another note it appears that the solution of the generalized color valence problem presented in this paper, more precisely a generalization of the technique, is a first step towards showing polynomial-time solvability of graphs of bounded clique width. More concretely, the generalization applies to graphs with fixed rank decomposition.
As mentioned in the introduction, for various other computational problems, classification results have been considered for classes characterized by two forbidden graphs. For these problems, there had been extensive prior work and algorithmic techniques were already available. For the isomorphism problem, such techniques were lacking and the intention of this paper is to develop them. The fact that for new classes the complexity of isomorphism can be determined using these techniques, while other methods seem to fail, shows that these techniques provide something conceptually different.
However, concerning a list of open cases that still remain for the classes characterized by two forbidden subgraphs one has to analyze precisely to which classes the techniques can be applied. For example, Brandstädt and Kratsch [8] show that cycles of length 5 in (P 5 , P 4 ∪ K 1 ))-free graphs are disjoint. By coloring vertices inside a 5-cycle depending on whether they have a neighbor outside the cycle, we can construct a decomposition functor. Furthermore, there is a description of the relevant prime graphs in [8] which allows to us apply the modular decomposition technique. This is just an example and a comprehensive description of the various cases that can actually be handled with the techniques remains as future work.