An on-line competitive algorithm for coloring bipartite graphs without long induced paths

The existence of an on-line competitive algorithm for coloring bipartite graphs remains a tantalizing open problem. So far there are only partial positive results for bipartite graphs with certain small forbidden graphs as induced subgraphs. We propose a new on-line competitive coloring algorithm for $P_9$-free bipartite graphs.


Introduction
A proper coloring of a graph is an assignment of colors to its vertices such that adjacent vertices receive distinct colors. It is easy to devise an (linear time) algorithm for 2-coloring bipartite graphs. Now, imagine that an algorithm receives vertices of a graph one by one knowing only the adjacency status of the vertex to vertices presented so far. The color of the current vertex must be fixed by the algorithm before the next vertex is revealed and it cannot be changed afterwards. This kind of algorithm is called an on-line coloring algorithm.
Formally, an on-line graph (G, π) is a graph G with a permutation π of its vertices. An on-line coloring algorithm A takes an on-line graph (G, π), say π = (v 1 , . . . , v n ), as an input. It produces a proper coloring of the vertices of G where the color of a vertex v i , for i = 1, . . . , n, depends only on the subgraph of G induced by v 1 , . . . , v i . It is convenient to imagine that consecutive vertices along π are revealed by some adaptive (malicious) adversary and the coloring process is a game between that adversary and the on-line algorithm.
Still, it is an easy exercise to show that if an adversary presents a bipartite graph and all the time the graph presented so far is connected then there is an on-line algorithm 2-coloring these graphs. But if an adversary can present a bipartite graph without any additional constraints then (s)he can trick out any on-line algorithm to use an arbitrary number of colors! Indeed, there is a strategy for adversary forcing any on-line algorithm to use at least log n + 1 colors on a forest of size n. On the other hand, the First-Fit algorithm (that is an on-line algorithm coloring each incoming vertex with the least admissible natural number) uses at most log n + 1 colors on forests of size n. When the game is played on bipartite graphs, an adversary can easily trick out First-Fit and force n 2 colors on a bipartite graph of size n. Lovász, Saks and Trotter [12] proposed a simple on-line algorithm (in fact as an exercise; see also [8]) using at most 2 log n + 1 colors on bipartite graphs of size n. This is best possible up to an additive constant as Gutowski et al. [4] showed that there is a strategy for adversary forcing any on-line algorithm to use at least 2 log n − 10 colors on a bipartite graph of size n.
For an on-line algorithm A by A(G, π) we mean the number of colors that A uses against an adversary presenting graph G with presentation order π.
An on-line coloring algorithm A is competitive on a class of graphs G if there is a function f such that for every G ∈ G and permutation π of vertices of G we have A(G, π) f (χ(G)). As we have discussed, there is no competitive coloring algorithm for forests. But there are reasonable classes of graphs admitting competitive algorithms, e.g., interval graphs can be colored on-line with at most 3χ − 2 colors (where χ is the chromatic number of the presented graph; see [11]) and cocomparability graphs can be colored on-line with a number of colors bounded by a tower function in terms of χ (see [9]). Also classes of graphs defined in terms of forbidden induced subgraphs were investigated in this context. For example, P 4 -free graphs (also known as cographs) are colored by First-Fit optimally, i.e. with χ colors, since any maximal independent set meets all maximal cliques in a P 4 -free graph. Also P 5 -free graphs can be colored on-line with O(4 χ ) colors (see [10]). And to complete the picture there is no competitive algorithm for P 6 -free graphs as Gyárfás and Lehel [6] showed a strategy for adversary forcing any on-line algorithm to use an arbitrary number of colors on bipartite P 6 -free graphs.
Confronted with so many negative results, it is not surprising that Gyárfás, Király and Lehel [5] introduced a relaxed version of competitiveness for on-line algorithms. The idea is to measure the efficiency of an on-line algorithm by comparing it to the best on-line algorithm for a given input (instead of the chromatic number). Hence, the on-line chromatic number of a graph G is defined as where the infimum is taken over all on-line algorithms A and the maximum is taken over all permutation π of vertices of G. An on-line algorithm A is on-line competitive for a class of graphs G, if there is a function f such that for every G ∈ G and permutation π of vertices of G we have A(G, π) f (χ * (G)).
Why are on-line competitive algorithms interesting? Imagine that you design an algorithm and the input graph is not known in advance. If your algorithm is on-line competitive then you have an insurance that whenever your algorithm uses many colors on some graph G with presentation order π then any other on-line algorithm may be also forced to use many colors on the same graph G with some presentation order π (and it includes also those on-line algorithms which are designed only for this single graph G!). The idea of comparing the outputs of two on-line algorithms directly (not via the optimal off-line result) is present in the literature. We refer the reader to [1], where a number of measures are discussed in the context of on-line bin packing problems. In particular, the relative worst case ratio, introduced there, is closely related to our setting for on-line colorings.
It may be true that there is an on-line competitive algorithm for all graphs. This is open, as well as for the class of all bipartite graphs. To the best of the authors knowledge, there is no promissing approach for the negative answer for these questions. However, there are some partial positive results. Gyárfás and Lehel [7] have shown that First-Fit is on-line competitive for forests and it is even optimal in the sense that if First-Fit uses k colors on G then the on-line chromatic number of G is k as well. They also have shown [5] that First-Fit is competitive (with an exponential bounding function) for graphs of girth at least 5. Finally, Broersma, Capponi and Paulusma [3] proposed an on-line coloring algorithm for P 7free bipartite graphs using at most 8χ * + 8 colors on graphs with on-line chromatic number χ * .
The contribution of this paper is the following theorem.

