Recognizing Graphs Close to Bipartite Graphs with an Application to Colouring Reconfiguration

We continue research into a well-studied family of problems that ask whether the vertices of a graph can be partitioned into sets $A$ and~$B$, where $A$ is an independent set and $B$ induces a graph from some specified graph class ${\cal G}$. We let ${\cal G}$ be the class of $k$-degenerate graphs. This problem is known to be polynomial-time solvable if $k=0$ (bipartite graphs) and NP-complete if $k=1$ (near-bipartite graphs) even for graphs of maximum degree $4$. Yang and Yuan [DM, 2006] showed that the $k=1$ case is polynomial-time solvable for graphs of maximum degree $3$. This also follows from a result of Catlin and Lai [DM, 1995]. We consider graphs of maximum degree $k+2$ on $n$ vertices. We show how to find $A$ and $B$ in $O(n)$ time for $k=1$, and in $O(n^2)$ time for $k\geq 2$. Together, these results provide an algorithmic version of a result of Catlin [JCTB, 1979] and also provide an algorithmic version of a generalization of Brook's Theorem, which was proven in a more general way by Borodin, Kostochka and Toft [DM, 2000] and Matamala [JGT, 2007]. Moreover, the two results enable us to complete the complexity classification of an open problem of Feghali et al. [JGT, 2016]: finding a path in the vertex colouring reconfiguration graph between two given $\ell$-colourings of a graph of maximum degree $k$.


Introduction
The Colouring problem asks if a given graph is k-colourable for some given integer k, that is, if the vertices of the graph can be coloured with at most k colours, such that no two adjacent vertices are coloured alike.This is a central problem in graph theory and well known to be NP-complete even if k = 3 [34].A stronger property of a graph is that of being (k − 1)-degenerate, which is the case when every induced subgraph has a vertex of degree at most k − 1: every (k − 1)-degenerate graph is k-colourable, but the converse is not true.
For an arbitrarily large integer k, there exist k-degenerate graphs that are not (k − 1)-degenerate but that can be decomposed into a p-degenerate induced subgraph and a q-degenerate induced subgraph for two small integers p and q.For example, if we take complete bipartite graphs of degree k, then we can let p = q = 0.If a k-degenerate graph is decomposable in this way, it is not only (k + 1)-colourable but even (p + q + 2)colourable.This leads to the well-studied problem of identifying graphs whose vertex sets can be partitioned into two sets A and B such that A and B induce a p-degenerate graph and q-degenerate graph, respectively; see, for instance, [9,10,31,38,44,45].If a graph has such a partition with p+q = ℓ−2, then we can say that the graph is "robustly" ℓ-colourable.For the sake of example: every planar graph is 5-degenerate, which implies that it is 6-colourable, but we can improve this to 5-colourable by applying the result of Thomassen [45], which states that every planar graph can be decomposed into a 0-degenerate graph and a 3-degenerate graph, or another result of Thomassen [44], which states that every planar graph can be decomposed into a 1-degenerate graph and a 2-degenerate graph.So being 5-colourable is a "robust" property of planar graphs (in contrast to being 4-colourable; there is no p and q with p + q ≤ 2 such that we can guarantee a decomposition of a planar graph into a p-degenerate graph and a q-degenerate graph; see [28] for p = 0, q = 2 and [20] for p = q = 1).
Research Question.We will apply the notion of "robust" k-colourability to a central problem in the area of graph reconfiguration, that of finding a path between two given k-colourings in the k-colouring reconfiguration graph R k (G) of a graph G.The graph R k (G) has as vertices the k-colourings of G and two k-colourings are adjacent if and only if they differ on exactly one vertex of G.This problem is PSPACE-hard even if k = 4 and G is planar bipartite [7].In its complexity classification for graphs of maximum degree ∆ [24] there is one open case (k, ∆) left.As argued in [24], in order to solve this case we must answer the following research question: Is it possible to find in polynomial time a partition (A, B) of the vertex set of a graph G of maximum degree k, such that A is 0-degenerate and B induces a (k − 2)-degenerate graph?

Known Existence Results
We note that in the above question we must find a partition (A, B) for p = 0 and q = k − 2. This is a different question than deciding whether such a partition exists.For the latter question, a number of different results exist in the literature.We will survey these results below, as they are very insightful for our question, although they do not solve it.
We first note that if p = 0, then we can take q as a distance measure to control how "far" the graph is from being bipartite.As every 0-degenerate graph is an independent set of vertices, checking if the distance is 0 is the same as checking bipartiteness, which can be solved in linear time.Graphs within distance 1 from being bipartite are said to be near-bipartite.By definition, such a graph has a near-bipartite decomposition, that is, a partition (A, B) of its vertex set, where A is an independent set and B induces a 1-degenerate graph, or equivalently, a forest.Deciding whether a graph is near-bipartite is NP-complete [14].
Yang and Yuan [48] proved that the problem remains NP-complete even for graphs of maximum degree 4, but becomes polynomial-time solvable for graphs of maximum degree 3. To prove the latter result, they showed that every connected graph of maximum degree at most 3 is near-bipartite except K 4 (we let K k denote the complete graph on k vertices).This characterization was also shown by Catlin and Lai, who proved that the independent set A may even be assumed to be maximum.Theorem 1 ( [18]).The vertex set of every connected graph of maximum degree 3 that is not isomorphic to K 4 can be partitioned into two sets A and B, where A is a maximum independent set and B is a forest.
Theorem 1 generalizes the k = 3 case of an earlier result of Catlin.
Theorem 2 ([17]).For every integer k ≥ 3, the vertex set of every connected graph of maximum degree k that is not isomorphic to K k+1 can be partitioned into two sets A and B, where A is a maximum independent set and B induces a graph that does not contain a K k .
Theorem 3 ([38]).For every three integers k ≥ 3 and p, q ≥ 0 with p + q = k − 2, the vertex set of every connected graph of maximum degree k that is not isomorphic to K k+1 can be partitioned into two sets A and B, where A induces a p-degenerate subgraph of maximum size and B induces a q-degenerate subgraph.
Before Theorem 3 appeared, Borodin, Kostochka and Toft proved a more general result, except that the property of the first set having maximum size is not assumed.We present a simpler version of their result and refer to [11] for full details.
Brooks' Theorem [15] states that every graph G with maximum degree k ≥ 2 is k-colourable unless G is a complete graph or an odd cycle.Recall that every (k − 1)degenerate graph is k-colourable.Hence Theorems 3 and 4, together with the trivial case k = 2, generalize Brooks' Theorem.
By choosing p = 0 in Theorem 3 we obtain the following special case, which implies that every connected graph of maximum degree k except K k+1 is within distance k − 2 from being bipartite.Theorem 5.For every integer k ≥ 3, the vertex set of every connected graph of maximum degree k that is not isomorphic to K k+1 can be partitioned into two sets A and B, where A is a maximum independent set and B induces a (k − 2)-degenerate subgraph.
Theorem 5 only guarantees that the existence of a desired partition (A, B) can be tested in polynomial time.It does not tell us how to find such a partition.Obtaining an algorithmic version of Theorem 5 corresponds to our research question.We cannot hope to keep the condition that A is a maximum independent set, as this would require solving an NP-complete problem: Independent Set for connected cubic graphs [25].Before giving our results we first survey some other algorithmic results.

