∆-List Vertex Coloring in Linear Time

San Skulrattanakulchai

Department of Computer Science, University of Colorado at Boulder, Boulder CO 80309 USA [email protected]

Abstract. We present a new proof of a theorem of Erd˝os,Rubin, and Taylor, which states that the list chromatic number (or choice number) of a connected, simple graph that is neither complete nor an odd does not exceed its maximum ∆. Our proof yields the first-known linear-time algorithm to ∆-list-color graphs satisfying the hypothesis of the theorem. Without change, our algorithm can also be used to ∆- color such graphs. It has the same running time as, but seems to be much simpler than, the current known algorithm, due to Lov´asz,for ∆- coloring such graphs. We also give a specialized version of our algorithm that works on subcubic graphs (ones with maximum degree three) by exploiting a simple decomposition principle for them.

1 Introduction

This paper presents efficient algorithms for a list vertex coloring problem. Our main contribution is a new proof of a theorem of Erd˝os,Rubin, and Taylor [1]. Our proof yields the first-known linear-time algorithm to ∆-list-color graphs that do not contain a complete graph or an odd cycle as a connected . Without change, our algorithm can also be used to ∆-color such graphs. It has the same running time as, but seems to be much simpler than, the current known algorithm for ∆-coloring such graphs. We also give a specialized version of our algorithm that works on subcubic graphs. (A subcubic graph has maximum degree 3.) The notations and the definitions of the graph terms we use are given in Sect. 1.1. We now discuss the problem we solve in detail. In the list vertex coloring problem [2], we are given a graph every vertex of which has been assigned its own list of colors as part of the input. Our task is to assign to every vertex a color chosen from its color list so that adjacent vertices receive distinct colors. A graph is list-colorable if the task is possible. The list vertex coloring problem is a generalization of the usual vertex coloring problem [2]. In the usual problem, we are given a graph and a constant number k of colors. Our task is to assign to every vertex a color chosen from the given k colors so that adjacent vertices receive distinct colors. A graph is k-colorable if the task is possible. To k-color the graph is to find such a color assignment. The chromatic number of a graph is the least k for which it is k-colorable. A graph is k-list-colorable if it is list-colorable given any list assignment as long as the size of each list is at least k. To find such a color assignment is to k-list-color the graph. The list chromatic number (or choice number) of a graph is the least k for which it is k-list-colorable. More generally, for any list size assignment f : V IN, we say that a graph is f-choosable if it is list-colorable given any list assignment→ as long as the list size of any vertex v is at least f(v). For example, a d-choosable graph is one that is list-colorable whenever every vertex’s color list contains at least as many colors as its degree. Observe that a k-list-colorable graph is always k-colorable since any algo- rithm for k-list-coloring can be used for k-coloring: simply assign the same list of k colors to every vertex of the input graph, and run the k-list-coloring al- gorithm on it. Note also that a graph is list-colorable if and only if each of its connected components is. Therefore, one needs only consider list-colorability of connected graphs. A Brooks graph is a connected graph that is neither complete nor an odd cycle. In [1] Erd˝oset al. prove that a connected graph is d-choosable if and only if at least one of its biconnected components is a Brooks graph. Consequently, they obtain the list version of Brooks’ Theorem: the list chromatic number (or choice number) of a Brooks graph does not exceed its maximum degree. In other words, a Brooks graph is ∆-list-colorable. In their proof they check biconnectivity of the graph at every inductive step following a sequence of vertex and edge deletions. This is an expensive operation: no algorithm is known that can dynamically compute graph biconnectivity under vertex and edge deletions in O(m+n) time. We give a new proof of their theorem and also derive the first O(m + n)-time ∆-list-coloring algorithm. Both their and our proofs rely on existence of some special types of induced subgraphs in a biconnected Brooks graph. They identify two types of special subgraphs. By adding another type to their list we are able to obtain a more efficient algorithm. Our success rests on the simple fact that it is easier to find objects of one’s desire when there are more of them around. Our algorithm naturally specializes to the problem of finding a coloring in the original Brooks’ Theorem [3]: the chromatic number of a Brooks graph does not exceed its maximum degree. In other words, a Brooks graph is ∆-colorable. The current known efficient algorithm for ∆-coloring Brooks graphs is due to Lov´asz[4]. (See also Problem 9.13, pp. 67 in [5].) By using the ideas given in Sect. 2.2, it is possible to implement his algorithm to make it run in O(m + n) time. Lov´asz’salgorithm computes a separating pair of vertices [6]. In contrast, our algorithm explores the graph in search of an occurrence of any one of a few simple unavoidable patterns, whose existence gives a straightforward coloring algorithm for the whole graph. Both Lov´asz’sand our algorithms call upon a subroutine to compute biconnected components. This is fine since there exist many simple biconnected components algorithms in the literature. (See [7, 8], for example.) Again, our algorithm is simpler than Lov´asz’sin this respect. All it needs from the biconnectivity computation is one biconnected component. In contrast, Lov´asz’salgorithm has to construct the so-called block-cutpoint from all the biconnected components. Another difference between the two algo- rithms concerns recoloring. Lov´asz’salgorithm colors each biconnected compo- nent separately, then put these colorings together by appropriately “permuting colors” in each component. Our algorithm never recolors. A class of graphs that has proven itself to be of special interest is the class of subcubic graphs [9]. References [10, 11] show that a simple decomposition principle for subcubic graphs give efficient algorithms for solving various coloring problems on them. We will exploit this principle to obtain a version of our algorithm that is specialized to subcubic Brooks graphs and that is simpler than the general version. It even does away with the biconnectivity computation altogether. In the rest of this section we discuss terminology. In Sect. 2 we develop our proof and algorithm for the theorem of Erd˝oset al. on general graphs. In Sect. 3 we develop an algorithm for the case of subcubic graphs.

