1 Introduction

All graphs mentioned in this paper are finite, simple and undirected. For a graph G, we denote its vertex set, edge set and maximum degree of G by V(G), E(G) and \(\Delta (G)\), respectively. A proper coloring of G is a mapping \(\varphi \): \(V(G)\longrightarrow \{1,\ldots , k\}\), such that \(\varphi (u)\ne \varphi (v)\) if \(uv\in E(G)\). Let \(k\ge 4\) be an integer. A proper coloring \(\varphi \) is called \(P_{k}\)-free if there is no bichromatic path with k-vertices. The \(P_k\)-free chromatic number, denoted by \(\chi _{P_{k}}(G)\), is the smallest integer t such that G has a \(P_{k}\)-free coloring using t colors. We remark that the \(P_{4}\)-free coloring is called the star coloring posed by Fertin, Raspaud and Reed [9], who showed that every graph G with maximum degree \(\Delta \) admits a star coloring using \(\lceil 20\Delta ^{3/2}\rceil \) colors. This bound was improved to \(\chi _{s}(G) \le 4.34\Delta ^{3/2}\) by Ndreca, Procacci and Scoppola [14].

For general \(k\ge 5\), the \(P_{k}\)-free coloring was posed by Alon, McDiarmid and Reed [1], who showed that every graph G with maximum degree \(\Delta \) has a \(P_k\)-free coloring using \(O(\Delta ^{(k-1)/(k-2)})\) colors. Our first result improves this result by showing

Theorem 1.1

Let \(k\ge 5\) be an integer, and let G be a graph with maximum degree \(\Delta \). Then,

$$\begin{aligned} \chi _{P_{k}}(G)\le (1+\lceil k/2\rceil ^{1/(k-3)})\Delta ^{(k-1)/(k-2)}+\Delta +1. \end{aligned}$$

The following result gives the lower bound on \(P_k\)-free chromatic number of graphs.

Theorem 1.2

Let \(k\ge 5\) be an integer. Then, there exists a graph G with maximum degree \(\Delta \) such that

$$\begin{aligned} \chi _{P_{k}}(G)\ge \varepsilon \frac{\Delta ^{(k-1)/(k-2)}}{(\log \Delta )^{1/(k-2)}}, \end{aligned}$$

where \(\varepsilon \) is an absolute constant.

The \(P_k\)-free coloring is closely related to acyclic coloring. Note that a proper coloring of G is acyclic if every cycle has at least 3 colors. The acyclic chromatic number \(\chi _{a}(G)\) of a graph G is the smallest integer t such that G has an acyclic coloring using t colors. The acyclic vertex coloring was first introduced by Grünbaum [10] and has been studied in terms of the planar graphs. Borodin [4] proved Grünbaum’s conjecture by showing every planar graph is acyclically 5-colorable. Moreover, Alon, Mohar and Sanders [2] proved that each projective plane graph is acyclic 7-colorable. For more information on acyclic coloring and some related topics, we refer the reader to [5, 6, 16, 17].

For general graphs, Alon, McDiarmid and Reed [1] gave the lower bounds for the acyclic chromatic number.

Theorem 1.3

Let G be a graph with maximum degree \(\Delta \). Then,

$$\begin{aligned} \chi _{a}(G) \le 50\Delta ^{4/3}. \end{aligned}$$

In 2015, Hou and Wu [12] combined \(P_k\)-free coloring and acyclic coloring and showed that if \(k\ge 5\) is an integer and a graph G with maximum degree \(\Delta \) does not contain cycles of length 4, then G admits an acyclic coloring with \(O(\Delta ^{(k-1)/(k-2)})\) colors such that no path with k vertices is bichromatic. We improve this result for \(k=5\) and prove that

Theorem 1.4

Let G be a graph with maximum degree \(\Delta \). Then, G has an acyclic coloring with \(O(\Delta ^{4/3})\) colors such that no path with 5 vertices is bichromatic.

This paper is organized as follows. Section 2 gives a brief introduction of Lovász Local Lemma which drive the proofs of our theorems. Theorems 1.1 and 1.4 are the typical applications of the entropy compression method. The proof of Theorem 1.4 is more complex, so, we first prove Theorem 1.4 in Sect. 3 and then prove Theorem 1.1 in Sect. 4. In Sect. 5, we prove Theorem 1.2.

2 Lovász Local Lemma

In this section, we introduce one of the most powerful tools of the probabilistic method: The Lovász Local Lemma, which is used to prove the existence of combinatorial objects satisfying a set of constraints. In particular, it is a very efficient tool to provide upper bounds on several chromatic numbers.

Given a finite set X, let \({\mathcal {E}}=\{A_{x}:x\in X\}\) be a collection of bad events in a probability space, each event \(A_{x}\) with probability \({\mathbb {P}}(A_{x})\) to happen. Let \(\bar{A_{x}}\) be the complement event of \(A_{x}\), and \({\mathbb {P}}(\bigcap _{x\in X}\bar{A_{x}})\) be the probability such that none of \({\mathcal {E}}\) occurs. The Lovász Local Lemma can bound the probability of bad events and give a sufficient criterion to guarantee that the event \(\bigcap _{x\in X}\bar{A_{x}}\) (i.e., the good event) has a strictly positive probability to happen.

