Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Graph coloring
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Algorithms == {{Infobox | above = Graph coloring | image = [[Image:3-coloringEx.svg]] | labelstyle = font-weight:normal | headerstyle = background: #DD9 | abovestyle = background: #DD9 | header1 = Decision | label2 = Name | data2 = Graph coloring, vertex coloring, ''k''-coloring | label3 = Input | data3 = Graph ''G'' with ''n'' vertices. Integer ''k'' | label4 = Output | data4 = Does ''G'' admit a proper vertex coloring with ''k'' colors? | label5 = Running time | data5 = ''O''(2<sup>''n''</sup>''n''){{sfnp|Björklund|Husfeldt|Koivisto|2009|page=550}} | label6 = Complexity | data6 = [[NP-complete]] | label7 = Reduction from | data7 = [[3SAT|3-Satisfiability]] | label8 = Garey–Johnson | data8 = GT4 | header9 = Optimisation | label10 = Name | data10 = Chromatic number | label11 = Input | data11 = Graph ''G'' with ''n'' vertices. | label12 = Output | data12 = ''χ''(''G'') | label13 = Complexity | data13 = [[NP-hard]] | label14 = Approximability | data14 = ''O''(''n'' (log ''n'')<sup>−3</sup> (log log ''n'')<sup>2</sup>) | label15 = Inapproximability | data15 = ''O''(''n''<sup>1−''ε''</sup>) unless [[P = NP]] | header16 = Counting problem | label17 = Name | data17 = Chromatic polynomial | label19 = Input | data19 = Graph ''G'' with ''n'' vertices. Integer ''k'' | label20 = Output | data20 = The number ''P'' (''G'', ''k'') of proper ''k''-colorings of ''G'' | label21 = Running time | data21 = ''O''(2<sup>''n''</sup>''n'') | label22 = Complexity | data22 = [[Sharp-P-complete|♯P-complete]] | label23 = Approximability | data23 = [[FPRAS]] for restricted cases | label24 = Inapproximability | data24 = No [[Polynomial-time approximation scheme|PTAS]] unless P = NP }} === Polynomial time === Determining if a graph can be colored with 2 colors is equivalent to determining whether or not the graph is [[Bipartite graph|bipartite]], and thus computable in [[linear time]] using [[breadth-first search]] or [[depth-first search]]. More generally, the chromatic number and a corresponding coloring of [[perfect graph]]s can be computed in [[polynomial time]] using [[semidefinite programming]]. [[Closed-form expression|Closed formulas]] for chromatic polynomials are known for many classes of graphs, such as forests, chordal graphs, cycles, wheels, and ladders, so these can be evaluated in polynomial time. If the graph is planar and has low branch-width (or is nonplanar but with a known [[branch-decomposition]]), then it can be solved in polynomial time using dynamic programming. In general, the time required is polynomial in the graph size, but exponential in the branch-width. === Exact algorithms === [[Brute-force search]] for a ''k''-coloring considers each of the <math>k^n</math> assignments of ''k'' colors to ''n'' vertices and checks for each if it is legal. To compute the chromatic number and the chromatic polynomial, this procedure is used for every <math>k=1,\ldots,n-1</math>, impractical for all but the smallest input graphs. Using [[dynamic programming]] and a bound on the number of [[maximal independent set]]s, ''k''-colorability can be decided in time and space <math>O(2.4423^n)</math>.{{sfnp|Lawler|1976}} Using the principle of [[inclusion–exclusion]] and [[Frank Yates|Yates]]'s algorithm for the fast zeta transform, ''k''-colorability can be decided in time <math>O(2^n n)</math>{{sfnp|Björklund|Husfeldt|Koivisto|2009|page=550}}{{sfnp|Yates|1937|page=66-67}}{{sfnp|Knuth|1997|loc=Chapter 4.6.4, pp. 501-502}}{{sfnp|Koivisto|2004|pp=45, 96–103}} for any ''k''. Faster algorithms are known for 3- and 4-colorability, which can be decided in time <math>O(1.3289^n)</math>{{sfnp|Beigel|Eppstein|2005}} and <math>O(1.7272^n)</math>,{{sfnp|Fomin|Gaspers|Saurabh|2007}} respectively. Exponentially faster algorithms are also known for 5- and 6-colorability, as well as for restricted families of graphs, including sparse graphs.{{sfnp|Zamir|2021}} === Contraction === The [[contraction (graph theory)|contraction]] <math>G/uv</math> of a graph ''G'' is the graph obtained by identifying the vertices ''u'' and ''v'', and removing any edges between them. The remaining edges originally incident to ''u'' or ''v'' are now incident to their identification (''i.e.'', the new fused node ''uv''). This operation plays a major role in the analysis of graph coloring. The chromatic number satisfies the [[recurrence relation]]: : <math>\chi(G) = \text{min} \{ \chi(G+uv), \chi(G/uv)\}</math> due to {{harvtxt|Zykov|1949}}, where ''u'' and ''v'' are non-adjacent vertices, and <math>G+uv</math> is the graph with the edge {{mvar|uv}} added. Several algorithms are based on evaluating this recurrence and the resulting computation tree is sometimes called a Zykov tree. The running time is based on a heuristic for choosing the vertices ''u'' and ''v''. The chromatic polynomial satisfies the following recurrence relation : <math>P(G-uv, k)= P(G/uv, k)+ P(G, k)</math> where ''u'' and ''v'' are adjacent vertices, and <math>G-uv</math> is the graph with the edge {{mvar|uv}} removed. <math>P(G - uv, k)</math> represents the number of possible proper colorings of the graph, where the vertices may have the same or different colors. Then the proper colorings arise from two different graphs. To explain, if the vertices ''u'' and ''v'' have different colors, then we might as well consider a graph where ''u'' and ''v'' are adjacent. If ''u'' and ''v'' have the same colors, we might as well consider a graph where ''u'' and ''v'' are contracted. Tutte's curiosity about which other graph properties satisfied this recurrence led him to discover a bivariate generalization of the chromatic polynomial, the [[Tutte polynomial]]. These expressions give rise to a recursive procedure called the ''deletion–contraction algorithm'', which forms the basis of many algorithms for graph coloring. The running time satisfies the same recurrence relation as the [[Fibonacci numbers]], so in the worst case the algorithm runs in time within a polynomial factor of <math>\left(\tfrac{1+\sqrt{5}}2\right)^{n+m}=O(1.6180^{n+m})</math> for ''n'' vertices and ''m'' edges.{{sfnp|Wilf|1986}} The analysis can be improved to within a polynomial factor of the number <math>t(G)</math> of [[spanning tree (mathematics)|spanning trees]] of the input graph.{{sfnp|Sekine|Imai|Tani|1995}} In practice, [[branch and bound]] strategies and [[isomorphism|graph isomorphism]] rejection are employed to avoid some recursive calls. The running time depends on the heuristic used to pick the vertex pair. === Greedy coloring === {{Main|Greedy coloring}} [[File:Greedy colourings.svg|thumb|right|Two greedy colorings of the same graph using different vertex orders. The right example generalizes to 2-colorable graphs with ''n'' vertices, where the greedy algorithm expends <math>n/2</math> colors.]] The [[greedy algorithm]] considers the vertices in a specific order <math>v_1</math>, ..., <math> v_n</math> and assigns to <math>v_i</math> the smallest available color not used by <math>v_i</math>'s neighbours among <math>v_1</math>, ..., <math> v_{i-1}</math>, adding a fresh color if needed. The quality of the resulting coloring depends on the chosen ordering. There exists an ordering that leads to a greedy coloring with the optimal number of <math>\chi(G)</math> colors. On the other hand, greedy colorings can be arbitrarily bad; for example, the [[crown graph]] on ''n'' vertices can be 2-colored, but has an ordering that leads to a greedy coloring with <math>n/2</math> colors. For [[chordal graph]]s, and for special cases of chordal graphs such as [[interval graph]]s and [[indifference graph]]s, the greedy coloring algorithm can be used to find optimal colorings in polynomial time, by choosing the vertex ordering to be the reverse of a [[perfect elimination ordering]] for the graph. The [[perfectly orderable graph]]s generalize this property, but it is NP-hard to find a perfect ordering of these graphs. If the vertices are ordered according to their [[degree (graph theory)|degree]]s, the resulting greedy coloring uses at most <math>\text{max}_i \text{ min} \{d(x_i ) + 1, i\}</math> colors, at most one more than the graph's maximum degree. This heuristic is sometimes called the Welsh–Powell algorithm.{{sfnp|Welsh|Powell|1967}} Another heuristic due to [[Daniel Brélaz|Brélaz]] establishes the ordering dynamically while the algorithm proceeds, choosing next the vertex adjacent to the largest number of different colors.{{sfnp|Brélaz|1979}} Many other graph coloring heuristics are similarly based on greedy coloring for a specific static or dynamic strategy of ordering the vertices, these algorithms are sometimes called '''sequential coloring''' algorithms. The maximum (worst) number of colors that can be obtained by the greedy algorithm, by using a vertex ordering chosen to maximize this number, is called the [[Grundy number]] of a graph. === Heuristic algorithms === Two well-known polynomial-time heuristics for graph colouring are the [[DSatur]] and [[Recursive largest first algorithm|recursive largest first]] (RLF) algorithms. Similarly to the [[Greedy coloring|greedy colouring algorithm]], DSatur colours the [[Vertex (graph theory)|vertices]] of a [[Graph (graph theory)|graph]] one after another, expending a previously unused colour when needed. Once a new [[Vertex (graph theory)|vertex]] has been coloured, the algorithm determines which of the remaining uncoloured vertices has the highest number of different colours in its neighbourhood and colours this vertex next. This is defined as the ''degree of saturation'' of a given vertex. The [[recursive largest first algorithm]] operates in a different fashion by constructing each color class one at a time. It does this by identifying a [[maximal independent set]] of vertices in the graph using specialised heuristic rules. It then assigns these vertices to the same color and removes them from the graph. These actions are repeated on the remaining subgraph until no vertices remain. The worst-case complexity of DSatur is <math>O(n^2)</math>, where <math>n</math> is the number of vertices in the graph. The algorithm can also be implemented using a binary heap to store saturation degrees, operating in <math>O((n+m)\log n)</math> where <math>m</math> is the number of edges in the graph.{{sfnp|Lewis|2021}} This produces much faster runs with sparse graphs. The overall complexity of RLF is slightly higher than [[DSatur]] at <math>O(mn)</math>.{{sfnp|Lewis|2021}} DSatur and RLF are [[Exact algorithm|exact]] for [[bipartite graph|bipartite]], [[cycle graph|cycle]], and [[wheel graph]]s.{{sfnp|Lewis|2021}} === Parallel and distributed algorithms === <!-- [[Distributed graph coloring]] and [[Cole–Vishkin algorithm]] are redirects to this section --> It is known that a {{mvar|χ}}-chromatic graph can be {{mvar|c}}-colored in the deterministic LOCAL model, in <math>O(n^{1/\alpha})</math>. rounds, with <math>\alpha = \left\lfloor \frac{c - 1}{\chi - 1} \right\rfloor</math>. A matching lower bound of <math>\Omega(n^{1/\alpha})</math> rounds is also known. This lower bound holds even if quantum computers that can exchange quantum information, possibly with a pre-shared entangled state, are allowed. In the field of [[distributed algorithm]]s, graph coloring is closely related to the problem of [[symmetry breaking]]. The current state-of-the-art randomized algorithms are faster for sufficiently large maximum degree Δ than deterministic algorithms. The fastest randomized algorithms employ the [[multi-trials technique]] by Schneider and Wattenhofer.{{sfnp|Schneider|Wattenhofer|2010}} In a [[symmetric graph]], a [[deterministic algorithm|deterministic]] distributed algorithm cannot find a proper vertex coloring. Some auxiliary information is needed in order to break symmetry. A standard assumption is that initially each node has a ''unique identifier'', for example, from the set {{mset|1, 2, ..., ''n''}}. Put otherwise, we assume that we are given an ''n''-coloring. The challenge is to ''reduce'' the number of colors from ''n'' to, e.g., Δ + 1. The more colors are employed, e.g. ''O''(Δ) instead of Δ + 1, the fewer communication rounds are required.{{sfnp|Schneider|Wattenhofer|2010}} A straightforward distributed version of the greedy algorithm for (Δ + 1)-coloring requires Θ(''n'') communication rounds in the worst case – information may need to be propagated from one side of the network to another side. The simplest interesting case is an ''n''-[[cycle graph|cycle]]. Richard Cole and [[Uzi Vishkin]]<ref>{{harvtxt|Cole|Vishkin|1986}}, see also {{harvtxt|Cormen|Leiserson|Rivest|1990|loc = Section 30.5}}.</ref> show that there is a distributed algorithm that reduces the number of colors from ''n'' to ''O''(log ''n'') in one synchronous communication step. By iterating the same procedure, it is possible to obtain a 3-coloring of an ''n''-cycle in ''O''({{log-star}} ''n'') communication steps (assuming that we have unique node identifiers). The function {{log-star}}, [[iterated logarithm]], is an extremely slowly growing function, "almost constant". Hence the result by Cole and Vishkin raised the question of whether there is a ''constant-time'' distributed algorithm for 3-coloring an ''n''-cycle. {{harvtxt|Linial|1992}} showed that this is not possible: any deterministic distributed algorithm requires Ω({{log-star}} ''n'') communication steps to reduce an ''n''-coloring to a 3-coloring in an ''n''-cycle. The technique by Cole and Vishkin can be applied in arbitrary bounded-degree graphs as well; the running time is poly(Δ) + ''O''({{log-star}} ''n'').{{sfnp|Goldberg|Plotkin|Shannon|1988}} The technique was extended to [[unit disk graph]]s by Schneider and Wattenhofer.{{sfnp|Schneider|Wattenhofer|2008}} The fastest deterministic algorithms for (Δ + 1)-coloring for small Δ are due to Leonid Barenboim, Michael Elkin and Fabian Kuhn.<ref>{{harvtxt|Barenboim|Elkin|2009}}; {{harvtxt|Kuhn|2009}}.</ref> The algorithm by Barenboim et al. runs in time ''O''(Δ) + {{log-star}}(''n'')/2, which is optimal in terms of ''n'' since the constant factor 1/2 cannot be improved due to Linial's lower bound. {{harvtxt|Panconesi|Srinivasan|1996}} use network decompositions to compute a Δ+1 coloring in time <math> 2 ^{O\left(\sqrt{\log n}\right)} </math>. The problem of edge coloring has also been studied in the distributed model. {{harvtxt|Panconesi|Rizzi|2001}} achieve a (2Δ − 1)-coloring in ''O''(Δ + {{log-star}} ''n'') time in this model. The lower bound for distributed vertex coloring due to {{harvtxt|Linial|1992}} applies to the distributed edge coloring problem as well. === Decentralized algorithms === Decentralized algorithms are ones where no [[message passing]] is allowed (in contrast to distributed algorithms where local message passing takes places), and efficient decentralized algorithms exist that will color a graph if a proper coloring exists. These assume that a vertex is able to sense whether any of its neighbors are using the same color as the vertex i.e., whether a local conflict exists. This is a mild assumption in many applications e.g. in wireless channel allocation it is usually reasonable to assume that a station will be able to detect whether other interfering transmitters are using the same channel (e.g. by measuring the SINR). This sensing information is sufficient to allow algorithms based on learning automata to find a proper graph coloring with probability one.<ref>E.g. see {{harvtxt|Leith|Clifford|2006}} and {{harvtxt|Duffy|O'Connell|Sapozhnikov|2008}}.</ref> === Computational complexity === Graph coloring is computationally hard. It is [[NP-complete]] to decide if a given graph admits a ''k''-coloring for a given ''k'' except for the cases ''k'' ∈ {{brace|0,1,2}}. In particular, it is NP-hard to compute the chromatic number.<ref>{{harvtxt|Garey|Johnson|Stockmeyer|1974}}; {{harvtxt|Garey|Johnson|1979}}.</ref> The 3-coloring problem remains NP-complete even on 4-regular [[planar graph]]s.{{sfnp|Dailey|1980}} On graphs with maximal degree 3 or less, however, [[Brooks' theorem]] implies that the 3-coloring problem can be solved in linear time. Further, for every ''k'' > 3, a ''k''-coloring of a planar graph exists by the [[four color theorem]], and it is possible to find such a coloring in polynomial time. However, finding the [[lexicographic order|lexicographically]] smallest 4-coloring of a planar graph is NP-complete.{{sfnp|Khuller|Vazirani|1991}} The best known [[approximation algorithm]] computes a coloring of size at most within a factor ''O''(''n''(log log ''n'')<sup>2</sup>(log n)<sup>−3</sup>) of the chromatic number.{{sfnp|Halldórsson|1993}} For all ''ε'' > 0, approximating the chromatic number within ''n''<sup>1−''ε''</sup> is [[NP-hard]].{{sfnp|Zuckerman|2007}} It is also NP-hard to color a 3-colorable graph with 5 colors,{{sfnp|Bulín|Krokhin|Opršal|2019}} 4-colorable graph with 7 colours,{{sfnp|Bulín|Krokhin|Opršal|2019}} and a ''k''-colorable graph with <math>\textstyle\binom k {\lfloor k/2 \rfloor} - 1</math> colors for ''k'' ≥ 5.{{sfnp|Wrochna|Živný|2020}} Computing the coefficients of the chromatic polynomial is [[Sharp-P-complete|♯P-hard]]. In fact, even computing the value of <math>\chi(G,k)</math> is ♯P-hard at any [[rational point]] ''k'' except for ''k'' = 1 and ''k'' = 2.{{sfnp|Jaeger|Vertigan|Welsh|1990}} There is no [[FPRAS]] for evaluating the chromatic polynomial at any rational point ''k'' ≥ 1.5 except for ''k'' = 2 unless [[NP (complexity)|NP]] = [[RP (complexity)|RP]].{{sfnp|Goldberg|Jerrum|2008}} For edge coloring, the proof of Vizing's result gives an algorithm that uses at most Δ+1 colors. However, deciding between the two candidate values for the edge chromatic number is NP-complete.{{sfnp|Holyer|1981}} In terms of approximation algorithms, Vizing's algorithm shows that the edge chromatic number can be approximated to within 4/3, and the hardness result shows that no (4/3 − ''ε'')-algorithm exists for any ''ε > 0'' unless [[P = NP]]. These are among the oldest results in the literature of approximation algorithms, even though neither paper makes explicit use of that notion.{{sfnp|Crescenzi|Kann|1998}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)