Degree and the Handshake Lemma

Suppose thirty people attend a party, and each shakes hands with some subset of the others. Could it happen that exactly one person shakes an odd number of hands? This question sounds trivial. Really, though, it asks about the structure of every finite Graph. The answer is always no. This fact is known as the Handshake Lemma. The idea matters because vertex degree is the single most basic numerical invariant of a graph. The Handshake Lemma is the first non-obvious theorem a student meets in graph theory. It is a genuine parity constraint derived from nothing but counting the same set two different ways. The big picture is this: every edge of a graph has exactly two endpoints. So when we add up how many edges touch each vertex, we count every edge exactly twice. This single observation — the Handshake Lemma, also called the Degree-Sum Formula — forces the sum of all degrees to be even. As an immediate corollary, it also forces the number of odd-degree vertices to be even. These facts look modest. But they are the seed from which the theory of Eulerian Graphs and Circuits grows. They are also the first and most basic test applied to any candidate degree sequence, before asking whether it can be realized by an actual graph. This article gives the formal definition of degree. It states and proves the degree-sum formula and the parity corollary with full rigor. It also works through concrete numerical examples to show the counting argument in action. We also show, with an explicit example, why the theorem is a genuine theorem about simple undirected structure. It is not a vacuous truth. We demonstrate this by exhibiting what happens when the graph axioms are altered. By the end you will be able to state the Handshake Lemma precisely. You will reproduce its double-counting proof without gaps. You will apply it to rule out impossible degree sequences instantly. And you will see exactly why it is the correct entry point into deeper structural graph theory.

Key takeaways
  • The degree of a vertex is the number of edges incident to it (a loop contributes 2).
  • The Handshake Lemma: the sum of all vertex degrees equals twice the number of edges.
  • Corollary: every finite graph has an even number of odd-degree vertices.
  • The proof is a double-counting argument on the set of (vertex, incident-edge) pairs.
  • The lemma gives an instant necessary condition for a sequence of numbers to be a valid degree sequence.
  • Key idea: counting the same finite set two different ways (by vertex, and by edge) forces the degree sum to be even.

Where this lives today

The Handshake Lemma is not merely a warm-up exercise; it recurs as a load-bearing lemma across mathematics and its applications:

  • Eulerian circuits. The classical theorem that a connected graph has an Eulerian circuit if and only if every vertex has even degree relies on the Handshake Lemma to even make sense of "every vertex even" as a coherent global condition; this is developed fully under Eulerian Graphs and Circuits.
  • Network science and social networks. In any network model — social graphs, citation graphs, communication networks — the Handshake Lemma guarantees that average degree is exactly 2∣E∣/∣V∣2|E|/|V|, a basic descriptive statistic used throughout empirical network analysis.
  • Chip-firing and sandpile models. Degree sums appear as normalization constants in combinatorial dynamical systems on graphs, where the total "capacity" of a graph is governed by 2∣E∣2|E|.
  • Coding theory and parity checks. The parity phenomenon underlying the Handshake Lemma — sums of a set of integers containing an even number of odd terms — is the same combinatorial principle behind parity-check bits in error-detecting codes.
  • Statistical mechanics. In the Ising model and related lattice models, the graph of interactions has a degree sum controlling the number of nearest-neighbor coupling terms, entering directly into the partition function.
  • Algorithm design. Many graph algorithms (e.g., verifying an adjacency list encodes a simple graph, or checking feasibility before running a matching or flow algorithm) use the Handshake Lemma as an O(n)O(n) sanity check before more expensive computation.
  • Realizability theory. As foreshadowed, the lemma is the first of several necessary conditions checked in the Degree Sequences and Realizability problem, which asks precisely which integer sequences arise as degree sequences of simple graphs.

Ask the tutor: Why does the Handshake Lemma's parity corollary become the exact starting hypothesis needed for Euler's theorem on Eulerian circuits?

DefinitionDegree, Degree Sum, and the Handshake Lemma

Let G=(V,E)G = (V, E) be a finite undirected graph (as in Graphs and Basic Definitions), where EE is a multiset of unordered pairs of vertices, allowing multiple edges and loops.

