Discrete Mathematics and Combinatorics

Extremal Combinatorics and How Many Edges Force a Triangle

Find the exact number of links that guarantees a triangle, follow the proof, and see where the same kind of question leads.

Key takeaways

  • A graph with n vertices and more than ⌊n²/4⌋ edges must contain a triangle.
  • The bound is sharp, because splitting the vertices into two nearly equal halves and joining every cross pair creates no triangle.
  • Turán's theorem extends the result to larger fully connected groups, with several balanced parts in place of two.
  • Solving an extremal problem requires both a construction and a matching proof.
  • Similar questions about families of sets lead to theorems such as Sperner's and Erdős–Ko–Rado, and many cases remain open.

A network on n points can have as many as n²/4 links, rounded down, without containing a single triangle. Add one more link, no matter where, and a triangle must appear. This result, proved by W. Mantel in 1907, is the starting point of extremal combinatorics.

The subject asks how large or small a structure can be before some feature becomes unavoidable. You look for two things that meet: an example that gets as far as possible without the feature, and a proof that nothing can go further.

The question

Here a graph is a set of points, called vertices, with links, called edges, joining some pairs. A triangle is three vertices all joined to one another. With n vertices there are n(n − 1)/2 possible edges. How many can you draw before you are forced to close a triangle?

The symbol ⌊x⌋ means x rounded down to a whole number.

Vertices Possible edges Most without a triangle
4 6 4
5 10 6
6 15 9
10 45 25
100 4,950 2,500

For large n, roughly half of all possible edges can be present with no triangle at all.

The construction

Split the vertices into two teams. Join every vertex in one team to every vertex in the other, and draw no edges inside a team. Such a graph is called complete bipartite.

Any triangle would need two of its three corners on the same team, and those two are not joined. So there are none. If the teams have sizes a and n − a, the number of edges is a(n − a), largest when the teams are as equal as possible. For n = 6 that is 3 × 3 = 9, and for n = 7 it is 3 × 4 = 12.

The two halves of an extremal result
Construction Two nearly equal teams Join every cross pair No triangle, ⌊n²/4⌋ edges Upper bound Assume no triangle Linked ends share no neighbor Then edges are at most n²/4 VS Construction Two nearly equal teams Join every cross pair No triangle, ⌊n²/4⌋ edges Upper bound Assume no triangle Linked ends share no neighbor Then edges are at most n²/4

The proof

Suppose a graph on n vertices, with m edges, has no triangle. Let d(v) be the degree of vertex v, its number of edges.

Take any edge joining u and v. No third vertex is joined to both, or we would have a triangle. So the neighbors of u and the neighbors of v do not overlap, and

d(u) + d(v) ≤ n

Now add this inequality over all m edges. Each vertex v appears once for each of its d(v) edges, contributing d(v) each time. So the left side is the sum of the squares of the degrees.

sum of d(v)² ≤ m·n
sum of d(v)² ≥ (sum of d(v))² / n = (2m)² / n      (Cauchy–Schwarz inequality)
4m² / n ≤ m·n
m ≤ n² / 4

The middle line says that for a fixed total, the sum of squares is smallest when all values are equal. The step 2m for the sum of degrees is the handshaking lemma.

Since m is a whole number, m ≤ ⌊n²/4⌋.

Testing the proof on numbers

Take 6 vertices and 10 edges, one more than the bound of 9. The degrees add to 20. The sum of their squares is at least 20²/6, which is about 66.7. If there were no triangle, the sum of squares could be at most m × n = 10 × 6 = 60. Both cannot hold, so every graph with 6 vertices and 10 edges has a triangle, all without examining a single drawing.

A second proof

There is another argument, perhaps easier to picture. Assume no triangle and pick a vertex v with the largest degree, which we call D.

  1. No two neighbors of v are joined, since together with v they would form a triangle.
  2. So every edge has at least one end among the other n − D vertices.
  3. Each of those vertices has at most D edges.
  4. Therefore m ≤ D × (n − D).

For a fixed total n, the product D × (n − D) is largest when D is n/2, where it equals n²/4. The proof also shows what an extreme graph must look like: for equality to hold when n is even, the two groups must have n/2 vertices each with every cross pair joined. That is the construction again.

One edge too many, many triangles

Crossing the threshold produces more than one triangle. Start with the two-team graph on 10 vertices, 5 and 5, and add one edge inside a team. Its two ends are both joined to all 5 vertices on the other side, so 5 triangles appear at once.

