Coloring Triangle-Free Graphs on Surfaces

Gimbel and Thomassen asked whether 3-colorability of a triangle-free graph drawn on a fixed surface can be tested in polynomial time. We settle the question by giving a linear-time algorithm for every surface which combined with previous results gives a lineartime algorithm to compute the chromatic number of such graphs. Our algorithm is based on a structure theorem that for a triangle-free graph drawn on a surface Σ guarantees the existence of a subgraph H, whose size depends only on Σ, such that there is an easy test whether a 3-coloring of H extends to a 3-coloring of G. The test is based on a topological obstruction, called the "winding number" of a 3-coloring. To prove the structure theorem we make use of disjoint paths with specified ends to find a 3-coloring. If the input triangle-free graph G drawn in Σ is 3-colorable we can find a 3-coloring in quadratic time, and if G quadrangulates Σ then we can find the 3-coloring in linear time. The latter algorithm requires two ingredients that may be of independent interest: a generalization of a data structure of Kowalik and Kurowski to weighted graphs and a speedup of a disjoint paths algorithm of Robertson and Seymour to linear time.