1.1 Terminology

For any positive integer n, the set of all positive integers not greater than n is denoted [n]. We follow the terminology of [12] and consider only undirected graphs with- out parallel edges. By default, G = (V,E) denotes the graph under consideration with V = n and E = m. The degree of a vertex v is usually denoted d(v), and | | | | also as dG(v) whenever G needs to be distinguished from some other graph also under consideration. The minimum (maximum) degree of the graph is denoted δ (∆). By a path we mean one with no repeated vertices. A cycle or path is even (odd) if it has an even (odd) number of edges. A wheel Wk consists of a cycle Ck, and a hub vertex w that is not on the cycle but is adjacent to every vertex on the cycle. The cycle vertices are the rim; the k edges joining the hub w to the rim are called spokes.A whel is a wheel Wk with ` spokes missing, where 1 ` < k 1. In other words, a whel can be obtained from a wheel by removing at≤ least one− spoke while keeping at least two spokes. A theta graph θ(a, b, c) consists of 3 internally disjoint paths Pa+1, Pb+1, and Pc+1 connecting 2 end vertices, where the path lengths a, b, and c satisfy 0 < a b c.A diamond is ≤ ≤ the complete graph K4 with one edge missing. It is at the same time the smallest whel and the theta graph θ(1, 2, 2). Let H be a subgraph of G. A path avoids H if it uses no edge of H. A vertex w is called a neighbor of H if w is adjacent in G to some vertex of H but is itself not a vertex of H. We always use the term “induced” to mean “induced by its vertex set.” For example, C is an induced cycle if C is a subgraph of G isomorphic to a cycle and C is induced by its own vertex set. We use the term available color at various places in the description of our algorithm. During the execution of the algorithm, a color c is available for a vertex v if it is in the color list of v and no vertex adjacent to v is already colored c. In this paper, the term linear means O(m + n), i.e., linear in the size and order of the input graph. 2 General Graphs

2.1 Lemmas and Theorem

Lemma 1 (Cycle List Coloring Lemma). If every vertex of a cycle C has a list of at least 2 colors, then C is list-colorable unless C is odd and every vertex has the same list of 2 colors.