We state the Lovász Local Lemma in its general form, originally formulated by Erdős and Lovász [8].

Lemma 2.1

(Lovász Local Lemma [8]) Consider a set \({\mathcal {E}}=\{A_{1},\ldots ,A_{n}\}\) of (typically bad) events such that for each \(A_{i}\) is mutually independent of \({\mathcal {E}}-(D_{i}\cup A_{i})\), for some \(D_{i}\subseteq {\mathcal {E}}\). If we have reals \(x_{1},\ldots ,x_{n}\in [0,1)\) such that for each \(1\le i\le n\),

$$\begin{aligned} {\mathbb {P}}(A_{i})\le x_{i}\prod _{A_{j}\in D_{i}}(1-x_{j}), \end{aligned}$$

then the probability that none of the events in \({\mathcal {E}}\) occurs is at least \(\prod _{i=1}^{n}(1-x_{i})>0\).

Moser and Tardos [13] designed an algorithmic version of the Local Lemma, which is called Entropy Compression Method by Tao [15]. This method has been applied to many graph colorings by Esperet and Parreau [7]. Recently, Goncalves, Montassier and Pinlou [11] provided a more general method to improve the previous results. In Sects. 3 and 4, we will give proofs of Theorems 1.1 and 1.4 using the method in [11].

3 Proof of Theorem 1.4

In this section, we give a proof of Theorem 1.4 using the entropy compression method. First, we give some notations and definitions. Let G be a graph. We use \(n=|V(G)|\) to be the order of G. The length of a path or a cycle is its number of vertices. A k-path, denoted by \(P_{k}\), is a path with length k. A pair of nonadjacent vertices (uv) is special if they have more than \(4.16\Delta ^{2/3}\) common neighbors. For \(v\in V(G)\), let S(v) denote the set of special vertices of v.

Let G be a graph with maximum degree \(\Delta \) and \(\kappa =\lceil 4.33\Delta ^{4/3}\rceil +\Delta \). We order the vertices of G as \(v_{1},\ldots ,v_{n}\). For each vertex v, order the 4-cycles (resp., 5-paths) containing v as \(C_{1},\ldots ,C_{\alpha }\) (resp., \(P_{1},\ldots ,P_{\beta }\)). We prove Theorem 1.4 by showing that G has an acyclic coloring using \(\kappa \) colors such that no path of length 5 is bichromatic. For each vertex \(v\in V(G)\), if we select a color uniformly at random from \(\{1,\ldots ,\kappa \}\) for v, then we can get a random coloring \(\varphi \) of G. Now we define the following four bad events for v.

BadEvent 1. There is a vertex \(u\in N(v)\) such that \(\varphi (v)=\varphi (u)\);

BadEvent 2. There is a special vertex \(u\in S(v)\) such that \(\varphi (v)=\varphi (u)\);

BadEvent 3. There is a bichromatic 4-cycle \(C_{4}=u_{i_{1}}u_{i_{2}}u_{i_{3}}u_{i_{4}}\) containing v;

BadEvent 4. There is a bichromatic 5-path \(P_{5}=v_{i_{1}}v_{i_{2}}v_{i_{3}}v_{i_{4}}v_{i_{5}}\) containing v.

Obviously, if there exists a coloring \(\varphi \) such that none of the above four bad events happens for each vertex in G, then \(\varphi \) is a needed coloring.

Now we prove Theorem 1.4 by contradiction. Suppose that G does not have an acyclic coloring using \(\kappa \) colors such that no path of length 5 is bichromatic. Let t be a sufficiently large integer, and \(\Upsilon \in \{1,2,\ldots ,\kappa \}^{t}\) be a random vector of length t. Note that the number of \(\Upsilon \) is exactly \(\kappa ^{t}\). Let \(\Upsilon [i]\) be the ith element of \(\Upsilon \). For a given \(\Upsilon \), we get a partial acyclic \(P_5\)-free coloring \(\varphi \) and a record R through Algorithm 1. Note that R is a vector of length t.

