Rainbow Tur\'an problems for paths and forests of stars

For a fixed graph $F$, we would like to determine the maximum number of edges in a properly edge-colored graph on $n$ vertices which does not contain a {\emph rainbow copy} of $F$, that is, a copy of $F$ all of whose edges receive a different color. This maximum, denoted by $ex^*(n,F)$, is the {\emph rainbow Tur\'an number} of $F$, and its systematic study was initiated by Keevash, Mubayi, Sudakov and Verstra\"ete in 2007. We determine $ex^*(n,F)$ exactly when $F$ is a forest of stars, and give bounds on $ex^*(n,F)$ when $F$ is a path with $k$ edges, disproving a conjecture in Keevash et al.


Introduction
For a fixed graph F , we would like to determine the maximum number of edges in a properly edge-colored graph on n vertices which does not contain a rainbow copy of F , that is, a copy of F all of whose edges receive a different color. This maximum, denoted by ex * (n, F ), is the rainbow Turán number of F , and its systematic study was initiated by Keevash, Mubayi, Sudakov and Verstraëte in 2007 [9]. Among other things they proved that when F has chromatic number at least 3, then ex * (n, F ) = (1 + o(1))ex(n, F ) where ex(n, F ) is the (usual) Turán number of F . They also showed that ex * (n, K s,t ) = O(n 2−1/s ) where K s,t is the complete bipartite graph with classes of size s and t. This research was continued by Das, Lee and Sudakov [5], who partially answered a question from [9] on even cycles (this case has an interesting connection to additive number theory). In this paper, we determine ex * (n, F ) exactly when F is a forest of stars, and give bounds on ex * (n, F ) when F is a path with l edges, disproving a conjecture in [9].
Our methods also yield short proofs of the classic results on Erdős and Gallai on the (usual) Turán numbers of matchings [6], and of some recent results of Lidický, Liu and Palmer [10] on the Turán numbers of forests of stars.

Matchings
Write M k for a matching with k edges. The usual Turán number for matchings was determined by Erdős and Gallai [6], who proved the following. Define G n,k = (V, E) to be the graph containing a clique G k on vertex set V k ⊂ V , where |V | = n, |V k | = k, and in which each v ∈ V k is joined to every vertex of W = V \ V k . Then ex(n, M k ) = max{e(G n,k−1 ), e(K 2k−1 )} = max k − 1 2 + (k − 1)(n − k + 1), 2k − 1 2 = n(k − 1) + O(k 2 ), and, for sufficiently large n, G n,k−1 is the unique extremal graph. The second term of the maximum is necessary since a clique on 2k − 1 vertices also contains no M k , and for small n it has more edges than G n,k−1 .
In other words, for sufficiently large n, ex(n, M k ) = k−1 2 + (k − 1)(n − k + 1). Rather surprisingly, the same is true for ex * (n, M k ). First we establish a weak version of this result. Although both the next two theorems are special cases of the results in the next section, their proofs will serve as templates for what follows. Proof. Suppose G = (V, E) has the maximum number of edges such that there exists a proper edge-coloring χ of G with no rainbow M k . Then G must contain a rainbow M k−1 , on vertex set A, say. Write B = V \ A, C ⊂ A for those vertices of A which send at least t = 2k edges to B, and set c = |C|. We must have c ≤ k−1, or else we could greedily build a rainbow matching from A to B of size k as follows. First choose an edge c 1 b 1 ∈ E, where c 1 ∈ C and b 1 ∈ B, where without loss of generality χ(c 1 b 1 ) = 1. Then choose an edge c 2 b 2 ∈ E of a different color, say χ(c 2 b 2 ) = 2, where c 2 ∈ C and b 2 ∈ B with b 2 = b 1 . This is possible since d(c 2 ) ≥ 3. Continuing, we finally choose c k b k ∈ E with χ(c k b k ) = k, which is possible since d(c k ) ≥ 2k −1 (we have k −1 vertices b 1 , . . . , b k−1 and k − 1 edge colors to avoid). Alternatively, the inequality c ≤ k − 1 follows on observing that if any edge c i c j of our M k−1 has two vertices from C, then c i c j can be replaced by two edges c i b i and c j b j of new colors.
At least (and in fact, exactly) k − 1 − c of the edges of our M k−1 contain no vertex of C; write M ′ for this set of edges. We claim that For if e ∈ E(G ′ ) has a color not appearing among the colors of M ′ , we can form a rainbow copy of M k by starting with M ′ and e, and then greedily extending from the vertices of C as above (at the last stage we have k − 1 colors and at most (c − 1) + 2 ≤ (k − 2) + 2 = k vertices to avoid). Consequently, the maximum degree in G [B] is at most k − 1 − c, and so e(G[B]) ≤ k−1−c 2 (n − 2(k − 1)). Therefore, Next we refine this argument to get an exact result, at least for sufficiently large n.
Proof. We already know that ex * (n, To this end, suppose again that G = (V, E) has the maximum number of edges such that there exists a proper edge-coloring χ of G with no rainbow M k . Following the proof of Theorem 1, we see that we must have as long as n ≥ 9k 2 . Armed with this information, we deduce that , we could greedily extend e to a rainbow matching M k using the vertices of C. Consequently, We remark that this method can be used to prove Erdős and Gallai's result that ex(n, M k ) = k−1 2 + (k − 1)(n − k + 1), at least for sufficiently large n. Rather than elaborate here, we note that the theorem is a special case of the result of Lidický, Liu and Palmer on star forests, which we will reprove in the next section. Note also that our argument avoids Hall's theorem.

Forests of stars
In this section we address the rainbow Turán number of a forest F where each component is a star. In this case, the Turán number was determined by Lidický, Liu and Palmer [10]. We give a new proof of this result at the end of this section.
Let F be a forest of k stars S 1 , S 2 , . . . , S k such that e(S j ) ≤ e(S j+1 ) for each j. We will construct a family of n-vertex graphs that each have a proper edge-coloring with no rainbow The graph H F (n, c) is defined as follows. For c = k − 1, we connect a set C of c = k − 1 universal vertices to an edge-maximal graph H of maximum degree f (c) = f (k − 1) = e(S 1 ) − 1 on the remaining n − k + 1 vertices. (A universal vertex is one that is joined to every other vertex, so that in particular G[C] is a clique.) When c ≤ k − 2, we connect a set C of c universal vertices to an edge-maximal f (c)-edge-colorable graph H on n − c vertices.
Note the slight distinction in the definition of the subgraph H in the two cases c = k − 1 and c ≤ k − 2. In both cases, it is easy to see that H can only contain k − c − 1 of the stars in F . The remaining c + 1 stars must each use at least one vertex from C, which is impossible. Therefore, in both cases, H F (n, c) does not contain a rainbow copy of F . When c = k − 1, the subgraph H is (e(S 1 ) − 1)-regular when either n − c or e(S 1 ) − 1 is even. Otherwise, H has one vertex of degree e(S 1 ) − 2 and n − k vertices of degree e(S 1 ) − 1. Therefore, the total number of edges in H F (n, k − 1) is When c ≤ k − 2, there are exactly ⌊ n−c 2 ⌋ edges of each color in H, so that H has f (c)⌊ n−c 2 ⌋ edges. Therefore, the total number of edges in H F (n, c) is Consequently, for all c ≤ k − 1, the number of edges in the graph H F (n, c) is Furthermore, the subgraph H of H F (n, c) has average degree f (c) − ǫ, where ǫ < 1.
The key to our analysis is the following technical lemma, which allows us to restrict our attention to the family H F (n, c). Lemma 3. Let F be a forest of k stars. Suppose that G is an edge-maximal properly edgecolored graph on n vertices containing no rainbow copy of F . Then, for sufficiently large n, G is isomorphic to one of the graphs H F (n, c).
Before turning to the proof of this lemma, we explain its use in the proof of our main result, Theorem 4. Specifically, suppose we have proved Lemma 3, and consider a fixed forest of stars F . In order to find the extremal graphs for a rainbow copy of F , we just need to determine the value of c = c(F ) that maximizes the number of edges e(H F (n, c)) of H F (n, c).
For example, when F is a forest of stars each of size 1 (i.e., a matching), then, for large n, the sum in (1) is maximized when c = k−1. Therefore, for large n, an edge-maximal properly edge-colored graph G containing no rainbow copy of F must be isomorphic to H F (n, k − 1). In this case, f (k − 1) = e(S 1 ) − 1 = 0 (this holds whenever F contains a star of size 1), so that G consists of a universal set of size k − 1 joined to an independent set of size n − k + 1. This reproves Theorem 2.
It turns out that, for every F , the maximum of e(H F (n, c)) is attained at either c = 0 or c = k − 1.
Theorem 4. Let F be a forest of k stars. Suppose that G is an edge-maximal properly edgecolored graph on n vertices containing no rainbow copy of F . Then, for sufficiently large n, 1) if F contains no star of size 1, then G is isomorphic to H F (n, 0); 2) otherwise, G is isomorphic to the larger of H F (n, 0) and H F (n, k − 1).
Proof. First consider the case when F contains no star of size 1. In this case, if F contains at least one star of size at least 3, then, for sufficiently large n, the right hand side of (1) is maximized when c = 0. Therefore, by Lemma 3, G must be isomorphic to H F (n, 0) (for large n).
If every star in F has size 2, then the sum of the two main terms in (1) is constant over all c ≤ k −1, so we need to examine the error term. In both the cases c = k −1 and c ≤ k −2, we have Simple computations show that this is maximized at c = 0. Therefore, G must be isomorphic to H F (n, 0). To summarize, if F contains no star of size 1, G must be isomorphic to H F (n, 0), if n is sufficiently large. As already mentioned, this extremal graph is just an edge-maximal graph that is properly edge-colored with f (0) = e(F ) − 1 colors. Now suppose that F contains a star of size 1. Write s ≥ 1 for the number of stars of size 1, t for the number of stars of size 2, and p = k − s − t for the number of stars of size at least 3 in F . If p = 0, then we should clearly take c = k − 1 to maximize the sum of the two main terms in (1). Consequently, we may assume p > 0. We now have three estimates for p t s 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 5 4 4 3 3 2 2 2 2 2 1 1 1 1 1 Table 1: Illustration of the proof of Theorem 4 the number of edges in H F (n, c), depending on the value of c. If c < p (and p > 0), then which is maximized (for large n) when c = 0 (as each e(S i ) in the above sum is at least 3). Thus, when c < p (and p > 0), we should take c = 0, and then which is maximized (for large n) when c = k − 1. (We remind the reader that in the case we are considering, which is larger than (3) when n is large. Therefore, for sufficiently large n, the number of edges in H F (n, c) is maximized when c is either 0 or k − 1.
The choice of c to maximize the sum of the two main terms in (1) can be illustrated as follows (see Table 1). Write down a row of k 2s, and underneath this row, write down the star sizes e(S k ), e(S k−1 ), . . . , e(S 1 ) in decreasing order. Next, take the sum of the first c entries in the top row and the last k − c entries in the bottom row, where c ≤ k − 1. This sum represents twice the coefficient of n in (1).
We now turn our attention to the proof of Lemma 3. We begin with a simple lemma.
Lemma 5. Fix positive integers d and ∆ and a constant 0 ≤ ǫ < 1. If G is a graph with average degree at least d − ǫ and maximum degree at most ∆, then the number of vertices in G of degree less than d is at most In particular, the number of vertices in G of degree at least d is Ω(n) (i.e. at least Cn where Proof. The sum of the degrees in G is at least (d−ǫ)n. On the other hand, if x is the number of vertices of degree less than d in G, then the sum of the degrees in G is at most Combining these two estimates and solving for x gives the result.
We are now ready to prove Lemma 3.
Proof of Lemma 3. Let G be as in the statement of the theorem, and let C be the set of vertices in G of degree at least 3e(F ). Write c = |C|. Observe that c ≤ k − 1, since otherwise we could greedily embed the components of F into G, using the vertices of C as their centers.
has maximum degree at most 3e(F ). Since G has at least as many edges as the graph H F (n, c), it follows that G ′ must have average degree at least f (c) − ǫ, for some ǫ < 1. Therefore, by Lemma 5, the subgraph G ′ has at least Ω(n) vertices of degree Now suppose (for a contradiction) that G ′ has a vertex v of degree greater than f (c). Then we can form a rainbow copy of F in G as follows. Choose k−c−1 vertices of G ′ of degree f (c) that are at distance at least 3 from each other and from v (this is possible since the maximum degree is constant). We can build a rainbow forest of the stars S 1 , S 2 , . . . , S k−c−1 on these vertices, since these stars use f (c) + 1 −e(S k−c ) edge colors. The vertex v has degree at least f (c) + 1, so it is incident to at least f (c) + 1 − (f (c) + 1 − e(S k−c )) = e(S k−c ) unused colors. Therefore, we can extend the rainbow forest to include S k−c . Finally, the remaining c stars of F can be greedily embedded using the vertices in C as their centers, so that G contains a rainbow copy of F . This is a contradiction. Therefore, G ′ has maximum degree at most f (c). When c = k − 1 we are done, since we have shown that G has at most as many edges as H F (n, k − 1).
Let us now consider the case c ≤ k − 2. The lower bound e(G) ≥ e (H F (n, c)) shows that the number of edges in G ′ is at least In particular, G ′ has n − O(1) vertices of degree f (c), since G ′ has maximum degree f (c). We claim that G ′ must be colored with f (c) edge colors. Suppose, for a contradiction, that G ′ is colored with at least f (c) + 1 colors. Then there is a color class, say red, with at most edges. Therefore, there are Ω(n) vertices in G ′ of degree f (c) that are not incident to a red edge.
Since c ≤ k − 2, the sum in f (c) has at least two terms, so that As e(S 1 ) is an integer, this implies that e(S 1 ) ≤ ⌈f (c)/2⌉. We now embed S 1 in G ′ using a red edge. If n − c is even, then every vertex in G ′ has degree f (c) ≥ ⌈f (c)/2⌉, so we can choose a vertex v incident to a red edge and embed S 1 using that red edge.
When n − c is odd, G ′ may contain vertices of degree less than f (c). Consider a red edge uv and observe that at least one of the vertices u and v (say v) has degree at least ⌈f (c)/2⌉; otherwise the number of edges in G ′ is less than f (c) n−c 2 . Therefore, we can embed S 1 using the red edge uv with v as the center. Now, among the vertices not incident to red edges, pick k − c − 1 vertices of degree f (c) that are at distance at least 3 from each other and from the center v of S 1 . Using these vertices as centers, we can greedily build a rainbow forest of stars S 2 , S 3 , . . . , S k−c , since we have only used at most e(S 1 ) − 1 of the f (c) colors incident to these vertices. Finally, the remaining c stars of F can be greedily embedded using the vertices in C as their centers, so that G contains a rainbow copy of F . This is a contradiction. Therefore, G ′ is properly f (c)-edge-colored.
We now give a new proof of the result of Lidický, Liu and Palmer on the Turán number of forests of stars.
We begin by describing the extremal graph for the forest of stars S 1 , S 2 , . . . , S k , where e(S j ) ≤ e(S j+1 ) for each j. Let H ′ F (n, i) be the graph obtained by connecting a set of i universal vertices to an edge-maximal graph of maximal degree e(S k−i ) − 1 on n − i vertices. Observe that if one of e(S k−i )−1 or n−i is even, and n is large enough, then H is (e(S k−i )−1)regular. If both are odd, then H has exactly one vertex of degree e(S k−i ) − 2, and n − i − 1 vertices of degree e(S k−i ) − 1. Each of the graphs H ′ F (n, i) is F -free, since otherwise each of the i + 1 stars S k , S k−1 , . . . , S k−i must use at least one vertex from the universal set of size i, which is impossible.
Theorem 6 (Lidický, Liu, Palmer [10]). Let F be a forest of k stars S 1 , S 2 , . . . , S k , such that e(S j ) ≤ e(S j+1 ) for each j. Then ex(n, F ) = max Proof. Note that G has at least as many edges as H ′ F (n, i) for all i ≤ k − 1. Suppose that G has a set C of c vertices of degree at least e(F ). We must have c ≤ k − 1, since otherwise we could greedily embed F from the vertices of C. Let G ′ = G[V \ C] be the graph on the remaining n − c vertices. The maximum degree of G ′ is less than e(F ). First let us suppose that c = k − 1. In this case, we claim that the maximum degree of G ′ is at most e(S 1 ) − 1. Indeed, if there is a vertex v of higher degree, then we can embed S 1 into G ′ using v, and complete the forest F by greedily embedding the stars S 2 , S 3 , . . . S k using the vertices of C as their centers.
Next suppose that c < k − 1. Suppose (for a contradiction) that e(S k−c−1 ) = e(S k−c ). Comparing G to H ′ F (n, c+1), we see that G ′ must have average degree at least e(S k−c−1 )−ǫ = e(S k−c ) − ǫ. Therefore, by Lemma 5, the graph G ′ contains Ω(n) vertices of degree at least e(S k−c ). Now we can embed F as follows. Choose k − c vertices of G ′ of degree e(S k−c ) that are at distance at least 3 from each other. We can embed the stars S 1 , S 2 , . . . , S k−c on these vertices. Next we can greedily embed the remaining stars S k−c+1 , . . . , S k into G using the vertices of C as their centers; a contradiction. Therefore, we may assume that e(S k−c−1 ) < e(S k−c ). By comparing G to H ′ F (n, c), we see that G ′ must have average degree at least e(S k−c ) − 1. Therefore, by Lemma 5, the graph G ′ contains Ω(n) vertices of degree at least e(S k−c ) − 1. Now suppose that G ′ has a vertex v of degree greater than e(S k−c ) − 1. Then we can embed F as follows. Choose k − c − 1 vertices of G ′ of degree e(S k−c ) − 1 that are at distance at least 3 from each other and from v. We can embed the stars S 1 , S 2 , . . . , S k−c−1 on these vertices, since e(S k−c ) − 1 ≥ e(S k−c−1 ). Next we embed the star S k−c at v, and then greedily embed the remaining stars S k−c+1 , . . . , S k into G using the vertices of C as their centers; a contradiction. Therefore, the maximum degree of G ′ is e(S k−c ) − 1.

Paths
In this paper, P l will denote a path with l edges, which we will call a path of length l. The usual Turán number for paths was determined asymptotically by Erdős and Gallai [6], and exactly by Faudree and Schelp [7]. Erdős and Gallai proved that, given a path length l, if l divides n then ex(n, P l ) = n l l 2 = l − 1 2 n, and the unique extremal graph is the disjoint union of n l copies of K l . We briefly recall the proof. First we show that any graph G with minimum degree at least δ contains a path of length 2δ (provided of course that 2δ < n). Next, consider a graph G of order n with more than l−1 2 n edges (i.e., of average degree greater than l − 1). By repeatedly removing a vertex of minimum degree, we can show that G must contain a subgraph H whose minimum degree is at least l 2 , and so H contains a path of length l. Following this approach for the rainbow Turán problem therefore requires us to find a rainbow path of length cδ in a graph of minimum degree δ. To this end, we have the following theorem, which generalizes a result of Gyárfás and Mhalla [8], and is itself a special case of a theorem of Babu, Chandran and Rajendraprasad [2]. For completeness, we provide a short proof of the result we need, which is less technical than the proof in [2]. Theorem 7. Let G be a graph with minimum degree δ = δ(G). Then any proper edgecoloring of G contains a rainbow path of length at least 2 3 δ. Proof. Suppose that c is a proper edge-coloring of G. Take a longest rainbow path P = v 0 v 1 · · · v l in G, of length l. Without loss of generality, c(v i−1 v i ) = i for each i (i.e., the i th edge of P receives color i). Write s o for the number of edges colored with colors 1, . . . , l that v 0 sends to vertices outside P , and note that v 0 can send no other edges outside P , or else P could be extended. Also write s i for the number of edges of colors 1, . . . , l that v 0 sends to other vertices of P (including v 1 ), and write s × for the number of edges of other colors that v 0 sends to vertices of P . Finally, define t o , t i and t × to be the analogous quantities for v l .
Observe now that since c is a proper coloring, that since there are exactly l vertices on P other than v 0 , and that would be a rainbow path in G of length l + 1. Analogous inequalities hold for t o , t i and t × . Consequently, combining (1), (2) and (3) with the minimum degree condition, we have so that l ≥ 2 3 δ, as desired. We remark that the constant 2 3 cannot be improved in general. To see this, let G be the disjoint union of r copies of K 4 , and properly 3-color the edges of each K 4 (there is a unique way to do this, up to isomorphism). Then δ(G) = 3, and the longest rainbow path in G has length 2. However, Chen and Li [4], and independently Mousset [12], proved that a proper edge-coloring of K n contains a rainbow path of length 3 4 n−o(n). It is widely believed (see [1]) that a proper edge-coloring of K n in fact contains both a rainbow path and a rainbow cycle of length n − o(n), and perhaps even a rainbow path of length n − 2. However, Maamoun and Meyniel [11] showed that we are not always guaranteed a rainbow path of length n − 1. In their construction, n = 2 k , and we identify the vertices of K 2 k with the points of the Boolean cube {0, 1} k . If we now color each edge uv with color u − v = 0, a monochromatic path v 0 v 1 · · · v n−1 of length n − 1 in K n would involve all possible colors (except for 0), so that A slight modification of the proof of Theorem 7 yields a short proof of the full result of Babu, Chandran and Rajendraprasad [2] mentioned above. Their result deals with general (not necessarily proper) edge-colorings, in which, given an edge-colored graph G, θ(G) is the minimum number of distinct colors seen at each vertex. Clearly θ(G) = δ(G) if the coloring is proper.
Theorem 8. Let G be an edge-colored graph in which every vertex is incident to at least θ = θ(G) edge-colors. Then G contains a rainbow path of length at least 2 3 θ. Proof. We follow the proof of Theorem 7, with a slight change in the definitions of s o , s i and s × . This time, s o is the number of colors of edges that v 0 sends to vertices outside P (as before, each of these colors already occurs on P ), and s × is the number of colors not seen on P which occur as the colors of edges v 0 sends to P . Now s i is the number of colors from 1 to l that occur as colors of edges v 0 sends to P and which are not counted in s o . The rest of the proof goes through as before, with δ replaced by θ.
Returning to the problem at hand, we can use Theorem 7 to obtain a bound on the rainbow Turán number of paths.
Theorem 9. For each fixed l ≥ 1, we have Proof. We will make use of the standard fact that a graph G of average degree more than 2d contains a subgraph H of minimum degree at least d + 1. This is proved by repeatedly removing a vertex of minimum degree from G. First, suppose that l is even, and write l = 2k. Let G be a graph of order n with more than 3l−2 2 n = (3k − 1)n edges (and so of average degree more than 2(3k − 1)). Then G contains a subgraph H of minimum degree at least 3k, which by Theorem 7 contains a rainbow path of length 2k = l.
Second, suppose that l is odd, and write l = 2k + 1. Let G be a graph of order n with more than 3l−1 2 = (3k + 1)n edges (and so of average degree more than 2(3k + 1)). Then G contains a subgraph H of minimum degree at least 3k + 2, which by Theorem 7 contains a rainbow path of length 2k + 1 = l.
For small values of l, one can do considerably better. It is trivial that ex * (n, P 1 ) = ex(n, P 1 ) = 0 and that ex * (n, P 2 ) = ex(n, P 2 ) = n 2 . When l = 3, we have the following simple result.
Theorem 10. Suppose that n is divisible by 4. Then ex * (n, P 3 ) = 3n 2 = 3 2 ex(n, P 3 ) + O(1). Proof. The example already shown, namely n 4 disjoint copies of properly 3-colored K 4 s, shows that ex * (n, P 3 ) ≥ 3n 2 . For the other direction, suppose that G = (V, E) is a graph with more than 3n 2 edges and no rainbow P 3 , and select v ∈ V with d(v) ≥ 3 (there must be at least one such v). Then the neighbors v 1 , . . . , v r of v can only be adjacent to each other, since if v i w ∈ E with vw ∈ E then wv i vv j is a rainbow P 3 for some j (chosen so that the colors of v i w and vv j are different).
where this time k has been chosen so that v i v j and vv k receive different colors.
] is a component of G whose average degree is at most 3, so we may remove it and apply induction.
For P 4 , we have the following theorem.
Proof. The lower bound comes from the proper edge-coloring of K 4,4 illustrated in Figure  1, which contains no rainbow P 4 . (To see this, note that in the given coloring, any 4-cycle containing two identically-colored edges must in fact be 2-colored, so that every 4-cycle contains either 2 or 4 colors. Now suppose (to the contrary) that xyzst is a rainbow P 4 . Then the cycle xyzsx must contain all 4 colors, so that edges st and sx must receive the same color, which is impossible since they are adjacent.) Next, if n = 8k, then the disjoint union of k such edge-colored K 4,4 s has 2n edges and no rainbow P 4 . Consequently, ex * (n, P 4 ) ≥ 2n if 8|n, and ex * (n, P 4 ) ≥ 2n + O(1) in general. For the upper bound, we show that every proper edge-coloring of an n-vertex graph G with m > 2n edges contains a rainbow P 4 .
As noted before, G contains a subgraph G ′ of minimum degree at least 3, since otherwise we can repeatedly remove vertices of degrees 1 and 2 so that the average degree increases. Furthermore, G ′ has average degree greater than 4. Therefore, G ′ has a vertex v of degree at least 5. We will show that G ′ contains a rainbow P 4 . The proof now splits into two cases.
Case 1: G ′ contains a rainbow P 3 ending at v. This case is illustrated in Figure 2; let the rainbow P 3 be P = vxyz, where edges vx, xy and yz are colored 1, 2 and 3 respectively. Since v has degree at least 5, it must be adjacent to at least 2 vertices not on P ; suppose these vertices are s and t. If either of the edges vs and vt receives a color other than 2 or 3, then we have a rainbow P 4 . Now suppose that c(vs) = 2 and c(vt) = 3, where c denotes the color of the edge. If v is adjacent to any other vertex u not on P , then since c(uv) would have to be different from 1, 2 and 3, the edge uv with P forms a rainbow P 4 . Otherwise, the vertex v has degree 5 and is adjacent to both y and z. Without loss of generality, suppose c(vy) = 4 and c(vz) = 5.
Suppose that the vertex z is adjacent to x. Note that c(xz) cannot be 1, 2 or 3, and so svxzy is a rainbow P 4 . If z is not adjacent to x, then z is adjacent to a vertex w not on P (possibly w = s or w = t) as the minimum degree of G ′ is at least 3. We know that c(wz) cannot be 3 or 5; if c(wz) = 1 then wzvyx is a rainbow P 4 , while if c(wz) = 2 then wzyvx is a rainbow P 4 . However, if c(wz) is not 1, 2 or 3, then vxyzw is a rainbow P 4 . Accordingly, this completes the proof in Case 1. Case 2: G ′ contains no rainbow P 3 ending at v. Since δ(G ′ ) ≥ 3, G ′ contains a rainbow P 2 ending at v; let this path be vxy, where c(vx) = 1 and c(xy) = 2. The vertex y has degree at least 3; if y were adjacent to two vertices s and t other than v and x, then one of edges ys and yt would receive color 3, creating a rainbow P 3 ending at v. Consequently, the degree of y is 3 and y is adjacent to v and a new vertex z. Furthermore, c(yz) = 1, and, without loss of generality, c(yv) = 3. Let P be the path vxyz.
The vertex z is adjacent to at most one vertex w not on P and the edge zw must receive color 3 to avoid the rainbow P 3 vyzw ending at v. Consequently, z is adjacent to at least one of v or x. The proof now splits into three sub-cases. Case 2A: z is adjacent to x and a new vertex w. This case is illustrated on the left of Figure 3. Edge xz cannot receive any of colors 1, 2 or 3, and so vxzw is a rainbow P 3 ending at v. Case 2B: z is adjacent to v and a new vertex w. This case is illustrated in the center of Figure 3. Edge vz must receive color 2 to avoid the rainbow P 3 vzyx ending at v. Now, if w were adjacent to two vertices s and t other than v, x, y and z, then one of edges ws and wt would receive color other than 2 and 3, creating a rainbow P 3 ending at v. Therefore, there is at least one edge from w to v, x, or y. Such an edge cannot receive colors 1, 2, or 3. If wv is an edge, then vwzy is a rainbow P 3 ; if wx is an edge, then vxwz is a rainbow P 3 ; if wy is an edge, then vxyw is a rainbow P 3 . In all cases we have found a rainbow P 3 ending at v. Case 2C: z is adjacent to both v and x. This case is illustrated on the right of Figure 3. In this case, the vertices v, x, y, z induce a properly 3-edge-colored K 4 as otherwise we can easily find a rainbow P 3 ending at v. We will exploit the resulting symmetry in the three colors 1, 2 and 3. The vertex v must be adjacent to a new vertex u, and, without loss of generality, c(uv) = 4. If the vertex u is adjacent to a new vertex w, then we may assume that c(uw) = 1, and then wuvzx would be a rainbow P 4 . Otherwise, u is adjacent to at least two of x, y and z; suppose it is adjacent to x. Then c(ux) cannot be 1, 2, 3 or 4, and then xuvzy is a rainbow P 4 .
Thus, in all three sub-cases we obtain either a rainbow P 3 ending at v (leading us to Case 1), or a rainbow P 4 in G ′ . Keevash, Mubayi, Sudakov and Verstraëte conjectured that the extremal example for rainbow P l s is a disjoint union of cliques of size c(l), where c(l) is chosen as large as possible so that K c(l) can be properly edge-colored with no rainbow P l . It is not hard to show that a properly edge-colored K 5 must contain a rainbow P 4 , so that c(4) = 4. Consequently, the conjecture implies that ex * (n, P 4 ) = 3n 2 + O(1), which is false, as our theorem shows.