Proof. Let C have k vertices. First suppose some vertex has more than 2 colors in its list. Label it v1 and label the other vertices v2, . . . , vk according as they appear on the tour of C starting from v1. Choose a color c in the list of v1 so that vk has at least 2 available colors if v1 is colored c. Assign color c to v1. Now color v2, . . . , vk in that order, choosing any color available for each. Next suppose every vertex has exactly 2 colors in its list but some lists are different. Choose two consecutive vertices with distinct lists and label them v1 and vk. Label the other vertices v2, . . . , vk 1 according as they appear on the − tour of C starting from v1 and ending at vk. Now assign colors the same way as previous case. Last suppose C is even and all lists are the same list of 2 colors. Starting from any vertex, tour the cycle and color each vertex in the order visited by the tour using any color available for each. It is easy to check that in all three cases every vertex has some available color at the time when the algorithm is about to color it. ut Lemma 2 (Theta Graph List Coloring Lemma). Any theta graph θ(a, b, c) is list-colorable if each of its two end vertices has a list of at least 3 colors, and each of the rest of its vertices has a list of at least 2 colors.

Proof. We may assume that all inequalities on the sizes of the lists hold with equality. Let s, t be the end vertices connected by the three paths Pa+1, Pb+1 and Pc+1. Let Pa+1 = (s, u1, . . . , ua 1, t), Pb+1 = (s, v1, . . . , vb 1, t), and Pc+1 = − − (s, w1, . . . , wc 1, t). First color s by a color from its list that is different from any − color in the list of v1. This is always possible since s has 3 colors in its list while v1 has only 2. Then color w1, w2 . . . , wc 1, u1, u2, . . . , ua 1, t, vb 1, vb 2, . . . , v1 in that order, using any color available− for each. − − − ut Lemma 3. A graph that is connected but not regular is ∆-list-colorable.

Proof. Let v1 be a vertex whose degree is less than ∆. For j 2 to n set vj ← to be any vertex in V v1, . . . , vj 1 adjacent to some vertex in v1, . . . , vj 1 . \{ − } { − } Color vn, . . . , v1 in that order, using any color available for each. This procedure never fails since for j = n, . . . , 2 vertex vj is adjacent to some uncolored vi, where i < j, and d(vj) ∆ and vj has ∆ colors in its list. Moreover, v1 is colorable ≤ ≥ because d(v1) < ∆ and v1 has ∆ colors in its list. ≥ ut Lemma 4. A connected graph G is ∆-list-colorable if it contains any of (i) an even cycle, (ii) a whel, or (iii) a theta graph, as an induced subgraph. Proof. First suppose that G contains an induced even cycle C = v1, . . . , v2k . h i For j 2k + 1 to n set vj to be any vertex in V v1, . . . , vj 1 adjacent to ← \{ − } some vertex in v1, . . . , vj 1 . Color vn, . . . , v2k+1 in that order, using any color available for each;{ then color− } C using its vertices’ lists of available colors by invoking the Cycle List Coloring Lemma. This procedure never fails since for j = n, . . . , 2k + 1 vertex vj is adjacent to some uncolored vi, where i < j, and d(vj) = ∆ and vj has ∆ colors in its list. Moreover, C is colorable because ≥ right after v2k+1 is colored, each vertex on the even cycle C has a list of at least 2 available colors. Next suppose that G contains an induced whel consisting of w as the hub vertex and cycle C = v1, . . . , vk as the rim. Set vk+1 w. For i k + 2 h i ← ← to n set vi to be some vertex in V v1, . . . , vi 1 adjacent to some vertex in \{ − } v1, . . . , vi 1 . Color vn, . . . , vk+2 in that order, using any color available for { − } each. Choose a color for vk+1 so that the vertices in the resulting uncolored cycle C do not have the same list of 2 available colors. This can always be done since vk+1 is adjacent to more than one but not all vertices of C and vk+1 has at least 2 available colors. Now cycle C is colorable using its vertices’ lists of available colors by the Cycle List Coloring Lemma. Now suppose that G contains an induced theta subgraph θ(a, b, c). There are k = a + b + c 1 vertices in the θ graph. Label them v1, . . . , vk. For i k + 1 − ← to n set vi to be some vertex in V v1, . . . , vi 1 adjacent to some vertex in \{ − } v1, . . . , vi 1 . Color vn, . . . , vk+1 in that order, using any color available for {each. The− uncolored} vertices of the theta graph have lists of available colors satisfying the hypotheses of the Theta Graph List Coloring Lemma, so they are colorable using colors from these lists. ut Lemma 5. Let G be a biconnected Brooks graph. Then G contains one of (i) an even cycle, (ii) a whel, or (iii) a theta graph, as an induced subgraph.

