Misplaced Pages

Recursive largest first algorithm

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Algorithm for graph coloring

The Recursive Largest First (RLF) algorithm is a heuristic for the NP-hard graph coloring problem. It was originally proposed by Frank Leighton in 1979.

The RLF algorithm assigns colors to a graph’s vertices by constructing each color class one at a time. It does this by identifying a maximal independent set of vertices in the graph, assigning these to the same color, and then removing these vertices from the graph. These actions are repeated on the remaining subgraph until no vertices remain.

To form high-quality solutions (solutions using few colors), the RLF algorithm uses specialized heuristic rules to try to identify "good quality" independent sets. These heuristics make the RLF algorithm exact for bipartite, cycle, and wheel graphs. In general, however, the algorithm is approximate and may well return solutions that use more colors than the graph’s chromatic number.

Description

The algorithm can be described by the following three steps. At the end of this process, S {\displaystyle {\mathcal {S}}} gives a partition of the vertices representing a feasible | S | {\displaystyle |{\mathcal {S}}|} -colouring of the graph G {\displaystyle G} .

  1. Let S = {\displaystyle {\mathcal {S}}=\emptyset } be an empty solution. Also, let G = ( V , E ) {\displaystyle G=(V,E)} be the graph we wish to color, comprising a vertex set V {\displaystyle V} and an edge set E {\displaystyle E} .
  2. Identify a maximal independent set S V {\displaystyle S\subseteq V} . To do this:
    1. The first vertex added to S {\displaystyle S} should be the vertex in G {\displaystyle G} that has the largest number of neighbors.
    2. Subsequent vertices added to S {\displaystyle S} should be chosen as those that (a) are not currently adjacent to any vertex in S {\displaystyle S} , and (b) have a maximal number of neighbors that are adjacent to vertices in S {\displaystyle S} . Ties in condition (b) can be broken by selecting the vertex with the minimum number of neighbors not in S {\displaystyle S} . Vertices are added to S {\displaystyle S} in this way until it is impossible to add further vertices.
  3. Now set S = S { S } {\displaystyle {\mathcal {S}}={\mathcal {S}}\cup \{S\}} and remove the vertices of S {\displaystyle S} from G {\displaystyle G} . If G {\displaystyle G} still contains vertices, then return to Step 2; otherwise end.

Example

A wheel graph with seven vertices

Consider the graph G = ( V , E ) {\displaystyle G=(V,E)} shown on the right. This is a wheel graph and will therefore be optimally colored by RLF. Executing the algorithm results in the vertices being selected and colored in the following order:

  1. Vertex g {\displaystyle g} (color 1)
  2. Vertex a {\displaystyle a} , c {\displaystyle c} , and then e {\displaystyle e} (color 2)
  3. Vertex b {\displaystyle b} , d {\displaystyle d} , and then f {\displaystyle f} (color 3)

This gives the final three-colored solution S = { { g } , { a , c , e } , { b , d , f } } {\displaystyle {\mathcal {S}}=\{\{g\},\{a,c,e\},\{b,d,f\}\}} .

Performance

Let n {\displaystyle n} be the number of vertices in the graph and let m {\displaystyle m} be the number of edges. Using big O notation, in his original publication Leighton states the complexity of RLF to be O ( n 3 ) {\displaystyle {\mathcal {O}}(n^{3})} ; however, this can be improved upon. Much of the expense of this algorithm is due to Step 2, where vertex selection is made according to the heuristic rules stated above. Indeed, each time a vertex is selected for addition to the independent set S {\displaystyle S} , information regarding the neighbors needs to be recalculated for each uncolored vertex. These calculations can be performed in O ( m ) {\displaystyle {\mathcal {O}}(m)} time, meaning that the overall complexity of RLF is O ( m n ) {\displaystyle {\mathcal {O}}(mn)} .

If the heuristics of Step 2 are replaced with random selection, then the complexity of this algorithm reduces to O ( n + m ) {\displaystyle {\mathcal {O}}(n+m)} ; however, the resultant algorithm will usually return lower quality solutions compared to those of RLF. It will also now be inexact for bipartite, cycle, and wheel graphs.

In an empirical comparison by Lewis in 2021, RLF was shown to produce significantly better vertex colorings than alternative heuristics such as the O ( n + m ) {\displaystyle {\mathcal {O}}(n+m)} greedy algorithm and the O ( ( n + m ) lg n ) {\displaystyle {\mathcal {O}}((n+m)\lg n)} DSatur algorithm on random graphs. However, runtimes with RLF were also seen to be higher than these alternatives due to its higher overall complexity.

References

  1. Leighton, F. (1979). "A graph coloring algorithm for large scheduling problems". Journal of Research of the National Bureau of Standards. 84 (6): 489–503. doi:10.6028/jres.084.024. PMC 6756213. PMID 34880531.
  2. ^ Lewis, R. (2021). A Guide to Graph Colouring: Algorithms and Applications. Texts in Computer Science. Springer. doi:10.1007/978-3-030-81054-2. ISBN 978-3-030-81053-5. S2CID 57188465.

External links

Categories: