Sub topic 3
Counting Diagonals and Triangulating a Polygon
Prerequisites and the key idea
Assume you know the angle sum of a triangle and can use basic counting. A polygon is a closed plane figure made from straight line segments. A diagonal is a line segment joining two non-adjacent vertices of a polygon.
A side joins neighboring vertices, so it is not a diagonal. For example, a quadrilateral has four vertices and four sides. Its two diagonals join opposite vertices.
Triangulating a polygon
Triangulation means dividing a polygon into triangles by drawing diagonals from one vertex. An n-sided polygon can always be divided into n - 2 triangles.
Why? Choose one vertex and draw diagonals to every non-adjacent vertex. This creates:
- n - 3 diagonals from the chosen vertex
- n - 2 triangles
For example, a hexagon creates four triangles when triangulated from one vertex.
This fact also explains the interior-angle sum of a polygon. Since each triangle has angle sum 180°, the total interior-angle sum is:
(n - 2) × 180°
The diagonal-count formula
To count all diagonals, consider each vertex separately. From one vertex, you can draw n - 3 diagonals because you cannot connect it to itself or to its two neighboring vertices.
This gives n(n - 3) possible connections. However, every diagonal is counted twice, once from each endpoint. Therefore:
Number of diagonals = n(n - 3) / 2
| Polygon | n | Diagonals |
|---|---|---|
| Pentagon | 5 | 5 |
| Hexagon | 6 | 9 |
| Octagon | 8 | 20 |
Worked example
How many diagonals does a decagon have?
A decagon has n = 10 sides.
Diagonals = 10(10 - 3) / 2 = 10 × 7 / 2 = 35
A decagon has 35 diagonals.
def diagonals(n):
if n < 3:
raise ValueError("A polygon must have at least 3 sides.")
return n * (n - 3) // 2
for n in (5, 6, 8, 10):
print(n, diagonals(n))CAT shortcuts and common errors
Use the formula when the question asks for all diagonals. Use n - 3 when it asks for diagonals from one specified vertex.
A common error is using n(n - 1)/2. That counts every pair of vertices, including the n sides. Subtracting the sides gives n(n - 3)/2.
Another error is forgetting the division by 2. Each diagonal has two endpoints, so counting from every vertex counts each diagonal twice.
Exercise
A polygon has 12 sides. How many diagonals can be drawn from one vertex, and how many diagonals does the whole polygon have?
Show answer
From one vertex: 12 - 3 = 9. Overall: 12(12 - 3)/2 = 54 diagonals.