Maths WorkshopMaths problems with full solutions
Exercise 1938Combinatorics › Graph theoryOlympiadAdded 4 Nov 2026

Triangle-free graphs have at most n²/4 edges (Mantel)

#double counting#graphs#Cauchy–Schwarz#extremal graph theory

Statement

A graph on nn vertices has no triangle. Prove that it has at most n24\dfrac{n^2}4 edges. When is equality possible?

Hint

If uu and vv are adjacent, can they have a common neighbour? Deduce a bound on d(u)+d(v)d(u)+d(v), then sum over all edges.

Show solutionHide solution

Solution

Idea. Count the pairs (vertex, edge containing it) in two ways.

Local bound. Let uvuv be an edge. If a vertex ww were adjacent to both uu and vv, then uvwuvw would be a triangle. So the neighbourhoods of uu and vv are disjoint, and
d(u)+d(v)≤n.d(u)+d(v)\le n.

Summation. Let ee be the number of edges. Summing over all edges uvuv,
∑uv∈E(d(u)+d(v))≤ne.\sum_{uv\in E}\bigl(d(u)+d(v)\bigr)\le ne.
On the left, each vertex vv appears d(v)d(v) times, each with the term d(v)d(v). So the left side equals ∑vd(v)2\sum_vd(v)^2:
∑vd(v)2≤ne.\sum_vd(v)^2\le ne.

Cauchy–Schwarz. Since ∑vd(v)=2e\sum_vd(v)=2e,
∑vd(v)2≥(∑vd(v))2n=4e2n.\sum_vd(v)^2\ge\frac{\left(\sum_vd(v)\right)^2}n=\frac{4e^2}n.

Conclusion. 4e2n≤ne\dfrac{4e^2}n\le ne, so e≤n24e\le\dfrac{n^2}4.

Equality. For nn even, the complete bipartite graph Kn/2,n/2K_{n/2,n/2} is triangle-free with n24\frac{n^2}4 edges. For nn odd, the bound is ⌊n24⌋\left\lfloor\frac{n^2}4\right\rfloor and is attained by K(n−1)/2,(n+1)/2K_{(n-1)/2,(n+1)/2}.

Lesson. Double counting: when a sum over edges involves degrees, rewrite it as a sum over vertices; combine with Cauchy–Schwarz.