Proof. Since G is biconnected we see that ∆ δ 2 and G contains some cycle, and thus contains some induced cycle. We are≥ done≥ if any of its induced cycles is even. So assume that every induced cycle is odd. First suppose that G contains a triangle. Let K be a maximal con- taining this triangle. Then K is necessarily a proper subgraph of G since G is not complete. Thus K has some neighbor. Say that v1, . . . , vk are the vertices of K. No neighbor w of K can be adjacent to all the vi’s since otherwise w and all the vi’s would form a clique containing K, contradicting maximality of K. Now if any neighbor w is adjacent to vi, vj but not to v`, where i, j, ` are all distinct, then we get an induced diamond on the vertices w, vi, vj, v`, and we are done. So assume that every neighbor is adjacent to exactly one vertex in K. Pick a vertex vi adjacent to some neighbor of K. Since G is biconnected, there is a shortest path P avoiding K and connecting vi to some other vertex vj. Let ` be such that 1 ` k and ` = i, j. Vertex v` together with the vertices on P ≤ ≤ 6 then induce a whel with v` as its hub. Next suppose that G contains an induced odd cycle C = v1, . . . , vk that is not a triangle. Cycle C cannot be the whole of G since G ish not an oddi cycle. So C has some neighbor. If some neighbor w of C is adjacent to every vi, then w, v1, v2, v3 induces a diamond, and we are done. If some neighbor w of C is {adjacent to more} than one but not all vertices of C, then w and the vertices of C induce a whel, and we are done. So assume that every neighbor of C is adjacent to exactly one vertex of C. Pick a vertex vi adjacent to some neighbor of C. Since G is biconnected, there is a shortest path P avoiding C and connecting vi to some other vertex vj. The vertices of C P then induce a theta graph. ∪ ut Theorem 1. A Brooks graph is ∆-list-colorable. Proof. Let G be a Brooks graph. If G is not regular, then it is ∆-list-colorable by Lemma 3. Suppose G is regular and consider its the block-cutpoint tree T . Let H be a biconnected component in G corresponding to a leaf in T . If H = G then H is a Brooks graph by assumption. If H = G, let v be the only vertex in H that is also a cutpoint in G. Since H corresponds6 to a leaf in T and v is a cutpoint in the regular graph G, it follows that dH (v) < dH (w) for any vertex w in H distinct from v. So H is not regular; and hence cannot be either a complete subgraph or an odd cycle. Therefore, H is a Brooks graph. By Lemma 5, the subgraph H contains either an induced even cycle, or an induced whel, or an induced theta graph; and so does G since it is a supergraph of H. So G is ∆- list-colorable by Lemma 4 since it is also connected. ut

