Discrete Mathematics and Combinatorics

The Handshaking Lemma and What Vertex Degrees Reveal

Why vertex degrees add to twice the edge count, and how that simple fact rules out networks and proves surprising results.

Key takeaways

  • The sum of degrees is exactly twice the number of edges, in every finite graph.
  • Every finite graph has an even number of odd-degree vertices.
  • A proposed list of degrees with an odd total can never come from a graph, though an even total is not enough for a simple graph.
  • Degrees let you count edges and corners of shapes without drawing them.
  • The same counting idea extends to directed graphs, bipartite graphs and trees.

The handshaking lemma says that in any finite graph, the sum of all the vertex degrees equals twice the number of edges. A graph is a set of points (vertices) joined by links (edges), and the degree of a vertex is the number of edge ends that meet there.

The reason is that every edge has two ends. If you count handshakes by asking each guest how many hands they shook and then add the answers, each handshake gets reported twice. An immediate consequence is that the number of vertices with odd degree is always even.

The lemma and its proof

Write deg(v) for the degree of vertex v and |E| for the number of edges. Then:

sum of deg(v) over all vertices v  =  2·|E|

The proof is a double count. Count the pairs (vertex, edge) in which the edge has an end at the vertex. Grouping by vertex, each v contributes deg(v). Grouping by edge, each edge contributes 2. Both methods count the same set, so the totals agree. This style of argument is combinatorial proof by counting two ways.

A loop, an edge from a vertex back to itself, has both ends at one vertex. With the usual convention that it adds 2 to that degree, the lemma holds for graphs with loops and repeated edges too.

Now split the vertices into those of even degree and those of odd degree. The total is even. The even degrees add to an even number, so the odd degrees must also add to an even number. A sum of odd numbers is even only when there is an even number of them.

What it rules out at once

Could you connect 15 computers so that each is cabled directly to exactly 3 others? The degrees would add to 45, which is odd. No such network exists, however cleverly you arrange the cables.

A graph in which every vertex has degree k is called k-regular. On n vertices it has nk/2 edges, so nk must be even. For simple graphs (no loops, no repeated edges) you also need k ≤ n − 1. For example:

Vertices n Degree k Product nk Edges
7 3 21 impossible
8 3 24 12
7 4 28 14
10 5 50 25

The average degree is 2|E| divided by the number of vertices. A network with 1,000 members and 4,000 friendships has average degree 8, even if some members have hundreds of friends and many have one.

Which degree lists are possible?

A list of degrees is graphical if some simple graph realizes it. An even sum is necessary but not sufficient. Consider 3, 3, 1, 1. The sum is 8, but each vertex of degree 3 must join all three others, which forces both remaining vertices to have degree at least 2.

The Havel–Hakimi method settles any list:

  1. Sort the list from largest to smallest.
  2. Remove the first number, d.
  3. Subtract 1 from each of the next d numbers.
  4. If any number becomes negative, or there are not enough numbers, stop: the list is not graphical.
  5. Repeat until only zeros remain, which means the list is graphical.

Try 5, 3, 3, 2, 2, 1:

5, 3, 3, 2, 2, 1    remove 5, subtract 1 from the next five
2, 2, 1, 1, 0       remove 2, subtract 1 from the next two
1, 0, 1, 0  →  re-sort: 1, 1, 0, 0
0, 0, 0             all zeros, so the list is graphical

Running the steps backward actually builds a graph with those degrees.

Testing a degree list with Havel–Hakimi
1 Sort Order the degrees from largest to smallest 2 Remove Take off the largest degree d 3 Subtract Lower the next d entries by 1 4 Decide A negative or missing entry means no; all zeros means yes Sort Order the degrees from largest to smallest 1 Remove Take off the largest degree d 2 Subtract Lower the next d entries by 1 3 Decide A negative or missing entry means no; all zeros means yes 4

Two vertices always share a degree

In any simple graph with at least two vertices, some two vertices have the same degree. Put another way, at any party where each pair of guests shakes hands at most once, two guests have shaken the same number of hands.

