Multiple authors, beginning with Lipton and Miller in 1978, have studied efficient algorithms for five-coloring planar graphs. The algorithm of Lipton and Miller took time O(n\log n), but subsequent researchers reduced the time bound to O(n). The version below is from a 1996 paper by Robertson, Sanders, Seymour, and Thomas, which describes it briefly in connection with a slower O(n^2)-time algorithm for four-coloring. The algorithm as described here operates on multigraphs and relies on the ability to have multiple copies of edges between a single pair of vertices. It is based on
Wernicke's theorem, which states the following: :'''Wernicke's theorem
: Assume G
is planar, nonempty, has no faces bounded by two edges, and has minimum degree 5. Then G''' has a vertex of degree 5 which is adjacent to a vertex of degree at most 6. We will use a representation of the graph in which each vertex maintains a circular
linked list of adjacent vertices, in clockwise planar order. In concept, the algorithm is recursive, reducing the graph to a smaller graph with one less vertex, five-coloring that graph, and then using that coloring to determine a coloring for the larger graph in constant time. In practice, rather than maintain an explicit graph representation for each reduced graph, we will remove vertices from the graph as we go, adding them to a stack, then color them as we pop them back off the stack at the end. We will maintain three stacks: • S4: Contains all remaining vertices with either degree at most four, or degree five and at most four distinct adjacent vertices (due to
multiple edges). • S5: Contains all remaining vertices that have degree five, five distinct adjacent vertices, and at least one adjacent vertex with degree at most six. • Sd: Contains all vertices deleted from the graph so far, in the order that they were deleted. The algorithm works as follows: • In the first step, we collapse all multiple edges to single edges, so that the graph is simple. Next, we iterate over the vertices of the graph, pushing any vertex matching the conditions for S4 or S5 onto the appropriate stack. • Next, as long as S4 is non-empty, we pop
v from S4 and delete
v from the graph, pushing it onto Sd, along with a list of its neighbors at this point in time. We check each former neighbor of
v, pushing it onto S4 or S5 if it now meets the necessary conditions. • When S4 becomes empty, we know that our graph has minimum degree five. If the graph is empty, we go to the final step 5 below. Otherwise, Wernicke's Theorem tells us that S5 is nonempty. Pop
v off S5, delete it from the graph, and let
v1,
v2,
v3,
v4,
v5 be the former neighbors of
v in clockwise planar order, where
v1 is the neighbor of degree at most 6. We check if
v1 is adjacent to
v3 (which we can do in constant time due to the degree of
v1). There are two cases: • If
v1 is not adjacent to
v3, we can merge these two vertices into a single vertex. To do this, we remove
v from both circular adjacency lists, and then splice the two lists together into one list at the point where
v was formerly found. Provided that
v maintains a reference to its position in each list, this can be done in constant time. It's possible that this might create faces bounded by two edges at the two points where the lists are spliced together; we delete one edge from any such faces. After doing this, we push
v3 onto Sd, along with a note that
v1 is the vertex that it was merged with. Any vertices affected by the merge are added or removed from the stacks as appropriate. • Otherwise,
v2 lies inside the face outlined by
v,
v1, and
v3. Consequently,
v2 cannot be adjacent to
v4, which lies outside this face. We merge
v2 and
v4 in the same manner as
v1 and
v3 above. • Go to step 2. • At this point S4, S5, and the graph are empty. We pop vertices off Sd. If the vertex were merged with another vertex in step 3, the vertex that it was merged with will already have been colored, and we assign it the same color. This is valid because we only merged vertices that were not adjacent in the original graph. If we had removed it in step 2 because it had at most 4 adjacent vertices, all of its neighbors at the time of its removal will have already been colored, and we can simply assign it a color that none of its neighbors is using. ==Alternate proof==