Known Algorithmic Results
Special Graph Classes.As discussed, Yang and Yuan [48] proved that recognizing near-bipartite graphs is polynomial-time solvable for graphs of maximum degree k when k ≤ 3 and NP-complete when k ≥ 4. They also proved that recognizing nearbipartite graphs of diameter k is polynomial-time solvable when k ≤ 2 and NPcomplete when k ≥ 4. Recently, we solved their missing case by proving that the problem is NP-complete for graphs of diameter 3 [4].Brandstädt et al. [12] proved that recognizing near-bipartite perfect graphs is NP-complete.We also proved that recognizing near-bipartite graphs is NP-complete for line graphs of maximum degree 4 [3].
Borodin and Glebov [10] showed that every planar graph of girth at least 5 is nearbipartite (see [31] for an extension of this result).Dross, Montassier and Pinlou [22] asked whether every triangle-free planar graph is near-bipartite.In fact they proved that if this is not the case, then the problem of recognizing near-bipartite graphs is NPcomplete for triangle-free planar graphs.Their construction can be easily modified to prove that the problem of recognizing near-bipartite graphs is NP-complete for planar graphs. 4inimum Independent Feedback Vertex Sets.The problem of finding a decomposition into an independent set A and a forest B where the size of A is minimum has also been studied.In this context A is said to be an independent feedback vertex set.Computing a minimum independent feedback vertex set has been shown to be NP-hard even for planar bipartite graphs of maximum degree 4, but linear-time solvable for graphs of bounded treewidth, chordal graphs and P 4 -free graphs [43] (it was already known that near-bipartite P 4 -free graphs can be recognized in linear time [12]).Recently, we extended the polynomial-time result from [43] for P 4 -free graphs to P 5free graphs [3].We also gave a polynomial-time algorithm for computing a minimum independent feedback vertex set of a graph of diameter 2 [4].
The problem of computing small independent feedback vertex sets has also been studied from the perspective of parameterized complexity.In this setting, the size of A is taken as the parameter.Misra et al. [41] gave the first FPT algorithm for this problem, which was later improved by Agrawal et al. [1].
Problem Variants.The Induced Forest 2-Partition problem is closely related to the problem of recognizing near-bipartite graphs.It asks whether the vertex set of a given graph can be decomposed into two disjoint sets A and B, where both A and B induce forests.Wu, Yuan and Zhao [47] proved that Induced Forest 2-Partition is NP-complete for graphs of maximum degree 5 and polynomial-time solvable for graphs of maximum degree at most 4. The problem variant where the maximum degree of one of the two induced forests is bounded by some constant has also been studied, in particular from a structural point of view (see, for instance, [22]).
A similar problem, known as Dominating Induced Matching, asks whether the vertex set of a graph can be partitioned into an independent set and an induced matching (a set of isolated edges) and was shown by Grinstead et al. [26] to be NP-complete.Brandstädt, Le and Szymczak [14] proved NP-completeness of another closely related problem, that of deciding whether the vertex set of a given graph can be decomposed into an independent set and a tree.As trees, induced matchings and forests are 2colourable, these two problems and that of recognizing near-bipartite graphs can be seen as restricted variants of the 3-Colouring problem.This problem is well known to be NP-complete [35].However, the NP-hardness result of Brandstädt et al. [12] for perfect graphs shows that there are hereditary graph classes on which the complexities of recognizing near-bipartite graphs and 3-Colouring do not coincide, as 3-Colouring (or even k-Colouring with k part of the input [27]) is polynomial-time solvable for perfect graphs.
A 3-colouring of a graph is acyclic if every two colour classes induce a forest.We observe that every graph with an acyclic 3-colouring is near-bipartite, but the reverse is not necessarily true.Kostochka [32] proved that the corresponding decision problem Acyclic 3-Colouring is NP-complete.Later, Ochem [42] showed that Acyclic 3-Colouring is NP-complete even for planar bipartite graphs of maximum degree 4. As every bipartite graph is near-bipartite, this result implies that there are hereditary graph classes on which the complexities of recognizing near-bipartite graphs and Acyclic 3-Colouring do not coincide.
Generalizations.For a fixed graph class G (that is, G is not part of the input), Brandstädt, Le and Szymczak [14] considered the following more general problem:

Stable(G)
Instance: A graph G = (V, E).Question: Can V be decomposed into two disjoint sets A and B, where A is an independent set and B induces a graph in G?
Note that Stable(G) is equivalent to 3-Colouring if we choose G to be the class of bipartite graphs.If we choose G to be the class of (k − 2)-degenerate graphs, then we obtain the decision version of the problem we consider in this paper.
If G is the class of complete graphs, then Stable(G) is the problem of recognizing split graphs, and this problem can be solved in polynomial time.Brandstädt, Le and Szymczak [14] proved that Stable(G) is NP-complete when G is the class of trees or the class of trivially perfect graphs, and polynomial-time solvable when G is the class of co-bipartite graphs, the class of split graphs, or the class of threshold graphs.Moreover, Stable(G) has also been shown to be NP-complete when G is the class of trianglefree graphs [16], the class of P 4 -free graphs [29], the class of graphs of maximum degree 1 [37], or, more generally, a class of graphs that has any additive hereditary property not equal to or divisible by the property of being edgeless [33], whereas it is also polynomial-time solvable if G is the class of complete bipartite graphs [23] (see [13] for a faster algorithm).The Stable(G) problem has also been studied for hereditary graph classes G with subfactorial or factorial speed [21,36] (the speed of a graph class is the function that given an integer n returns the number of labelled graphs on n vertices in the class).
By relaxing the condition on the set A being independent we obtain the more general problem of (G 1 , G 2 )-Recognition, which asks whether the vertex set of a graph can be decomposed into disjoint sets A and B, such that A induces a graph in G 1 and B induces a graph in G 2 .For instance, if G 1 is the class of cliques and G 2 is the class of disjoint unions of cliques, then the (G 1 , G 2 )-Recognition problem is equivalent to recognizing unipolar graphs (see [39] for a quadratic algorithm).Generalizing Stable(G) can also lead to a family of transversal problems, such as Feedback Vertex Set.However, such generalizations are beyond the scope of our paper.