Degree. For a vertex v∈Vv \in V, the degree of vv, written deg⁡(v)\deg(v), is the number of edge-endpoints at vv: that is, the number of times vv occurs as an endpoint counted over all edges of EE, where a loop at vv (an edge from vv to itself) is counted twice.

Odd/even vertex. A vertex vv is called odd if deg⁡(v)\deg(v) is odd, and even if deg⁡(v)\deg(v) is even.

Degree sum. The degree sum of GG is

S(G)  =  ∑v∈Vdeg⁡(v).S(G) \;=\; \sum_{v \in V} \deg(v).

Handshake Lemma (Degree-Sum Formula). For every finite graph G=(V,E)G = (V,E),

∑v∈Vdeg⁡(v)  =  2∣E∣.\sum_{v \in V} \deg(v) \;=\; 2|E|.

Corollary (Parity of odd vertices). In every finite graph, the number of vertices of odd degree is even.

Intuition

Picture each edge as a physical handshake between two people at a party: the edge has two ends, and each end belongs to one person. If we go around the room and ask every person "how many handshakes were you part of?", and then add up all the answers, each handshake gets counted exactly twice — once from each participant's point of view. That is the entire content of the Handshake Lemma. It is not a deep fact about graphs; it is a completely general fact about anything with two ends, dressed up in graph-theoretic language. The subtlety, such as it is, lies entirely in realizing that this simple counting fact has a nontrivial consequence: since 2∣E∣2|E| is even, the sum of the degrees must be even, and a sum of integers can only be even if it contains an even number of odd summands. This chain — double count, get an even total, conclude a parity restriction on individual terms — is the whole proof, and it is worth internalizing as a pattern because it recurs throughout combinatorics. The picture below shows a small graph together with its degree sequence, illustrating the double count directly: the edge-endpoint tally by vertex sums to twice the edge count.

Figure
A graph with 5 vertices and 5 edges: degrees sum to 2×5=102 \times 5 = 10
v₁ v₂ v₃ v₄ v₅ deg=2 deg=3 deg=2 deg=2 deg=1 Sum of degrees = 2+3+2+2+1 = 10 = 2·|E| = 2·5. Odd-degree vertices: v₂, v₅ — exactly 2 (even count).

Central results

TheoremThe Handshake Lemma

Let G=(V,E)G = (V, E) be a finite undirected graph, where loops and multiple edges are permitted, ∣V∣<∞|V| < \infty, and ∣E∣<∞|E| < \infty. Then

∑v∈Vdeg⁡(v)=2∣E∣.\sum_{v \in V} \deg(v) = 2|E|.
Proof

We use the technique of double counting: we count the elements of one finite set in two different ways and equate the results. Define the set of incidences

I  =  {(v,e):v∈V, e∈E, v is an endpoint of e},I \;=\; \{ (v, e) : v \in V,\ e \in E,\ v \text{ is an endpoint of } e \},

where, if ee is a loop at vv (i.e. e={v,v}e = \{v,v\}), the pair (v,e)(v,e) is counted twice in II — once for each of the two endpoint-slots of ee — consistent with the convention that a loop contributes 22 to the degree of its vertex. (Formally, one may think of each edge ee as coming with an ordered pair of "endpoint slots," and II is the set of (vertex, slot) incidences; for a non-loop edge {u,w}\{u,w\} the two slots go to uu and ww respectively, and for a loop at vv both slots go to vv.) Since VV and EE are both finite, II is finite, and we compute ∣I∣|I| in two ways.

Count by vertex. Group the incidences by their first coordinate v∈Vv \in V. For a fixed vertex vv, the incidences (v,e)∈I(v, e) \in I are in bijection with the endpoint-slots of vv across all edges, and by the definition of degree, the number of such slots is exactly deg⁡(v)\deg(v). Since VV is partitioned into these disjoint groups (every incidence has exactly one first coordinate),

∣I∣=∑v∈Vdeg⁡(v).|I| = \sum_{v \in V} \deg(v).

