Discrete MathematicsGraphs, Paths and Circuits1 of 6
Graphs, Paths and Circuits · 1

Graphs, Degree and the Handshake Lemma

When we want to study how things are connected, like people shaking hands at a party or computers wired together in a network, we strip away everything except the objects themselves and the connections between them.

Can five people at a party each shake hands with exactly three of the others?

Graphs, Vertices and Edges

Moving the vertices or pulling edges across one another changes how the drawing looks, while every vertex keeps the exact same connections.

No matter where the vertices sit or how the edges cross, every vertex keeps the same connections, so the graph stays the same.

***

1

Degree and the Handshake Lemma

The degree of a vertex is the number of edges touching it, and the Handshake Lemma connects the degrees of the individual vertices to the total number of edges in the graph.

Degree and the Handshake Lemma

Counting the line-ends at each vertex and counting the two ends of every edge must give the same total:

∑v∈Vdeg⁡(v)⏟line-ends counted by vertices\displaystyle \underbrace{\ends{\sum_{v \in V} \deg(v)}}_{\text{line-ends counted by vertices}} =2∣E∣⏟line-ends counted by edges\displaystyle = \underbrace{2\lines{|E|}}_{\text{line-ends counted by edges}}

Here VV is the set of vertices, deg⁡(v)\ends{\deg(v)} is the degree of vertex vv, and ∣E∣\lines{|E|} is the number of edges (the vertical bars mean "the number of items in the set").

Because every edge has two ends, each edge adds 2\added{2} to the sum of all degrees.

Every edge has two ends, so each edge adds one to two degrees and two to the sum of all degrees.

***

2

Counting Edges and Odd-Degree Vertices

We can use line-end counting to find the total number of edges without drawing the graph, and to see right away when a handshake puzzle is impossible.

If 1010 servers are each wired directly to 4\ends{4} other servers, how many ethernet cables connect them? And why did our opening puzzle of 55 people each shaking 3\ends{3} hands fail?

Counting Edges and Odd-Degree Vertices
10 servers,\displaystyle 10\text{ servers,}
each wired to 4 others\displaystyle \text{each wired to }\ends{4}\text{ others}
cables\displaystyle \lines{\text{cables}} =  ?\displaystyle = \;?
Text solution
1. Count the cable-ends at the serversEach of the 1010 servers has 4\ends{4} cable-ends plugged into it, which gives the total number of cable-ends in the network:
total cable-ends\displaystyle \text{total cable-ends} =10×4\displaystyle = 10 \times \ends{4} =40\displaystyle = \ends{40}
2. Pair the cable-ends into whole cablesEvery cable uses 22 ends, so dividing the total ends by 22 gives the number of cables:
∣E∣\displaystyle \lines{|E|} =402\displaystyle = \frac{\ends{40}}{2} =20 cables\displaystyle = \lines{20}\text{ cables}
3. Test the five-person handshake puzzle in the same wayFive people each shaking 3\ends{3} hands would require an odd number of line-ends, which cannot be paired into whole edges:
total line-ends=5×3=15  ⟹  ∣E∣=152=7.5 edges(impossible)\displaystyle \begin{aligned}\text{total line-ends} &= 5 \times \ends{3} = \ends{15} \\ \implies \lines{|E|} &= \frac{\ends{15}}{2} \\ &= \lines{7}\fails{.5}\text{ edges} \\ &\quad \fails{\text{(impossible)}}\end{aligned}

Because 2∣E∣2\lines{|E|} is always even, the sum of all degrees in a graph must be even. Vertices with an even degree do not change whether the sum is even or odd, so the vertices with an odd degree must always pair up to make an even sum.

***

3

The Line-End Budget and Degree Bounds

When we know the number of edges first, we can treat 2∣E∣2\lines{|E|} as a fixed budget of line-ends to find a missing degree, count how many vertices are in the graph, or find the largest possible size of a graph when we only have a minimum or maximum degree.

Suppose a graph has 12\lines{12} edges:

And what if we only know an inequality, such as 21\lines{21} cables where every server connects to at least 4\ends{4} others, or 1010 vertices where every vertex has degree at most 3\ends{3}?