Theorem 1.
There is an on-line competitive algorithm coloring P 9 -free bipartite graphs and using at most 6(χ * + 1) 2 colors, where χ * is the on-line chromatic number of the presented graph.
Note that this is a full version of [13] published in the proceedings of ISAAC 2014. In [13], we discuss how our techniques simplify results for P 7 -free bipartite graphs. Already in [13], we presented Algorithm 1 with a proof that it is on-line competitive for P 8 -free bipartite graphs. (This may be a good warmup or source of extra intuitions behind the argument in this paper.)

Forcing structure
In this section we introduce a family of bipartite graphs without long induced paths (P 6 -free) and with arbitrarily large on-line chromatic number. Our on-line algorithm, Algorithm 1 has the property that whenever it uses many colors on a graph G then G has a large graph from our family as an induced subgraph and therefore G has a large on-line chromatic number, as desired.
A connected bipartite graph G has a unique partition of vertices into two independent sets. We call these partition sets the sides of G. A vertex v in a bipartite graph G is universal to a subgraph C of G if v is adjacent to all vertices of C in one of the sides of G.
Consider a family of connected bipartite graphs {X k } k 1 defined recursively as follows. Each X k has a distinguished vertex called the root. The side of X k containing the root of X k , we call the root side of X k , while the other side we call the non-root side. X 1 is a single vertex being the root. X 2 is a single edge with one of its vertices being the root. X k , for k 3, is a graph formed by two disjoint copies of X k−1 , say X 1 k−1 and X 2 k−1 , with no edge between the copies, and one extra vertex v adjacent to all vertices on the root side of X 1 k−1 and all vertices on the non-root side of X 2 k−1 . The vertex v is the root of X k . Note that for each k, the root of X k is adjacent to the whole non-root side of X k , i.e., the root of X k is universal in X k . See Figure 1 for an schematic illustration of the definition of X k .
A family of P 6 -free bipartite graphs with arbitrarily large on-line chromatic number was first presented in [6]. The family {X k } k 1 was already studied in [2], in Figure 1. Family of bipartite graphs particular Claim 3 is proved there. We encourage the reader to verify that X k is P 6 -free for k 1.
Claim 2. Let k 2. Then, for every binary sequence α 1 , . . . , α k−1 , there are copies Y 1 , . . . , Y k−1 of X 1 , . . . , X k−1 contained as induced subgraphs in X k , on pairwise disjoint sets of vertices and with no edges between the copies, such that for every Proof. We prove the lemma by induction on k. For the base case k = 2, fix α 1 ∈ {0, 1}. Now, X 2 is an edge and put Y 1 as a single vertex being the root of X 2 if α 1 = 1 and being the other vertex if α 1 = 0. So suppose k 3. By the definition X k consists of two independent copies X 1 k−1 and X 2 k−1 of X k−1 and a root vertex that is universal to the root side of X 1 k−1 and to the non-root side of X 2 k−1 . Let us first consider the case α k−1 = 0. Then X 1 k−1 is a copy of X k−1 with the non-root on the desired side of X k . On X 2 k−1 we apply induction for the sequence α 1 , . . . , α k−2 and find Y 1 , . . . , Y k−2 copies of X 1 , . . . , X k−2 as induced subgraphs of X 2 k−1 that are pairwise disjoint with no edges between the copies and clearly no edges to X 1 k−1 as well. Since the root side of X 2 k−1 is contained in the root side of X k we have that for all i ∈ {1, . . . , k − 2} the sides of the roots of Y i are in the root side of X k if and only if α i = 1.
The case α k−1 = 1 is similar with the difference that we use X 2 k−1 as a copy of X k−1 and that we apply induction on X 1 k−1 for the sequence α 1 , . . . , α k−2 . Claim 3. If G contains X k as an induced subgraph, then χ * (G) k.
Proof. Let A be any on-line coloring algorithm. We prove by induction on k that the adversary can present the vertices of G such that A uses at least k colors. It is clear that any coloring algorithm has to use one color for X 1 and two colors for X 2 . So suppose that k 3. Adversary starts with presenting disjoint copies Y 1 , . . . , Y k−1 of X 1 , . . . , X k−1 one after another, with no edges between the copies, and by induction he can do this in such a way that A uses i colors on Y i , for i ∈ {1, . . . , k − 1}. Therefore there are distinct colors c 1 , . . . , c k−1 such that c i is used on Y i for every i and let v i ∈ Y i be a vertex colored with c i . Then we set α i = 1 if v i is on the non-root side of Y i and α i = 0 otherwise. Now we explain how to embed Y 1 , . . . , Y k−1 into G. Let v be the root of the induced copy of X k contained in G. By Claim 2 there are pairwise disjoint induced copies of X 1 . . . , X k−1 in X k with no edges between the copies, such that for all i ∈ {1, . . . , k − 1} the root of X i is on the same side as v if and only if α i = 1. Adversary identifies those copies with Y 1 , . . . , Y k−1 . By the choice of α i it follows that v i is on the non-root side of X k , for all i ∈ {1, . . . , k − 1}. Since v is universal in X k , it is adjacent to v i for all i.
After presenting all Y 1 , . . . , Y k−1 the adversary introduces vertex v, being the root of X k in G and forces A to use a color different from c 1 , . . . , c k−1 .