Count by edge. Group the incidences by their second coordinate e∈Ee \in E. Every edge ee, whether a loop or not, contributes exactly two endpoint-slots — this is true by definition: a non-loop edge {u,w}\{u, w\} has one slot at uu and one at ww (two slots total, at two distinct vertices), and a loop at vv has two slots both at vv. Hence for every e∈Ee \in E, the number of incidences (v,e)∈I(v,e) \in I with second coordinate ee is exactly 22. Since EE is partitioned into these disjoint groups (every incidence has exactly one second coordinate),

∣I∣=∑e∈E2=2∣E∣.|I| = \sum_{e \in E} 2 = 2|E|.

Equate the two counts. Since both computations count the same finite set II,

∑v∈Vdeg⁡(v)=∣I∣=2∣E∣.\sum_{v \in V} \deg(v) = |I| = 2|E|.

This is exactly the claimed identity, completing the proof. ■\blacksquare

∎
CorollaryEven number of odd vertices

Let G=(V,E)G = (V,E) be a finite undirected graph. Then the number of vertices of odd degree is even.

Proof

By Handshake Lemma (proved above),

∑v∈Vdeg⁡(v)=2∣E∣,\sum_{v \in V} \deg(v) = 2|E|,

and the right side is an even integer. Partition VV into the set VoddV_{\text{odd}} of odd-degree vertices and the set VevenV_{\text{even}} of even-degree vertices. Then

∑v∈Vdeg⁡(v)=∑v∈Vodddeg⁡(v)  +  ∑v∈Vevendeg⁡(v).\sum_{v \in V} \deg(v) = \sum_{v \in V_{\text{odd}}} \deg(v) \;+\; \sum_{v \in V_{\text{even}}} \deg(v).

The second sum, ∑v∈Vevendeg⁡(v)\sum_{v \in V_{\text{even}}} \deg(v), is a sum of even integers, hence is even (a finite sum of even integers is even, by induction on the number of summands using that even + even = even). Since the total sum ∑v∈Vdeg⁡(v)\sum_{v\in V}\deg(v) is even and the sum over VevenV_{\text{even}} is even, the remaining sum ∑v∈Vodddeg⁡(v)\sum_{v \in V_{\text{odd}}} \deg(v) must also be even — because even minus even is even (if total=A+B\text{total} = A + B with total and BB even, then A=total−BA = \text{total} - B is even). Now suppose, for contradiction, that ∣Vodd∣|V_{\text{odd}}| is odd. Then ∑v∈Vodddeg⁡(v)\sum_{v \in V_{\text{odd}}} \deg(v) is a sum of an odd number of odd integers. We claim such a sum is always odd. Indeed, each odd integer can be written as 2ki+12k_i + 1; summing mm of them (with m=∣Vodd∣m = |V_{\text{odd}}| odd) gives

∑i=1m(2ki+1)=2∑i=1mki+m,\sum_{i=1}^{m} (2k_i + 1) = 2\sum_{i=1}^m k_i + m,

which is even plus mm; since mm is odd, this total is odd. This contradicts the fact established above that ∑v∈Vodddeg⁡(v)\sum_{v\in V_{\text{odd}}} \deg(v) is even. Hence ∣Vodd∣|V_{\text{odd}}| cannot be odd, so ∣Vodd∣|V_{\text{odd}}| is even. ■\blacksquare

∎

Worked examples

Example 1: A graph with an explicit asymmetric degree sequence. Let GG have vertex set V={a,b,c,d,e,f}V = \{a, b, c, d, e, f\} and edge set

E={ ab, ac, ad, bc, bd, be, cf, ef },E = \{\, ab,\ ac,\ ad,\ bc,\ bd,\ be,\ cf,\ ef \,\},