With n vertices, each degree lies between 0 and n − 1. That is n possible values for n vertices, which looks like enough to make them all different. But a vertex of degree 0 (joined to nobody) and a vertex of degree n − 1 (joined to everybody) cannot both exist. So at most n − 1 values are in use, and the pigeonhole principle forces a repeat.

Counting without drawing

The lemma is a handy calculator for polyhedra, since the corners and edges of a solid form a graph. The classic soccer ball pattern has 12 pentagons and 20 hexagons. Each edge borders two faces, so the same double count gives:

edges    = (12·5 + 20·6)/2 = (60 + 120)/2 = 90
vertices = 2·90/3 = 60            (three edges meet at every corner)
check    : V − E + F = 60 − 90 + 32 = 2

The final line is Euler's formula, discussed in the Euler characteristic. Counting face sides twice is the handshaking lemma applied to a map's faces, and it is central to showing that certain graphs cannot be drawn flat, as in planar graphs.

Odd vertices come in pairs

The parity statement can be sharpened. Apply the lemma to a single connected component, meaning a maximal piece in which every vertex can reach every other. That piece is a graph in its own right, so it too has an even number of odd vertices.

So if a graph has exactly two vertices of odd degree, they must lie in the same component, and there is a path between them. You learn that a route exists without ever finding it.

Parity arguments of this kind drive several famous results. Sperner's lemma about colored triangulations can be proved by building a graph whose odd vertices correspond to the objects sought, and Sperner's lemma in turn yields fixed point theorems. The odd-degree count also decides whether a figure can be traced in one stroke, the subject of Euler paths and circuits.

A walk through the rooms

Here is a puzzle that shows the parity idea at work. A house has several rooms, and some doors lead between rooms while others lead outside. Suppose every room has an even number of doors. Can the number of outside doors be odd?

Model each room as a vertex and add one extra vertex for "outside". Each door is an edge. Every room vertex has even degree, so the only vertex that could be odd is the outside one. A graph cannot have exactly one odd vertex, so the outside vertex is even too. The house has an even number of exterior doors, whatever its floor plan.

A variation proves that a route exists. Say every room has at most two doors with red handles. Make a graph using only the red doors. Each room vertex now has degree 0, 1 or 2, although the outside vertex may have more. If you enter from outside through a red door and keep going through the other red door in each room, you can never get stuck in a loop or revisit a room. You either leave the house again or end in a room with exactly one red door.

If the number of red exterior doors is odd, the exterior doors cannot all be paired off with one another. At least one of those walks must therefore end inside, in a room with exactly one red door. This is the engine of the proof of Sperner's lemma, and it even suggests an algorithm: follow the doors until you stop.

Directed and two-sided versions

In a directed graph, each edge leaves one vertex and enters another. Counting by tails or by heads gives:

sum of out-degrees  =  sum of in-degrees  =  |E|

In a bipartite graph, the vertices split into two groups and every edge runs between groups. Each edge has exactly one end in each group, so the degrees on either side add to |E| on their own. Say 12 volunteers each sign up for 5 shifts, and each shift takes exactly 4 volunteers. There are 60 sign-ups, so there must be 60/4 = 15 shifts.

For trees, which are connected graphs without cycles, a tree on n vertices has n − 1 edges, so its degrees add to 2n − 2. With n ≥ 2, every degree is at least 1. If only one vertex had degree 1, the sum would be at least 1 + 2(n − 1) = 2n − 1, which is too big. Hence every such tree has at least two leaves, a fact used throughout the theory of trees.

What degrees cannot tell you

Degrees are a coarse summary. A single ring of six vertices and two separate triangles share the degree list 2, 2, 2, 2, 2, 2. One is connected and the other is not. Different graphs with identical degrees can differ in distances, cycles and colorings.

Watch for these errors:

  • Concluding that two graphs are the same because their degree lists match.
  • Forgetting that a loop contributes 2.
  • Assuming an even degree total guarantees a simple graph exists.
  • Applying the parity rule to infinite graphs. A path that starts at one vertex and runs forever has exactly one vertex of degree 1.

Even so, checking degrees is the first thing to try. It costs almost nothing, and it often settles whether a proposed network is possible before you spend any effort drawing it.

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