Our Results
In Section 2, we consider near-bipartite decompositions of subcubic graphs (that is, graphs of maximum degree at most 3).Recall that by Theorem 1 the only connected subcubic graph that is not near-bipartite is K 4 (see also [48]) and so near-bipartite subcubic graphs can be recognized in polynomial time.However, neither the proof of Theorem 1 in [18] nor the proof of this fact in [48] leads to a linear-time algorithm for finding the desired partition (A, B).As mentioned, in the case of Theorem 1, this would in fact require solving an NP-complete problem: Independent Set for cubic graphs [25].We give an O(n)-time algorithm that finds a near-bipartite decomposition of any subcubic graph with no component isomorphic to K 4 .
We say a partition (A, B) of the vertex set of a graph is a k-degenerate decomposition if A is independent and B induces a (k − 2)-degenerate graph, so Section 2 is concerned with 3-degenerate decompositions of graphs of maximum degree 3.In Section 3, we consider, more generally, k-degenerate decompositions of graphs of maximum degree at most k for any k ≥ 3.By Theorem 5, the only connected graph with maximum degree k that does not have a k-degenerate decomposition is K k+1 .As mentioned, Theorem 5 does not imply a polynomial-time algorithm for finding such a decomposition.We give an O(n 2 )-time algorithm to find such a decomposition for any k ≥ 3 (in contrast with the O(n)-time algorithm in Section 2 for the special case when k = 3).
Our results in Sections 2 and 3 provide an algorithmic version of Theorem 5 and, as Theorem 5 generalizes Theorem 2, they also imply an algorithmic version of Theorem 2.
In Section 4 we prove that the problem of deciding whether a graph of maximum degree 2k − 2 has a k-degenerate decomposition is NP-complete.We do this by adapting the proof of the aforementioned result of Yang and Yuan [48], which states that recognizing near-bipartite graphs of maximum degree 4 is NP-complete (the k = 3 case).In Section 5 we apply our algorithms from Sections 2 and 3 to completely settle the complexity classification of the graph colouring reconfiguration problem considered in [24].Finally, in Section 6, we give directions for future work.
2 Linear Time for Graphs of Maximum Degree at Most 3 In this section we prove the following result.Theorem 6.Let G be a subcubic graph on n vertices, with no component isomorphic to K 4 .Then a near-bipartite decomposition of G can be found in O(n) time.
Proof.We will repeatedly apply a set of rules to G.Each rule takes constant time to apply and after each application of a rule, the resulting graph contains fewer vertices.The rules are applied until the empty graph is obtained.We then reconstruct G from the empty graph by working through the rules applied in reverse order.As we rebuild G in this way, we find a near-bipartite decomposition of each obtained graph.We do this by describing how to extend, in constant time, a near-bipartite decomposition of a graph before some rule is undone to a near-bipartite decomposition of the resulting graph after that rule is undone.If we can do this then we say that the rule is safe.We conclude that the total running time of the algorithm is O(n).It only remains to describe the rules, show that it takes constant time to do and undo each of them and prove that they are safe.
We need the following terminology.The claw is the graph with vertices u, v 1 , v 2 , v 3 and edges uv 1 , uv 2 , uv 3 ; the vertex u is the centre of the claw (see Fig. 1).The triangular prism is the graph obtained from two triangles on vertices u 1 , u 2 , u 3 and v 1 , v 2 , v 3 , respectively, by adding the edges u i v i for i ∈ {1, 2, 3} (see Fig. 1).Two vertices are false twins if they have the same neighbourhood (note that such vertices must be non-adjacent).Let u be an arbitrary vertex of G. Our choice of u as an arbitrary vertex implies that u can be found in constant time.We then use the first of the following rules that is applicable.Rule 1.If u has degree at most 2, then remove u.Rule 2. If there is a vertex v of degree at most 2 that is at distance at most 3 from u, then remove v. Rule 3. If G contains an induced diamond D whose vertices are at distance at most 3 from u, then remove the vertices of D. Rule 4. If there is a pair of false twins u 1 , u 2 each at distance at most 2 from u, then remove u 1 , u 2 and their common neighbours (note that u ∈ {u 1 , u 2 } is possible).Rule 5.If u is in a connected component that is a triangular prism P , then remove the vertices of P .Rule 6.If Rules 1-5 do not apply but u is in a triangle T , then the neighbours of the vertices in T that are outside T are pairwise distinct (since there is no induced diamond) and at least two them, which we denote by x ′ , y ′ , are nonadjacent (otherwise u belongs to a triangular prism).Remove the vertices of T and add an edge between x ′ and y ′ .Rule 7. If u is the centre of an induced claw but has a neighbour v that belongs to a triangle, then apply one of the Rules 1-6 on v. Rule 8.If the graph induced by the vertices at distance at most 3 from u contains the graph H 1 , H 2 or H 3 , depicted in Fig. 2, with the vertex u in the position shown in the figure, then remove the vertices of this graph H i .Rule 9.If Rules 1-8 do not apply but u is the centre of an induced claw and its three neighbours u 1 , u 2 , u 3 are also centres of induced claws, then remove u, u 1 , u 2 , u 3 and for i ∈ {1, 2, 3} add an edge joining the two neighbours of u i distinct from u and denote it by e i ; we say that such an edge is new (note that such neighbours of two distinct u i and u j may overlap).Let us show that at least one of the rules is always applicable.Suppose that, on the contrary, there is a vertex u of a subcubic graph for which no rule applies.Then u and its neighbours each have degree 3 (Rules 1 and 2) and so each either belongs to a triangle or is the centre of an induced claw.By Rule 6, u must be the centre of an induced claw and therefore, by Rule 7, the same is also true for each neighbour of u.This implies that Rule 9 applies, a contradiction.
Because G is subcubic, each of these rules takes constant time to verify and process.In particular, in some rules we need to detect some induced subgraph of constant size that contains u or replace u by some other vertex v.In all such cases we need to explore a set of vertices of distance at most 4 from u.As G is subcubic, this set has size at most 1 + 3 + 3 2 + 3 3 + 3 4 = 121, so we can indeed do this in constant time.
It is clear that, as claimed, the application of a rule reduces the number of vertices and that if we repeatedly choose an arbitrary vertex u and apply a rule, we eventually obtain the empty graph.We now consider undoing the applied rules in reverse order to rebuild G.As this is done, we will irrevocably colour vertices with colour 1 or 2 in such a way that the vertices coloured 1 will form an independent set and the vertices coloured 2 will induce a forest.Thus a rule is safe if this colouring can be extended whenever that rule is undone.When we reach G, the final colouring will correspond to the required near-bipartite decomposition.
We must prove each rule is safe.At each step of reconstructing G, we refer to the graph before a rule is undone as the prior graph and to the graph after that rule is undone as the subsequent graph.Note that the application of any of the Rules 1-9 again yields a subcubic graph.By the result of Yang and Yuan [48], every connected subcubic graph is near-bipartite, apart from K 4 .So we need to ensure that an application of a rule does not create a K 4 .This cannot happen when we remove vertices, but we will need to consider it for Rules 6 and 9. Claim 1. Rules 1-5 are safe.
In Rules 1-5 we only delete vertices.Rule 1 is safe since if both neighbours of u are coloured 2, then u can be coloured 1; otherwise u can be coloured 2. Similarly, we see that Rule 2 is safe.To see that Rule 3 is safe, let D be the diamond with vertex labels as illustrated in Fig. 3, where u is one of v, w, x, y.If x ′ and y ′ are coloured 2, we colour x and y with 1 and v and w with 2. Otherwise we colour v with 1 and x, y and w with 2. We now show that Rule 4 is safe.Let u 1 and u 2 be false twins (at distance at most 2 from u).As G is subcubic, every vertex in N (u 1 ) with a neighbour in N (u 1 ) has no neighbours outside N (u 1 )∪{u 1 , u 2 } and every vertex in N (u 1 ) with no neighbour in N (u 1 ) has at most one neighbour not equal to u 1 or u 2 .Moreover, as G is subcubic, N (u 1 ) contains no cycle.Hence we can always colour u 1 , u 2 with 1 and the vertices of N (u 1 ) with 2 regardless of the colours of vertices outside N (u 1 ) ∪ {u 1 , u 2 }.Indeed, every vertex of N (u 1 ) will have at most one neighbour that is not coloured 1, so cannot be in a cycle of vertices coloured 2 in the subsequent graph.Rule 5 is also safe since P is 3-regular and hence would be a component of our subsequent graph, so we can colour its vertices by assigning colour 1 to exactly one vertex from each of the two triangles and colour 2 to its other vertices (see Fig. 1).This completes the proof of Claim 1.
First, let us demonstrate that Rule 6 is safe.If x ′ and y ′ are contained in a K 4 of the prior graph, then the subsequent graph contains a diamond whose vertices are at distance at most 3 from u.This contradicts Rule 3. Let T be the triangle with vertex labels as illustrated in Fig. 3. Suppose x ′ , y ′ and u ′ are coloured 2. Then we colour u with 1 and x and y with 2. The vertices in the subsequent graph with colour 2 still induce a forest, as we have replaced an edge in the forest by a path on four vertices.Suppose x ′ and y ′ are coloured 2 and u ′ is coloured 1.Then we colour x with 1, and y and u with 2. Otherwise, since x ′ and y ′ are joined by an edge in the prior graph, we may assume that x ′ has colour 1 and y ′ has colour 2. In this case we can colour y with 1, and x and u with 2. This completes the proof that Rule 6 is safe.Since Rules 1-6 are safe, it follows that Rule 7 is also safe.This completes the proof of Claim 2.
We now show that Rule 8 is safe.Suppose u is contained in H 1 .We use the vertex labels from Fig. 2. As Rule 1 could not be applied, we find that u has a third neighbour u 3 distinct from u 1 and u 2 .Regardless of whether u 3 is coloured 1 or 2, we colour u, u 1 , u 2 , v 1 , w with 2 and v 2 , v 3 with 1 to obtain a near-bipartite decomposition of G.We can also readily colour the vertices of H 2 or H 3 should u be contained in one of them (note that since H 2 and H 3 are 3-regular, these graphs can only appear as components in our subsequent graph).This completes the proof of Claim 3.