using xyxy as shorthand for the edge {x,y}\{x,y\}, with 88 edges total. Compute each degree directly by counting occurrences of each letter across the edge list:

  • deg⁡(a)\deg(a): aa appears in ab,ac,adab, ac, ad — three times, so deg⁡(a)=3\deg(a) = 3.
  • deg⁡(b)\deg(b): bb appears in ab,bc,bd,beab, bc, bd, be — four times, so deg⁡(b)=4\deg(b) = 4.
  • deg⁡(c)\deg(c): cc appears in ac,bc,cfac, bc, cf — three times, so deg⁡(c)=3\deg(c) = 3.
  • deg⁡(d)\deg(d): dd appears in ad,bdad, bd — two times, so deg⁡(d)=2\deg(d) = 2.
  • deg⁡(e)\deg(e): ee appears in be,efbe, ef — two times, so deg⁡(e)=2\deg(e) = 2.
  • deg⁡(f)\deg(f): ff appears in cf,efcf, ef — two times, so deg⁡(f)=2\deg(f) = 2.

Sum of degrees:

3+4+3+2+2+2=16.3 + 4 + 3 + 2 + 2 + 2 = 16.

Number of edges: ∣E∣=8|E| = 8, and indeed 2∣E∣=162|E| = 16, matching the Handshake Lemma exactly. Odd-degree vertices: aa (degree 3) and cc (degree 3) are odd; b,d,e,fb, d, e, f are all even. That is 22 odd vertices — an even count, confirming the corollary. Note the asymmetry: the degrees {3,4,3,2,2,2}\{3,4,3,2,2,2\} are not symmetric or evenly spread, yet the parity conclusion still holds exactly as guaranteed.

Example 2: Using the lemma as an instant impossibility test. Suppose someone claims to have drawn a simple graph (no loops, no multiple edges) on vertex set of size 77 with degree sequence

(5,5,4,3,3,2,1).(5, 5, 4, 3, 3, 2, 1).

Before checking whether such a graph can actually be constructed (a harder question, addressed by Degree Sequences and Realizability), we apply the Handshake Lemma as a fast necessary-condition filter. Sum the proposed degrees:

5+5+4+3+3+2+1=23.5 + 5 + 4 + 3 + 3 + 2 + 1 = 23.

By the Handshake Lemma this sum must equal 2∣E∣2|E| for some nonnegative integer ∣E∣|E|, i.e., it must be even. But 2323 is odd. Hence no finite graph — simple or not — can have this degree sequence; the claim is impossible, and we know this without attempting to draw a single edge. Contrast this with the sequence (5,4,4,3,3,2,1)(5, 4, 4, 3, 3, 2, 1), whose sum is

5+4+4+3+3+2+1=22=2×11,5+4+4+3+3+2+1 = 22 = 2 \times 11,