2.2 Algorithm We assume the following of our input. The input Brooks graph G = (V,E) is represented as adjacency lists (see [13]). Each vertex has exactly ∆ colors in its color list. (If not, we can throw away all colors in excess of ∆ without affecting ∆- list-colorability of G.) Vertices, edges, and colors are numbered using consecutive integers starting from 1. So V = [n], E = [m], and the highest possible color is n∆. Each color list Ci (i [n]) is represented as a linked list. The proof of Theorem∈ 1 suggests the following high-level algorithm for ∆- list-coloring G. If G is not regular, apply the algorithm in the proof of Lemma 3 and we are done. If G is regular, do the following. Execute some biconnected components algorithm [7, 8] on G but stop the algorithm as soon as a biconnected component corresponding to a leaf in the block-cutpoint tree of G is identified. So we can stop the algorithm of [7] or [8] as soon as it discovers the first biconnected component. Call this component H. Apply the algorithm in the proof of Lemma 5 on component H to extract an induced even cycle, or an induced whel, or an induced theta graph. Now apply the algorithm from the appropriate part of the proof of Lemma 4. The biconnected components algorithms [7, 8] are known to take O(m + n) time. We will describe how to accomplish these two tasks. Task A To implement the algorithm in the proof of Lemma 5 so that it takes O(m + n) time. Task B To implement the algorithms in the proof of Lemmas 3 & 4 so that they take O(m + n) time. Task A To find an induced cycle, use a modified depth-first search (DFS) to explore the graph. Put in the language of the tree-based view of DFS [13], we make sure any back edge is explored before any tree edge. This can be done by going through the adjacency list of the currently active vertex v once. If back edges are found and w is the vertex on the recursion stack closest and adjacent to v via a back edge, then all the vertices on the tree path from w to v induce a cycle. If no back edges are found, then continue exploring the graph in the depth-first manner. Here is how to find a maximal clique containing a triangle. Use a boolean array to keep track of the vertices belonging to the current clique. Also, keep a count of the number of vertices in the current clique. Use another boolean array to keep track of processed vertices. Put all neighbors of the current clique in the queue. Repeat the following until the queue is empty. Delete a vertex v from the queue. If v has already been processed, continue checking the queue. Otherwise, process v as follows. If v is adjacent to all vertices in the current clique, add v to the current clique, and add all neighbors of v not belonging to the current clique to the queue, and mark v processed. To find a shortest path avoiding H (which is either a maximal clique or an induced non-triangle odd cycle, every neighbor of which is adjacent to exactly one vertex of it) and connecting two vertices of H, use breadth-first search (BFS). (See [13]). This implementation clearly takes O(m + n) time. Task B We will describe an implementation of the algorithm in Lemma 3 only since the one in Lemma 4 is similar. Ordering the vertices as v1, . . . , vn can be done by either DFS or BFS. Preprocess the color lists as follows.

chop Cv1 so that it has exactly d(v1) + 1 colors for i 2 to n do chop Cv so that it has exactly d(vi) colors ← i n n After the preprocessing, we have i=1 Ci = 2m+1 and i=1 Ci 2m+1. Let k be the highest color to ever appearP in| any| chopped color| S list. We| ≤ may assume n Ci = [k]. For if not, we can renumber the colors by putting all the colors Si=1 in all the Ci’s in a list M, do a radix sort on M, throwing away all duplicate colors, and then get a new number for each color according to its position in the sorted list M. All this work takes O(m + n) time since the highest possible color 2 is n∆, which is O(n ). For each vertex i, we will use a list Ui to keep colors made unavailable for i owing to their having been assigned to some of i’s neighbors. We will use a boolean array A[1..k] together with list Ui to determine a color available for each vertex i. The coloring pseudocode is as follows.

for i 1 to n do empty list Ui; for i ← n downto 1 do ← { for each color c in Cv do A[c] true; i ← for each color c in Uv do A[c] false; i ← c first color in Cv ; while A[c] = false do c next color in Cv ; ← i ← i assign color c to vi; for each vertex j on the adjacency list of vi do append color c to Uj } It is not hard to see that this implementation is correct and takes O(m + n) time. The foregoing discussion gives our main theorem. Theorem 2. There exists an O(m + n)-time algorithm to ∆-list-color Brooks graphs.

3 Subcubic Graphs

