Exact Coloring of Real-Life Graphs Is Easy
Total Page:16
File Type:pdf, Size:1020Kb
6.4 Exact Coloring of Real-Life Graphs is Easy Olivier Coudert Synopsys, Inc., 700 East Middlefield Rd. Mountain View, CA 94043 .............. ..... Abstract jpqq .. ..., .. m!miI. , ....’. Graph coloring has several important applications in : L .............. ......... ..................... : VISI CAI]. Since graph coloring is NP-complete, heuris- tics arc used to approximate the optimum solution. Rut Iicurisbic solutions are typically 10% off, and as much as Figure 1: Max. clique, max. independent sct, inin. col- 100% off, the minimum coloring. This paper shows that oring, and min. clique partition. since real-life graphs appear to be 1-perfect, one can in- deed solve them exactly for a small overhead. 2 Notations 1 Introduction A simple (i.e., undirected and self-loop frcc) graph G Coloring a graph consists of assigning a color to ev- is denoted by V(G),E(G)),where V(G)is its set of cry vertex so that no two vertices linked by an edge vertices, and E IG) its set of edges. We denotc hy N(V) have the same color. The associated optimization the set of neighbors of a vertex v in a iven graph G, i.c., problem consists of minimizing the number of colors. N(w) = {v’ E V(G)I {TJ,~’}E E(C)f. The t1egrc.c of a Graph coloring is used in microcode o timization [15, vertex is its number of neighbors, IN(v)I. Givcri a set of pp. 168-1691, scheduling [8, pp. 248-252L resource bind- vertices V,we will often use the notation G- V to dcnotc ing and sharing [8, pp. 277-2941 [15, pp. 230-2331, the subgraph induced by (V(G)- V,E(G)). Whcn the (un)constrained state encoding of (a)synchronous finite context is not ambiguous, we will denotc a suhgraph hy state machines [15, pp. 323-3271, and planar routing [6]. its set of vertices. Other non-CAD applications include code compilation, In the sequel, n is the number of vertices, and IC the frequency assignment, and network optimization. Be- number of colors used by a coloring. The saturatzon nurn- cause graph coloring is NP-complete, heuristics are used ber of a vertex v is the number of colors used by its neigh- to produce an approximate solution. bors (i.e., the number of forbidden colors for v). We say This paper shows that since real-life coloring instances that a color is saturated if it cannot be used anyrnorc to appear to be 1-perfect, one can solve them exactly in no extend a partial coloring. more time than heuristics, while heuristics are on average A clzque is a set of vertices that are all linked lo each 10% off, and as much as 100% off, from the optimum. other by edges. An zndependent set is a set of vertices This paper is organized as follows. Section 2 gives that are not connected by any edge. Partitioning the set some definitions and notations. Section 3 presents the of vertices into cliques is nothing but coloring the com- well-known sequential coloring algorithm, and pinpoints plementary graph. Fig. 1 illustrates these NI’-complel~c its main weakness. Based on experimental evidence, it problems [9 . An independent set is maxzmal iff it is not then explains why solving the maximumclique problem is a proper sub set of another independent set. a decisive factor when coloring real-life graphs. Section 4 Let y(G) be the size of the maximum clique of G, and introduces original pruning techniques to solve maximum x(G) be the chromatic number of G, i.e., the minimum clique. Section 5 gives experimental results. It shows number of colors needed to color G. Since every vertex of that all the real-life application instances we had access a clique must be assigned a different color, y(G) 5 x(G). to (> 600) are solved exactly in a few seconds. When r(G) = x(G),we say that C is l-pcrfccll. Permission to make digital/hnrd copy of all or part of this work 3 Exact Coloring for personal or classroom use is granted without fee provided that copies are not made or distributedfor profit or commercial Coloring a graph can be done in two ways. One can advantage, the copyright notice, the title of the publication and its date appear, and notice is given that copying is by determine a color class one at a time: this consists of enu- permission of ACM, Inc. To copy otherwise, to republish, to merating maximal independent sets. Or one can color the post on servers or to redistribute to lists, requires prior specific vertices one at a time: this is called sequential coloring. permission and/or a fee. DAC 97, Anaheim, Californin G is perfect iff euery subgraph of G is 1-perfect. Exact coloring (c) 1997 ACM 0-89791-920-3/97/08 .. $3.50 of perfect graphs is polynomial [lo], but much too slow in practice. 121 fiirictioii SC(G); C t a clique of G; k to; forcach o E C { /* color the clique */ ktk+1; color t~ with k; /* a color is an integer 2 1 */ 1 return SCrcc(G,k, IV(G)l + 1, ICl); /* G is a graph partially colored, using L colors, and */ /* brst is the chromatic number found so far */ Figure 4: Three non 1-perfect graphs: y(G) < x(G). fiiiictioii SCrec(G, k, best, Ib); if G is entirely colored return k; /* new best coloring */ pi +- an uncolored vertex of G; 3.2 Why is Sequential Coloring Hard? for (c c I; c 5 min(k + 1, best - I); c +- c + 1) { /* for rach potential color */ The way the lowcr bound is used in SC is largcly incf- if (V~J’E N(v , coIor(v’) # c) { /* c is non-conflicting */ fective. As a comparison, considcr a hrancli-and-hoi~ri~l color v wit 1I c; algorithm that solvrs maximum clique (c.g., Fig. 5). bcst +- SCrrc(G, niax(c, k),brsf, Ib); Based on the inequality y(G) 5 x(G),a coloring is coni- uiirolor TI; is if Ib = besl rctiirii bcst; /* y(G) = x(G): abort */ puted at each recursion and uscd as an upprr hound to prune the search tree of maximum clique. Conversely, a clique is a lower bound on the chromatic number of returii best; a graph. But the analogy ends here: a clique does not give any valuable information on a graph partially col- Figure 2: SC, the exact sequential coloring. ored with unsaturated colors. Indeed, quickly estimat- ing a lower bound on the number of colors necessary to optimaly complete an unsaturated coloring is an open problem. SC uses several unsaturated colors at the samc time (e.g., the two gray colors used in the second and third graphs of Fig. 3), and thus has only one stalac lowcr bound which is not reevaluated at each recursioii, unlike “standard” branch-and-bound algorithms. We thcrcforc Figure 3: Sequential coloring. have the following fact (e.g., [13, pp. 2201): Fact 1 If y(G) < x(G), then the lower bound does not anfluence the length of the computataon at all, because the This section discusses the sequential coloring algo- search must exhaustavely enumerate all potentaal (unsuc- rithm. We pinpoint the main weakness of this algorithm, cessful) colorangs that would amprove op x(G),whach can and explain why the maximum clique problem is a key take exponentaal tame. player when coloring real-life graphs. Let us face the second fact ([a, 31, [13, pp. 243 2471): 3.1 Sequential Coloring Fact 2 Almost all graphs G salasfy: Fig. 2 outlines the exact sequential coloring algorithm SC [5]. It first generates a clique, which is used both as a lower bound and as a starting point for the coloring, since every vertex of the clique must be assigned a different This shows an actual large gap between y(G) and x(G). color and does not need to be recolored afterwards. Then Combined with Fact 1, this leaves little hope to address uncolored vertices are picked one at a time, and each is exact coloring in general. assigned a color (an integer 2 1) non-conflicting with its neighbors’ colors. 3.3 Why is Maximum Clique Important? al- An efficient heuristic, the well known DSATUR However, Fact 3 gives a different perspective 011 exact gorithm [4], consists of picking the vertex that has the graph coloring from the practical point of view: largest saturation number, and in breaking ties with the larges!, degree in the uncolored graph. The idea is to Fact 3 All the practical instances we found (more than choose the vertex that is the most “diflicult” to color, and 600 real-life examples in scheduling, register allocataon, tjhatJpropagates as many condraints as possible. Fig. 3 planar routing, and frequency assignment) are 1-perfed (from left to right) shows how a simple graph is sequen- graphs, a.e., y(G) = x(G). t,ially colored with this heuristic. The reader is referred to [16] for an extensive descrip- For instance, the graph of Fig. 3 is 1-perfect. Fig. 4 tion of some improvements and variations of sequential shows non 1-perfect ‘graphs (the one on the right is coloring (e.g., non-sequential backtracking [4, 181). myciel3, see Section 5). 122 fiiiic ticm MaxClique( G); rctiirri MaxClrqurIlec(G, 0,0,+m); /* G is the remaining graph, C is the clique under con- */ /* striiction, and best is the largest cliquc found so far. */ fiinction MaxClzqueRec(G, C, lest, ub); . .. .. if G is empty return C; /* new best solution */ ..........N( v) .