Sharp bounds for decomposing graphs into edges and triangles

For a real constant $\alpha$, let $\pi_3^\alpha(G)$ be the minimum of twice the number of $K_2$'s plus $\alpha$ times the number of $K_3$'s over all edge decompositions of $G$ into copies of $K_2$ and $K_3$, where $K_r$ denotes the complete graph on $r$ vertices. Let $\pi_3^\alpha(n)$ be the maximum of $\pi_3^\alpha(G)$ over all graphs $G$ with $n$ vertices. The extremal function $\pi_3^3(n)$ was first studied by Gy\H{o}ri and Tuza [Decompositions of graphs into complete subgraphs of given order, Studia Sci. Math. Hungar. 22 (1987), 315--320]. In a recent progress on this problem, Kr\'al', Lidick\'y, Martins and Pehova [Decomposing graphs into edges and triangles, Combin. Prob. Comput. 28 (2019) 465--472] proved via flag algebras that $\pi_3^3(n)\le (1/2+o(1))n^2$. We extend their result by determining the exact value of $\pi_3^\alpha(n)$ and the set of extremal graphs for all $\alpha$ and sufficiently large $n$. In particular, we show for $\alpha=3$ that $K_n$ and the complete bipartite graph $K_{\lfloor n/2\rfloor,\lceil n/2\rceil}$ are the only possible extremal examples for large $n$.


