Quiz Entry - updated: 2026.11.27
Why is the sum of all vertex degrees always exactly $2m$?
Every edge has two ends, and each end adds 1 to the degree of the vertex it sits on. Summing the degrees therefore counts every edge exactly twice: $\sum_v \deg(v) = 2m$. A self-loop has both ends at one vertex and adds 2 to its degree, so the rule holds for it too.
Checked on the example graph with its ten edges a to j: U has degree 2, V 3, W 4, X 5, Y 2 and Z 4 (h, i and both ends of the loop j). The sum is $20 = 2 \cdot 10$.
Two consequences follow at once:
- The number of vertices with odd degree is even, because the degrees add up to an even number. In the example they are V and X. This is the handshaking lemma: at any party, the number of guests who shook an odd number of hands is even.
- The average degree is $2m/n$. And whenever an algorithm visits every vertex and looks at all of its incident edges, the edge work adds up to $\sum_v \deg(v) = 2m$, which is why such a sweep over an adjacency list costs $O(n + m)$ and not more.
Go deeper:
Handshaking lemma โ the degree sum formula, its proof, and the odd-degree corollary.