Graph coloring

| Main Article
| Discussion
| Related Articles  [?]
| Bibliography  [?]
| External Links  [?]
| Citable Version  [?]

|
|
|
|
|
|
|
|

This editable Main Article is under development and subject to a disclaimer.

[edit intro]

In graph theory, graph coloring is an arbitrary assignment of labels (colors) to objects within a graph. Such objects can be vertices, edges, faces, or a mixture of those. A graph coloring is distinct from a graph labeling in that in the former, the same label may be used more than once.

Graph coloring is a rich source of theoretical questions and practical applications. It has found applications in areas such as scheduling, register allocation in compilers, frequency assignment in mobile radios, and pattern matching. It has even become popular with the general public in the form of the popular number puzzle Sudoku. Graph coloring is still a very active field of research.

## Contents

* 1 Vertex coloring
* 2 Chromatic number
* 3 Chromatic polynomial
* 3.1 Examples
* 3.2 Properties
* 3.3 Computing the chromatic polynomial
* 4 List of other colorings
* 5 Applications to Computer Science
* 6 References
* 7 Literature
* 8 See also
* 9 External links

## Vertex coloring[edit]

Vertex coloring, the process of assigning a color to each vertex of a graph, is one of the most fundamental types of coloring. Other coloring problems can be transformed into a vertex coloring problems: for example, an edge coloring of a graph is just the vertex coloring of its line graph. Likewise, a face coloring of a planar graph is just the vertex coloring of its (planar) dual.

When used without qualification, the term graph coloring generally means vertex coloring. Also (unless otherwise specified), a coloring is nearly always assumed to be proper, meaning that no two adjacent vertices are assigned the same color.

A coloring using at most k colors is called a (proper)  k-coloring and is equivalent to the problem of partitioning the vertex set into k or fewer independent sets.

## Chromatic number[edit]

The least number of colors needed to color the graph is called its chromatic number χ. For example, the chromatic number of a complete graph Kn of n vertices is χ(Kn)=n. A graph that can be assigned a (proper) k-coloring is  k-colorable, and it is  k-chromatic if its chromatic number is exactly k.

The problem of finding a minimum coloring of a graph is NP-hard. The corresponding decision problem (is there a coloring which uses at most k colors?) is NP-complete, and in fact was one of Karp's 21 NP-complete problems. It remains NP-complete even on planar graphs of degree at most 4, as shown by Garey and Johnson in 1974, although on planar graphs it's trivial for k ≠ 3 (due to the four color theorem). There are however some efficient approximation algorithms that employ semidefinite programming.

Some properties of χ(G):