Introduction
In a recent progress on a problem of Győri and Tuza [27], Král', Lidický, Martins and Pehova [19] proved via flag algebras that the edges of any n-vertex graph can be decomposed into copies of K 2 and K 3 whose total number of vertices is at most (1/2 + o(1))n 2 , where K r denotes the clique on r vertices. The origins of this problem can be traced back to Erdős, Goodman and Pósa [10] who considered the problem of minimising the total number of cliques in an edge decomposition of an arbitrary n-vertex graph. They showed the following: Theorem 1 (Erdős, Goodman, Pósa [10]). The edges of every n-vertex graph can be decomposed into at most ⌊n 2 /4⌋ complete graphs.
The only extremal example for this bound is the (bipartite) Turán graph T 2 (n) := K ⌊n/2⌋,⌈n/2⌉ , where K a,b denotes the complete bipartite graph with part sizes a and b. Moreover, this result still holds if we restrict the sizes of the cliques used in the decomposition to 2 and 3 (that is, single edges and triangles). In a series of papers published independently by Chung [4], Győri and Kostochka [11], and Kahn [18], they proved that in fact something stronger than Theorem 1 is true, confirming a conjecture by Katona and Tarján: Theorem 2 (Chung [4], Győri and Kostochka [11], Kahn [18]). Every n-vertex graph can be edge decomposed into cliques whose total number of vertices is at most ⌊n 2 /2⌋.
In this paper we show, by building upon the proof in [19], that for all large n it holds in fact π 3 (n) n 2 /2 + 1. Moreover, if a graph G of order n attains π 3 (n) then G is the complete graph K n or the Turán graph T 2 (n).
Which of these two graphs is extremal is a matter of divisibility of n by 6. In the case of the Turán graph, we trivially have π 3 (T 2 (n)) = 2⌊n/2⌋⌈n/2⌉, giving n 2 /2 for even n and (n 2 − 1)/2 for odd n. In order to determine π 3 (K n ), we have to determine the maximum number of edgedisjoint triangles in K n . Clearly, the graph made of their edges is triangle-divisible, that is, each vertex has even degree and the total number of edges is divisible by three. It is routine to see that the minimum size of a graph H on n vertices whose complement H is triangle-divisible is attained by taking at most one copy of the claw K 1,3 and a perfect matching on the remaining vertices for even n, and isolated vertices plus at most one copy of the 4-cycle K 2,2 for odd n. (Note that n 2 is never equal to 2 modulo 3.) In fact, this gives the value of π 3 (K n ) for all large n by the following general result (which we will use also inside our proof).
Theorem 4 (Barber, Kuhn, Lo and Osthus [2]). For every ε > 0, if G is a triangle-divisible graph of large order n and minimum degree at least (0.9 + ε)n, then G has a perfect triangle decomposition.
The constant 0.9 in the minimum degree condition in Theorem 4 comes from the result of Dross [6] on fractional triangle decompostions, and it was conjectured by Nash-Williams [21] that it can be replaced by 3/4. Very recently, Dukes and Horsley [7] and Delcourt and Postle [5] improved the constant to 0.852 and (7 + √ 21)/14 = 0.8273..., respectively.
Let us list the values of π 3 for the graphs K n and T 2 (n) for large n.
Thus, by the calculations of Table 1, we have for all large n that E n consists of those graphs in {T 2 (n), K n } which maximise π 3 while ℓ(n) is this maximum value.
Clearly, ℓ(n) is a lower bound on π 3 (n) for large n. Our main result is that this is equality.
Theorem 5. There exists n 0 ∈ N such that for all n n 0 , we have π 3 (n) = ℓ(n) and the set of π 3 (n)-extremal graphs up to isomorphism is exactly E n .
A simple corollary of Theorem 5 is an affirmative answer to a question of Pyber [23], see also [27,Problem 45], for sufficiently large n. A covering of a graph G is a collection of subgraphs of G such that every edge of G appears in at least one subgraph. (For comparison, a decomposition requires that every edge appears in exactly one subgraph.) Corollary 6. There exists n 0 ∈ N such that for all n n 0 , the edge set of every n-vertex graph can be covered with triangles and edges so that the sum of their orders is at most ⌊n 2 /2⌋.
Proof. Theorem 5 directly implies the corollary unless n ≡ 4 (mod 6) and the graph under consideration is K n . So assume that n ≡ 4 (mod 6). Denote the vertices of K n by v 1 , ... , v n . Recall that an optimal decomposition for K n is obtained by taking edges The rest of the graph becomes triangle-divisible and Theorem 4 can be applied. This gives a decomposition of cost n 2 /2 + 1. A covering of cost at most n 2 /2 can be obtained from this decomposition by replacing edges v 1 v 2 and v 1 v 3 by a triangle v 1 v 2 v 3 . (Notice that the pair v 2 v 3 is covered by two triangles in the resulting covering.) We also study an extension of Theorem 5, where we consider decompositions into K 2 's and K 3 's but we modify the cost of K 3 's to be α (with the cost of K 2 still being 2). The minimum over all costs of such decompositions of a graph G is denoted by π α 3 (G). The maximum value of π α 3 (G) over all n-vertex graphs G is denoted by π α 3 (n). Notice that π 3 3 (G) = π 3 (G) and π 3 3 (n) = π 3 (n). Denote K n without one edge by K − n and K n without a matching of size two by K = n . Then the following result holds.
Theorem 7. For every real α exists n 0 ∈ N such that every π α 3 -extremal graph G with n n 0 vertices satisfies the following (up to isomorphism).
This paper is organised as follows. In Section 2 we give an outline of the proof of Theorem 3 from [19] that we build on. Theorem 5 is proved in Section 3. Extension for other weights of triangles is in Section 4. Some related results are mentioned in Section 5.
For a graph G, we denote the set neighbours of x ∈ V (G) by Γ G (x) (or just Γ (x) when G is understood) and the number of edges in a set B ⊆ E(G) incident with x by d B (x). We denote by K[V 1 , V 2 ] the complete bipartite graph with vertex partition (V 1 , V 2 ). The term [X, Y ]-edges refers to edges xy ∈ E(G) such that x ∈ X and y ∈ Y . We write [x, Y ]-edges as a short-hand for [{x}, Y ]-edges.
Let t 2 (n) := |E(T 2 (n))| be the number of edges in the Turán graph T 2 (n). Recall that t 2 (n) = ⌊n 2 /4⌋. By a cherry we mean a path with 2 edges.
We consider graphs up to isomorphism; in particular, we write G = H to denote that G and H are isomorphic graphs.
2 Outline of the proof of Theorem 3 from [19] In this section we give a short outline of the proof of [19,Lemma 5], which was a key step in proving π 3 (n) n 2 /2 + o(n 2 ) and is a starting point of our argument towards Theorem 5. For an n-vertex graph G and each i ∈ N, let K i (G) be the set of all i-cliques in G. Let π 3,f (G) be the minimum of 2 such that for every edge xy ∈ E(G) we have c(xy) + z:xyz∈K 3 (G) c(xyz) 1. Of course, π 3,f (G) π 3 (G). By a result of Haxell and Rödl [17] or a more general version by Yuster [28], it also holds that π 3 (G) π 3,f (G) + o(n 2 ). So, to show that π 3 (G) n 2 /2 + o(n 2 ), it suffices to consider the fractional equivalent π 3,f (G).
Lemma 8. Let G be an n-vertex graph. Then where the sum is taken over 7-vertex subsets W of V (G).
Outline of proof. Let M be the following positive semi-definite matrix be the following vector of rooted graphs, each having 4 vertices with the root denoted by the white square: .
Take any graph G of order n → ∞. For w ∈ V (G), let v G,w ∈ Ê 7 denote the column vector whose i-th component is p(F i , (G, w)), the density of the 1-flag F i in the rooted graph (G, w), which is G with the vertex w designated as the root.
It was shown in [19] that Namely, if we re-write the left-hand size as a linear combination H c H p(H, G), where H ranges over all 7-vertex unlabelled graphs and p(H, G) is the density of H in G, then each coefficient c H is at most 21. Since H p(H, G) = 1, the claimed inequality (1) follows.
In particular, since M is positive semi-definite, the quantity 1 The main result of [19] that π 3 (n) n 2 /2 + o(n 2 ) now follows directly from Lemma 8.