Claim 4. Rule 9 is safe.
Suppose that the prior graph contains fewer than three new edges.Then we may assume without loss of generality that e 1 = e 2 .Then u 1 and u 2 are false twins at distance 1 from u and we can apply Rule 4, a contradiction.So we may assume that the prior graph contains exactly three new edges.We claim that the application of Rule 9 does not yield a K 4 .For contradiction, suppose it does.Let K be the created K 4 .Then at least one new edge is contained in K.If exactly one new edge e is contained in K, then K − e is a diamond in the subsequent graph.Then we could have applied Rule 3, a contradiction.If all three new edges are in K, then they must induce either a path on four vertices or a triangle in the subsequent graph.In the first case the subsequent graph is H 2 and in the second case the subsequent graph is H 3 .In both cases we would have applied Rule 8, a contradiction.Finally, suppose that K contains exactly two new edges, say e 1 and e 2 .If e 1 and e 2 do not share a vertex, then they cover the vertices of K. Hence the endvertices of e 1 are false twins (at distance 2 from u) in the subsequent graph, since they are both adjacent to u 1 and to each end-vertex of e 2 .Then we could have applied Rule 4, a contradiction.If e 1 = v 1 v 2 and e 2 = v 3 v 4 share a vertex, say v 2 = v 4 , then v 1 and v 3 are adjacent in the subsequent graph and the vertex w ∈ K \ {v 1 , v 2 , v 3 } is adjacent only to v 1 , v 2 and v 3 .Therefore Rule 8 could have been applied, a contradiction.
Thus an application of Rule 9 does not yield a K 4 , and we may colour u 1 , u 2 , u 3 with 2 and u with 1. Indeed note that since if two end-vertices of a new edge are coloured 2, then in the subsequent graph the vertices coloured 2 will still induce a forest, in which such a new edge is replaced by a path of length 2. This completes the proof of Claim 4 and therefore completes the proof of Theorem 6.
⊓ ⊔ 3 Quadratic Time for Graphs of Maximum Degree at Least 3 Let k ≥ 3 be an integer.Recall that a graph G has a k-degenerate decomposition if its vertex set can be decomposed into sets A and B where A is an independent set and B induces a (k − 2)-degenerate graph.Note that 3-degenerate decompositions are near-bipartite decompositions.We give an O(n 2 ) algorithm for finding a k-degenerate decomposition of a graph on n vertices of maximum degree at most k for every k ≥ 3 (note that for k = 3 we can also use Theorem 6).
For k ≥ 1, we say that an order v 1 , v 2 , . . ., v n of the vertices of a graph G is kdegenerate if for all i ≥ 2, the vertex v i has at most k neighbours in {v 1 , . . ., v i−1 }.It is clear that a graph is k-degenerate if and only if it has a k-degenerate order.If O is a k-degenerate order for G and W is a subset of the vertex set of G, then we let O| W be the restriction of O to W , and let G[W ] be the subgraph of G induced by W .For a set of vertices C, we denote the neighbourhood of C by We need the following lemma, which is a refinement of Lemma 8 in [24] with the same proof.We include a sketch of the argument for completeness.
, the set A is a maximal independent set and the first vertex in O belongs to A.
Proof.Let O be v 1 , v 2 , . . ., v n .Consider the greedy algorithm that starts with two empty sets A and B, and, at step i, assigns v i to A unless v i has a neighbour of smaller index already in A, in which case it assigns v i to B. Clearly the set A is an independent set and every vertex of B has at least one neighbour in A, so A is a maximal independent set.At any step i, if the vertex v i is assigned to B, then it has a neighbour of smaller index that belongs to A. This implies that v i has at most k − 2 neighbours of smaller index that belong to B.

⊓ ⊔
A pair of non-adjacent vertices {u, v} in a graph G is strong if u and v have a common neighbour in each component of the graph G \ {u, v}.In particular, note that if u and v have a common neighbour and G\{u, v} is connected, then {u, v} is a strong pair.
Lemma 2. Let k ≥ 3. Let G be a connected k-regular graph on n vertices that contains a strong pair {u, v}.If {u, v} is given as input, a k-degenerate decomposition of G can be found in O(kn) time.
Proof.Let G ′ be the graph obtained by identifying u and v into a new vertex z with N (z) = N (u) ∪ N (v).For each component C of G ′ \ {z}, let z C be a vertex of C that is adjacent to both u and v in G.We find a (k − 1)-degenerate order O of the vertices of G ′ as follows.Let z be the first vertex in O. Consider each component C of G ′ \ {z} in turn, and append to O the vertices of C in the reverse of the order they are found in a breadth-first search from z C (note that this can be done in O(kn) time).Then O is a (k − 1)-degenerate order as every vertex has a neighbour later in the order except for each z C vertex, which has degree k − 1.It follows from Lemma 1 that we can find a k-degenerate decomposition (A, B) of . We must amend it to find a (k −2)-degenerate order for G[B ′ ] that also includes the vertices of C \{t}.We consider two cases.First suppose v ∈ A. Then append to O| B first the neighbours of u in C \ {t} and then the neighbours of v.As the vertices of C \ {t} are adjacent to t the only one that could have more than k − 2 vertices before it in the order is the one that appears last, but this is also adjacent to v so we do indeed have a (k − 2)-degenerate order.Now suppose v ∈ B. Then u has a neighbour in G ′ that belongs to A (as A is a maximal independent set).Hence u has at most k−2 neighbours in B ′ .Append to O| B the vertices of C \ {t}, ending with a neighbour of u (we know there is at least one), then move u to be the final vertex in the order.Again the only vertex of C \ {t} that could have more than k − 2 neighbours before it in the order is the one that appears last, and by choosing it to be a neighbour of u and putting u later in the order we ensure that a (k − 2)-degenerate order is obtained.