which is even, so it passes the Handshake Lemma test (there are 22 odd terms: 55 and 3,33,3 — wait, count carefully: terms 5,3,3,15, 3, 3, 1 are odd, that's four odd terms, an even count, consistent). Passing this test is necessary but not sufficient for realizability as a simple graph; that finer question is the subject of the Erdős–Gallai criterion, treated under Degree Sequences and Realizability.

CounterexampleWhy finiteness of the edge set is needed

The Handshake Lemma is stated for a graph with a finite edge set EE. If we drop finiteness of EE, both the theorem statement and its proof break down, and the conclusion can fail. Consider an infinite graph G=(V,E)G = (V, E) with V=ZV = \mathbb{Z} (all integers) and

E={ {n,n+1}:n∈Z },E = \{\, \{n, n+1\} : n \in \mathbb{Z} \,\},

the two-way infinite path. Every vertex n∈Zn \in \mathbb{Z} is an endpoint of exactly two edges (the edge to n−1n-1 and the edge to n+1n+1), so deg⁡(n)=2\deg(n) = 2 for every vertex — in particular every degree is even, so there are zero odd-degree vertices, and one might think the corollary trivially holds here. To see the real failure, modify the example: attach one extra pendant edge at vertex 00 to a new vertex 0′0', giving deg⁡(0)=3\deg(0) = 3 and deg⁡(0′)=1\deg(0') = 1, while every other integer vertex keeps degree 22. Now there are exactly two odd vertices (00 and 0′0'), so parity still happens to hold in this modified example — infinite graphs do not automatically break the corollary. The real breakdown is in the degree-sum formula itself, which is what the corollary's proof depends on. In the original two-way infinite path, every vertex has degree 22, so

∑v∈Zdeg⁡(v)=∑v∈Z2,\sum_{v \in \mathbb{Z}} \deg(v) = \sum_{v \in \mathbb{Z}} 2,

a "sum" of infinitely many 22's, which does not converge to any real number under the usual definition of a sum of a series with infinitely many equal nonzero terms — it diverges to +∞+\infty. Meanwhile EE itself is countably infinite, so "2∣E∣2|E|" is not a well-defined integer either. The equation ∑vdeg⁡(v)=2∣E∣\sum_v \deg(v) = 2|E| literally has no meaning here: both sides are "infinite" in a sense that carries no numerical content, so the identity cannot even be asserted, let alone used to derive a parity statement about a finite count of odd vertices (there is no reason a subset of an infinite set need be finite). The double-counting proof itself used the fact that II is a finite set to justify partitioning it into finitely many groups and adding; with EE infinite, II is infinite, and the entire counting argument — which relies on finite sums equaling each other via finite additivity — no longer applies. This is precisely why the theorem's hypothesis restricts to finite graphs.

Scope, edge cases & common traps

SituationDoes the Handshake Lemma apply?Notes
Simple finite graphYesStandard case; every proof step above applies directly.
Finite graph with multiple edgesYesMulti-edges are just multiple elements of the multiset EE; each contributes 2 endpoint-slots as usual.
Finite graph with loopsYes, with the loop-counts-twice conventionMust use deg⁡(v)\deg(v) counting a loop as 22, exactly as in the definition; otherwise the formula fails.
Directed graphsNot directly — needs separate in/out-degree versionThe correct analogue is ∑vdeg⁡+(v)=∑vdeg⁡−(v)=∣E∣\sum_v \deg^+(v) = \sum_v \deg^-(v) = |E|; conflating this with the undirected formula is a common error.
Infinite graphsNo, not in generalSee the counterexample above; the sums may not be finite or well-defined.
Degree sequence realizabilityHandshake Lemma gives only a necessary conditionPassing the even-sum test does not guarantee a graph exists; see Degree Sequences and Realizability for the full (Erdős–Gallai) criterion.

The mathematician behind it

Origins · 1 minLeonhard Euler and how this was discovered
LE
Leonhard Euler
1707–1783 · Königsberg, Prussia, 1735

Leonhard Euler, one of the most prolific mathematicians in history, is credited with founding graph theory through his 1736 resolution of the Seven Bridges of Königsberg problem. In analyzing whether a walk could cross each of the city's seven bridges exactly once, Euler implicitly used the parity of vertex degree — precisely the fact formalized centuries later as the Handshake Lemma — to show that such a walk was impossible, since the landmasses (vertices) all had odd numbers of connecting bridges (edges). His argument is the historical seed of both the Handshake Lemma and, more deeply, the theory of Eulerian Graphs and Circuits that bears his name.

History
- 1735 — Euler presents his analysis of the Königsberg bridges problem to the St. Petersburg Academy.
- 1736 — Euler's paper Solutio problematis ad geometriam situs pertinentis is published, reasoning about vertex degree parity to prove impossibility of an Eulerian walk.
- 1847 — Gustav Kirchhoff applies degree-sum reasoning implicitly in his work on electrical networks and spanning trees.
- 1936 — Dénes Kőnig's Theorie der endlichen und unendlichen Graphen systematizes graph theory as a formal discipline, stating degree-sum results explicitly.
- 1960s — The Erdős–Gallai and Havel–Hakimi results build directly on the Handshake Lemma's parity constraint to give full realizability criteria for degree sequences.
What exactly counts as an "edge" in the Handshake Lemma — does it require simple graphs?

No. The Handshake Lemma holds for any finite undirected graph, including those with multiple edges (parallel edges between the same pair of vertices) and loops (an edge from a vertex to itself), as long as each loop is counted as contributing 22 to the degree of its vertex. The double-counting proof never used simplicity; it only used that every edge has exactly two endpoint-slots, whether those slots land on two distinct vertices or on the same vertex twice via a loop. Restricting to simple graphs is common in many textbook treatments for pedagogical clarity, but the lemma itself is more general, and this generality matters when analyzing multigraphs arising in applications such as circuit design.

Does the Handshake Lemma tell us whether a given degree sequence corresponds to an actual graph?

Only partially. The Handshake Lemma gives a necessary condition: the degree sum must be even, equivalently the number of odd terms in the sequence must be even. It is not sufficient — there exist sequences with even sum that still cannot be realized by any simple graph, as shown in the warning above with (3,3,3,1)(3,3,3,1). Determining full realizability requires stronger tools such as the Erdős–Gallai inequalities or the Havel–Hakimi algorithm, both developed under the heading of Degree Sequences and Realizability. Think of the Handshake Lemma as a fast, free filter you always apply first.

How does the Handshake Lemma generalize to directed graphs?

For a directed graph, each edge (arc) has a distinct tail and head, so the natural invariants are the out-degree deg⁡+(v)\deg^+(v) (number of arcs leaving vv) and in-degree deg⁡−(v)\deg^-(v) (number of arcs entering vv). The directed analogue of the Handshake Lemma states ∑vdeg⁡+(v)=∑vdeg⁡−(v)=∣E∣\sum_{v} \deg^+(v) = \sum_v \deg^-(v) = |E|, since each arc contributes exactly one unit to some vertex's out-degree and exactly one unit to some (possibly different) vertex's in-degree. This is a different — and in some ways simpler — identity than the undirected version, and it is a common error to try to apply the undirected formula ∑deg⁡(v)=2∣E∣\sum \deg(v) = 2|E| directly to a directed graph's total degree without this distinction.

Can the number of odd-degree vertices be zero?

Yes, and this is perfectly consistent with the corollary, since zero is an even number. A graph in which every vertex has even degree — such as any cycle graph CnC_n, where every vertex has degree exactly 22 — has zero odd-degree vertices. In fact, "every vertex has even degree" is precisely the necessary condition (together with connectivity) for the existence of an Eulerian circuit, which is why this special all-even case is so important; it is the starting point for Eulerian Graphs and Circuits.

Why is this called "double counting" and is that a rigorous proof technique?

Double counting is a fully rigorous combinatorial proof technique: to show two quantities AA and BB are equal, one exhibits a single finite set II and shows that ∣I∣=A|I| = A by one method of enumeration and ∣I∣=B|I| = B by another, concluding A=BA = B by transitivity of equality applied to ∣I∣|I|. It requires no probabilistic or approximate reasoning — it is exact arithmetic on cardinalities of finite sets, justified by the fact that partitioning a finite set into disjoint groups and summing the group sizes always recovers the total cardinality. This is the same technique used to prove many binomial coefficient identities and is one of the most powerful elementary tools in enumerative combinatorics.

Does the Handshake Lemma say anything about the number of edges directly?

Yes — rearranged, it gives ∣E∣=12∑v∈Vdeg⁡(v)|E| = \frac{1}{2}\sum_{v \in V} \deg(v), so if you know all the vertex degrees you can recover the number of edges without ever looking at the edge list. This is often used in reverse: if you are told the degree sequence of a graph, you immediately know how many edges it must have (if it exists at all), which is useful both as a sanity check and as a first computational step in algorithms that reconstruct graphs from degree data, as in the Havel–Hakimi procedure referenced under Degree Sequences and Realizability.

What is the smallest example showing an odd number of odd-degree vertices is truly impossible?

There is no example, precisely because the corollary is a theorem, not a heuristic — but it is instructive to see why small attempts fail. Try to build a graph on 33 vertices with degrees (1,1,1)(1,1,1) — an odd number (three) of odd-degree vertices. The degree sum would be 33, which is odd, so by the Handshake Lemma it cannot equal 2∣E∣2|E| for any integer ∣E∣|E|; no such graph exists, confirmed by direct attempt: connecting all three vertices pairwise gives each vertex degree 22 (triangle), and any proper subset of those edges gives at least one vertex of degree 00 or forces a repeated odd count elsewhere. Every attempt to force exactly one, or exactly three, vertices to odd degree fails for the same underlying arithmetic reason.

Before this

Where this leads