TL;DR
The degree of a vertex is the number of edges that touch it. It is the simplest measure of how connected one point of a Graph is: a person with many friends in a friendship network has a high degree, and a dead-end road junction has degree 1. Add up the degrees of every vertex and you get exactly twice the number of edges, because every edge touches two vertices.
Builds on: Graph, sums · Leads to: Eulerian Path, Degree Distribution, Adjacency Matrix, Graph Convolutional Network
Where it's used
Road maps. Put a dot at every junction and a line for every road. The degree of a junction is the number of roads meeting there. A degree-1 junction is a dead end, a degree-2 point is just a bend in a road, and a degree-4 crossing is a busy intersection. Traffic planners use this count to see where roads split and where they meet.
Social networks. Let each person be a vertex and each friendship an edge. The degree is then the number of friends, and the average degree is the typical number of friends. Random models such as Erdős–Rényi graphs give a predicted pattern to compare against. Platforms and researchers look for vertices with unusually high degree, often called hubs, because information reaches the rest of the network through them.
Route planning and puzzles. Euler's 1736 answer to the Königsberg bridge puzzle was a degree argument, and it is the origin of the Eulerian path question. Whether a walk that crosses every bridge once can exist depends only on how many bridges touch each land area. The degrees settled the question without any measurement of distance.
Graph neural networks. In a Graph Convolutional Network, a kind of graph neural network, each vertex combines the features of its neighbours. The usual rule divides each neighbour's contribution by a function of the degrees involved, so that a hub does not drown out every other vertex in a single update.
How it works
Take a small graph with four vertices, , , and , and four edges: , , and . Here is how to find each degree and check the total.
-
List the edges. There are four: , , , . Each one is a pair of vertices that it joins. Check: each edge has exactly two distinct ends, so the list has no single-ended or three-ended edges.
-
Pick a vertex and count the edges that touch it. For , the edges , and all contain . Three edges touch , so . Check: has three neighbours, , and , and each neighbour gives one edge.
-
Repeat for every other vertex. is on and , so . is on and , so . is only on , so . Check: the four numbers are 2, 2, 3 and 1.
-
Add the degrees. . Check: is twice the number of edges, which is .
-
Read the result. The total is not a coincidence. Each edge was counted once at each of its two ends, so the sum of degrees counts every edge twice.
flowchart LR P((P)) --- Q((Q)) Q --- R((R)) R --- P R --- S((S))
The diagram shows the same graph. The circle with the most lines, , has the highest degree.
The math
Definition
Let be a simple Graph, meaning no edge joins a vertex to itself and no pair of vertices is joined twice. The degree of a vertex , written , is the number of edges that contain :
The vertical bars mean "the number of elements" of the set inside them.
Read the formula as follows: look at every edge in , keep those that contain , and count them. This is step 2 of the walkthrough written in symbols.
Step 2 in symbols
For the vertex above, the edges containing are , and . Their count is . Writing for the set of neighbours of , the degree is also , because each neighbour is reached by exactly one edge. Here .
The handshake lemma
Every edge has two ends, and in a simple graph those ends are different vertices. Count the pairs (vertex, edge) where the vertex is an end of the edge. Counted by vertex, the total is the sum of the degrees. Counted by edge, each edge contributes exactly 2. So
The left sum is step 4 of the walkthrough, and the right side is the check in step 4. This identity is the handshake lemma, named after the fact that if each person in a room shakes hands with some others, the total number of hands shaken is twice the number of handshakes.
A consequence
The sum is even, so the sum of degrees is always even. If every vertex except one had odd degree, the sum would be odd, which is impossible. So any graph has an even number of vertices with odd degree. This small fact is the key to the Königsberg puzzle, and it is the starting point of the Eulerian path lesson.
Worked examples
The triangle has vertices , , and edges , , .
- Degree of : the edges containing are and . So .
- By the same count, (edges , ) and (edges , ).
- Sum of degrees: .
- Twice the number of edges: . The two agree.
Interpretation: in a cycle where every vertex has two neighbours, every degree is 2, and the total is always twice the number of edges.
Four vertices , , , form a square, , , , , and one diagonal . That makes five edges.
- Degree of : edges , , . So .
- Degree of : edges , . So .
- Degree of : edges , , . So .
- Degree of : edges , . So .
- Sum: .
- Check: . The total matches.
Interpretation: the diagonal raises the degree of its two endpoints, and , from 2 to 3. Adding one edge always adds exactly 2 to the degree total, one at each end.
A small town has six junctions, to , joined by seven roads: , , , , , and .
- Degree of : roads , . So .
- Degree of : roads , . So .
- Degree of : roads , , . So .
- Degree of : roads , , . So .
- Degree of : roads , . So .
- Degree of : roads , . So .
- Sum: .
- Check: . The total matches.
- Count the odd degrees: only and are odd, so there are two.
Interpretation: junctions of degree 3 are T-junctions, and degree 2 points are just bends. The two odd-degree junctions are the ones a single continuous drive would have to start or end at.
Try it: A delivery van must drive every road exactly once, and it may start and end at different junctions. Which junctions could it start and finish at? Answer: and . They are the only two odd-degree junctions, and the map is connected, so such a route exists and must begin at one of them and end at the other.
Common mistakes and tradeoffs
It is tempting to think the degrees of a graph add up to the number of edges. In fact they add up to twice that number, because each edge is counted at both of its ends. The triangle above has 3 edges and degrees summing to 6.
It is tempting to think a vertex's degree tells you who its neighbours are. In fact it only gives a count. Two vertices of degree 3 can have completely different neighbourhoods. When you need to know which vertices are joined, look at the Adjacency Matrix or the edge list instead.
It is tempting to think the same definition works for directed graphs. In fact a directed edge has a start and an end, so each vertex gets two numbers: the in-degree (edges arriving) and the out-degree (edges leaving). The degree in the sense above is then their sum, and the handshake lemma becomes a statement about in-degrees and out-degrees separately.
When to use the degree: it is the cheapest local measure, computed in one pass over the edges, and it is enough to spot hubs, dead ends and parity questions such as the Königsberg puzzle.
When not to use it: it says nothing about paths, distances or the shape of the whole network. For the overall pattern across many vertices, look at the Degree Distribution. For fast questions such as "is joined to ?", the Adjacency Matrix answers that in one lookup, and the graph Laplacian puts the degrees on its diagonal.
History
In 1736 Leonhard Euler published his solution to the Königsberg bridge problem. He replaced each land area with a point and each bridge with a line, and he argued from how many lines met each point. That argument, counting the edges at each vertex, is the earliest use of vertex degree in the sense used here. The general identity that the degrees sum to twice the number of edges was stated and used as a basic fact of graph theory later, and it is often called the handshake lemma after the handshake picture that makes it easy to remember.
Recap
- A Graph joins vertices by edges. The degree of a vertex is the number of edges that touch it.
- Each edge has two ends, so the degrees of all vertices sum to (the handshake lemma).
- Consequence: the number of odd-degree vertices is even, which decides puzzles like the Königsberg bridges.
- Degree is a local measure. Read the Degree Distribution for the whole network, and the Adjacency Matrix for who is joined to whom.
What to read next: the Eulerian Path lesson uses the odd-degree count to decide when a route can cross every edge once. The Graph Convolutional Network lesson uses degrees to scale messages between vertices.
Check yourself
QuestionA simple graph has 6 edges. What is the sum of all vertex degrees?Show answer
Each edge has two ends, so the sum is . This is the handshake lemma: the sum of degrees is always twice the number of edges.
QuestionIn a graph with vertices , , , and edges , , , , what are the degrees of , , and ?Show answer
is on , and , so . is on and , so . is on and , so . is only on , so . Check: .
QuestionWhy can a graph never have exactly one vertex of odd degree?Show answer
The sum of degrees equals , which is even. If exactly one degree were odd, the sum would be an even number of even degrees plus one odd degree, and that is odd. Since the sum must be even, the situation is impossible. In general the number of odd-degree vertices is always even.
QuestionA town's road network has 9 junctions. Eight of them have degree 4 and one has degree 2. How many roads are there?Show answer
Sum of degrees: . Each road contributes 2 to the sum, so the number of roads is .
QuestionA friend says a junction of degree 2 must be a straight stretch of road. Is that right?Show answer
No. Degree 2 means exactly two roads meet there, and they may meet at any angle, so the junction can be a sharp corner. The degree counts roads, not directions or angles.