The Line-End Budget and Degree Bounds
12 edges\lines{12}\text{ edges}
5\htmlClass{lc-green}{5}
4\htmlClass{lc-green}{4}
4\htmlClass{lc-green}{4}
3\htmlClass{lc-green}{3}
3\htmlClass{lc-green}{3}
3\htmlClass{lc-green}{3}
??
Text solution
1. Find the total line-end budget from the edgesEach of the 12\lines{12} edges supplies 22 line-ends to hand out to the vertices:
line-end budget\displaystyle \text{line-end budget} =12×2\displaystyle = \lines{12} \times 2 =24\displaystyle = \ends{24}
2. Subtract the known degrees to find a missing degreeThe first six vertices use up 22\ends{22} of the 24\ends{24} line-ends, leaving the rest for the seventh vertex:
deg⁡(v7)=24−(5+4+4+3+3+3)=24−22=2\displaystyle \begin{aligned}\ends{\deg(v_7)} &= \ends{24} - (\ends{5} + \ends{4} + \ends{4} \\ &\qquad\quad + \ends{3} + \ends{3} + \ends{3}) \\ &= \ends{24} - \ends{22} \\ &= \ends{2}\end{aligned}
3. Group the remaining budget to count unknown verticesIf 33 vertices of degree 4\ends{4} take 3×4=123 \times \ends{4} = \ends{12} line-ends, the remaining 12\ends{12} line-ends split into groups of 3\ends{3} for the degree-3\ends{3} vertices:
degree-3 vertices=24−123=4  ⟹  total vertices=3+4=7\displaystyle \begin{aligned}\text{degree-}\ends{3}\text{ vertices} &= \frac{\ends{24} - \ends{12}}{\ends{3}} = 4 \\ \implies \text{total vertices} &= 3 + 4 = 7\end{aligned}
4. Bound the number of vertices using a minimum degreeWith 21\lines{21} cables supplying 21×2=42\lines{21} \times 2 = \ends{42} cable-ends, nn servers of degree at least 4\ends{4} need at least 4n\ends{4}n ends, which cannot exceed the 42\ends{42}-end budget:
4n≤42  ⟹  n≤10.5  ⟹  at most 10 servers\displaystyle \begin{aligned}&\ends{4}n \le \ends{42} \\ \implies\quad &n \le 10\fails{.5} \\ \implies\quad &\text{at most } 10\text{ servers}\end{aligned}
5. Bound the number of edges using a maximum degreeWith 1010 vertices of degree at most 3\ends{3}, the graph has at most 10×3=3010 \times \ends{3} = \ends{30} line-ends, which pairs into at most half that many edges:
2∣E∣≤30  ⟹  ∣E∣≤15 edges\displaystyle \begin{aligned}&2\lines{|E|} \le \ends{30} \\ \implies\quad &\lines{|E|} \le \lines{15}\text{ edges}\end{aligned}

***

4

Why the Handshake Lemma Is a One-Way Check

If a list of degrees adds up to an even number, does that guarantee we can actually draw the graph?

Let's test two degree lists for 44 vertices that both add up to 8\ends{8}: first 4,2,1,1\ends{4, 2, 1, 1}, and then 3,3,1,1\ends{3, 3, 1, 1}.

Why the Handshake Lemma Is a One-Way Filter
3,3,3,3,3→15  odd→impossible4,2,1,1→8  even→possible?\displaystyle \begin{aligned} \ends{3, 3, 3, 3, 3} &\to \ends{15}\ \ \fails{\text{odd}} \\ &\mathrel{\phantom{\to}} \fails{\text{impossible}} \\[6pt] \ends{4, 2, 1, 1} &\to \ends{8}\ \ \ends{\text{even}} \\ &\mathrel{\phantom{\to}} \text{possible?} \end{aligned}
Text solution
1. Check whether any single degree exceeds the number of other verticesIn a 44-vertex graph with no loops or duplicate edges, each vertex has only 33 other vertices to connect to, so the list 4,2,1,1\ends{4, 2, 1, 1} fails right away:
maximum possible degreeon 4 vertices=4−1=3<4\displaystyle \begin{aligned}&\text{maximum possible degree} \\ &\text{on } 4\text{ vertices} = 4 - 1 = \ends{3} < \fails{4}\end{aligned}
2. Connect the highest-degree vertices first on 3,3,1,1\ends{3, 3, 1, 1}Each of the two degree-3\ends{3} vertices must connect to all 33 of the other vertices in the graph, which forces at least 2\ends{2} edges onto every vertex and makes the degree-1\ends{1} vertices impossible:
edges forced onto eachof the last two vertices=2≠1\displaystyle \begin{aligned}&\text{edges forced onto each} \\ &\text{of the last two vertices} = \ends{2} \neq \fails{1}\end{aligned}
needs 3\text{needs }\htmlClass{lc-green}{3}
needs 3\text{needs }\htmlClass{lc-green}{3}
needs 1 (already has 2)\text{needs }\htmlClass{lc-orange}{1}\ (\text{already has }\htmlClass{lc-green}{2})
needs 1 (already has 2)\text{needs }\htmlClass{lc-orange}{1}\ (\text{already has }\htmlClass{lc-green}{2})

