
In
graph theory
In mathematics and computer science, graph theory is the study of ''graph (discrete mathematics), graphs'', which are mathematical structures used to model pairwise relations between objects. A graph in this context is made up of ''Vertex (graph ...
, the handshaking lemma is the statement that, in every finite
undirected graph
In discrete mathematics, particularly in graph theory, a graph is a structure consisting of a set of objects where some pairs of the objects are in some sense "related". The objects are represented by abstractions called '' vertices'' (also call ...
, the number of vertices that touch an odd number of edges is even. For example, if there is a party of people who shake hands, the number of people who shake an odd number of other people's hands is even. The handshaking lemma is a consequence of the degree sum formula, also sometimes called the handshaking lemma, according to which the sum of the
degrees
Degree may refer to:
As a unit of measurement
* Degree (angle), a unit of angle measurement
** Degree of geographical latitude
** Degree of geographical longitude
* Degree symbol (°), a notation used in science, engineering, and mathematics
...
(the numbers of times each vertex is touched) equals twice the number of edges in the graph. Both results were proven by in his famous paper on the
Seven Bridges of Königsberg
The Seven Bridges of Königsberg is a historically notable problem in mathematics. Its negative resolution by Leonhard Euler, in 1736, laid the foundations of graph theory and prefigured the idea of topology.
The city of Königsberg in Prussia ...
that began the study of graph theory.
Beyond the Seven Bridges of Königsberg Problem, which subsequently formalized
Eulerian Tours, other applications of the degree sum formula include proofs of certain combinatorial structures. For example, in the proofs of
Sperner's lemma
In mathematics, Sperner's lemma is a combinatorial result on colorings of triangulations, analogous to the Brouwer fixed point theorem, which is equivalent to it. It states that every Sperner coloring (described below) of a triangulation of an ...
and the
mountain climbing problem
In mathematics, the mountain climbing problem is a mathematical problem that considers a two-dimensional mountain range (represented as a continuous function), and asks whether it is possible for two mountaineering, mountain climbers starting at ...
the geometric properties of the formula commonly arise. The
complexity class
In computational complexity theory, a complexity class is a set (mathematics), set of computational problems "of related resource-based computational complexity, complexity". The two most commonly analyzed resources are time complexity, time and s ...
PPA encapsulates the difficulty of finding a second odd vertex, given one such vertex in a large
implicitly-defined graph
In the study of graph algorithms, an implicit graph representation (or more simply implicit graph) is a graph whose vertices or edges are not represented as explicit objects in a computer's memory, but rather are determined algorithmically from s ...
.
Definitions and statement
An
undirected graph
In discrete mathematics, particularly in graph theory, a graph is a structure consisting of a set of objects where some pairs of the objects are in some sense "related". The objects are represented by abstractions called '' vertices'' (also call ...
consists of a system of
vertices, and
edges
Enhanced Data rates for GSM Evolution (EDGE), also known as 2.75G and under various other names, is a 2G digital mobile phone technology for packet switched data transmission. It is a subset of General Packet Radio Service (GPRS) on the GS ...
connecting
unordered pair In mathematics, an unordered pair or pair set is a set of the form , i.e. a set having two elements ''a'' and ''b'' with , where = . In contrast, an ordered pair (''a'', ''b'') has ''a'' as its first element and ''b'' as its second elemen ...
s of vertices. In any graph, the
degree of a vertex
is defined as the number of edges that have
as an endpoint. For graphs that are allowed to contain
loops connecting a vertex to itself, a loop should be counted as contributing two units to the degree of its endpoint for the purposes of the handshaking lemma. Then, the handshaking lemma states that, in every finite graph, there must be an even number of vertices for which
is an odd number. The vertices of odd degree in a graph are sometimes called odd nodes (or odd vertices); in this terminology, the handshaking lemma can be rephrased as the statement that every graph has an even number of odd nodes.
The degree sum formula states that
where
is the set of nodes (or vertices) in the graph and
is the set of edges in the graph. That is, the sum of the vertex degrees equals twice the number of edges. In
directed graphs, another form of the degree-sum formula states that the sum of in-degrees of all vertices, and the sum of out-degrees, both equal the number of edges. Here, the in-degree is the number of incoming edges, and the out-degree is the number of outgoing edges. A version of the degree sum formula also applies to finite
families of sets
Family (from ) is a group of people related either by consanguinity (by recognized birth) or affinity (by marriage or other relationship). It forms the basis for social order. Ideally, families offer predictability, structure, and safety ...
or, equivalently,
multigraph
In mathematics, and more specifically in graph theory, a multigraph is a graph which is permitted to have multiple edges (also called ''parallel edges''), that is, edges that have the same end nodes. Thus two vertices may be connected by mor ...
s: the sum of the degrees of the elements (where the degree equals the number of sets containing it) always equals the sum of the
cardinalities
In mathematics, the cardinality of a finite set is the number of its elements, and is therefore a measure of size of the set. Since the discovery by Georg Cantor, in the late 19th century, of different sizes of infinite sets, the term ''cardinal ...
of the sets.
Both results also apply to any
subgraph of the given graph and in particular to its
connected components. A consequence is that, for any odd vertex, there must exist a
path
A path is a route for physical travel – see Trail.
Path or PATH may also refer to:
Physical paths of different types
* Bicycle path
* Bridle path, used by people on horseback
* Course (navigation), the intended path of a vehicle
* Desir ...
connecting it to another odd vertex.
Applications
Euler paths and tours
Leonhard Euler
Leonhard Euler ( ; ; ; 15 April 170718 September 1783) was a Swiss polymath who was active as a mathematician, physicist, astronomer, logician, geographer, and engineer. He founded the studies of graph theory and topology and made influential ...
first proved the handshaking lemma in his work on the
Seven Bridges of Königsberg
The Seven Bridges of Königsberg is a historically notable problem in mathematics. Its negative resolution by Leonhard Euler, in 1736, laid the foundations of graph theory and prefigured the idea of topology.
The city of Königsberg in Prussia ...
, asking for a walking tour of the city of Königsberg (now
Kaliningrad
Kaliningrad,. known as Königsberg; ; . until 1946, is the largest city and administrative centre of Kaliningrad Oblast, an Enclave and exclave, exclave of Russia between Lithuania and Poland ( west of the bulk of Russia), located on the Prego ...
) crossing each of its seven bridges once. This can be translated into graph-theoretic terms as asking for an
Euler path
In graph theory, an Eulerian trail (or Eulerian path) is a trail in a finite graph that visits every edge exactly once (allowing for revisiting vertices). Similarly, an Eulerian circuit or Eulerian cycle is an Eulerian trail that starts and ends ...
or
Euler tour
In graph theory, an Eulerian trail (or Eulerian path) is a trail in a finite graph that visits every edge exactly once (allowing for revisiting vertices). Similarly, an Eulerian circuit or Eulerian cycle is an Eulerian trail that starts and end ...
of a connected graph representing the city and its bridges: a
walk
Walking (also known as ambulation) is one of the main gaits of terrestrial locomotion among legged animals. Walking is typically slower than running and other gaits. Walking is defined as an "inverted pendulum" gait in which the body vaults over ...
through the graph that traverses each edge once, either ending at a different vertex than it starts in the case of an Euler path or returning to its starting point in the case of an Euler tour. Euler stated the fundamental results for this problem in terms of the number of odd vertices in the graph, which the handshaking lemma restricts to be an even number. If this number is zero, an Euler tour exists, and if it is two, an Euler path exists. Otherwise, the problem cannot be solved. In the case of the Seven Bridges of Königsberg, the graph representing the problem has four odd vertices, and has neither an Euler path nor an Euler tour. It was therefore impossible to tour all seven bridges in Königsberg without repeating a bridge.
In
the Christofides–Serdyukov algorithm for approximating the
traveling salesperson problem
In the Computational complexity theory, theory of computational complexity, the travelling salesman problem (TSP) asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible ...
, the geometric implications of the degree sum formula plays a vital role, allowing the algorithm to connect vertices in pairs in order to construct a graph on which an Euler tour forms an approximate TSP tour.
Combinatorial enumeration
Several combinatorial structures may be shown to be even in number by relating them to the odd vertices in an appropriate "exchange graph".
For instance, as
C. A. B. Smith proved, in any
cubic graph
In the mathematical field of graph theory, a cubic graph is a graph in which all vertices have degree three. In other words, a cubic graph is a 3-regular graph. Cubic graphs are also called trivalent graphs.
A bicubic graph is a cubic bip ...
there must be an even number of
Hamiltonian cycle
In the mathematics, mathematical field of graph theory, a Hamiltonian path (or traceable path) is a path (graph theory), path in an undirected or directed graph that visits each vertex (graph theory), vertex exactly once. A Hamiltonian cycle (or ...
s through any fixed edge
; these are cycles that pass through each vertex exactly once. used a proof based on the handshaking lemma to extend this result to graphs in which all vertices have odd degree. Thomason defines an exchange graph the vertices of which are in one-to-one correspondence with the Hamiltonian paths in
beginning at
and continuing through edge
. Two such paths
and
are defined as being connected by an edge in
if one may obtain
by adding a new edge to the end of
and removing another edge from the middle of
. This operation is reversible, forming a
symmetric relation
A symmetric relation is a type of binary relation. Formally, a binary relation ''R'' over a set ''X'' is symmetric if:
: \forall a, b \in X(a R b \Leftrightarrow b R a) ,
where the notation ''aRb'' means that .
An example is the relation "is equ ...
, so
is an undirected graph. If path
ends at vertex then the vertex corresponding to
in
has degree equal to the number of ways that
may be extended by an edge that does not connect back to
; that is, the degree of this vertex in
is either
(an even number) if
does not form part of a Hamiltonian cycle through or
(an odd number) if
is part of a Hamiltonian cycle through
. Since
has an even number of odd vertices,
must have an even number of Hamiltonian cycles through
.
Other applications
The handshaking lemma (or degree sum formula) are also used in proofs of several other results in mathematics. These include the following:

*
Sperner's lemma
In mathematics, Sperner's lemma is a combinatorial result on colorings of triangulations, analogous to the Brouwer fixed point theorem, which is equivalent to it. It states that every Sperner coloring (described below) of a triangulation of an ...
states that, if a big triangle is subdivided into smaller triangles meeting edge-to-edge, and the vertices are labeled with three colors so that only two of the colors are used along each edge of the big triangle, then at least one of the smaller triangles has vertices of all three colors; it has applications in
fixed-point theorem
In mathematics, a fixed-point theorem is a result saying that a function ''F'' will have at least one fixed point (a point ''x'' for which ''F''(''x'') = ''x''), under some conditions on ''F'' that can be stated in general terms.
In mathematica ...
s,
root-finding algorithms
In numerical analysis, a root-finding algorithm is an algorithm for finding zeros, also called "roots", of continuous functions. A zero of a function is a number such that . As, generally, the zeros of a function cannot be computed exactly nor e ...
, and
fair division
Fair division is the problem in game theory of dividing a set of resources among several people who have an Entitlement (fair division), entitlement to them so that each person receives their due share. The central tenet of fair division is that ...
. One proof of this lemma forms an exchange graph whose vertices are the triangles (both small and large) and whose edges connect pairs of triangles that share two vertices of some particular two colors. The big triangle necessarily has odd degree in this exchange graph, as does a small triangle with all three colors, but not the other small triangles. By the handshaking lemma, there must be an odd number of small triangles with all three colors, and therefore at least one such triangle must exist.

*The
mountain climbing problem
In mathematics, the mountain climbing problem is a mathematical problem that considers a two-dimensional mountain range (represented as a continuous function), and asks whether it is possible for two mountaineering, mountain climbers starting at ...
states that, for sufficiently well-behaved functions on a
unit interval
In mathematics, the unit interval is the closed interval , that is, the set of all real numbers that are greater than or equal to 0 and less than or equal to 1. It is often denoted ' (capital letter ). In addition to its role in real analysi ...
, with equal values at the ends of the interval, it is possible to coordinate the motion of two points, starting from opposite ends of the interval, so that they meet somewhere in the middle while remaining at points of equal value throughout the motion. One proof of this involves approximating the function by a
piecewise linear function
In mathematics, a piecewise linear or segmented function is a real-valued function of a real variable, whose graph is composed of straight-line segments.
Definition
A piecewise linear function is a function defined on a (possibly unbounded) ...
with the same extreme points, parameterizing the position of the two moving points by the coordinates of a single point in the
unit square
In mathematics, a unit square is a square whose sides have length . Often, ''the'' unit square refers specifically to the square in the Cartesian plane with corners at the four points ), , , and .
Cartesian coordinates
In a Cartesian coordinat ...
, and showing that the available positions for the two points form a finite graph, embedded in this square, with only the starting position and its reversal as odd vertices. By the handshaking lemma, these two positions belong to the same
connected component of the graph, and a path from one to the other necessarily passes through the desired meeting point.
*The
reconstruction conjecture
Informally, the reconstruction conjecture in graph theory says that graphs are determined uniquely by their subgraphs. It is due to KellyKelly, P. J.A congruence theorem for trees ''Pacific J. Math.'' 7 (1957), 961–968. and Ulam.Ulam, S. ...
concerns the problem of uniquely determining the structure of a graph from the
multiset
In mathematics, a multiset (or bag, or mset) is a modification of the concept of a set that, unlike a set, allows for multiple instances for each of its elements. The number of instances given for each element is called the ''multiplicity'' of ...
of subgraphs formed by removing a single vertex from it. Given this information, the degree-sum formula can be used to recover the number of edges in the given graph and the degrees of each vertex. From this, it is possible to determine whether the given graph is a
regular graph
In graph theory, a regular graph is a Graph (discrete mathematics), graph where each Vertex (graph theory), vertex has the same number of neighbors; i.e. every vertex has the same Degree (graph theory), degree or valency. A regular directed graph ...
, and if so to determine it uniquely from any vertex-deleted subgraph by adding a new neighbor for all the subgraph vertices of too-low degree. Therefore, all regular graphs can be reconstructed.
*The game of
Hex
Hex usually refers to:
* A curse or supposed real and potentially supernaturally realized malicious wish
* Hexadecimal, a base-16 number system often used in computer nomenclature
Hex, HEX, or The Hex may also refer to:
Magic
* Hex sign, a b ...
is played by two players, who place pieces of their color on a tiling of a
parallelogram
In Euclidean geometry, a parallelogram is a simple polygon, simple (non-list of self-intersecting polygons, self-intersecting) quadrilateral with two pairs of Parallel (geometry), parallel sides. The opposite or facing sides of a parallelogram a ...
-shaped board by
hexagon
In geometry, a hexagon (from Greek , , meaning "six", and , , meaning "corner, angle") is a six-sided polygon. The total of the internal angles of any simple (non-self-intersecting) hexagon is 720°.
Regular hexagon
A regular hexagon is de ...
s until one player has a connected path of adjacent pieces from one side of the board to the other. It can never end in a draw: by the time the board has been completely filled with pieces, one of the players will have formed a winning path. One proof of this forms a graph from a filled game board, with vertices at the corners of the hexagons, and with edges on sides of hexagons that separate the two players' colors. This graph has four odd vertices at the corners of the board, and even vertices elsewhere, so it must contain a path connecting two corners, which necessarily has a winning path for one player on one of its sides.
Proof
Euler's proof of the degree sum formula uses the technique of
double counting: he counts the number of incident pairs
where
is an edge and vertex
is one of its endpoints, in two different ways. Vertex
belongs to
pairs, where
(the degree of
) is the number of edges incident to it. Therefore, the number of incident pairs is the sum of the degrees. However, each edge in the graph belongs to exactly two incident pairs, one for each of its endpoints; therefore, the number of incident pairs is
. Since these two formulas count the same set of objects, they must have equal values. The same proof can be interpreted as summing the entries of the
incidence matrix
In mathematics, an incidence matrix is a logical matrix that shows the relationship between two classes of objects, usually called an incidence relation. If the first class is ''X'' and the second is ''Y'', the matrix has one row for each element o ...
of the graph in two ways, by rows to get the sum of degrees and by columns to get twice the number of edges.
For graphs, the handshaking lemma follows as a corollary of the degree sum formula. In a sum of integers, the
parity of the sum is not affected by the even terms in the sum; the overall sum is even when there is an even number of odd terms, and odd when there is an odd number of odd terms. Since one side of the degree sum formula is the even number the sum on the other side must have an even number of odd terms; that is, there must be an even number of odd-degree vertices.
Alternatively, it is possible to use
mathematical induction
Mathematical induction is a method for mathematical proof, proving that a statement P(n) is true for every natural number n, that is, that the infinitely many cases P(0), P(1), P(2), P(3), \dots all hold. This is done by first proving a ...
to prove the degree sum formula, or to prove directly that the number of odd-degree vertices is even, by removing one edge at a time from a given graph and using a
case analysis on the degrees of its endpoints to determine the effect of this removal on the parity of the number of odd-degree vertices.
In special classes of graphs
Regular graphs
The degree sum formula implies that every
-
regular graph
In graph theory, a regular graph is a Graph (discrete mathematics), graph where each Vertex (graph theory), vertex has the same number of neighbors; i.e. every vertex has the same Degree (graph theory), degree or valency. A regular directed graph ...
with
vertices has
edges. Because the number of edges must be an integer, it follows that when
is odd the number of vertices must be even. Additionally, for odd values the number of edges must be divisible
Bipartite and biregular graphs
A
bipartite graph
In the mathematics, mathematical field of graph theory, a bipartite graph (or bigraph) is a Graph (discrete mathematics), graph whose vertex (graph theory), vertices can be divided into two disjoint sets, disjoint and Independent set (graph theo ...
has its vertices split into two subsets, with each edge having one endpoint in each subset. It follows from the same double counting argument that, in each subset, the sum of degrees equals the number of edges in the graph. In particular, both subsets have equal degree sums. For
biregular graph
In graph-theoretic mathematics, a biregular graph or semiregular bipartite graph is a bipartite graph G=(U,V,E) for which every two vertices on the same side of the given bipartition have the same degree as each other. If the degree of the vertic ...
s, with a partition of the vertices into subsets
and
with every vertex in a subset
having degree
, it must be the case that
; both equal the number of edges.
Infinite graphs

The handshaking lemma does not apply in its usual form to infinite graphs, even when they have only a finite number of odd-degree vertices. For instance, an infinite
path graph
In the mathematical field of graph theory, a path graph (or linear graph) is a graph whose vertices can be listed in the order such that the edges are where . Equivalently, a path with at least two vertices is connected and has two termina ...
with one endpoint has only a single odd-degree vertex rather than having an even number of such vertices. However, it is possible to formulate a version of the handshaking lemma using the concept of an
end
End, END, Ending, or ENDS may refer to:
End Mathematics
*End (category theory)
* End (topology)
* End (graph theory)
* End (group theory) (a subcase of the previous)
* End (endomorphism) Sports and games
*End (gridiron football)
*End, a division ...
, an equivalence class of semi-infinite paths ("rays") considering two rays as equivalent when there exists a third ray that uses infinitely many vertices from each of them. The degree of an end is the maximum number of edge-disjoint rays that it contains, and an end is odd if its degree is finite and odd. More generally, it is possible to define an end as being odd or even, regardless of whether it has infinite degree, in graphs for which all vertices have finite degree. Then, in such graphs, the number of odd vertices and odd ends, added together, is either even or infinite.
Subgraphs
By a theorem of
Gallai the vertices of any graph can be partitioned as
where in the two resulting
induced subgraph
In graph theory, an induced subgraph of a graph is another graph, formed from a subset of the vertices of the graph and ''all'' of the edges, from the original graph, connecting pairs of vertices in that subset.
Definition
Formally, let G=(V,E) ...
s,