1. χ(G) = 1 if and only if G is totally disconnected.
2. χ(G) ≥ 3 if and only if G has an odd cycle (equivalently, if G is not bipartite).
3. χ(G) ≥ ω(G).
4. χ(G) ≤ Δ(G)+1.
5. χ(G) ≤ Δ(G) unless G is a complete graph or an odd cycle (Brooks' theorem).
6. χ(G) ≤ 4, for any planar graph G. This famous result, called the four-color theorem, was stated by P. J. Heawood in 1890 (first written reference by Augustus De Morgan in 1852), but remained unproven until 1976, when it was established by Kenneth Appel and Wolfgang Haken at the University of Illinois at Urbana-Champaign.

Here Δ(G) is the maximum degree, and ω(G), the clique number.

About infinite graphs, much less is known. The following is one of the few results about infinite graph coloring:

If all finite subgraphs of an infinite graph G are k-colorable, then so is G. (de Bruijn, Erdős 1951)

## Chromatic polynomial[edit]

This graph can be 3-coloured in 12 different ways.

The chromatic polynomial counts the number of ways a graph can be coloured using no more than a given number of colours. For example, using three colours, the graph in the image to the right can be coloured in 12 ways. With only two colours, it cannot be coloured at all. With four colours, it can be coloured in 24 + 4⋅12 = 72 ways: using all four colours, there are 4! = 24 valid colourings (every assignment of four colors to any 4-vertex graph is a proper coloring); and for every choice of three of the four colours, there are 12 valid 3-colourings. So, for the graph in the example, a table of the number of valid colourings would start like this:

Available colors | 1 | 2 | 3 | 4 | …

|
|
|
|
|

Number of colorings | 0 | 0 | 12 | 72 | …

The chromatic polynomial is a function P(G,t) that counts the number of t-colorings of G. As the name indicates, for a given G the function is indeed a polynomial in t. For the example graph, P(G,t)=t(t−1)2(t−2), and indeed P(G,4)=72.

The chromatic polynomial includes at least as much information about the colorability of G as does the chromatic number. Indeed, χ is the smallest positive integer that is not a root of the chromatic polynomial,

χ(G)=min⁡{k:P(G,k)>0}

It was first used by Birkhoff and Lewis in their attack on the four-color theorem. It remains an unsolved problem to characterize graphs which have the same chromatic polynomial and to determine precisely what polynomials are chromatic.

### Examples[edit]

The Petersen graph Chromatic polynomials for certain graphs  Triangle K3 | t(t−1)(t−2)

|

Complete graph Kn | t(t−1)(t−2)...(t−n+1)
Tree with n vertices | t(t−1)n−1
Cycle Cn | (t−1)n+(−1)n(t−1)
Petersen graph | t(t−1)(t−2)(t7−12t6+67t5−230t4+529t3−814t2+775t−352)

### Properties[edit]

* P(G,0)=0
* P(G,1)=0 if G contains an edge
* P(G,t)=0, if t<χ(G).
* P(G,−1) is the number of acyclic orientations of G[1]
* If G has n vertices, m edges, and k components G1,G2,…,Gk, then
* P(G,t) has degree n.
* The coefficient of tn in P(G,t) is 1.
* The coefficient of tn−1 in P(G,t) is −m.
* The coefficients of t0,t1, … tk−1 are all zero.
* The coefficient of tk is nonzero.
* P(G,t)=P(G1,t)P(G2,t)⋯P(Gk,t)
* The coefficients of every chromatic polynomial alternate in signs.
* A graph G with n vertices is a tree if and only P(G,t)=t(t−1)n−1.
* The derivative evaluated at unity, P′(G,1) is the chromatic invariant θ(G) up to sign

### Computing the chromatic polynomial[edit]

Whenever G contains a loop, it cannot be legally colored at all, so

P(G,t)=0.

If e not a loop, then the chromatic polynomial satisifes the recurrence relation

P(G,t)=P(G−e,t)−P(G/e,t),

where G−e is the graph with the edge removed, and G/e is the graph with the edge's endpoints contracted into a single vertex.

The two expressions give raise to a recursive procedure, called the deletion–contraction algorithm. In the recursive step, the instance is transformed into two instances that are at least one edge smaller, so the running time comes within a polynomial factor of 2m, where m is the number of edges. The analysis can be improved to 1.62n+m.

Other algorithms are known, but all are exponential in the size of the graph. For some classes of graphs, polynomial-time algorithms are known. These include the empty and complete graphs, forests, chordal graphs, wheels, and ladders. In general, computing the chromatic polynomial is Sharp-P-complete, so it is unlikely that a polynomial time algorithm for all graphs will be found.

## List of other colorings[edit]

Not only can the idea of vertex coloring be extended to edges, but also be added with different conditions to form new structures and problems.

* edge coloring \- edges are colored
* list coloring \- each vertex chooses from a list of colors
* list edge-coloring \- each edge chooses from a list of colors
* total coloring \- vertices and edges are colored
* harmonious coloring \- every pair of colors appears on at most one edge
* complete coloring \- every pair of colors appears on at least one edge
* exact coloring \- every pair of colors appears on exactly one edge
* acyclic coloring \- every 2-chromatic subgraph is acyclic
* strong coloring \- every color appears in every partition of equal size exactly once
* on-line coloring \- the instance of the problem is not given in advance and its successive parts become known over time
* equitable coloring \- the sizes of color classes differ by at most one
* sum-coloring \- the criterion of minimalization is the sum of colors
* T-coloring \- distance between two colors of adjacent vertices must not belong to fixed set T
* rank coloring \- if two vertices have the same color i, then every path between them contain a vertex with color greater than i.
* interval edge-coloring \- a color of edges meeting in a common vertex must be contiguous.
* circular coloring \- motivated by task systems in which production proceeds in a cyclic way
* path coloring \- models a routing problem in graphs
* fractional coloring \- vertices may have multiple colors, and on each edge the sum of the color parts of each vertex is not greater than one

Some improper colorings:

* cocoloring \-- every color class induces an independent set or a clique
* subcoloring \-- every color class induces a union of cliques

## Applications to Computer Science[edit]

Main Article: register allocation by graph coloring

In Computer Science, compilers\
computer programs which translate one formal language to another
can employ vertex coloring to determine a satisfactory solution to the problem of register allocation. Vertex coloring is the most popular approach, and is one of the most effective.

Typically, a compiler will translate a source written in a high-level language (HLL) to a target in assembly language or machine code. There are a few critical differences between the source and target languages. In particular, HLLs allow for a large or unlimited number of variables, while the typical microprocessor only allows for efficient access to a small number of variables, called registers, and inefficient access to main memory. Since only a small percentage of the variables within a computer program are used at one time, there is an opportunity to place multiple variables into the same register
but only if those variables are not used at the same time.

The register allocation problem can be viewed as a vertex coloring problem as follows: every variable in a program is treated as a vertex in an undirected graph. Then, if at any point during program execution two variables each hold some value that will later be read, then those two variables are said to interfere, and an edge is drawn between them. Unfortunately, it is not always possible to determine if two variables interfere (a consequence of the halting problem), and thus a compiler must act conservatively and assume that they do interfere unless they can be shown not to. This graph is called the interference graph.

As was mentioned earlier, determining a k-coloring for a graph is NP-Hard. Nonetheless, the compiler must solve such a problem. Thus, a compiler uses a heuristic algorithm to produce a non-optimal solution to the vertex coloring problem, attempting to minimize the number of colors used. If, ultimately, the number of colors used is greater than the number of registers in the target language, then the graph must be transformed to reduce the number of necessary colors. A compiler accomplishes this by spilling one or more variables, storing them in a memory location instead of a register.

## References[edit]

1. ↑ Stanley, 1973

## Literature[edit]

* R. L. Brooks: On colouring the nodes of a network. In: Proc. Cambridge Phil. Soc. 37, 1941, 194-197.
* N. G. de Bruijn, P. Erdős: A colour problem for infinite graphs and a problem in the theory of relations. In: Nederl. Akad. Wetensch. Proc. Ser. A 54, 1951 371-373\. (Indag. Math. 13.)
* Tommy R. Jensen, Bjarne Toft: Graph coloring problems. Wiley-Interscience, New York 1995 ISBN 0-471-02865-7.
* Marek Kubale and others: Graph Colorings. American Mathematical Society 2004 ISBN 0-8218-3458-4.
* M. R. Garey, D. S. Johnson, and L. Stockmeyer. Some simplified NP-complete problems. Proceedings of the sixth annual ACM symposium on Theory of computing, p.47-63. 1974.
* Michael R. Garey and David S. Johnson (1979). Computers and Intractability: A Guide to the Theory of NP-Completeness. W.H. Freeman. ISBN 0-7167-1045-5. A1.1: GT4, pg.191.

## See also[edit]

* Four-color theorem
* Uniquely colorable graph
* Critical graph
* Graph homomorphism
* Perfect graph
* Hadwiger–Nelson problem
* Sudoku
* register allocation by graph coloring

## External links[edit]

* Graph Coloring Page by Joseph Culberson (graph coloring programs)
* CoLoRaTiOn by Jim Andrews and Mike Fellows is a graph coloring puzzle
* GF-Graph Coloring Program [1]