In Algorithm 1, first, we input a random vector \(\Upsilon \) and assign R[i] an initial value \(A_{0}\) for \(1\le i\le t\). Then, we uncolor all the vertices in G. For the sake of simplicity, let \(\varphi (v)=\centerdot \) imply that v is uncolored (lines 1–3). At the ith step \((i=1, \ldots , t)\), we choose the uncolored vertex with smallest index, say v, based on the process of \((i-1)\)th step, and color it with \(\Upsilon [i]\) (lines 5–6). Next, we verify whether one of the four bad events happens. If BadEvent 1 happens, then we uncolor v and set \(R[i]=A_{1}(u)\) by lines 7–9. Else if BadEvent 2 happens, then we uncolor v and set \(R[i]=A_{2}(u)\) by lines 10–12. Else if BadEvent 3 happens, then we uncolor \(u_{i_{1}},u_{i_{2}}\) and set \(R[i]=A_{3}(C_{4}=u_{i_{1}}u_{i_{2}}u_{i_{3}}u_{i_{4}})\) by lines 13–16. Else if BadEvent 4 happens, then we uncolor \(v_{i_{1}},v_{i_{2}},v_{i_{3}}\) and set \(R[i]=A_{4}(P_{5}=v_{i_{1}}v_{i_{2}}v_{i_{3}}v_{i_{4}}v_{i_{5}})\) by lines 17–22. Otherwise, we can obtain that none of the four bad events occurs on v, we keep the color of v and the initial value of R[i]. Finally, we return a partial acyclic \(P_5\)-free coloring \(\varphi \): \(V(G)\longrightarrow \{\centerdot , 1, 2,\ldots , \kappa \}\) and a record R which is a vector of length t consisting of \(A_{0}, A_{1}, A_{2}, A_{3}\) and \(A_{4}\).

Suppose that \((\varphi _{i},R_{i})\) is the output after the ith step for \(1\le i\le t\). Note that \(\varphi _{i}\) is a partial coloring of G and \(R_i[j]=A_0\) for \(j>i\). Now, we show that the first i elements of \(\Upsilon \) can be recovered from \((\varphi _{i},R_{i})\). We denote the first i elements of \(\Upsilon \) by \(\Upsilon _{i}\).

Lemma 3.1

At step i, \(\Upsilon _{i}\) can be recovered from \((\varphi _{i},R_{i})\).

Proof

We prove the lemma by induction on i. It is trivial if \(i=1\). Let \(i\ge 2\). Assume that \(\Upsilon _{i-1}\) can be recovered from \((\varphi _{i-1},R_{i-1})\). We should get \((\varphi _{i-1},R_{i-1})\) using \((\varphi _{i},R_{i})\). Note that \(R_{i-1}[j]=R_{i}[j]\) if \(i\ne j\) and is \(R_{i-1}[i]=A_{0}\). This implies that \(R_{i-1}\) can be uniquely determined. Reading the first \(i-1\) elements in \(R_{i-1}\) successively, we can deduce that the uncolored vertex with smallest index before step i, say v, is uniquely determined. Now we get \(\varphi _{i-1}\) and \(\Upsilon [i]\) by the following four cases.

If \(R_{i}[i]=A_{0}\), then \(\Upsilon [i]=\varphi _{i}(v)\) and \(\varphi _{i-1}\) can be recovered from \(\varphi _{i}\) by uncoloring v.

If \(R_{i}[i]=A_{1}(u)\) or \(A_{2}(u)\), then according to lines 7 and 10 in Algorithm 1, \(\Upsilon [i]=\varphi _{i}(u)\) and \(\varphi _{i-1}=\varphi _{i}\).

figure a

If \(R_{i}[i]=A_{3}(C_{4}=u_{i_{1}}u_{i_{2}}u_{i_{3}}u_{i_{4}})\), according to line 13, without loss of generality, assume \(v=u_{i_{1}}\), then \(\Upsilon [i]=\varphi _{i}(u_{i_{3}})\), and \(\varphi _{i-1}\) can be obtained from \(\varphi _{i}\) by coloring \(u_{i_{2}}\) with \(\varphi _{i}(u_{i_{4}})\).

If \(R_{i}[i]=A_{4}(P_{5}=v_{i_{1}}v_{i_{2}}v_{i_{3}}v_{i_{4}}v_{i_{5}})\), according to line 17, \(\Upsilon [i]=\varphi _{i}(v_{i_{4}})\) when \(v=v_{i_{2}}\), and \(\Upsilon _{i}=\varphi _{i}(v_{i_{5}})\) when \(v=v_{i_{1}}\) or \(v_{i_{3}}\). \(\varphi _{i-1}\) can be obtained from \(\varphi _{i}\) by coloring \(v_{i_{2}}\) with \(\varphi _{i}(v_{i_{4}})\) and coloring \(v_{i_{1}}, v_{i_{3}}\) with \(\varphi _{i}(v_{i_{5}})\).

So, we have get \((\varphi _{i-1},R_{i-1})\) by the above arguments. By induction hypothesis, \(\Upsilon _{i-1}\) can be recovered from \((\varphi _{i-1},R_{i-1})\), which together with \(\Upsilon [i]\) yields that \(\Upsilon _{i}\) has been recovered. This completes the proof. \(\square \)

By Lemma 3.1, we know that the function defined by Algorithm 1 is injective, and thus, the number of \(\Upsilon \) is no more than the number of the couples \((\varphi ,R)\). However, we will show there are at most \(o(\kappa ^{t})\) couples \((\varphi ,R)\), a contradiction.

Lemma 3.2

There are at most \(o(\kappa ^{t})\) couples \((\varphi ,R)\).

Proof