Two four-vertex degree lists can have the exact same even sum of 8\ends{8}, while 3,2,2,1\ends{3, 2, 2, 1} connects cleanly into a graph and 3,3,1,1\ends{3, 3, 1, 1} forces too many connections onto the degree-11 vertices.

Even when the degrees add up to an even number, some degree lists still can't be wired up without breaking a rule.

***

Key concepts

Every problem here comes down to counting line-ends in two ways:

∑v∈Vdeg⁡(v)\displaystyle \ends{\sum_{v \in V} \deg(v)} =2∣E∣\displaystyle = 2\lines{|E|}
Degrees to edges

When you know the degrees, add them to count the line-ends, then divide by 22 to get the edges (for 1010 servers of degree 4\ends{4}, there are 10×4=4010 \times \ends{4} = \ends{40} ends, so 40÷2=20\ends{40} \div 2 = \lines{20} cables).

Edges to degrees (the line-end budget)

When you know the edges, multiply by 22 first to find the total budget of line-ends, then hand those ends out to find a missing degree, count unknown vertices, or set up an inequality (with 21\lines{21} cables giving 42\ends{42} ends, nn servers of degree at least 4\ends{4} must satisfy 4n≤42\ends{4}n \le \ends{42}, so n≤10n \le 10).

Odd-degree parity check

Because 2∣E∣2\lines{|E|} is even, odd-degree vertices must always come in pairs (five vertices of degree 3\ends{3} require 5×3=155 \times \ends{3} = \ends{15} ends, so no such graph exists).

When not to stop at the Handshake Lemma

When asked if a specific list of degrees on nn vertices can be drawn, an even sum is only the first check. Before saying yes, make sure no vertex has degree greater than n−1\ends{n - 1} (ruling out 4,2,1,1\ends{4, 2, 1, 1} on 44 vertices) and trace where the edges from the highest-degree vertices must go to see if they force too many edges onto the lowest-degree vertices (ruling out 3,3,1,1\ends{3, 3, 1, 1} on 44 vertices).

***

5

Practice

1

A computer network has 1212 routers, and every router is wired directly to 5\ends{5} other routers. How many cables are in the network?

How many cable-ends are plugged into the 1212 routers altogether, and how many ends does each cable use?

The 1212 routers have 12×5=6012 \times \ends{5} = \ends{60} cable-ends in total. Be careful not to stop at 60\ends{60}: that counts each cable twice, once at each router it touches. Dividing by 22 ends per cable gives 60÷2=30\ends{60} \div 2 = \lines{30}.
2

A graph has 99 vertices. Six of the vertices have degrees 1,2,3,4,5,\ends{1, 2, 3, 4, 5,} and 6\ends{6}. Can the remaining three vertices all have even degrees? Explain why or why not.

Count how many of the first six vertices have an odd degree, and check what happens to that count if the last three are all even.

Among the first six vertices, three have odd degrees (1,3,\ends{1, 3,} and 5\ends{5}). Watch out for the slip of thinking that having 33 remaining vertices balances the 33 odd degrees, since what matters is whether the degrees themselves are odd or even. If the last three vertices all had even degrees, the entire graph would have 3\fails{3} odd-degree vertices, which is impossible because the number of odd-degree vertices in any graph must be even. Therefore, the answer is No.
3