Proof of Theorem 5
We use the so-called stability approach, where the first step is to describe the approximate structure of all almost π 3 -extremal graphs of order n → ∞ within o(n 2 ) adjacencies. Namely, our Corollary 10 will show that every such graph is close to K n or T 2 (n).
For this purpose, we start by showing that all almost π 3 -extremal graphs contain almost no copies of the three graphs in Figure 1 (which are obtained by taking the unlabelled versions of the corresponding graphs in − → F ). This is achieved by the following lemma that builds on the results from [19]. Second, by the almost optimality of G and the fact that each term in the left-hand side of (1) is non-negative, we have that We now show that G must contain few copies of the graphs H 2 , H 5 and H 7 . Suppose, for contradiction, that G contains at least c n 4 copies of H 2 . Then, by a simple double-counting argument we have that at least cn/4 vertices in G contain at least c n 3 /4 copies of the rooted flag F 2 . In particular, the second coordinate of at least cn/4 of the vectors v G,w is at least c/4. For each such vector u, let u ′ := u/ u 2 be the scalar multiple of u of ℓ 2 -norm 1. Since The scalar product of u ′ and the ℓ 2 -normalised zero eigenvector v/ √ 20 (whose second coordinate is 0) is at most where λ 2 > 0 is the smallest positive eigenvalue of M (in fact, one can check with computer that λ 2 = 0.0005228...). Thus, we have that the left-hand side of (2) in which each term is non-negative by M 0 is at The analogous argument shows that the densities of H 5 and H 7 in G are also at most c.
Let us say that two graphs G 1 and G 2 of the same order are k-close in the edit distance (or simply k-close) if there is a relabelling of the vertices of G 2 so that |E(G 1 )△E(G 2 )| k. In other words, we can make G 1 and G 2 isomorphic by changing at most k adjacencies.
Corollary 10. For every δ > 0 there exists n 1 ∈ N such that if G is a graph of order n n 1 with π 3 (G) ℓ(n) − n 2 /n 1 , then G is δn 2 -close in edit distance to K n or to T 2 (n).
By Lemma 9 and the Induced Removal Lemma [1], G can be made {H 2 , H 5 , H 7 }-free by changing at most cn 2 adjacencies. Denote this new graph by G ′ and note that Let us show that G ′ is either triangle-free, or the disjoint union of at most two cliques. Indeed, if some vertices a, b, c span a triangle in G ′ then, by the Also, no pair xy in A 3 × A 0 can be an edge as otherwise e.g. the 4-set {a, b, x, y} spans a copy of H 5 in G. It follows that G is the disjoint union of the cliques on A 0 and A 3 ∪ {a, b, c}, as required.
Thus, by the stability result for Mantel's theorem by Erdős [8] and Simonovits [26], the graph G ′ must indeed be δn 2 /2-close in edit distance to T 2 (n).
Otherwise, G ′ is the disjoint union of two cliques. Let us show that one of them has size at most δn/2. Indeed, otherwise G ′ has a triangle packing covering all but at most n/2 + 2 edges by Theorem 4, meaning that π 3 (G ′ ) e(G ′ ) + n/2 + 2. Also, e(G ′ ) is maximum when clique sizes are as far apart as possible. Thus, by the lower bound on π 3 (G) π 3 (G ′ ) + 2cn 2 , we conclude that e.g. ℓ(n) − 3cn 2 δn/2 2 , leading to a contradiction to our choice of constants. Therefore, G ′ is at most n · δn/2 adjacency edits away from K n , as desired.
The key steps in proving Theorem 5 are Lemmas 11-13. Lemma 11. There exist constants δ > 0 and n 1 ∈ N such that, among all graphs on n n 1 vertices which are δn 2 -close to T 2 (n), the maximiser of π 3 is T 2 (n).
Proof. Choose sufficiently small ε ≫ δ ≫ 1/n 1 > 0. Let G be an arbitrary graph with n n 1 vertices which is δn 2 -close to T 2 (n). We will show that π 3 (G) π 3 (T 2 (n)) with equality if and only if G = T 2 (n). In fact, this claim can be directly derived from the result of Győri [12, Theorem 1] that a graph with n vertices and t 2 (n) + k edges, where n → ∞ and k = o(n 2 ), has at least k − O(k 2 /n 2 ) edge-disjoint triangles. More specifically, for each ε > 0 there exists δ > 0 and n 0 ∈ N such that every graph with n n 0 vertices and t 2 (n) + k edges, where k δn 2 , has at least k − εk 2 /n 2 edge-disjoint triangles. (See also [13,Theorem 1] for a generalisation of this to r-cliques for any fixed r 3.) Since G is δn 2 -close to T 2 (n), it must have at most t 2 (n) + δn 2 edges. From this and 1/n ≪ δ ≪ ε ≪ 1, we have that, for k := e(G) − t 2 (n), Clearly, if equality is achieved then k = 0, that is, e(G) = t 2 (n); furthermore, G must be triangle-free and thus G = T 2 (n), as required.
Using Theorem 4 and the calculation for K n described in Table 1, one can show that π 3 (G) = n 2 + w(n) for all large n and every G ∈ E ′ n . We are going to show that these are exactly the extremal graphs among those close to K n . It is more convenient to do first the case when we have some bound on the minimum degree of a graph and then derive the general case (in a separate Lemma 13).
Lemma 12. There exist constants δ > 0 and n 0 ∈ N such that the following holds. Let G be a graph on n n 0 vertices with minimum degree at least n/8 such that G is δn 2 -close to K n and π 3 (G) n 2 + w(n). Then G ∈ E ′ n .
Proof. Choose small constants in the following order: c ≫ δ ≫ 1/n 0 > 0. Suppose that G is a graph of order n n 0 as in the statement of the lemma. Let w := w(n).
Moreover, for every edge yz ∈ M and any two distinct vertices y ′ , z ′ ∈ X, at most one of yy ′ and zz ′ can be an edge of G (otherwise y ′ yzz ′ is an augmenting path contradicting the maximality of M ). It follows that, if |X| = 1, then for every edge yz ∈ M there are at least |X| edges missing between yz and X. Let Y W denote the set of missing edges in G[W ]. Thus where the indicator function ½ |X|=1 is 1 if |X| = 1 and is 0 otherwise. Moreover, the set Y U of missing edges in G with at least one endpoint in U satisfies by the definition of U . Note that e(G) = n 2 − |Y W | − |Y U |. See Figure 2 for a sketch ot Y W and Y U .
We now build a decomposition D of G into edges and triangles, starting with D = ∅. If we add edges/triangles to D, we regard them as removed from E(G). It is convenient to split our argument into the following two cases.
In this case, our procedure for constructing D is as follows.
Step 1: Add the following to D as K 2 's: the edges of the matching M and the edges of some ⌊|X|/2⌋ cherries with distinct endpoints in X such that their middle points are pairwise distinct.
Step 2: For each u ∈ U , one at a time, add to D a maximum set of edge-disjoint K 3 's containing u and two vertices from W . Add all remaining edges incident to vertices in U as K 2 's to D.
Step 3: (a) Let S ′ ⊆ V (G) be the set of vertices with odd degree after Step 2. Add to D the edges of some |S ′ |/2 cherries with distinct endpoints in S ′ such that their middle points are pairwise distinct.
(b) If the number of remaining edges is not divisible by 3, then fix this by adding to D (as single edges) the edge set of some cycle of length 4 or 5.
Step 4: Add a perfect triangle decomposition of the remaining edges to D.
For i ∈ {1, 2, 3}, let Z i be the set of edges that are added to D in Step i as copies of K 2 . See Figure 2 for some illustrations of the above steps.
Claim. The above steps can be carried out as stated. Moreover, the obtained decomposition D of G has at most |M | + |X| + |U | 2 + 2|U | + 6 copies of K 2 . Proof of Claim. In order to do Step 1 as stated, we can iteratively pick any two new vertices x, y ∈ X and then an arbitrary vertex z which is suitable as the middle point for a cherry on xy. Note that the number of choices for z is at least n − 2 − 2cn, the number of common neighbours of x, y ∈ X ⊆ W , minus |X| − 1, the number of vertices previously used as middle points. This is positive by (3) and c ≪ 1, so we can always proceed. Note for future reference that every vertex is incident to at most 3 edges removed in Step 1. Also, Step 1 adds |Z 1 | = |M | + 2(⌊|X|/2⌋) |M | + |X| copies of K 2 to D.
Clearly, Step 2 can always be processed. Consider the moment when we apply Step 2 to some u ∈ U . In the current graph, the induced subgraph G[Γ (u) ∩ W ] has minimum degree at least |Γ (u) ∩ W | − cn − 3, which is at least |Γ (u) ∩ W |/2 since |Γ (u)| n/8 − 3. So by Dirac's theorem, this subgraph has a matching covering all but at most one vertex, that is, all edges between u and W except at most one are decomposed as triangles in Step 2. Let U ′ be the set of those u ∈ U for which an exceptional edge occurs. Thus we have |U ′ | |U | copies of K 2 connecting U to W that are added to D in Step 2. There are trivially at most |U | 2 edges with both endpoints in U . So Step 2 adds |Z 2 | |U | 2 + |U | copies of K 2 to D. Note that all edges incident to U are decomposed after Step 2.
Since all vertices of W but at most one had even degrees before Step 2, we have that S ′ has at most |U ′ | + 1 |U | + 1 vertices. Similarly as in Step 1, a simple greedy algorithm finds all cherries as stated Step 3(a). (Note that S ′ , as the set of all odd-degree vertices, has even size.) The minimum degree of G[W ] after Step 3(a) is at least 0.99n, since each w ∈ W has at most 2|U | + 6 incident edges removed (at most 2|U | from Step 2 and at most 3 in each of Steps 1 and 3(a)). Thus, we can find the required 4-or 5-cycle in Step 3(b).
Clearly, we add |Z 3 | |S ′ | + 5 |U | + 6 copies of K 2 to D in Step 3. Note that, at the end of Step 3, the graph G[W ] has minimum degree at least, say, 0.98n while all its degrees are even. By Theorem 4, all remaining edges can be decomposed using only triangles, so Step 4 indeed removes all remaining edges.
Step 4 adds no additional K 2 's, so the total number of K 2 's in D is finishing the proof of the claim. Now we compute the cost of D. Using the notation from above, we have Substituting the bounds from (4) and (5) and rearranging the terms, we get First, suppose that |U | > 0. Then, the estimate |U | 2δn/c yields that Since w 2, we must have that |X| 1. Observe that n is odd as otherwise w n/2 and, by |M | n/2, the cases |X| ∈ {0, 1} also contradict (7). So every vertex of degree n − 1 has even degree, meaning that every vertex of S is in some pair from Y W or Y U . Hence, 2|M | 2|Y W | + |Y U |. Substituting this into the right-hand size of (6) and using our bound on |Y U | from (5), we obtain which again is negative for |U | > 0 and large n, contradicting w 2.
Thus U is empty and, by the assumption of Case 1, S is also empty (and so are X and M ). This gives that the initial graph G has minimum degree at least (1 − c)n, |Z 1 | = |Z 2 | = 0, S ′ = ∅, and no K 2 's are added to D in Step 3(a).
If n is even, then every vertex of G has at least one missing edge, e(G) n 2 − n 2 and which is strictly less than π 3 (K n ), a contradiction.
Let n be odd and let r := n 2 − e(G) be the number of missing edges in G. Suppose that r > 0, as otherwise G = K n and we are done. The upper bound on π 3 (G) given by D is ρ r + n 2 − r, where we define ρ r as the unique element of {0, 4, 5} with n 2 − ρ r − r ≡ 0 (mod 3). Therefore, r 3 as otherwise π 3 (G) n 2 + 1 contradicting w 2. On the other hand, all the degrees of G are even so r = 3 and the only non-empty component of G is a triangle. However, this contradicts w 2 because π 3 (G) = n 2 − 1, n ≡ 1, 3 (mod 6), n 2 + 1, n ≡ 5 (mod 6).
Some things simplify in this case (as we do not need to deal with U ). On the other hand, we have to be a bit more careful with calculations, as the new extremal graphs (K n minus a matching) fall into this case. In particular, removing a 4-or 5-cycle may be too wasteful here. So we construct a decomposition D of G as follows. Recall that M is a maximum matching in G[S] and X is the set of vertices of S not matched by M .
Step 1: Make the graph triangle-disivible by removing the following as K 2 's. If X = ∅, then remove all but one edge xy ∈ M and a path of length ρ + 1 ∈ {1, 2, 3} whose endpoints are x and y (thus, for ρ = 0, we remove just the matching M ). If X is non-empty, then remove M and the edge sets of some |X|/2 − 1 paths of length 2 and one path of length ρ + 2 ∈ {2, 3, 4} so that their degree-1 vertices partition X and their degree-2 vertices are pairwise distinct.
Step 2: Decompose the rest perfectly into triangles.
Note that S, the set of all odd-degree vertices of G, has even size (and also |X| = |S| − 2|M | is even). Since the minimal degree of G is at least (1 − c)n, a simple greedy algorithm achieves Step 1 (and Theorem 4 takes care of Step 2).
Suppose that X = ∅. First, let n be even. Then every vertex not in S is incident to at least one non-edge of G, |Y W | (n − 2|M |)/2, and by (8), If 2|M | n − 2, then all inequalities here become equalities and thus |M | = n−2 2 , |Y W | = 1, ρ = 2, w = n 2 , and n ≡ 0, 2 (mod 6). However, then the graph after Step 1 has exactly n 2 − 1 − n−2 2 − 2 edges, which is not divisible by 3, a contradiction. Thus 2|M | = n, the copies of K 2 in the decomposition contains a perfect matching of G, and π 3 (G) π 3 (K n ) with equality only if G = K n , giving the desired. So suppose that n is odd. Since every vertex of S has to be incident to a missing edge of G, we have |Y W | |S|/2 = |M | and the bound in (8) becomes w ρ. It follows that we have equality throughout, |Y W | = |M |, w = ρ = 2, n ≡ 1, 3 (mod 6), and n 2 − |M | − ρ ≡ 0 (mod 3); the last gives that |M | ≡ 2 (mod 3). Thus G is as required. Finally, it remains to consider the case when |X| = 2. This time, (9) yields that 2 w ρ − |M | + 1 3.
Lemma 13. There exist constants δ > 0 and n 1 ∈ N such that the following holds. Let G be a graph on n n 1 vertices maximizing π 3 (G) among all graphs that are δn 2 -close to K n . Then G ∈ E ′ n .
Proof. Let n 0 and δ be the constants from Lemma 12. We claim that, for example, n 1 := 2n 0 is enough for the conclusion of Lemma 13 to hold. Indeed, take any extremal graph G of order n n 1 . If G satisfies the assumption on minimum degree of Lemma 12, then we are done. Hence assume that the minimum degree of G is less than n/8. Let G n := G, and iteratively define a sequence of graphs G n−1 , G n−2 , ... as follows. Given a graph G i of order i, if it has a vertex x of degree less than i/8, let G i−1 := G i − x be obtained from G i by removing the vertex x; otherwise stop. Note that the process does not reach i < n/2 for otherwise G has roughly at least (n/2) × (n/4) non-edges, which is a contradiction to G being δn 2 -close to K n .
Let G s with |G s | = s n/2 n 0 be the graph for which the above process terminates. By Lemma 12, we have that π 3 (G s ) s 2 2 + 1. By decomposing all edges in E(G) \ E(G s ) as K 2 's, we obtain that This is a convex function in s so it is maximized on the boundary of n 2 s n − 1. If s = n/2, we get π 3 (G n ) n 2 /4 + 2 < n 2 π 3 (K n ). If s = n − 1, we get In both cases, we get a contradiction to G n being extremal.
First, let us show that every π α 3 -maximiser G is in K n or K = n . Suppose for a contradiction that G violates this. In particular, we have π α 3 (G) π α 3 (K n ). By (10), we have that π 3 3 (G) π 3 3 (K n ). For n → ∞, it holds by Table 1 that π α 3 (K n ) (1 + Ω(1)) π α 3 (T 2 (n)). Hence G needs to be close to K n and Lemma 13 applies to G. In particular, this means that n ≡ 1, 3 (mod 6). Lemma 13 gives that all π 3 3 -extremal graphs are obtained from K n by removing a matching of size congruent to 2 modulo 3. It follows from (10) that, among these graphs, π α 3 is strictly maximized by K = n since this graph has the largest ν.
Theorem 4 gives that 3ν(K = n ) = n 2 − 6. Since π α 3 (G) π α 3 (K = n ) and π 3 3 (G) < π 3 3 (K = n ), this implies by (10) that ν(G) > ν(K = n ). Since also ν(G) < ν(K n ) (otherwise π α 3 (G) < π α 3 (K n )), we conclude that 3ν(G) = n 2 − 3, that is, exactly three pairs of vertices of G are not included into some triangle from an optimal decomposition of G. This implies that G is a complete graph without one edge, or a path on three vertices, or a triangle. Among these three candidates (that have the same ν), K − has the largest size and thus maximizes π α 3 . So K − is the only possible candidate for G. However, π α This contradiction finishes the proof in case 3 < α < 4.