Based on the four bad events which might happen in Algorithm 1, the elements of the record R can be partitioned into five classes \(A_{0}, A_{1}, A_{2}, A_{3}\) and \(A_{4}\). Let \(t_{i}\) be the number of class \(A_{i}\) for \(0\le i \le 4\). Note that each class of \(A_{1}\) ( \(A_{2}, A_{3}, A_{4},\) respectively ) implies that Algorithm 1 uncolors 1 ( 1, 2, 3,  respectively ) previously colored vertex.

Since there only one vertex is colored at each step, and \(t_{1}+t_{2}+2t_{3}+3t_{4}\) corresponds to the number of uncolored vertices during the execution of Algorithm 1, we have

$$\begin{aligned} t_{1}+t_{2}+2t_{3}+3t_{4}\le t=\sum _{0 \le i \le 4}t_{i}. \end{aligned}$$
(1)

For fixed \(t_{0}, t_{1}, t_{2}, t_{3}\) and \(t_{4}\), we denote by \(\sharp Seq(t_{0}, t_{1}, t_{2}, t_{3}, t_{4})\) the number of possible permutations of the five classes \(A_{0}, A_{1}, A_{2}, A_{3}\) and \(A_{4}\) in the records. Then, we have

$$\begin{aligned} \sharp Seq(t_{0}, t_{1}, t_{2}, t_{3}, t_{4}) \le&\genfrac(){0.0pt}0{t}{t_{0}} \genfrac(){0.0pt}0{t-t_{0}}{t_{1}} \genfrac(){0.0pt}0{t-t_{0}-t_{1}}{t_{2}} \genfrac(){0.0pt}0{t-t_{0}-t_{1}-t_{2}}{t_{3}} \genfrac(){0.0pt}0{t_{4}}{t_{4}}\\ =&\frac{t!}{t_{0}! t_{1}! t_{2}! t_{3}! t_{4}!}. \end{aligned}$$

In the following, we will compute the number of possible records for each permutation of \(A_{0}, A_{1}, A_{2}, A_{3}\) and \(A_{4}\).

According to Algorithm 1, for each \(A_{1}(u)\), there are at most \(\Delta \) vertices \(u \in N(v)\) such that \(\varphi (v)=\varphi (u)\). So,

$$\begin{aligned} C_{1}=\Delta . \end{aligned}$$

For \(A_{2}(u)\), each pair (uv) has more than \(4.16\Delta ^{2/3}\) common neighbors by the definition of special pair. Since there are at most \(\Delta (\Delta -1)\le \Delta ^{2}\) induced paths of length 2 starting at v, the number of special vertices u is at most \(\frac{\Delta ^{2}}{4.16\Delta ^{2/3}}=\frac{\Delta ^{4/3}}{4.16}\). Let

$$\begin{aligned} C_{2}=\frac{\Delta ^{4/3}}{4.16}. \end{aligned}$$

For \(v\in V(G)\), now we bound induced 4-cycles \(u_{i_{1}}u_{i_{2}}u_{i_{3}}u_{i_{4}}\) with \(v=u_{i_{1}}\) such that \((v, u_{i_{3}})\) is not special pair. Note that there are at most \(\Delta (\Delta -1)\le \Delta ^{2}\) induced paths \(vu_{i_{2}}u_{i_{3}}\) of length 2 starting at v. Since \((u_{i_{3}},v)\) is not special pair, there are at most \(4.16\Delta ^{2/3}\) 4-cycles containing the path \(vu_{i_{2}}u_{i_{3}}\). Therefore, the number of 4-cycles containing v is at most \(\Delta ^{2}\times (\frac{1}{2}\times 4.16\Delta ^{2/3})=2.08\Delta ^{8/3}\). So, let

$$\begin{aligned} C_{3}=2.08\Delta ^{8/3}. \end{aligned}$$

For \(v\in V(G)\), now we bound induced paths \((v_{i_{1}}v_{i_{2}}v_{i_{3}}v_{i_{4}}v_{i_{5}})\) containing v. For a fixed vertex v, if \(v=v_{i_{3}}\), then there are \(\left( {\begin{array}{c}\Delta \\ 2\end{array}}\right) \) possibilities to choose \(v_{i_{2}}\) and \(v_{i_{4}}\), hence there are at most \(\left( {\begin{array}{c}\Delta \\ 2\end{array}}\right) (\Delta -1)^{2} < \frac{\Delta ^{4}}{2}\) paths \(P_{5}\) containing v. If \(v=v_{i_{1}}\) or \(v_{i_{5}}\), then the number of paths \(P_{5}\) is at most \(\Delta (\Delta -1)^{3} < \Delta ^{4}\). Otherwise, if \(v=v_{i_{2}}\) or \(v_{i_{4}}\), then the number of paths \(P_{5}\) is at most \(\Delta (\Delta -1)^{3} < \Delta ^{4}\). Consequently, the number of such paths \(P_{5}\) containing v is at most \(\frac{5}{2}\Delta ^{4}\). So, let

$$\begin{aligned} C_{4}=\frac{5}{2}\Delta ^{4}. \end{aligned}$$