A graph with 77 vertices has 14\lines{14} edges. Five of its vertices have degrees 6,5,4,4,\ends{6, 5, 4, 4,} and 3\ends{3}, and the last two vertices have the same degree. What is the degree of each of the last two vertices?

Find the total budget of line-ends from the 14\lines{14} edges before subtracting the degrees of the first five vertices.

The 14\lines{14} edges supply a budget of 14×2=28\lines{14} \times 2 = \ends{28} line-ends, and the first five vertices use 6+5+4+4+3=22\ends{6} + \ends{5} + \ends{4} + \ends{4} + \ends{3} = \ends{22} line-ends, leaving 28−22=6\ends{28} - \ends{22} = \ends{6} line-ends. Don't stop at 6\ends{6}, which is the combined degree of the last two vertices together; splitting those 6\ends{6} ends equally between the two vertices gives 6÷2=3\ends{6} \div 2 = \ends{3}.
4

A graph has 18\lines{18} edges. Four of its vertices have degree 5\ends{5}, and every other vertex has degree 4\ends{4}. How many vertices are in the graph in total?

After the four degree-5\ends{5} vertices take their share of the line-end budget, how many degree-4\ends{4} vertices can the remaining ends support?

The 18\lines{18} edges provide a budget of 18×2=36\lines{18} \times 2 = \ends{36} line-ends. The four degree-5\ends{5} vertices use 4×5=204 \times \ends{5} = \ends{20} ends, leaving 36−20=16\ends{36} - \ends{20} = \ends{16} ends, which gives 16÷4=4\ends{16} \div \ends{4} = 4 vertices of degree 4\ends{4}. Be careful not to stop at 44, since that only counts the degree-44 vertices and forgets the original 44 vertices of degree 5\ends{5}. Adding both groups gives 4+4=84 + 4 = 8.
5

A network has 19\lines{19} cables, and every server must be connected to at least 3\ends{3} other servers. What is the maximum number of servers the network can have?

Compare the total cable-ends supplied by the 19\lines{19} cables with the minimum number of ends needed by nn servers.

The 19\lines{19} cables supply 19×2=38\lines{19} \times 2 = \ends{38} cable-ends. With nn servers each needing at least 3\ends{3} ends, 3n≤38\ends{3}n \le \ends{38}, so n≤12.67n \le 12\fails{.67}. Watch out for rounding 12.6712\fails{.67} to the nearest whole number (13\fails{13}): 13\fails{13} servers would require at least 13×3=39\fails{13} \times \ends{3} = \fails{39} cable-ends, which exceeds our budget of 38\ends{38}. Rounding down gives a maximum of 1212.
6

A graph has 77 vertices, and every vertex has degree at most 3\ends{3}. What is the maximum number of edges the graph can have?

Find the maximum number of line-ends the 77 vertices can hold in total, then convert line-ends into whole edges.

The 77 vertices can hold at most 7×3=217 \times \ends{3} = \ends{21} line-ends, so the number of edges is at most 21÷2=10.5\ends{21} \div 2 = \lines{10}\fails{.5}. Don't round 10.5\lines{10}\fails{.5} up to 11\fails{11}, because 11\fails{11} edges would require 22\fails{22} line-ends (the 21\fails{21}st line-end cannot be used on its own since the sum of degrees must be even). The maximum number of edges is 10\lines{10}.
7

Can you draw a graph with 55 vertices whose degrees are 4,4,3,2,\ends{4, 4, 3, 2,} and 1\ends{1}? Explain why or why not.

Instead of stopping at the sum of the degrees, trace where the edges from the two degree-4\ends{4} vertices must go.

Adding the degrees gives 4+4+3+2+1=14\ends{4} + \ends{4} + \ends{3} + \ends{2} + \ends{1} = \ends{14}, which is even, and no degree exceeds 4\ends{4}. Be careful not to stop here and answer "Yes" just because the list passes the Handshake Lemma. In a 55-vertex graph, each of the two degree-4\ends{4} vertices must connect to all 44 of the other vertices. That forces every vertex in the graph to have at least 2\ends{2} connections, so no vertex can have degree 1\ends{1}. Therefore, the answer is No.