⊓ ⊔
Given a graph G, five of its vertices t, u, v, w, x and a set of vertices C, we say that C induces a (u, v)-lock with special vertices (t, {w, x}) if t, w, x ∈ C and N (C) = {u, v}, and both u and v are adjacent to t, each vertex in {w, x} is adjacent to precisely one vertex in {u, v}, and G[C] contains all possible edges except for wt and xt.We say that C is a lock if it is a (u, v)-lock with special vertices (t, {w, x}) for some choice of t, u, v, w, x.Lemma 5. Let k ≥ 3. Let G be a k-regular connected graph on n vertices containing a (u, v)-lock C with special vertices (t, {w, x}).If C and u, v, t, w, x are given as input, then a k-degenerate decomposition of G can be found in O(kn) time.
Proof.Since t has two neighbours outside C, it follows that C \ {t} is a clique on k vertices.If w and x have the same neighbour in {u, v}, say u, then N (C \ {t}) = {t, u} and so we are done by Lemma 4. We may therefore assume that w and x have distinct neighbours in {u, v}.Let G ′ be the graph obtained from G by deleting C \ {t} and note that G ′ is connected since t is adjacent to both u and v.Note that both u and v have degree k − 1 in G ′ .We can therefore find a (k − 1)-degenerate order O of G ′ in O(kn) time by taking the vertices in the reverse of the order they are found in a breadth-first search from u. Furthermore, since the only neighbours of t in G ′ are u and v, both of which have degree k − 1, by moving t to the start of the order O, we obtain a another (k − 1)-degenerate order O ′ .By Lemma 1, we can therefore find a k-degenerate decomposition (A, B) of G ′ such that O ′ | B is a (k − 2)-degenerate order on B and t ∈ A. Thus both u and v belong to B. We let A ′ = A ∪ {w} and B ′ = B ∪ (C \ {w, t}), and claim that (A ′ , B ′ ) is a k-degenerate decomposition of G.It is clear that A ′ is an independent set.We have the (k − 2)-degenerate order O ′ | B on B. We obtain a (k − 2)-degenerate order on B ′ by appending to O ′ | B the vertices of C \ {w, t} beginning with x.Indeed, the only neighbour of x that is earlier in the order is its single neighbour in {u, v} (and note that 1 A pair of non-adjacent vertices u, v in a graph is a good pair if u and v have a common neighbour.Note that if a good pair u, v is not strong, then G \ {u, v} must be disconnected.We are now ready to state and prove the following result. Theorem 7. Let k ≥ 3 and G be a graph on n vertices with maximum degree at most k.If no component of G is isomorphic to K k+1 , then a k-degenerate decomposition of G can be found in O(kn 2 ) time.
Proof.We may assume that G is connected, otherwise it can be considered componentwise.If G is not k-regular, then it has a vertex u of degree at most k − 1, so we can find a (k − 1)-degenerate order O of G in O(kn) time by taking the vertices in the reverse of the order they are found in a breadth-first search from u.In this case, we are done by Lemma 1.For k-regular graphs, we use the procedure shown in Algorithm 1.We note that if G is biconnected then, by [2, Lemma 3], there is always a good pair u, v such that G \ {u, v} is connected, but this does not aid us in finding an algorithm for general graphs.
Let us make a few comments on this procedure.As G is regular, connected and not complete, we can initially choose any vertex as u and find another vertex v to form a good pair in O(k 2 ) = O(kn) time.If we perform a breadth-first search (which takes O(n + m) = O(kn) time) from a neighbour of u that retreats from u or v whenever they are encountered, we discover a component of G\{u, v}.If the component contains a common neighbour of u and v but is not equal to G \ {u, v}, we repeat starting from a neighbour of u or v that was not discovered.Thus we discover in O(kn) time that either u, v is a strong pair (if we find all components of G \ {u, v} and they each contain a common neighbour of u and v), or that it is not.We set C to be one of the components of G \ {u, v} arbitrarily.By Lemma 2, we therefore conclude that Lines 1 Algorithm 1: Finding a k-degenerate decomposition for connected k-regular graphs.
Input : A connected k-regular graph G Output : A k-degenerate decomposition of G 1 find a good pair u, v and let C be a component of G \ {u, v}; 2 if u, v is a strong pair then apply Lemma 2; 3 else if the union of C and one or both of u and v is a clique on k + 1 vertices minus an edge then apply Lemma 3; 4 else if C is a clique on k vertices whose neighbourhood is {u, v} then apply Lemma 4; 5 else if C is a (u, v)-lock then apply Lemma 5; 6 else and 2 take O(kn) time.It is easy to check in O(kn) time whether we apply Lemmas 3-5 on Lines 3-5 and applying these lemmas takes O(kn) in each case.Now suppose that we do not apply any of these lemmas, in which case we reach Line 7. We will show that we can find u ′ , v ′ and, if necessary, a strong pair, so after executing Line 9, the algorithm will stop on Line 2. In all other cases C ′ will be strictly smaller than C.This means that we apply Line 9 at most O(n) times, implying that we execute Lines 2-9 at most O(n) times.This will give an overall running time of O(kn 2 ).It remains to show that if execution reaches Line 7 then we can find the required good pair u ′ , v ′ and the component C ′ in O(kn) time.
Let us first show that C contains good pairs -that is, that it is not a clique.If C is a clique, then it contains either k − 1 or k vertices (as each vertex has degree k in G and the only other possible neighbours of vertices in C are u and v).If C has k − 1 vertices, then each vertex of C must be adjacent to both u and v and we would have applied Lemma 3 on Line 3, a contradiction.If C has k vertices, then each vertex of C is adjacent to exactly one of u and v (and neither u nor v can be adjacent to every vertex in C, as this would form a K k+1 , contradicting the fact that G is connected), in which case we would have applied Lemma 4 on Line 4, a contradiction.Therefore we may assume that C is not a clique.
We need describe how to choose a good pair u ′ , v ′ in C. If we can show that u and v are in the same component of G \ {u ′ , v ′ } (which must necessarily contain all of G \ C), then we are done as either G \ {u ′ , v ′ } is connected or there is another component C ′ of G \ {u ′ , v ′ } which must be contained in C (and note that in this case C ′ can be found in O(kn) time using breadth-first search).
If u and v have a common neighbour outside C or at least three common neighbours in C, then any good pair in C can be chosen as u ′ , v ′ (as u and v will then be in the same component of G \ {u ′ , v ′ }).If u and v have exactly two common neighbours t 1 , t 2 that both belong to C, then any good pair other than t 1 , t 2 can be chosen as u ′ , v ′ .If t 1 , t 2 is the only good pair in C (so all other vertices in C are adjacent), then C is a clique minus an edge and must contain k vertices (t 1 , t 2 and the k − 2 neighbours of t 1 that are not in {u, v}).Considering degree, any vertex in C other than t 1 or t 2 must be adjacent to exactly one of u and v.If every vertex in C \ {t 1 , t 2 } is adjacent to, say u, then C ∪ {u} is a clique on k + 1 vertices minus an edge and we would have applied Lemma 3 on Line 3, a contradiction.We may therefore assume that at least one vertex in C \ {t 1 , t 2 } is adjacent to u and at least one is adjacent to v, so there is a path from u to v avoiding t 1 and t 2 , and G \ {t 1 , t 2 } is connected, so we are done.
Finally, suppose that u and v have exactly one common neighbour t that belongs to C. Then any good pair not including t can be chosen as u ′ , v ′ , as then u and v will be in the same component of G \ {u ′ , v ′ }.Suppose, for contradiction, that no such pair exists.Then C \ {t} is a clique.The vertex t has k − 2 neighbours in C \ {t}.Since k ≥ 3, let z be one of those neighbours.Since t is the only common neighbour of u and v, we have that z can only be adjacent to at most one of u and v. Therefore, t has a neighbour non-adjacent to z, so z must have a neighbour non-adjacent to t, which we denote w.As w is also adjacent to at most one of u and v, it also has a neighbour x that is a non-neighbour of t (and cannot be t itself).So C \ {t} contains at least k vertices: the k − 2 neighbours of t plus w and x.As C \ {t} induces a clique, it must have exactly k vertices, since G cannot contain a K k+1 .Thus the set C forms a lock, and so we would have applied Lemma 5 on Line 5.This contradiction completes the proof.
⊓ ⊔ Theorems 6 and 7 provide an algorithmic version of Theorem 5.Moreover, Theorems 6 and 7 concern decompositions (A, B) of the vertex set of a graph where A is independent and B induces a (k − 2)-degenerate graph.As B therefore cannot be a clique on k vertices, both theorems also provide an algorithmic version of Theorem 2.

Hardness for Graphs of Large Maximum Degree
Recall that Yang and Yuan [48] showed that the problem of deciding whether a graph of maximum degree 4 is near-bipartite, or equivalently, has a 3-degenerate decomposition is NP-complete.We show how their proof can be adapted to prove that for every k ≥ 3 the problem of deciding whether a graph of maximum degree 2k −2 has a k-degenerate decomposition is NP-complete.
We start by explaining the proof of Yang and Yuan.They use a reduction from 1-in-3-Sat with positive literals only.That is, we are given a set of variables X = {x 1 , . . ., x n } and a set of clauses C = {C 1 , . . ., C m } such that each clause C i is of the form (x a ∨ x b ∨ x c ) for some a, b, c with 1 ≤ a < b < c ≤ n, and the question is whether there exists a truth assignment that makes exactly one of the three variables in each clause true (and the other two false).
Given an instance of 1-in-3-Sat, Yang and Yuan construct a graph G as follows.First, as a building block they introduce a graph H(a, b, c, d, e) that consists of five vertices a, b, c, d, e with edges ab, ac, bc, bd, be, cd, ce (see also Fig. 4).They define the graph H k recursively a follows: and a i 2j−1 and identify the vertices e i−1 j and a i 2j .
See Fig. 5 for the graph H 2 .Observe that the graph H i contains 2 i pairwise vertexdisjoint copies of H that do not have their d and e vertices identified with a vertices.Yang and Yuan prove the following observations for i ≥ 1: (i) the graph H i is near-bipartite; (ii) in any near-bipartite decomposition of H i either all vertices d i j and e i j (j ∈ {1, . . ., 2 i }) belong to A or they all belong to B; (iii) in any near-bipartite decomposition of H i at least one of the vertices b i j , c i j (j ∈ {1, . . ., 2 i }) belongs to B.
To finish off the construction of the G, Yang and Yuan, take H q [x 1 ], . . ., H q [x n ] of the graph H q , where q is chosen such that 2 q−1 < m ≤ 2 q , so that each copy of H q [x i ] corresponds to the variable x i .To distinguish variables in different copies of H q , we will refer, for example, to the copy of e i j in H q [x h ] as e i j [x h ].For each clause C j = (x a ∨ x b ∨ x c ) they introduce a clause-triangle, that is, a triangle with vertices x j a , x j b , x j c .If variable x h occurs in a clause C j , then they add an edge between x j h and d q j [x h ] and an edge between x j h and e q j [x h ].Note that G has maximum degree 4.
Next, Yang and Yang prove the following three observations in the case where G is near-bipartite: (iv) exactly one of the vertices of each clause-triangle belongs to A; (v) if a vertex x j h belongs to A, then every other x j * h also belongs to A; and (vi) if a vertex x j h belongs to B, then every other x j * h also belongs to B.
Observation (iv) holds by definition of A. Observations (v) and (vi) follow from combining observations (ii) and (iii).Finally, using properties (iv)-(vi), it is straightforward to prove that there exists a truth assignment of C that makes exactly one of the three variables in each clause true if and only if G is near-bipartite; see also [48].
Our Adjustments.To prove that for k ≥ 3 the problem of deciding whether a graph of maximum degree 2k − 2 has a k-degenerate decomposition is NP-complete, we reduce from 1-in-k-SAT with positive literals only.This problem is readily seen to be NP-complete via a reduction from 1-in-3-SAT with positive literals only.We adjust the construction of Yang and Yuan in the following way: 2. Construct the graphs H i using the following modified construction: and a i (k−1)(j−1)+ℓ .3. Take H q to be the vertex gadgets, where (k − 1) q−1 < m ≤ (k − 1) q .4. Change each clause gadget from a triangle into a complete graph on k vertices (corresponding to the k variables of that clause).
5. Replace the two edges going from each variable vertex in each clause gadget to the corresponding d and e vertices in the corresponding variable gadget by k − 1 edges going to the k − 1 vertices of the independent set D replacing these d and e vertices.
The above adjustments in the construction of Yang and Yuan [48] increase the maximum degree from 4 to 2(k − 1).This can be seen as follows.First, each variable vertex in the clause gadget has k−1 neighbours in the corresponding variable gadget in addition to its k −1 neighbours in the clause gadget.Moreover, in each variable gadget, all but one of the vertices that correspond to the vertex a in the graph H have degree 2(k − 1), as such vertices were adjacent to vertices b and c of two different subgraphs of type H and have now been every vertex of two cliques B of size k − 1.Every vertex in a clique B that replaced a pair of vertices b and c also has 2k − 2 neighbours, namely k − 2 neighbours in that clique, one neighbour corresponding to a and k − 1 neighbours in the independent set D that replaced d and e.Finally, each vertex in an independent set that replaced the vertices d and e, but that has not been identified with a vertex a has k − 1 neighbours in the clique B that replaced b and c and at most one neighbour in a corresponding clause gadget, if one exists.
Note that for k = 3 we obtain the construction of Yang and Yuan [48].By exactly the same arguments as in their proof for k = 3, we can prove the following result that extends the result in [48].
Theorem 8.For every k ≥ 3, the problem of deciding whether a graph of maximum degree 2k − 2 has a k-degenerate decomposition is NP-complete.

Application: Reconfigurations of Vertex Colourings
Our interest in finding k-degenerate decompositions stems from an open problem in the area of reconfigurations.For a graph G and an integer k ≥ 1, the k-colouring reconfiguration graph R k (G) has vertex set consisting of all possible k-colourings of G and two vertices of R k (G) are adjacent if and only if the corresponding k-colourings differ on exactly one vertex.The following problem has been the subject of much study; see e.g.[6,7,8,19,24,30]: Given a graph G on n vertices and two k-colourings α and β of G, find a path (if one exists) in R k (G) between α and β.
In this section, we are concerned with determining, for every pair k, ∆, the complexity of this problem on graphs G with maximum degree ∆.In Section 5.1 we will prove the following result using Theorem 7.
Proposition 1.Let G be a connected graph on n vertices with maximum degree ∆ ≥ 3. Then it is possible to find a path in R ∆+1 (G) (if one exists) between any two given (∆ + 1)-colourings in O(n 2 ) time.
In [24,Theorem 6], three of the authors of the current paper proved Proposition 1 in all cases except where the input graph G is ∆-regular.Their argument used the fact that if G has maximum degree ∆, but is not ∆-regular, then G is (∆ − 1)-degenerate.In this case it is possible to translate a structural result of Mihók [40] (also proved by Wood [46]) into an O(n 2 )-time algorithm, as shown in [24].However, this does not work if G is ∆-regular.
The following theorem and proof demonstrate that Proposition 1 indeed fills the gap left by past work on this problem.Theorem 9. Let ∆ ≥ 0 be a (fixed) integer.Let G be a connected graph on n vertices with maximum degree ∆.The problem of finding a path (if one exists) between two k-colourings α and Proof.In [30], the problem was shown to be solvable in O(n + m) time on (general) graphs with n vertices and m edges for k ≤ 3.An O(n 2 ) time algorithm for the case where k ≥ 4, 0 ≤ ∆ ≤ k − 2 was presented in [19].In [7], PSPACE-hardness for k ≥ 4, ∆ ≥ k was proved.This leaves only the case where k ≥ 4 and ∆ = k − 1, which follows from Proposition 1.

The Proof of Proposition 1
It was already known [24, Theorem every connected graph on n vertices with maximum degree ∆ ≥ 3, there is a path of length O(n 2 ) between any two given (∆+1)colourings in R ∆+1 (G) unless one or both of the (∆+1)-colourings is an isolated vertex in R ∆+1 (G).To prove Proposition 1, we have to show how to find such paths between colourings in R ∆+1 (G) in O(n 2 ) time.Apart from using Theorem 7, this requires us to replace several structural lemmas of [24] by their algorithmic counterparts.As we have also managed to simplify some of the arguments from [24], we present a self-contained proof of Proposition 1 in this section.At several places in the proof of Proposition 1 we seek to show that from some given colouring α of a graph G, we can find a path in R ∆+1 (G) to another colouring with some specified property.Rather than explicitly referring to paths in R ∆+1 (G), we think, equivalently, in terms of recolouring vertices of G one by one in order to turn α into the colouring we require.
We now define a number of terms that will use to describe vertices of G with respect to a (∆ + 1)-colouring α.A vertex v is locked by α if ∆ distinct colours appear on its neighbours; note that in this case every neighbour of v has a unique colour.A vertex that is not locked is free.Clearly a vertex can be recoloured only if it is free.A vertex v is superfree if there is a colour c = ∆ + 1 such that neither v nor any of its neighbours is coloured c, that is, c = α(u) for any u in the closed neighbourhood A vertex v can be recoloured with a colour other than ∆ + 1 if and only if v is superfree.For any two colours j, k ∈ {1, . . ., ∆ + 1}, a (j, k)-component is a connected component in the subgraph of G induced by the vertices coloured j or k.As we continually recolour, these terms should be assumed to be used with respect to the current colouring unless specified otherwise.We let L α denote the set of vertices u with colour α(u) = ∆ + 1.We say that we compact α if we determine a path in R ∆+1 (G) from α to a (∆ + 1)-colouring α * of G with |L α * | < |L α |.We say that α has the lock-property if, for every u ∈ L α and every v ∈ N [u], we have that v is locked.
The following lemma is crucial.
Lemma 6.Let G be a connected graph on n vertices with maximum degree ∆ ≥ 3 that is not isomorphic to K ∆+1 .Let α be a (∆ + 1)-colouring of G that is not an isolated vertex in R ∆+1 (G) such that L α = ∅.Then it is possible to compact α in O(n) time.
Proof.We note that G has O(n) edges as ∆ is a fixed constant.Let L α = {u 1 , . . ., u p } for some p ≥ 1.We first prove a series of claims, which will enable us to deal with several special cases.
Claim 1.Given a free vertex v in N [u i ] for some i ∈ {1, . . ., p}, we can compact α in O(1) time.
We prove Claim 1 as follows.First suppose that u i is free.Let c = ∆ + 1 be a colour not used on N [u i ].We can determine c in O(1) time, as ∆ is a constant.Then we can recolour u i with colour c.Now assume that u i is not free, that is, u i is locked.Then v is a neighbour of u i .We determine a colour c ′ not used on N [v] in O(1) time such that c ′ = ∆ + 1.We recolour v with colour c ′ , and now u i is free and can be recoloured with α(v) = ∆ + 1.Hence, we have compacted α in O(1) time.This proves Claim 1.
is, the colours on D are swapped).We prove Claim 2 as follows.We recolour all vertices of D that have colour j with colour ∆ + 1.This yields a new as none of these vertices has a neighbour in L α .We then recolour all vertices of D that have colour k with the colour j.Again this is a valid operation as, by the choice of D, all their neighbours that were given colour j by α are now coloured ∆ + 1.We finally recolour all vertices of D that were given colour j by α (and so have ∆ + 1 in the current colouring) with the colour k.This yields the (∆ + 1)-colouring α ′ .Moreover, the running time of doing this is linear in the size of D. This proves Claim 2.
Suppose that α has the lock-property.For every i ∈ {1, . . ., p} and every j ∈ {1, . . ., ∆}, we denote the unique neighbour of u i coloured j by v i,j .For every i ∈ {1, . . ., p} and every j, k ∈ {1, . . ., ∆} (j = k), the graph G j,k i is the (j, k)-component containing v i,j .We note that G j,k i and G k,j i may or may not be equal.These definitions are with respect to α unless stated otherwise.We will write, for example, G α j,k i if we need to specify the colouring.Claim 3. Suppose that α has the lock-property.Let i be in {1, . . ., p} and let j and k be two distinct colours in {1, . . ., ∆}.If G j,k i is not a path where each end-vertex is locked and no vertex is superfree, then we can compact α in O(n) time.We start with two observations.If a vertex v ∈ V (G j,k i ) has degree at least 2 in G j,k i , then v has two neighbours with the same colour, so it is free.By the lock-property, for all ℓ ∈ {1, . . ., p}, every vertex in N [u ℓ ] is locked.Hence v is not adjacent to a vertex in L α .If a vertex v ∈ V (G j,k i ) has degree at least 3 in G j,k i , then v is also superfree.As v i,j is in N [u i ], by the lock-property, we find that v i,j is locked.Hence v i,j has degree 1 in G j,k i .We now perform a breadth-first search in G j,k i starting from v i,j .This takes O(n) time, as ∆ is a constant.We stop if we find a superfree vertex w or else if we have visited all vertices of G j,k i .First suppose that we found a superfree vertex w.As all vertices closer to v i,j than w in G j,k i are not superfree, they must have degree 2 and form a path P from v i,j to w.As the internal vertices of P have degree 2 in G j,k i , they are free and so have no neighbour in L α by the lock-property.Since w is superfree, there is some colour c = ∆ + 1 with which we can recolour w.As colours j and k appear on N [w], we find that c ∈ {j, k}.After we recolour w with c, we note that G j,k i (defined with respect to this new colouring) is a (j, k)-component where no vertex coloured k has a neighbour in L α .We apply Claim 2 and note that now u i has no neighbour coloured j.We therefore recolour u i with j and have compacted α in O(n) time.
Now suppose that we found that no vertex in G j,k i is superfree.Then no vertex of G j,k i has degree more than 2. Hence G j,k i is a path or cycle.Since v i,j has degree 1, we find that G j,k i must be a path.Let z be the end-vertex of G j,k i other than v i,j .As no vertex of the path G j,k i is superfree and v i,j is locked, z must be free by the assumption of the claim.Hence, every vertex of G j,k i apart from v i,j is free, which means that no vertex of G j,k i with colour k has a neighbour in L α by the lock-property.We apply Claim 2. Afterwards we can recolour u i with colour j to compact α in O(n) time.This proves Claim 3. Claim 4. Suppose that α has the lock-property.Let i 1 and i 2 be in {1, . . ., p} (we allow the case i 1 = i 2 ) and let j 1 , j 2 , k 1 and k 2 be in {1, . . ., ∆}, j , a contradiction.Thus w has four neighbours that use only two colours between them.So w has at most ∆ − 2 colours in its neighbourhood.This means that w is superfree, a contradiction.This proves Claim 4.
Claim 5. Suppose that α has the lock-property.Let i be in {1, . . ., p} and let j and k be in {1, . . ., ∆} with j = k.If G j,k i and G k,j i are two distinct paths, each with locked end-vertices and no superfree vertices, and moreover, G j,k i does not contain exactly two vertices, then it is possible to compact α in O(n) time.We prove Claim 5 as follows.Since v i,j ∈ N [u i ] is locked by the lock-property, v i,j has exactly one neighbour s coloured k.This means that G j,k i has at least two vertices, and thus at least three vertices by the assumption of the claim.Hence s has another neighbour with colour j.This means that s is free (note that s is not superfree by the assumption of the claim).
Let t be a neighbour of s not in G j,k i .Recall that ∆ ≥ 3, so t exists.Let c = α(t), and since s is free, c = ∆ + 1 by the lock-property.As t does not belong to G j,k i , we find that c / ∈ {j, k}.First suppose that t is locked.Then, by definition, t has a neighbour with colour ∆+ 1.Let h ∈ L α be this neighbour for some h ∈ {1, . . ., p}.If h = i, then G j,k i and G c,k i intersect on the free vertex s, contradicting Claim 4. Hence, h = i.Then we recolour s with ∆ + 1.This is possible, as s is free and any vertices adjacent to vertices in L α are locked by the lock-property.We then recolour v i,j with colour k.As t is locked by α, we find that α has coloured exactly one neighbour of t with colour j and exactly one neighbour (namely s) with colour k.If t is adjacent to v i,j then this is the neighbour of t that is coloured j by α; in this case we recolour t with colour j.If t is non-adjacent to v i,j then we recolour t with colour k.Thus we can recolour t either with colour j or with colour k.Now both u h and u i are free and can be recoloured.In this way in O(n) time we have reduced the total number of vertices coloured ∆ + 1 by 2 − 1 = 1, that is, we have compacted α.Now suppose that t is free.As the end-vertex of G j,k i other than v i,j is locked by assumption of the claim, it has a neighbour u ℓ ∈ L α .If ℓ = i, then G j,k i = G k,j i , which is not possible by the assumption of the claim.Hence we have ℓ = i.We let z 1 be the neighbour of t on G j,k i closest to u i , and we let z 2 be the neighbour of t on G j,k i closest to u ℓ .Note that z 1 = z 2 = s is possible.We now recolour t with colour ∆ + 1.This is possible, as t is free and thus has no neighbour in L α by the lock-property.As z 2 is not superfree, z 2 is either locked or free.In the first case α colours each neighbour of z 2 with a unique colour.In the second case z 2 is an inner vertex of G j,k i and, as z 2 is not superfree, α colours exactly two neighbours of z 2 with the same colour, which is either j or k.Hence, t is the only neighbour of z 2 which α colours with colour c.Similarly, t is the only neighbour of z 1 with colour c.Hence, after recolouring t with colour ∆ + 1, we can recolour z 1 and z 2 with c.All the internal vertices in G j,k i are free, so by the lock-property, they have no neighbours in L α .Next we apply Claim 2 to the two obtained subpaths of G j,k i \ {z 1 , z 2 } containing neighbours of u i and u ℓ , respectively.Afterwards, both u i and u ℓ can be recoloured.In this way in O(n) time we have reduced the number of vertices coloured ∆ + 1 by 2 − 1 = 1, that is, we have compacted α.Hence we have proven Claim 5.
Our Algorithm.If α does not have the lock-property then we are done by Claim 1.We may therefore assume that α has the lock-property.As α is not an isolated vertex in R ∆+1 (G), G has at least one free vertex x.Let P be a shortest path in G from x to a vertex in L α , say to u 1 .We may assume that x is chosen such that x is the free vertex on P closest to u 1 .Then every internal vertex of P is locked and coloured with a colour coloured 1.If z is an internal vertex of H 2,3 , two other neighbours of z with colour 3.This implies that z is superfree, contradicting the fact that G β 1,2 1 has no superfree vertices.Thus z is the end-vertex of H 2,3 other than x, that is, z = x ′ .
We now let y be the first vertex of G from v 1,2 .Note that such a vertex y exists, as z belongs to G 1 (as α(z) = 3).Thus α(y) = β(y), so y belongs to H 2,3 .The end-vertices of G 1 not a path whose end-vertices are locked and that does not contain any superfree vertices, and so we are done by applying Claim 3.This completes the description of the algorithm.
The correctness of our algorithm follows directly from its description.Hence it remains to discuss its runtime.
Runtime analysis.We first compute the set L α in O(n) time, as ∆ is a constant.We then apply Claim 1 on each u i .As this takes O(1) time per vertex, obtaining the lockproperty takes O(n) in total.As ∆ is a constant, for a given pair (i, j), the vertex v i,j can be found in O(1) time.Moreover, for a given triple (i, j, k), we can compute G j,k i in O(n) time.As ∆ is a constant, we can find a free vertex x in O(n) time.
We can find the path P to a vertex in L α , which we assumed was u 1 , by using a breadth-first search starting from x.As ∆ is a constant, this takes O(n) time.We may also assume that x is the free vertex on P closest to u 1 on this path, as otherwise we can replace x by some other free vertex of P in O(n) time.
We check in O(n) time whether G 1,2 1 is a path whose end-vertices are locked and that does not contain any superfree vertices.We check the same in O(n) time for G 2,1 1 .If we find that for at least one of these graphs this is not the case, then our algorithm applies Claim 3 (either with i = j = 1, k = 2 or with i = k = 1, j = 2), and we are done in O(n) time.So suppose this is the case for both G 1,2 1 and G 2,1 1 .Then we check in O(n) time whether G 1,2 1 = G 2,1 1 .If not, then our algorithm applies Claim 5 (with i = j = 1, k = 2), and we are done in O(n) time.So suppose that G 1,2 1 = G 2,1 1 .Recolouring the vertex w in H 2,3 (if it exists) and applying Claim 2 (either with j = 3, k = 2 or with j = 2, k = 3) takes O(n) time.So far we have used O(n) time.Hence, it takes O(n) time to do the similar procedure for the colouring β obtained after applying Claim 2. We find the vertices z and z ′ in O(1) time.Afterwards we apply Claim 3, which takes O(n) time.So we used O(n) time in total.This completes the proof of the lemma.

⊓ ⊔
We are now ready to prove Proposition 1 for graphs G with maximum degree ∆ ≥ 3 by following the arguments from [24] without the requirement that G is (∆ − 1)degenerate (that is, we allow G to be ∆-regular).So the proof is similar to the proof in [24] for (∆ − 1)-degenerate graphs except that we use Theorem 7 instead of its algorithmic counterpart for (∆ − 1)-degenerate graphs.To show this we give a selfcontained proof.
Proposition 1 [restated].Let G be a connected vertices with maximum degree ∆ ≥ 3. Then it is possible to find a path in R ∆+1 (G) (if one exists) between any two given (∆ + 1)-colourings in O(n 2 ) time.
Proof.We use induction on ∆.If ∆ ∈ {1, 2}, then the statement is trivially true.Let ∆ ≥ 3 and assume that we have an O(n 2 ) time algorithm for connected graphs on n vertices with maximum degree ∆ − 1. Applying Lemma 6 O(n) times, in O(n 2 ) time we can find a path from α to some ∆-colouring γ 1 and a path from β to some ∆-colouring γ 2 .By Theorem 7 we can find in O(n 2 ) time a partition {S 1 , S 2 } of V (G) such that S 1 is an independent set and S 2 induces a (∆ − 2)-degenerate graph, which we denote by H.We modify the pair (S 1 , S 2 ) in O(n 2 ) time by moving vertices from S 2 to S 1 until S 1 is a maximal independent set.
Let γ H 1 and γ H 2 be the ∆-colourings of H that are the restrictions of γ 1 and γ 2 , respectively, to S 2 .Let γ ′ 1 and γ ′ 2 be the (∆ + 1)-colourings obtained from γ 1 and γ 2 , respectively, by recolouring every vertex in S 1 with the colour ∆+ 1.As S 1 is maximal, H has maximum degree at most ∆ − 1.We apply the induction hypothesis to find in O(n 2 ) time a path between the two ∆-colourings γ H 1 and γ H 2 in R ∆ (H) (note that neither is an isolated vertex of R ∆ (H) since H is (∆ − 2)-degenerate).Note that this immediately translates into a path between γ ′ 1 and γ ′ 2 in R ∆+1 (G).Hence we obtain a path between α and β in R ∆+1 (G).This completes the proof.

Future Work
In this section we pose two open problems.We have proven that for every integer k ≥ 3, the problem of finding a k-degenerate decomposition is polynomial-time solvable on graphs of maximum degree k and NP-hard for graphs of maximum degree 2k − 2 (by generalizing the hardness proof of [48] for k = 3).This brings us to our first open problem.
Open Problem 1 Determine, for every integer k ≥ 4, the complexity of finding a k-degenerate decomposition for graphs of maximum degree k + 1.
Our second open problem is related to Theorem 3. Recall that this theorem states that for every three integers k ≥ 3 and p, q ≥ 0 with p + q = k − 2, the vertex set of every connected graph of maximum degree k that is not isomorphic to K k+1 can be partitioned into two sets A and B, where A induces a p-degenerate subgraph of maximum size and B induces a q-degenerate subgraph.Our algorithms in Sections 2 and 3 form an algorithmic version of Theorem 5, which is a special case of Theorem 3 in which p = 1 and q = k − 1.

Fig. 1 .
Fig.1.The claw and the triangular prism.A near-bipartite decomposition of the triangular prism is indicated: the white vertices form an independent set and the black vertices induce a forest.

Fig. 2 .
Fig.2.The graphs used in Rule 8.A near-bipartite decomposition of each is indicated: the white vertices form an independent set and the black vertices induce a forest.

Fig. 3 .
Fig. 3.The diamond and triangle (solid edges and vertices) together with their neighbourhoods in a cubic graph.

1 .
Change the graph H(a, b, c, d, e) to the graph H(a, B, D), where B and D are sets of k − 1 vertices.To obtain this graph, replace the (adjacent) vertices b and c by a clique on the set B and replace the (non-adjacent) vertices d and e by an independent set on the set D. Make every vertex in B adjacent to every vertex in D (just as every vertex in {b, c} was adjacent to every vertex in {d, e}).

Claim 2 .
Let j and k be distinct colours in {1, . . ., ∆}.If a (j, k)-component D is such that no vertex coloured j in D has a neighbour in L α , then in O(|V (D)|) time we can recolour G from α to the (∆ + 1)-colouring α ′ with α ′ i1 and G j2,k2 i2 are two distinct paths, each with locked end-vertices and no superfree vertices, then G j1,k1 i1 and G j2,k2 i2 do not intersect on a free vertex.We prove Claim 4 as follows.For contradiction, suppose that G j1,k1 i1 and G j2,k2 i2 intersect on a free vertex w.Then w is an internal vertex on each of G j1,k1 i1 and G j2,k2 i2 .Moreover, the two neighbours of w in G j1,k1 i1 are disjoint from the two neighbours of w

β 1, 2 1 1 , 2 1. 1 , 2 1 1 , 2 1β 1 ,2 1 from v 1 , 2 . 1 , 2 1.1
are v 1,1 and v 1,2 , neither of which belong to H 2,3 .Hence, y is an inner vertex of G β If y is an internal vertex of both H 2,3 and G β , then y would be superfree, contradicting the fact that G β has no superfree vertices.This means that y is an end-vertex of H 2,3 .As β(x) = 3 while β(y) = 1 or β(y) = 2, we find that y = x.It follows that y = z = x ′ , and so β(y) = 2.Consider the vertex z ′ on Gβ 1,2 1 reached immediately before y = z = x ′ when traversing G Then α(z ′ ) = β(z ′ ) = 1.As α(v 1,2 ) = α(y) = 2,we find that z ′ is an inner vertex of G α It follows that z ′ is a free vertex.Note that z is adjacent to v 1,1 and z ′ and that α(z) = 3 and α(v 1,1 ) = α(z ′ ) = 1.Therefore z ′ is a vertex of G intersect on the vertex z ′ .By Claim 4, it follows that G α 1,3 and u and v are non-adjacent so A \ {z} ∪ {u, v} is an independent set.⊓ ⊔ Lemma 3. Let k ≥ 3. Let G be a k-regular connected graph on n vertices, which contains a set C of k + 1 vertices that induce a clique minus an edge uv.If C, u and v are given as input, then a k-degenerate decomposition of G can be found in O(kn) time.and all other vertices of C have no neighbours outside C. Let t be the neighbour of u not in C, and let w be the neighbour of v not in C. We may assume that t is distinct from w, otherwise we are done by Lemma 2. We can find a (k − 1)-degenerate order O of G ′ in O(kn) time by taking the vertices in the reverse of the order they are found in a breadth-first search from t, and then, if t and w do not belong to the same component of G ′ , appending the vertices in the reverse of the order they are found in a breadth-first search from w.By Lemma 1, we can compute a k-degenerate decomposition (A, B) of G ′ in O(kn) time such that O| B is a (k − 2)-degenerate order of B. If both t and w belong to B, let A ′ = A ∪ {u, v} and B ′ = B ∪ (C \ {u, v}) and, since (C \ {u, v}) is a clique on k − 1 vertices with no edge joining it to B, if follows that (A ′ , B ′ ) is a k-degenerate decomposition of G. Assume now without loss of generality that t ∈ A (we make no assumption about whether w is also in A).Then let A ′ = A ∪ {x} and B ′ = B ∪ (C \ {x}).Then A ′ is an independent set.Recall that O| B is a (k − 2)-degenerate order of B. We show that we can append the vertices of C \ {x} to obtain a (k − 2)-degenerate order of B ′ .First add v, then the vertices of C \ {u, v, x} and finally u.It is clear that no vertex has more than k − 2 neighbours earlier in the order.
Proof.Let x be a vertex in C distinct from u and v. Let G ′ be the graph obtained from G by deleting C. Each of u and v has exactly one neighbour that does not belong to C ⊓ ⊔ Lemma 4. Let k ≥ 3. Let G be a k-regular connected graph on n vertices containing a clique C on k vertices whose neighbourhood is of size 2. If C is given as input, a k-degenerate decomposition of G can be found in O(kn) time.Proof.Let u and v be vertices not in C such that for each vertex in C, its unique neighbour not in C is either u or v. Neither u nor v can be adjacent to every vertex in C (as then the other would be adjacent to none, contradicting the premise that the neighbourhood has size 2).Since k ≥ 3, one of u and v has at least two neighbours in C. Consider the graph G ′ obtained from G by removing C and adding the edge uv (if it does not already exist).Note that u and v each have degree at most k in G ′ and at least one of them, say u, has degree less than k.Therefore, we can find a (k − 1)-degenerate order O of G ′ in O(kn) time by taking the vertices in the order they are found in a breadth-first search from u. Thus we can obtain a k-degenerate decomposition (A, B) of G ′ by Lemma 1, such that O| B is a (k − 2)-degenerate order of G[B] and A is a maximal independent set.At least one of u and v must belong to B. Assume without loss of generality that either v ∈ A, u ∈ B or both u and v belong to B, and, in the latter case, assume that u has at least two neighbours in C. Consider a neighbour t of u in C. We set A ′ = A ∪ {t} and B ′ = B ∪ (C \ {t}), and claim that