Therefore, for fixed \(t_{0}, t_{1}, t_{2}, t_{3}, t_{4}\), it suffices to show that the number of possible records R is at most \(B_{t}\):

$$\begin{aligned} B_{t}(t_{0}, t_{1}, t_{2}, t_{3}, t_{4})= \frac{t!}{t_{0}! t_{1}! t_{2}! t_{3}! t_{4}!}\times \prod _{1\le i\le 4}C_{i}^{t_{i}} \end{aligned}$$

where \(C_{1}=\Delta \), \(C_{2}=\frac{\Delta ^{4/3}}{4.16}\), \(C_{3}=2.08\Delta ^{8/3}\), and \(C_{4}=\frac{5}{2}\Delta ^{4}\). Taking the sum of all possible tuples \((t_{0}, t_{1}, t_{2}, t_{3}, t_{4})\) satisfying inequation (1), we can obtain the following immediate upper bound for the total number of possible records:

$$\begin{aligned} \sum _{(t_{0}, t_{1}, t_{2}, t_{3}, t_{4})}B_{t}(t_{0}, t_{1}, t_{2}, t_{3}, t_{4}). \end{aligned}$$

Next, we present two lemmas which are proved in [11].

Lemma 3.3

For \(1\le i\le p\), let \(s_{i}\) be positive integers and \(C_{i}\) be reals with \(C_{i}>1\). Then, for sufficiently large t,

$$\begin{aligned} B_{t}(t_{0}, t_{1},\ldots , t_{p})\le t(\inf _{0<x\le 1}Q(x))^{t}, \end{aligned}$$

where \(B_{t}(t_{0}, t_{1},\ldots , t_{p})= \frac{t!}{t_{0}! t_{1}! \ldots t_{p}!}\times \prod _{1\le i\le p}C_{i}^{t_{i}}\) is defined for nonnegative integers \(t_{0}, t_{1},\ldots , t_{p}\) such that \(t=\sum _{0 \le i \le p}t_{i}\ge \sum _{1\le i \le p}s_{i}t_{i}\) and \(Q(x)=\frac{1}{x}(1+\sum _{1\le i\le p}C_{i}x^{s_{i}})\) is defined for \(0<x\le 1\).

Lemma 3.4

Summing over all possible \((p+1)\)-tuples \(t_{0}, t_{1},\ldots , t_{p}\) satisfying \(t=\sum _{0 \le i \le p}t_{i}\ge \sum _{1\le i \le p}s_{i}t_{i}\), we have for sufficiently large t that

$$\begin{aligned} \sum _{(t_{0}, t_{1},\ldots , t_{p})}B_{t}(t_{0}, t_{1},\ldots , t_{p})\le t(t+1)^{p}(\inf _{0<x\le 1}Q(x))^{t}. \end{aligned}$$

According to the above two lemmas, let \(p=4\) and t large sufficiently, it suffices to obtain

$$\begin{aligned} \sum _{(t_{0}, t_{1}, t_{2}, t_{3}, t_{4})}B_{t}(t_{0}, t_{1}, t_{2}, t_{3}, t_{4})\le t(t+1)^{4}(\inf _{0<x\le 1}Q(x))^{t}, \end{aligned}$$

where 

$$\begin{aligned} Q(x)=\frac{1}{x}(1+C_{1}x+C_{2}x+C_{3}x^{2}+C_{4}x^{3}) \end{aligned}$$

for \(0<x\le 1.\) To minimize Q(x), let

$$\begin{aligned} x=\frac{1}{\sqrt{2.08}\Delta ^{4/3}}. \end{aligned}$$

Then, we have

$$\begin{aligned} Q(x)=&\frac{1}{x}+C_{1}+C_{2}+C_{3}x+C_{4}x^{2}\\ =&\sqrt{2.08}\Delta ^{4/3}+\Delta +\frac{\Delta ^{4/3}}{4.16} +2.08\Delta ^{8/3}\times \frac{1}{\sqrt{2.08}\Delta ^{4/3}}+\frac{5}{2}\Delta ^{4}\times \frac{1}{2.08\Delta ^{8/3}}\\ <&4.33\Delta ^{4/3}+\Delta . \end{aligned}$$

It is easy to see that the number of the partial colorings \(\varphi \) is at most \((\kappa +1)^{n}\). Thus, the number of the couples \((\varphi ,R)\) is at most \(o(\kappa ^{t})\), which completes the proof of Lemma 3.2. \(\square \)

4 Proof of Theorem 1.1

In this section, we give a proof of Theorem 1.1. Let G be a graph with maximum degree \(\Delta \), and let \(\kappa =(1+\lceil k/2\rceil ^{1/(k-3)})\Delta ^{(k-1)/(k-2)}+\Delta +1\). We order the vertices of G as \(v_{1},\ldots ,v_{n}\). For each vertex v, order the k-paths containing v as \(P_{1},\ldots ,P_{\beta }\). For a coloring \(\varphi \) of G, we define the following two bad events for each vertex v.