Let G be a subcubic graph. Consider a maximal collection of edge-disjoint cycles in G. Cycles in must be vertex-disjoint since G is subcubic.C The graph = G is a collectionC of trees since is maximal. This simple fact is the decompositionT − C principle [11] for subcubicC graphs: A subcubic graph G can be decomposed in linear time into edge-disjoint subgraphs and , where is a collection of vertex-disjoint cycles, and is a forest ofC maximumT degreeC at most 3. Furthermore, we can choose to decomposeT G so that all cycles in are induced cycles. C We now describe a particularly simple algorithm to 3-list-color any subcubic, Brooks graph G. First check whether G is cubic or not. If not, then apply the algorithm in the proof of Lemma 3. So assume that G is cubic. Decompose G into trees and induced cycles . If contains an even cycle, then apply the algorithmT in the first part of theC proofC of Lemma 4. So assume that every cycle in is odd. Suppose there is a cycle C with a neighbor w that is adjacent toC either 2 or 3 vertices of C. Such a neighbor∈ C w must be a tree vertex since G is cubic. We claim that w together with the vertices of C induce a whel, so that we can apply the algorithm in the second part of the proof of Lemma 4. This is clear if w is adjacent to 2 vertices of C since C is odd. If w is adjacent to 3 vertices of C, then C cannot be a triangle. For otherwise w together with the vertices of C would induce a K4 which would necessarily equal G, contradicting G being a Brooks graph. So assume that every neighbor of any cycle C is ∈ C adjacent to exactly one vertex of C. Suppose there exist cycles C1,C2 joined ∈ C by at least 2 edges. Let C1 = v1, . . . , vp and C2 = w1, . . . , wq and viwk and h i h i vjw` be two edges joining them. We may assume that i < j and no edge joins any of vi+1, . . . , vj 1 to any vertex of C2. The cycle C2 consists of two paths − joining wk to w`. Necessarily one of these paths is even and the other is odd since C2 is odd. (The odd path may have length 1.) The vertices on one of these paths together with vertices vi, vi+1, . . . , vj 1, vj induce either an even cycle or a theta graph θ(1, b, c); and we can apply− the algorithm in either the first or the third part of the proof of Lemma 4, respectively. So assume that any two cycles in are joined by at most 1 edge. Let H be the graph that results from contractingC all cycles in . Then δ(H) 3 and thus H contains some cycle. Let D be an induced cycle inCH. Cycle D necessarily≥ contains some vertex [X] that exists as the result of the contraction of some cycle X. Consider such a vertex. In D, there are two edges e1, e2 incident with [X]. In G, edge e1 (e2) is incident with a vertex x1 (x2) on the cycle X. In G, cycle X consists of one odd path and one even path connecting x1 to x2. (The odd path may have length 1.) By replacing every vertex of D that was derived from cycle contraction with one of these two paths we can turn the cycle D in H into a cycle C in G. We execute the following replacement procedure. If vertex [X] is not the last one yet to be replaced, then replace [X] by the shorter of the two cycle paths in X connecting x1 to x2. Otherwise, replace [X] by choosing from one of the two cycle paths in X the one that will make the resulting cycle C even. The vertices of C then induce either an even cycle or a theta graph θ(1, b, c), and we can apply the algorithm in either the first or the third part of the proof of Lemma 4, respectively.

Acknowledgments I am most grateful to Hal Gabow for the Cycle List Coloring Lemma, his careful reading of numerous versions of the manuscript, and helpful discussions. I also thank an anonymous referee whose comments help improve the paper.

References

[1] Erd˝os,P., Rubin, A.L., Taylor, H.: Choosability in graphs. In: Proceedings of the West-Coast Conference on Combinatorics, and Computing. Volume XXVI of Congressus Numerantium., Arcata, California (1979) 125–157 [2] Jensen, T.R., Toft, B.: Graph Coloring Problems. John Wiley & Sons, Inc., New York, New York (1995) [3] Brooks, R.L.: On colouring the nodes of a network. Proceedings of the Cambridge Philosophical Society. Mathematical and Physical Sciences 37 (1941) 194–197 [4] Lov´asz,L.: Three short proofs in graph theory. Journal of Combinatorial Theory Series B 19 (1975) 269–271 [5] Lov´asz,L.: Combinatorial Problems and Exercises. Second edn. North-Holland Publishing Co., Amsterdam (1993) [6] Hopcroft, J.E., Tarjan, R.E.: Dividing a graph into triconnected components. SIAM Journal on Computing 2 (1973) 135–158 [7] Tarjan, R.E.: Depth-first search and linear graph algorithms. SIAM Journal on Computing 1 (1972) 146–160 [8] Gabow, H.N.: Path-based depth-first search for strong and bi-connected compo- nents. Information Processing Letters 74 (2000) 107–114 [9] Greenlaw, R., Petreschi, R.: Cubic graphs. ACM Computing Surveys 27 (1995) 471–495 [10] Skulrattanakulchai, S.: 4-edge-coloring graphs of maximum degree 3 in linear time. Information Processing Letters 81 (2002) 191–195 [11] Gabow, H.N., Skulrattanakulchai, S.: Coloring algorithms on subcubic graphs. (submitted) [12] Bollob´as,B.: Modern Graph Theory. Springer-Verlag, New York (1998) [13] Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algo- rithms. Second edn. McGraw-Hill, New York (2001)