The case 4 α < 6
In this case we provide a direct proof, without using flag algebras or fractional decompositions. Let n be large and let G be any graph of order n such that π α 3 (G) = π α 3 (n). Let D be a decomposition of G with minimum weight consisting of t triangles and ℓ edges.
If G is a complete graph, then we are done. Hence we assume there exists some pair of vertices x, y ∈ G such that xy / ∈ E(G). Let G ′ be obtained from G by adding the edge xy. Let D ′ be an optimal decomposition of G ′ containing t ′ triangles and ℓ ′ edges. Recall that finding an optimal decomposition is equivalent to maximizing a triangle packing, that is, t ′ = ν(G ′ ). Hence t ′ t.
If xy is used as an edge in D ′ , then removing xy from D ′ gives a decomposition of G with cost π α 3 (G ′ ) − 2, contradicting the maximality of G. Therefore xy must appear in a triangle xyz ∈ D ′ . We now construct a decomposition D * of G by removing xyz from D ′ and adding the edges xz and yz. Since the total cost of D * is α(t ′ − 1) + 2(ℓ ′ + 2) we have which contradicts the maximality of π α 3 (G) if at least one of the inequalities is strict. Hence α = 4, xy must be in a triangle in D ′ and π α 3 (G ′ ) = π α 3 (n). This means that it is possible to keep adding edges to G, which results in a sequence of graphs G, G ′ , ... , K n where an optimal decomposition of each of these graphs has cost π α 3 (n), i.e. they all are π α 3 -extremal graphs. Note that we can add missing edges to G in any order, always obtaining a sequence of extremal graphs.
This allows us to reverse the process and examine a sequence of edge removals from K n .
Suppose that G is obtained from K n by removing the edge xy, i.e. G ′ is K n . Notice that if ℓ ′ > 0, i.e. the optimal decomposition of K n contains an edge, then there exist an option for D ′ that contains the edge xy, which was already ruled out. This means that K n is triangle-divisible, which is the case if and only if n ≡ 1, 3 (mod 6). Now assume that G is missing more than one edge. Hence K − n must be also extremal. By above, n ≡ 1, 3 (mod 6), K n is triangle-divisible, and π 4 3 (n) = 4ν(K n ), where ν(K n ) = 1 3 n 2 . Suppose that G is obtained from K n by removing two edges uv and xy. First, suppose that u = x. Let D ⋆ be a decomposition of G into triangles and one edge vy. This gives contradicting the maximality of π 4 3 (G). Hence xy and uv form a matching. Notice that x, y, u, and v have odd degrees in G, so ℓ 2 for else we are unable to fix the parity of the vertices x, y, u, and v. Now n 2 − ℓ − 2 needs to be divisible by 3, so ℓ 4. There indeed exists a decomposition with ℓ = 4 by taking edges xu, xv, yu, and yv and rest as triangles. This gives π 4 3 (G) = 4(ν(K n ) − 2) + 2 · 4 = π 4 3 (n).
Therefore, G is extremal.
Suppose that G is obtained from K n by removing three edges uv, xy, and zw. Since G ′ must be K n without a matching, uv, xy, and zw also form a matching. Let D ⋆ be a decomposition of G into triangles and edges ux, yz, and vw. This gives π 4 3 (G) cost(D ⋆ ) = 4(ν(K n ) − 2) + 6 < 4ν(K n ) = π 4 3 (n), contradicting the maximality of π 4 3 (G). This implies that G cannot be obtained from K n by deleting three or more edges, thus finishing the proof of this case and of Theorem 7.