BadEvent 1. There is a vertex \(u\in N(v)\) such that \(\varphi (v)=\varphi (u)\);

BadEvent 2. There is a bichromatic k-path \(P_{k}=v_{i_{1}}v_{i_{2}}\ldots v_{i_{k}}\) containing v.

Suppose that G does not have a \(P_{k}\)-free coloring using \(\kappa \) colors. Let t be a sufficiently large integer, and \(\Upsilon \in \{1,2,\ldots ,\kappa \}^{t}\) be a random vector of length t. For a given \(\Upsilon \), we get a partial \(P_{k}\)-free coloring \(\varphi \) and a record R through Algorithm 2.

In Algorithm 2, first, we input a vector \(\Upsilon \). At ith step \((i=1, \ldots , t)\), we choose the smallest index uncolored vertex, say v, based on the process of \((i-1)\)th step, and color it with \(\Upsilon [i]\). Next, we verify whether one of the two bad events happens. If one of these bad events happens, then we uncolor some vertices for the purpose of avoiding the two bad events happen. Finally, we returns a partial coloring \(\varphi \): \(V(G)\longrightarrow \{\centerdot , 1, 2,\ldots , \kappa \}\) and a record R which is a vector of length t consisting of \(A_{0}, A_{1}\) and \(A_{2}\).

Suppose that \((\varphi _{i},R_{i})\) is the output after the ith step for \(1\le i\le t\). Note that \(\varphi _{i}\) is a partial coloring of G and \(R_i[j]=A_0\) for \(j>i\). Then, \(\varphi _{i}\) is a partial coloring of G and \(R_i[j]=A_0\) for \(j>i\). Now, we show that \(\Upsilon _{i}\) can be recovered from \((\varphi _{i},R_{i})\), where \(\Upsilon _{i}\) denotes the first i elements of \(\Upsilon \).

Lemma 4.1

At step i, \(\Upsilon _{i}\) can be recovered from \((\varphi _{i},R_{i})\).

Proof

By induction on i. It is trivial if \(i=1\). Let \(i\ge 2\). Assume that \(\Upsilon _{i-1}\) can be recovered from \((\varphi _{i-1},R_{i-1})\). We should get \((\varphi _{i-1},R_{i-1})\) using \((\varphi _{i},R_{i})\). As in the proof of Lemma 3.1, we can obtain \(R_{i-1}\) and the uncolored vertex with smallest index before step i, say v. Now we get \(\varphi _{i-1}\) and \(\Upsilon [i]\) by the following three cases.

If \(R_{i}[i]=A_{0}\), then \(\Upsilon [i]=\varphi _{i}(v)\) and \(\varphi _{i-1}\) can be recovered from \(\varphi _{i}\) by uncoloring v.

If \(R_{i}[i]=A_{1}(u)\), then according to lines 7, 8, 9 in Algorithm 2, \(\Upsilon [i]=\varphi _{i}(u)\) and \(\varphi _{i-1}=\varphi _{i}\).

If \(R_{i}[i]=A_{2}(P_{k}=v_{i_{1}}v_{i_{2}}\ldots v_{i_{k}})\), then there are two cases based on k. If k is odd, then \(\Upsilon [i]=\varphi _{i}(v_{i_{k}})\) when \(v=v_{i_{j}}\) \((j\in \{1,3,\cdots , (k+1)/2\})\), and \(\Upsilon [i]=\varphi _{i}(v_{i_{k-1}})\) when \(v=v_{i_{p}}\) \((p\in \{2,4,\cdots , (k-1)/2\})\). Based on lines 11, 12, 13 in Algorithm 2, \(\varphi _{i-1}\) can be obtained from \(\varphi _{i}\) by coloring \(v_{i_{1}}, v_{i_{3}}, \cdots , v_{i_{k-2}}\) with \(\varphi _{i}(v_{i_{k}})\) and coloring \(v_{i_{2}}, v_{i_{4}}, \cdots , v_{i_{k-3}}\) with \(\varphi _{i}(v_{i_{k-1}})\). By the same arguments, we can obtain \(\varphi _{i-1}\) and \(\Upsilon [i]\) if k is even.

By induction hypothesis, \(\Upsilon _{i-1}\) can be recovered from \((\varphi _{i-1},R_{i-1})\), which together with \(\Upsilon [i]\) yields that \(\Upsilon _{i}\) has been recovered. This completes the proof. \(\square \)

figure b

By Lemma 4.1, we know that the function defined by Algorithm 2 is injective. Thus, the number of \(\Upsilon \) is no more than the number of the couples \((\varphi ,R)\). However, we will show there are at most \(o(\kappa ^{t})\) couples \((\varphi ,R)\), a contradiction.

Lemma 4.2

There are at most \(o(\kappa ^{t})\) couples \((\varphi ,R)\).

Proof

Based on the two bad events which might happen in Algorithm 2, the elements of the record R can be partitioned into three classes \(A_{0}, A_{1}, A_{2}\). Let \(t_{i}\) be the number of class \(A_{i}\) for \(0\le i \le 2\). Note that each class of \(A_{1}\) (or \(A_{2}\)) implies that Algorithm 2 uncolors 1 (or \(k-2\)) previously colored vertex.