Hans Rademacher showed that every graph with ⌊n²/4⌋ + 1 edges has at least ⌊n/2⌋ triangles. This jump from none to many is typical of extremal thresholds.

Turán's theorem

What if you want to avoid four vertices all joined to one another, or five? Pál Turán answered this in 1941. To avoid a fully joined group of r + 1 vertices, split the vertices into r teams as equal as possible and join all pairs from different teams. Nothing with more edges works.

For 10 vertices and no fully joined group of four, use teams of 4, 3 and 3:

edges = 4·3 + 4·3 + 3·3 = 33

So a 34th edge forces such a group. For large n the maximum is close to (1 − 1/r) × n²/2. This theorem is often regarded as the founding result of the field.

Other forbidden shapes

You can forbid any small graph H. A theorem of Erdős and Arthur Stone, with a form often credited to Erdős and Miklós Simonovits, says that the answer is governed mainly by the chromatic number of H, written χ: the fewest colors needed so that linked vertices differ. The maximum number of edges is about (1 − 1/(χ − 1)) × n²/2.

A triangle needs 3 colors, giving n²/4, as Mantel found. See graph coloring for the idea.

When χ = 2, the formula gives zero, meaning only that the maximum is small compared with n². Finding its true size is often hard. For a cycle of four edges, the maximum grows like n raised to the power 3/2, and the best constructions come from finite geometries related to the Fano plane. For several other simple-looking shapes, such as the cycle with eight edges, even the correct power of n was not known as of the mid-2020s.

Why dense graphs look orderly

A deeper tool, Endre Szemerédi's regularity lemma from the 1970s, says that the vertices of any very large dense graph can be divided into a bounded number of groups so that the edges between most pairs of groups behave almost like random ones. One consequence, often called the triangle removal lemma, says that if a large graph has only a tiny proportion of all possible triangles, then deleting a tiny proportion of the possible edges destroys every one of them.

That statement about graphs implies a statement about numbers: a set containing a fixed positive share of the integers up to a large N must include three evenly spaced members. Klaus Roth first proved this in the 1950s by other means. It is a striking example of additive combinatorics borrowing from graph theory.

Extremal questions about sets

The same style of question applies to collections of subsets.

Sperner's theorem (1928). How many subsets of an n-element set can you choose so that none contains another? The answer is the number of subsets of size ⌊n/2⌋. For n = 4 that is 6, namely all the pairs.

Erdős–Ko–Rado theorem. Choose subsets of size k from n elements so that every two share something, with n at least 2k. You can take at most as many as the sets containing one fixed element, which is C(n − 1, k − 1). Here C(a, b) counts the ways to choose b things from a. For n = 5 and k = 2 the maximum is 4.

These connect to partial orders and to the counting tools in permutations and combinations.

An open frontier

Move from edges, which join two vertices, to triples. How many triples can you choose from n points without containing all four triples on some set of four points? Turán asked this in the 1940s and conjectured that the limit is about 5/9 of all triples. It remained unproved as of the mid-2020s, although the two-point version is more than a century old.

How this differs from Ramsey theory

Both subjects find unavoidable structure. Ramsey theory colors all the edges and asks for a one-color pattern in some color. Extremal theory asks how dense a single set of edges must be to contain the pattern. A density result is usually stronger, since the most popular color in any coloring has high density, but it is only available when high density really does force the pattern.

Common mistakes

  • Reading the bound as "typical". A random graph with far fewer than n²/4 edges will usually contain triangles. Mantel's theorem describes the worst case for the forcer.
  • Expecting the threshold to force a particular triangle. It forces some triangle, somewhere.
  • Giving only a construction. An example with 9 edges and no triangle on 6 vertices does not show that every 10-edge graph has one. That needs the proof.
  • Dropping the rounding. For n = 7 the bound is 12, not 12.25.

Common questions

Where are such results used?

They support arguments in number theory, geometry and computer science, for instance to show that a dense enough set must contain a given pattern, or to prove limits on what a data structure can store.

Can I explore this by hand?

Yes. Draw 5 points, try to place 7 edges without a triangle, and watch each attempt fail. Then find the arrangement with 6.

Written for 4Mathematics with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 45 articles in Discrete Mathematics and Combinatorics →

Latest news on this topic