A -colouring of a graph is an assigment of distinct colours to the vertices of such that all vertices are coloured and adjacent vertices have distinct colours. The -colouring problem for a graph and a natural number consists in deciding whether is -colourable or not. For , the problem is equivalent to deciding whether has an edge, and for , it is equivalent to deciding whether is bipartite, which can be done in linear time using a BFS algorithm. For , Karp  showed that the problem is NP-complete.
There are some graph classes for which the -colouring problem is polynomially time solvable, such as perfect graphs . On the other hand, the problem remains NP-complete, even when restricted to the class of all triangle-free graphs with bounded maximum degree .
The class of -free graphs, defined as the class of all graphs not containing as an induced subgraph, is a very natural restriction and has appeared in many complexity results. An extension of the result from  is that the -colouring problem is NP-complete for -free graphs, for any graph containing a cycle [18, 21]. Moreover, if is a forest with a vertex of degree at least , then -colouring is NP-complete for -free graphs and [16, 22]. Combining these results, we obtain that for , the -colouring problem is NP-complete in -free graphs, for all graphs that are not a disjoint union of paths. So naturally, there has been much activity in determining for which and the -colouring problem is polynomially time solvable or NP-complete in -free graphs, where is the path on vertices. (There are also several recent results for graphs not having a disjoint union of paths as an induced subgraph, see [2, 3, 4, 5, 9, 20].)
Huang  proved that -colouring is NP-complete for -free graphs, and that -colouring is NP-complete for -free graphs (which implies that -colouring is NP-complete for -free graphs for ). On the other hand, Hoàng, Kamiński, Lozin, Sawada, and Shu  showed that -colouring can be solved in polynomial time on -free graphs for any fixed , and recently, Chudnovsky, Spirkl, and Zhong [6, 7] showed that the same is true for -free graphs and . This means we have a complete classification of the complexity of -colouring -free graphs for any fixed .
For , less is known. Randerath and Schiermeyer  and Bonomo, Chudnovsky, Maceli, Schaudt, Stein, and Zhong  gave polynomial time algorithms for -colouring - and -free graphs, respectively. However, no such algorithm is known for -free graphs (although some partial results are known for this class of graphs ). Interestingly, it is also unknown whether or not there exists such that -colouring is NP-complete on -free graphs.
Some of the positive results from above are easier to prove if in addition to the path , also the triangle, or other cycles, are excluded, and in fact, sometimes this was the first step for proving the full result. Let be any fixed family of graphs (here, it will always be a set of cycles). Call a graph -free if it does not contain any member of the family , and call -free if in addition, is -free. We refer to  and  for an overview on the complexity of colouring -free graphs.
In particular, in the case , Golovach, Paulusma and Song  showed that for any , the -colouring problem is polynomial time solvable for -free graphs. The same authors show that for every there is a such that every -free graph is -colourable, where is the family of all cycles up to length . Recall that by the results of [18, 21], it is also known that for all , -colouring is NP-complete for -free graphs.
We focus on graphs having no short odd cycles. The odd girth of a graph is the length of its shortest odd cycle (it is infinite if is bipartite). Adhering to the terminology from above, we call a graph -free, for odd, if it has odd girth at least .
The following is our main theorem.
For any odd , there is a polynomial time algorithm deciding whether a -free graph is -colourable (and giving a 3-colouring if one exists).
In particular, this implies:
There is a polynomial time algorithm deciding whether a -free graph is -colourable (and giving a 3-colouring if one exists).
We remark that the complexity of -colouring -free graphs is open for and both , . So, Theorem 1.2 can be seen as a first step to determining the complexity of this problem, or even to resolving the problem for -free graphs.
The paper is organised as follows. We give a quick overview of our proof in Section 2, and then go through some preliminaries in Section 3. We present the proof of Theorems 1.1 and 1.2 in Section 4. The proof relies on Lemma 4.1, which is also presented in Section 4. In Section 5, we prove Lemma 4.1 for all pairs , such that at least one of the following applies: ; is -free; or has an induced . In particular, the proof of Theorem 1.2 is completed after Section 5. The more complicated proof for -free graphs with having an induced is postponed to Section 6. Finally, Section 7 is devoted to the running-time analysis of our algorithm, the running time being .
2 Overview of the proof
Our proof relies on a structural analysis of a longest odd cycle of and it surroundings. This is done in Section 5, distinguishing the two possible lengths of : or (these cases are treated in Section 5.2 and 5.3, respectively). In the case that has length , we assume the cycle is forbidden or that (for the time being).
We distinguish different sets , , , of neighbours of , according to the location of their neighbours on , and prove all other vertices lie at most at distance 2 from (unless they are dominated by a non-neighbour, a case which can be safely ignored). We determine which sets can be adjacent to each other, and which cannot. The main results of the structural analysis in Sections 5.2 and 5.3 are summarised in Lemmas 5.12 and 5.24. Most importantly, these lemmas identify a set of bounded size dominating important parts of the graph.
In Section 5.4, we prove Lemma 4.1, by colouring in all possible ways. After doing so, all other vertices will either be adjacent to a coloured vertex, or are reducible, or belong to reducible bipartite subgraphs, by which we mean that they can be coloured in a canonical way (see Section 3 for a definition). This allows us to ultimately reduce the problem to a -list-colouring instance, which is known to be polynomial time solvable. This finishes the proof, unless and there is a .
We treat that case in Section 6. Our previous approach almost works in the same way. The only problem is that if in addition, has length , the structural analysis leaves us with one difficult case. Namely, there might be a set of vertices at distance from that cannot be dominated, or made reducible, in a similar way as the other sets. Our solution is that we test all colourings of , and for each such colouring, we also colour the vertices from , and some of their neighbours and second neighbours ‘by hand’ in a canonical way (that will depend on the colouring of ). When doing so, we have to make sure that any vertex not coloured ‘by hand’ will not be affected by our colouring - either because it is already coloured in a compatible way, or more generally, because its list of available colours did not decrease. The main challenge in Section 6 is how to choose the vertices that will be coloured together with , in way that other vertices will not be affected. This is achieved by a structural analysis. We can then proceed as before. That is, we test all colourings of , colour the reducible vertices and subgraphs, and thus reduce the problem to a -list-colouring instance.
3.1 Basic definitions
For , let . A graph has vertex set and edge set . We only need to consider connected graphs , since one can solve the -colouring problem on the components. We call (or one of its components ) trivial if it has only one vertex.
If does not contain another graph as an induced subgraph, we say is -free. If is a family of subgraphs, and does not contain any of the graphs in as an induced subgraph, we say is -free. Sometimes we write -free to mean that the graph is -free.
Let and . Then is the set of all neighbours of in , and is the set of all neighbours of vertices of in . If , we omit the subscript. Note that . Also, denotes the subgraph of induced by , and is the graph obtained from by deleting and its adjacent edges. We call a vertex complete to if all - edges are present, and if this holds for all , we say is complete to .
A stable set is a subset of pairwise non-adjacent vertices. A graph is bipartite if can be partitioned into two stable sets. A vertex dominates another vertex if . The following lemma is well-known and easy to prove.
Let be graphs such that is -free, and let . Then is -free, and if is dominated by one of its non-neighbours, then
|is -colourable if and only if is -colourable.|
3.2 Palettes, updates and reducibility
In the context of 3-colouring, we call a family of lists , where for every , a palette of the graph . We call feasible if no vertex has an empty list. A subpalette of is a palette such that for each . A graph and a palette of will often be written as a pair . We say that is colourable if there is a subpalette of such that for every vertex , and for every edge . We sometimes call a vertex with a list of size 1 a coloured vertex.
Updating the palette means obtaining a subpalette of by subsequently, for any vertex having a list of size in the current palette, deleting its colour from the list of each neighbour of . (For instance, if in a path all but one vertex have the list , and has list , then updating this palette gives a colouring of the path.) If updating a palette of a graph results in the same palette , we will say that is updated.
Given , call a vertex reducible (for colour ) if and for each . A trivial subgraph of is called reducible if is reducible. The subpalette obtained from by setting and keeping all other lists will be called the reduction palette for the reducible component .
A bipartite subgraph of , with partition classes , , is called reducible (for colours ) if there are distinct colours such that for ,
The subpalette obtained from by setting for and all , and keeping all other lists will be called the reduction palette for the reducible component .
We leave the proof of the following lemma as an exercise to the reader.
Let be a graph and let be palette of . Suppose is a reducible subgraph of , and is the corresponding reduction palette. Then is 3-colourable if and only if is 3-colourable.
4 The proof of Theorem 1.1
Let be a -free connected graph. Then there is a set of updated feasible palettes such that
and can be found in polynomial time;
is -colourable if and only if is -colourable for some ; and
for each , every component of is reducible.
We will also need a result on the list-colouring problem with lists of size at most 2. Given a graph and a finite list for each vertex (with no restriction on the total number of colours) the list-colouring problem asks for a a colouring of all vertices with colours from their lists. If for each vertex , the problem can be solved in time, by reducing the -list-colouring instance to a -SAT instance [10, 25].
With this result and Lemma 4.1 at hand, we are ready to present the proof of our main result.
Proof of Theorem 1.1.
Given , we apply Lemma 4.1 to obtain a set of palettes. For each , and each reducible component of , we consider the reduction palette for and solve the -list-colouring instance . This either gives us a valid -colouring for one of the palettes , and thus for our instance , or proves that no such colouring exists. ∎
Sections 5 and 6 are devoted to the proof of Lemma 4.1. As discussed above we first concentrate on the easier case that either , or is -free, or has an induced , which we deal with in Section 5, and leave the more complicated general case for Section 6. For simplicity of notation, let denote the class of all -free graphs such that at least one of the following holds:
is -free; or
has an induced .
5 The proof of Lemma 4.1 for
The section is organised as follows. First, we investigate the structure of the graph , proving some basic observations in Section 5.1, and then distinguishing two cases according to whether or not has an induced cycle of length . The structural analysis for the case that is -free is treated in Section 5.2, while the case that does have a cycle of length is treated in Section 5.3. All structural properties we find in these two sections will be conveniently summarised in two lemmas, Lemma 5.12 (at the end of Section 5.2) and Lemma 5.24 (end of Section 5.3). Then, in Section 5.4, where we will prove Lemma 4.1 for , we only need to refer to these two lemmas.
5.1 The base cycle and its neighbours
We start with a general definition describing the neighbours and second neighbours of a cycle of .
Let and let be a cycle in . For , define
and let denote the set of vertices located at distance two from .
Clearly, since we can assume is not bipartite (as otherwise the -colouring problem is well known to be polynomial), has an odd cycle . Because of the forbidden subgraphs, the length of the longest odd cycle is either or . We will see now that in each of these two cases, can be decomposed into some of the sets that Definition 5.1 gives for .
Suppose that no vertex in is dominated by any of its non-neighbours.222Because of Lemma 3.1, we need not worry about dominated vertices, and Claim 5.2 is the only place where we need to exclude them. In an algorithmic implementation of our method, one will ignore such vertices if detected by Claim 5.2, and colour them at the very end (in case a colouring is found). Let be a longest odd cycle in .
If , then , with .
If , then , with .
Furthermore, for each , each of the sets , , and is stable.
Since has no odd induced cycles of length up to , and no induced , it is not hard to see that in case (a), , and in case (b), . Moreover, each of the sets , , and , for every , or , is stable, as is triangle-free.
It only remains to show that no vertex of lies at distance from . Assume otherwise, and let be an induced path such that lies at distance from . Suppose , and that is adjacent to , but not adjacent to any with . Since does not dominate , there is a neighbour of that is not a neighbour of , and since is triangle-free, is not adjacent to . Furthermore, since is at distance from , we know that does not have any neighbours on . Thus is an induced , which is impossible. ∎
We can deduce some useful information on the components of .
In the situation of Claim 5.2, every nontrivial component of is bipartite and vertices of the same bipartition class of have identical neighbourhoods in .
Since is -free, we know that for every induced path of length 3 in , vertices and have the same neighbours in . In order to see that is bipartite, apply the observation from the previous sentence to any odd cycle in , thus generating a and therefore, a contradiction. ∎
5.2 The structure of if it is -free
For understanding the structure of , we first analyse the edges between and .
No vertex from can have neighbours both in and in .
This follows directly from the fact that is -free. ∎
For each there is an such that at least one of the following holds:
for some ; or
Because of the forbidden cycles (and observing that if then ), we know that if , then all neighbours of in lie in or in , and all neighbours of in lie in . Moreover, if has a neighbour in , then is contained either in or in . This gives (a), unless has neighbours in both and in . However, in that case, the neighbours of in must belong to , and hence, there is an induced going through , which is only allowed if . Putting these observations together, and using Claim 5.4 for (b), the statement follows. ∎
Let be the set of all which have neighbours in both and . (By Claim 5.5, this set is empty if .) Observe that if there are independent edges , such that , , , then is an induced path of length (i.e. of length ), which is impossible. Therefore, for any two vertices , we have that either or (or both). Choosing two vertices in each set such that and are inclusion-minimal, then choosing a neighbour of in , and a neighbour of in , and letting , we obtain the following claim.
There is a set of size at most such that every vertex in has a neighbour in .
Let us now analyse possible edges inside .
For any , if and , then
This follows from the fact that has no induced odd cycles of length up to . ∎
If are adjacent, then
there is a vertex on such that ; and
there are two consecutive vertices on such that and .
We now define a set of certain vertices of .
Let be the set of all vertices for which there is an such that and one of the following holds:
has a neighbour in .
Observe that by Claim 5.4, the vertex set of any component of is either contained in or disjoint from .
Let with . Then for any and , we have that .
Suppose otherwise. By Claim 5.7 there is an index such that and (after possibly changing the roles of and ). Then is an induced cycle of length , a contradiction. ∎
It turns out that is dominated by a set of bounded size.
There exist a set such that and .
Let . We claim that for any two vertices we have
Then we can take, for each with , a vertex , with the property that among all such choices, is inclusion-minimal, and choose an arbitrary vertex . If , we also choose a arbitrary vertex . Then by (1), the set consisting of all and all existing is as desired.
We distinguish two cases. First assume is as in Definition 5.9 (i), that is, . Then there is , say (the other case is symmetric). Since we assume (1) does not hold, we may assume that (after possibly swapping the roles of and ). Consider the induced path , which has length , a contradiction.
We now resume the main results of this subsection in the following lemma.
There is a set with such that for every component of one of the following holds.
is trivial and there is a vertex on such that ; or
is bipartite with partition classes , and
there are vertices such that for ;
there are for such that ; and
is complete to .
Now, consider any vertex . By Claim 5.5, there is an such that all neighbours of in belong to . If is isolated in , we take which is as required for (II). If is not isolated in , then Claim 5.3 implies that is bipartite and the vertices of each partition class have identical neighbourhoods in . So by Claim 5.8 and Claim 5.10, we have (III). ∎
5.3 The structure of if it contains a
In this subsection, we assume that has a cycle of length , and we let , and be the sets given by Definition 5.1 and Claim 5.2 for cycle , while denotes the set of vertices located at distance two from . In this subsection, all indices are taken modulo .
We start by understanding some basic adjacencies.
If and , then the following holds.
If then ; and
if then .
Any case not covered would lead to an induced odd cycle of length on vertices from . But such a cycle is forbidden in . ∎
Claim 5.13 easily implies the following claim.
If , then there is an edge between and .
We now turn to the edges between and . Our first claim follows directly from the fact that is -free.
There are no edges between and .
There may, however, exist edges between and . Let us see what we can say about these.
For each there is an such that
is complete to and is complete to .
Note that if , for some , then, by Claim 5.15 and since there are no induced odd cycle of length at most on vertices from , we obtain that This gives (a), which implies (b). ∎
Let and let be as in Claim 5.16. If and , then is complete to .
Assume (the other case is symmetric). Let and let . Consider the path This path has length , so it cannot be induced. Note that the only one possible chord is . As the vertex was chosen arbitrarily from , this means is complete to .
Changing the roles of the sets and in the above argument we see that is also complete to . ∎
Claim 5.17 enables us to prove the following claim.
There is a set with such that
if is such that , then ; and
for all with .
Choose for one vertex from each of the non-empty sets , for . Then, , and (ii) clearly holds. In order to see (i), note that by Claim 5.17 any neighbour of in is complete to , and thus sends an edge to . ∎
We now check edges in and their neighbours in .
For any , if and , then
Any case not covered would lead to an induced odd cycle on at most vertices from . ∎
Now, we will identify a useful subset .
We define as the set of endvertices of all edges such that there is with and .
Note that by Claim 5.3, any component of has either all or none of its vertices in .
For any , and the following hold.
If , then .
Each is adjacent to some neighbour of in .
There are consecutive vertices on such that and .
If , then there are consecutive vertices on such that and .
We now show that is dominated by a set of bounded size, .
There is a set such that and .
Let belong to different components from , and assume is such that and . We claim that at least one of the following holds.
Now, for each with , take an edge , with and , and with the property that among all such choices, is inclusion-minimal. Choose an arbitrary vertex . Then by (2), is as desired. ∎
We now show an interesting fact about the neighbourhoods of components of .
Let be a bipartite component of , with partition classes , and let . If there is no edge from to , then .
Otherwise, has neighbours , and a non-neighbour , and there is a vertex such that . By Claim 5.19, if , then . Assume