Related results
A related question of Erdős (see e.g., [9]) asks for the largest t = t(n, m) such that every graph with n vertices and t 2 (n) + m edges has at least t edge-disjoint triangles. Of course, t m. Győri [12] (see [14] for a correction) showed, for large n, that t m − O(m 2 /n 2 ) if m = o(n 2 ), and t = m if n is odd and m 2n − 10 or n is even and m 3n/2 − 5. Moreover, the last two bounds on m are sharp.
More recently, Győri and Keszegh [15] proved that every K 4 -free graph with t 2 (n) + m edges has m edge-disjoint triangles.
Theorem 5 shows that the maximum of π 3 (G) is attained for G = T 2 (n) or G = K n . However, if we restrict the set of graphs under consideration to graphs of a particular edge density, the decomposition is perhaps cheaper. Note that if the optimal decomposition of a graph G contains t triangles and ℓ edges, then π 3 (G) = 2e(G) − 3t. That is, we have that π 3 (G) = 2e(G) − 3ν(G), where as before ν(G) denotes the maximum number of edge-disjoint triangles in G. Then Theorem 3 implies an inequality between the edge density of G and its triangle packing density which we denote by ν d (G) := 3ν(G)/ n 2 : Corollary 14 (of Theorem 3). Let G be a graph with d n 2 edges. Then We also have that ν d (G) d, which is tight for all graphs which are the union of edge-disjoint triangles.
A question reminiscent of the seminal result of Razborov on the minimal triangle density in graphs [25] (see also [20,22]) would be to determine the exact lower bound on ν d (G) in terms of d (answering asymptotically the question of Erdős stated above).

Acknowledgement
Work on this project was started at Rocky Mountain Great Plains Graduate Research Workshops in Combinatorics 2018. The work is partially supported by NSF-DMS grants #1603823 and #1604458 "Collaborative Research: Rocky Mountain Great Plains Graduate Research Workshops in Combinatorics" and by NSA grant #H98230-18-1-0017, "The 2018 and 2019 Rocky Mountain Great Plains Graduate Research Workshops in Combinatorics." We would like to thank Ryan R. Martin for fruitful discussions during the early stages of this project, and Ben Barber for suggesting the problem presented in Section 5.