The proof
We present a new on-line algorithm for bipartite graphs, Algorithm 1, and we prove that this algorithm is on-line competitive for P 9 -free bipartite graphs.
Algorithm 1 uses three disjoint pallettes of colors, {a n } n 1 , {b n } n 1 and {c n } n 1 . In the following whenever the algorithm fixes a color of a vertex v we are going to refer to it by color(v). Also for any set of vertices X we denote color(X) = {color(x) | x ∈ X}. We say that v has color index i if color(v) ∈ {a i , b i }.
Suppose an adversary presents a new vertex v of a bipartite graph G. Then let G i [v] be the subgraph spanned by the vertices presented so far and colored with a color from {a 1 , . . . , a i , b 1 , . . . , b i , c 1 , . . . , c i } and vertex v, which is uncolored We say that a color c is mixed in a connected subgraph C of G if c is used on vertices on both sides of C.  Proof. Suppose an adversary introduces a vertex v of a bipartite graph G. We have to show that Algorithm 1 colors v properly, i.e., no vertex presented before v and adjacent to v has the same color as v. Let k 1 be the color index of v and (I 1 , I 2 ) be the bipartition of C k [v] such that v ∈ I 1 . If color(v) = a k , then there is no vertex in I 2 colored with a k because of the first if-condition. In particular, no neighbor of v is colored with a k .
If v is colored with b k , then there is a vertex u ∈ I 2 with color(u) = a k . Suppose v is not colored properly, which means that there is a vertex w ∈ I 2 with color b k . When w was introduced, there must have been a vertex u on the other side of w in C k [w] with color(w) = a k . Since C k [w] ⊆ C k [v] it follows that u ∈ I 1 . But then u and u certify that color a k is mixed in C k [v], which contradicts the fact that the color index of v is k.
We are left with the case that v is colored with c k . Because of the second ifcondition in the algorithm, a vertex can only get color c k if there is no vertex in I 2 colored in c k , so in particular no neighbor of v is colored with c k .
The following claim, captures an idea behind maintaining the first two pallettes of colors (the a i 's and b i 's). Namely, to force a single a i -color to be mixed we need to introduce a vertex merging two components. This idea is already present in previous works [2,3].
Claim 5. Suppose an adversary presents a bipartite graph G to Algorithm 1. Let v ∈ V (G) and let x, y be two vertices from opposite sides of C i [v] both colored with a i with i 1. Then x and y lie in different connected components of C i (v).
Proof. Let v, x and y be like in the statement of the claim. We are going to prove that at any moment after the introduction of x and y, x and y lie in different connected components of the subgraph spanned by vertices colored with a 1 , b 1 , c 1 . . . , a i , b Say x is presented before y. First note that x ∈ C i [y] as otherwise x had to be on the opposite side to y (because it is on the opposite side at the time v is presented) and therefore y would receive color b i . Now consider any vertex w presented after y and suppose the statement is true before w is introduced.
then whatever color is used for w this vertex does not merge the components of x and y in the subgraph spanned by vertices presented so far and colored with . This means that color a i is mixed in C i [w] and therefore w receives a color with an index at least i + 1. Thus, the subgraph spanned by the vertices of the colors a 1 , b 1 , c 1 . . . , a i , b i , c i stays the same and x and y remain in different connected components of this graph.
Since all vertices in C i (v) are colored with a 1 , b 1 , c 1 . . . , a i , b i , c i , we conclude that x and y lie in different components of C i (v).
Consider a vertex v with a color index k 2. Let v 1 , v 2 be the earliest introduced vertices from the opposite sides of C k−1 (v), colored with a k−1 (so witnessing that a k−1 is mixed). We call v 1 and v 2 the children of v. By Claim 5 it follows that C v1 k−1 (v) and C v2 k−1 (v) are distinct (so disjoint and no edge is between them). Suppose that an adversary presents a graph G which is P 9 -free. Consider v ∈ V (G) with color index k 3 and v 1 , v 2 children of v. Note that, at least one of does not contain an induced P 5 with one endpoint in v. Indeed, the join of two such paths at v would end up in an induced P 9 , which is forbidden in G. Choose arbitrarily a component C vi k−1 [v] with no induced P 5 ending at v and let v i,1 , v i,2 be the children of v i . We call v i,1 and v i,2 the grandchildren of v.
The next claim describes a property of a component containing grandchildren of a given vertex, namely, under certain condition we win a universal vertex to a subcomponent. The usage of the third pallette of colors, the c i 's, is inspired by this property.
Claim 6. Suppose an adversary presents a P 9 -free bipartite graph G to Algorithm 1. Let x be a vertex with color index i 2. Suppose that vertex y ∈ C i−1 (x), with color index j, lies on the other side of x in G and y is not adjacent to x. If there is no induced path of length 5 in C y i−1 [x] with one endpoint in x, then x has a neighbor in C y i−1 (x) that is universal to C j−1 [y]. Proof. We can assume that y has color index j 2, as otherwise C j−1 [y] = C 0 [y] = {y} and vacuously any neighbor of x is universal to C j−1 [y] (as the side it should be adjacent to is empty).
First, let us consider the case that x has a neighbor z in C j−1 [y] ⊆ C y i−1 (x) (see Figure 2 for this case). Since x and y are not adjacent we have y = z. As C z j−1 [y] is connected, there is an induced path P connecting x and y that has only vertices of C z j−1 (y) as inner vertices. Clearly, P has even length at least 4. Now the color index of y, namely j 2, assures the existence of a mixed pair coloered with a j−1 in C j−1 [y] and with Claim 5 it follows that C j−1 (y) has at least two connected components. In particular, there is a component C of C j−1 (y) other than C z j−1 (y). Clearly, y has a neighbor z in C , which we use to prolong P at y. Since there is no edge between C z j−1 (y) and C , vertex z is not adjacent to the inner vertices of P . And as G is bipartite z cannot be adjacent to x. We conclude the existence of an induced path of length 5 in C y i−1 [x] with x and z being its endpoints, a contradiction.
Second, we consider the case that x has no neighbor in C j−1 [y]. By our assumptions a shortest path connecting x and y in C y i−1 [x] must have length exactly 4. Let P = (x, r, s, y) be such a path. We claim that vertex r is universal to C j−1 [y]. Suppose to contrary that there is a vertex s in C j−1 [y] which is on the other side of y and which is not adjacent to r. Let Q = (y, s 1 , r 1 , . . . , s −1 , r −1 , s = s ) be a shortest path connecting y and s in C j−1 [y]. For convenience put s 0 = s. Now we choose the minimal m 0 such that r is adjacent to s m but not to s m+1 . Such an m exists since r is adjacent to s 0 = s but not to s . If m = 0 then the path (x, r, s, y, s 1 ) is an induced path of length 5 and if m > 0 then the path (x, r, s m , r m , s m+1 ) has length 5 and is induced unless x and r m are adjacent. But the latter is not possible since x has no neighbor in C j−1 [y]. Thus, in both cases we get a contradiction and we conclude that r is universal to C j−1 [y].
In the following we write v → i w for v, w ∈ V (G), if there is a sequence v = x 1 , . . . , x j = w with j i and x +1 is a grandchild of x , for all ∈ {1, . . . , j − 1}.
We make some immediate observations concerning this definition. Let v ∈ V (G) be a vertex with color index k 3. Then each w ∈ S i (v) has color index at least k − 2i + 2 and the component C w k−1 (v) does not contain an induced P 5 with one endpoint in v. Furthermore, each vertex in S i (v) is connected to v by a path in G and all vertices in the path, except v, have color index at most k − 1. This proves that S i (v) ⊆ C k−1 [v], for all i 1. Note also that if v 1 and v 2 are the grandchildren of v then we have . By Claim 5, we get that C v1 k−2 (v ) and C v2 k−2 (v ) are distinct. In particular, S i−1 (v 1 ) and S i−1 (v 2 ) are disjoint and there is no edge between them.
For a vertex v ∈ V (G), S i (v) is complete in G if for every u, w ∈ S i (v) such that u → i w and u, w lying on opposite sides of G, we have u and w being adjacent in G. Note that v is a universal vertex in S i (v), provided S i (v) is complete.
Claim 7. Suppose an adversary presents a bipartite graph G to Algorithm 1. Let v ∈ V (G) be a vertex with color index k and let k 2i 2. If S i (v) is complete then S i (v) contains an induced copy of X i in G with v being the root of the copy.
Proof. We prove the claim by induction on i. For i = 1 we work with S 1 (v) and X 1 being graphs with one vertex only, so the statement is trivial. For i 2, let v 1 and v 2 be the grandchildren of v.
is complete it also follows that S i−1 (v 1 ) and S i−1 (v 2 ) are complete. So by the induction hypothesis there are induced copies X 1 i−1 , X 2 i−1 of X i−1 in S i−1 (v 1 ) and S i−1 (v 2 ), respectively, and rooted in v 1 , v 2 , respectively. Recall that S i−1 (v 1 ) and S i−1 (v 2 ) are disjoint and there is no edge between them. Thus, the copies X 1 i−1 and X 2 i−1 of X i−1 are disjoint and there is no edge between them, as well. Since S i (v) is complete v is universal to both of the copies, and since v 1 and v 2 lie on opposite sides in G we get that the vertices of Claim 8. Suppose an adversary presents a P 9 -free bipartite graph G to Algorithm 1 and suppose vertex v is colored with a k and k 2. Then C k [v] contains an induced copy of X √ k/2 such that its root lies on the same side as v in G.
Proof. We prove the claim by induction on k. For k = 2 the statement is trivial. So suppose that k 3. If S √ k/2 (v) is complete then by Claim 7 we get an induced copy of X √ k/2 with a root mapped to v, as required. From now on we assume that S √ k/2 (v) is not complete. Let (I 1 , I 2 ) be the bipartition of C k [v] such that v ∈ I 1 . First, we will prove that there are vertices z, z ∈ C k [v] such that z ∈ I 1 , z has color index k − √ 2k + 2 and z is universal to C −1 [z]. To do so we consider the reason why Algorithm 1 colors v with a k .
The first possibility is that the second if-condition of the algorithm is satisfied, that is, there is a vertex u ∈ I 2 colored with c k . Now u can only receive color c k if there are vertices w, w ∈ C k [u] such that w is on the other side of u in C k [u], w has color index j k − √ 2k + 2 and w is universal to C j−1 [w]. Since C k (u) ⊆ C k (v) and u ∈ I 2 we have w ∈ I 1 . Therefore, z = w and z = w are vertices we are looking for.
The second reason for coloring v with a k could be that Algorithm 1 reaches its last line. In particular this means, that there is no vertex of color a k or c k in I 2 . Now we are going to make use of the fact that S √ k/2 (v) is not complete. There are vertices x, y ∈ S √ k/2 (v) ⊆ C k [v] such that x → √ k/2 y, the vertices x and y lie on different sides of C k [v] and are not adjacent. Let i and j be the color indices of x and y, respectively. Note that k i > j k − 2 k/2 + 2. By the definition of a grandchild it follows that C y i−1 [x] does not contain an induced P 5 with one endpoint in x. Hence we can apply Claim 6 and it follows that x has a neighbor r ∈ C y i−1 (x) that is universal to C j−1 [y]. We set z = r and z = y. Then, we have that z is universal to C j−1 [z] with j k − 2 k/2 + 2 k − √ 2k + 2.
Since z ∈ C k [v] we have z ∈ I 1 or z ∈ I 2 . However, the latter is not possible as otherwise z and z would fulfill the conditions of the third if-statement in Algorithm 1, which contradicts the fact that Algorithm 1 reached the last line while processing v. We conclude that z ∈ I 1 , which completes the proof of our subclaim. Now fix z, z witnessing our subclaim. Let z 1 and z 2 be the children of z. Both vertices received color a −1 and they are on different sides of G. By the induction hypothesis C −1 [z 1 ] and C −1 [z 2 ] contain a copy of X √ ( −1)/2 such that the roots are on the same side as z 1 and z 2 , respectively. Since there is no edge between C −1 [z 1 ] and C −1 [z 2 ] (this is a consequence of Claim 5) and both are contained in , it follows that z together with the copies of X √ ( −1)/2 induce a copy of X √ ( −1)/2 +1 that has z as its root (see Figure 3). Since C −1 [z] is contained in C k [v] and z is on the same side as v and since ( − 1)/2 + 1 (k − √ 2k + 1)/2 + 1 k/2 − k/2 + 1 k/2 , for all k 0, the proof is complete.
Now we are able to prove our main theorem.
Proof of Theorem 1. Let k be the largest color index used by Algorithm 1 while coloring vertices of G. In particular, Algorithm 1 uses at most 3k colors for G. If k = 1 then the statement is obvious. Suppose k 2. There must be a vertex in G colored with a k . By Claim 8 it follows that G contains X √ k/2 and by Claim 3, χ * (G) k/2 k/2 − 1. This together with 3k = 6( k/2 − 1 + 1) 2 6(χ * (G) + 1) 2 completes the proof.