Since there only one vertex is colored at each step, and \(t_{1}+(k-2)t_{2}\) corresponds to the number of uncolored vertices during the execution of Algorithm 2, we have

$$\begin{aligned} t_{1}+(k-2)t_{2}\le t=\sum _{0 \le i \le 2}t_{i}. \end{aligned}$$
(2)

For fixed \(t_{0}, t_{1}\) and \(t_{2}\), we denote by \(\sharp Seq(t_{0}, t_{1}, t_{2})\) the number of possible permutations of the three classes \(A_{0}, A_{1}\) and \(A_{2}\) in the records. Then, we have

$$\begin{aligned} \sharp Seq(t_{0}, t_{1}, t_{2}) \le&\genfrac(){0.0pt}0{t}{t_{0}} \genfrac(){0.0pt}0{t-t_{0}}{t_{1}} \genfrac(){0.0pt}0{t-t_{0}-t_{1}}{t_{2}}\\ =&\frac{t!}{t_{0}! t_{1}! t_{2}!}. \end{aligned}$$

In the following, we will compute the number of possible records for each permutation of \(A_{0}, A_{1}\) and \(A_{2}\).

According to Algorithm 2, for each \(A_{1}(u)\), there are at most \(\Delta \) vertices \(u \in N(v)\) such that \(\varphi (v)=\varphi (u)\). So, let

$$\begin{aligned} C_{1}=\Delta . \end{aligned}$$

For \(v\in V(G)\), now we bound induced k-paths \(P_{k}=v_{i_{1}}v_{i_{2}}\ldots v_{i_{k}}\) containing v. Note that there are at most \(\Delta (\Delta -1)^{k-2}\le \Delta ^{k-1}\) induced paths \(P_{k}\) starting at v. Since there are \(\lceil k/2 \rceil \) chooses for v in each path \(P_{k}\), the number of such paths \(P_{k}\) containing v is at most \(\lceil k/2\rceil \Delta ^{k-1}\). So, let

$$\begin{aligned} C_{2}=\lceil k/2\rceil \Delta ^{k-1}. \end{aligned}$$

Therefore, for fixed \(t_{0}, t_{1}, t_{2}\), it suffices to show that the number of possible records R is at most \(B_{t}\), where

$$\begin{aligned} B_{t}(t_{0}, t_{1}, t_{2})= \frac{t!}{t_{0}! t_{1}! t_{2}! }\times \prod _{1\le i\le 2}C_{i}^{t_{i}}. \end{aligned}$$

Taking the sum of all possible tuples \((t_{0}, t_{1}, t_{2})\) satisfying inequation (2), we can obtain the following immediate upper bound for the total number of possible records:

$$\begin{aligned} \sum _{(t_{0}, t_{1}, t_{2})}B_{t}(t_{0}, t_{1}, t_{2}). \end{aligned}$$

According to Lemmas 3.3 and 3.4 , let \(p=2\) and t large sufficiently. It suffices to obtain

$$\begin{aligned} \sum _{(t_{0}, t_{1}, t_{2})}B_{t}(t_{0}, t_{1}, t_{2})\le t(t+1)^{2}(\inf _{0<x\le 1}Q(x))^{t}, \end{aligned}$$

where 

$$\begin{aligned} Q(x)=\frac{1}{x}(1+C_{1}x+C_{2}x^{k-2}), \end{aligned}$$

for \(0<x\le 1.\) To minimize Q(x), let

$$\begin{aligned} x=\lceil k/2\rceil ^{1/3-k}\Delta ^{(1-k)/(k-2)}. \end{aligned}$$

Then, we have

$$\begin{aligned} Q(x)=&\frac{1}{x}+C_{1}+C_{2}x^{k-3}\\ =&(\lceil k/2\rceil ^{1/(k-3)}+1)\Delta ^{(k-1)/(k-2)}+\Delta \\ <&(\lceil k/2\rceil ^{1/(k-3)}+1)\Delta ^{(k-1)/(k-2)}+\Delta +1. \end{aligned}$$

It is easy to see that the number of the partial colorings \(\varphi \) is at most \((\kappa +1)^{n}\). Thus, the number of the couples \((\varphi ,R)\) is at most \(o(\kappa ^{t})\), which completes the proof of Lemma 4.2. \(\square \)

5 Proof of Theorem 1.2

In this section, we give a proof of Theorem 1.2. Let \(V=\{v_{1}, \ldots , v_{n}\}\) be a set of n labeled vertices, where n divisible by k. Let \(G=G(n,p)\) be a random graph on V such that for \(1\le i<j\le n\),

$$\begin{aligned} {\mathbb {P}}(v_{i}v_{j}\in E(G))=p. \end{aligned}$$

Put

$$\begin{aligned} p=c\Big (\frac{\log n}{n}\Big )^{1/k}, \end{aligned}$$

