Checking a polygon diagonal count with unordered vertex pairs
Count the diagonals of a polygon by counting every pair of vertices and removing the pairs that are sides. This guide works through a hexagon and extends the rule to any n.
A diagonal is a vertex pair that is not a side
A polygon with n vertices has many segments that could join two of them. Each such segment is either a side of the polygon, joining neighbors around the boundary, or a diagonal, joining two vertices that are not neighbors. So the set of all segments between vertex pairs splits cleanly into sides and diagonals. The number of sides equals n, since a closed polygon has as many sides as corners. The number of diagonals is therefore the number of all vertex pairs minus n. This turns a drawing problem into counting, which is more reliable than trying to draw and tally lines on a crowded figure.
Counting all pairs of six vertices
The order of the two endpoints does not matter, because the segment from vertex A to vertex C is the same segment as from C to A. That makes the count a combination, not a permutation. For six vertices, the combination calculator with n = 6 and r = 2 returns 15. You can see this by hand: each of the six vertices pairs with the five others, giving 30, and every pair has been seen from both ends, so halve it to 15. The halving is what the unordered count does for you.
Removing the six sides
A hexagon has six sides, each joining two neighboring vertices, and each of those sides is one of the 15 pairs. Subtracting them leaves 15 − 6 = 9 diagonals. The basic calculator confirms the subtraction. The polygon angle calculator with n = 6 returns an interior angle sum of 720 degrees, which confirms that the figure being counted has six boundary edges. Nine diagonals in a hexagon can be listed: three long ones through the center of a regular hexagon, and six shorter ones skipping a single vertex. In a regular hexagon the long ones are twice the side length and the short ones are the side length times the square root of 3, but the count of nine does not depend on any of those lengths.
Simplifying the diagonal count
Combining the pieces gives diagonals = n(n − 1)/2 − n, which simplifies to n(n − 3)/2. The simplified version has a direct reading: each vertex connects by diagonal to n − 3 others, since it cannot connect to itself or to its two neighbors, and the product n × (n − 3) counts each diagonal once from each end, so it is halved. Test it on the hexagon: 6 × 3 / 2 = 9. For a pentagon it gives 5 × 2 / 2 = 5, and for a triangle 3 × 0 / 2 = 0, which is correct because every pair of triangle vertices is already a side.
Larger polygons as a second example
An octagon has 8 vertices, so there are 28 vertex pairs. Removing 8 sides leaves 20 diagonals, and the formula gives 8 × 5 / 2 = 20. A 12-sided polygon has 66 pairs, 12 sides and 54 diagonals. The number of diagonals grows roughly with the square of n, while the number of sides grows only with n, so large polygons are mostly diagonals. A decagon already has 35 diagonals against 10 sides. This growth is why drawing all diagonals of a many-sided figure quickly becomes unreadable. A 20-sided polygon has 170 diagonals, and a 100-sided one has 4,850, which no drawing could show clearly. The count is still easy to get, because it only needs the number of vertices. That is the practical advantage of reasoning with pairs: the size of the problem does not matter, only the formula does.
Why unordered pairs and not arrangements
A common slip is to use the number of ordered pairs, n(n − 1), and then subtract n. For six vertices that gives 30 − 6 = 24, which is wrong on two counts: it counts each segment twice, and it subtracts only one ordering of each side. The unordered count fixes the first problem, and subtracting exactly n sides handles the second. Another slip is to subtract 2n for the sides, double counting the neighbors. Keeping the order straight, unordered pairs first and then sides, avoids both. A third slip is to forget that a vertex has two neighbors, and to subtract only 1 from n − 1 per vertex, which gives n(n − 2)/2. For the hexagon that would claim 12 diagonals, three more than exist. Checking one vertex by hand, listing its neighbors and the others it reaches, settles the question.
What a count does not say about the figure
The count depends only on the number of vertices. It assumes a simple polygon, with a boundary that does not cross itself. In a convex polygon, every diagonal lies inside the figure. In a concave one, some vertex pairs are joined by segments that leave the polygon, so a pair that is not a side may not be a diagonal in the strict inside sense. The formula counts nonadjacent vertex pairs either way. It also says nothing about lengths, angles or areas, which need coordinates or side data.
Using the tools together
Enter the vertex count as n and r = 2 in the combination calculator, subtract n with the basic calculator, and use the polygon angle calculator when you want to confirm that the polygon has the number of sides you intended. For regular figures, the interior angle sum is (n − 2) × 180, which is 720 for six. Entering the wrong n shows up there at once. For very large n, the combination result is large but exact, so no rounding concerns arise. The answer is a pure count, an integer with no unit.
Spotting an impossible answer
The diagonal count has a few easy tests. It must be a whole number, which holds because n(n − 3) is always even: one of n and n − 3 is even whatever n is. It is zero only for the triangle, and it is 2 for a quadrilateral, the two crossing lines of a square. For a pentagon it is 5, forming the familiar star. If a worksheet gives a fraction, a negative number or a value that does not match these small cases, the vertex count was entered wrongly or the formula was typed with a missing bracket. Checking n = 3, 4 and 5 against these counts is a quick way to validate any new formula.
Reproduce the checks
All vertex pairs
Open the Combination calculator and enter:
- Total items n
6- Items selected r
2
Expected output:
Combinations
15Pairs are unordered.
Remove boundary edges
Open the Basic calculator and enter:
- First number
15- Operation
subtract- Second number
6
Expected output:
Result
9The remaining pairs are diagonals.
Six-sided polygon control
Open the Polygon Angle Calculator and enter:
- Index or side count
6
Expected output:
sum
720The polygon has six boundary edges.
References and implementation scope
The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.
Sources
- MathWorld ↗ · 2026-10-08