where c is a constant depends on k, to be given later. According to a result about the degree of random graphs in [3], if \(\Delta \) denotes the maximum degree of G, then \({\mathbb {P}}\{\Delta \le 2np\}\rightarrow 1~as~n\rightarrow \infty .\) Therefore,

$$\begin{aligned} {\mathbb {P}}\{\Delta \le 2n^{(k-2)/(k-1)}(\log n)^{1/(k-1)}\}\rightarrow 1~as~n\rightarrow \infty . \end{aligned}$$
(3)

We only consider the case that k is even. The proof of the case that k is odd is similar, and we leave it to the reader. We claim that

$$\begin{aligned} {\mathbb {P}}\{\chi _{P_{k}}>\frac{2n}{k}\}\rightarrow 1~as~n\rightarrow \infty . \end{aligned}$$
(4)

We first show the following lemma.

Lemma 5.1

Let l be an integer with \(l\le 2n/k\), and let \((V_1,\ldots ,V_l)\) be a partition of V. Then, the probability that this partition is a \(P_{k}\)-free coloring of G is at most

$$\begin{aligned} \Big (1-p^{k-1}\Big )^{\left( {\begin{array}{c}4n/k^{2}\\ 2\end{array}}\right) }. \end{aligned}$$

Proof

For \(1\le i\le l\), let \(|V_{i}|\equiv b_i (\mod k/2)\), where \(0\le b_i\le k/2-1\). Now we remove \(b_i\) vertices from \(V_{i}\). Clearly, there are at least \(n-l(k/2-1)\ge (2n)/k\) vertices which lie in l disjoint parts. Next, we partition these parts into sets of vertices \(U_{1}, U_{2}, \ldots , U_{r}\) with \(|U_i|=k/2\) for each i. Note that \(r\ge 4n/k^{2}\), and the vertices in \(U_{i}\) are colored with the same color.

For each pair \((U_{i}, U_{j})\) with \(i\ne j\), if there exists a k-path P connecting this pair, then P is either monochromatic or bichromatic, which means the coloring is not a \(P_{k}\)-free coloring. Clearly, the probability for which this case happens is at least \(p^{k-1}\).

Since there are at least \(\genfrac(){0.0pt}0{4n/k^{2}}{2}\) pairs of \((U_{i},U_{j})\), the probability that the fixed coloring is a \(P_{k}\)-free coloring does not exceed

$$\begin{aligned} (1-p^{k-1})^{\left( {\begin{array}{c}4n/k^{2}\\ 2\end{array}}\right) }. \end{aligned}$$

\(\square \)

It is easy to see that there are at most \(n^{n}\) partitions of V. By Lemma 5.1, the probability that there exists a \(P_{k}\)-free coloring of G with at most (2n)/k colors does not exceed

$$\begin{aligned} n^{n}(1-p^{k-1})^{\left( {\begin{array}{c}4n/k^{2}\\ 2\end{array}}\right) } <&n^{n}\exp \Big \{-\genfrac(){0.0pt}0{4n/k^{2}}{2}p^{k-1}\Big \}\\ =&\exp \Big \{n\log n-c^{k-1}\genfrac(){0.0pt}0{4n/k^{2}}{2}\frac{\log n}{n}\Big \}. \end{aligned}$$

Now we choose c satisfying \(c^{k-1}> k^{4}/8\). So, this probability is o(1) as \(n\rightarrow \infty .\) Therefore, we can obtain the following statements:

$$\begin{aligned} {\mathbb {P}}\{\Delta \le&2n^{(k-2)/(k-1)}(\log n)^{1/(k-1)}\}\rightarrow 1~as~n\rightarrow \infty ;\\&{\mathbb {P}}\{\chi _{P_{k}}>\frac{2n}{k}\}\rightarrow 1~as~n\rightarrow \infty . \end{aligned}$$

Note that \(f(x)=x/\log x\) is an increasing function for \(x>e\). For large n, if \(\Delta \le 2n^{(k-2)/(k-1)}(\log n)^{1/(k-1)}\), then

$$\begin{aligned} f(\Delta ^{k-1})=&\frac{\Delta ^{k-1}}{(k-1)\log \Delta }\\ \le&\frac{(2c)^{k-1}n^{k-2}\log n}{(k-1)\log 2c+(k-2)\log n+\log \log n}\\ \le&\frac{(2c)^{k-1}n^{k-2}\log n}{(k-2)\log n}\\ \le&\frac{(2c)^{k-1}n^{k-2}}{k-2}. \end{aligned}$$

Thus, we conclude that

$$\begin{aligned} n\ge \varepsilon \frac{\Delta ^{(k-1)/(k-2)}}{(\log \Delta )^{1/(k-2)}}, \end{aligned}$$
(5)

for some real \(\varepsilon >0\).

Combining (3), (4), and (5), we know that there exists a graph G with maximum degree \(\Delta \) such that G has \(P_{k}\)-free chromatic number at least \(O(\frac{\Delta ^{(k-1)/(k-2)}}{(\log \Delta )^{1/(k-2)}})\).