Graphs, Degrees and the Handshake Lemma
A graph is just dots (vertices) joined by lines (edges). Every edge has two ends, so when you add up how many edges touch each vertex, you count every edge exactly twice, and the total always comes out even.
What the symbols mean
- Degree
How many edges touch the vertex v.
- Vertex set
All the vertices (dots) of the graph.
- Number of edges
How many connections there are.
Explanation
A graph is simply a bunch of dots (vertices) with lines (edges) between some of them, showing which things are connected. It's not the kind of graph you plot on; the name comes from the "graphic" picture of dots and lines that chemists used for molecules. Graphs are good for anything made of connections: people and friendships, cities and roads, web pages and links, atoms and bonds. The formula looks fancy, but it's just three pieces: (how many lines touch dot ), (add that up over every dot) and (twice the number of lines). It says that adding up the line-ends gives you twice the number of lines, which, once you see it, is hard to argue with.
A simple graph has no loops (edges from a vertex back to itself) and at most one edge between any two vertices. A directed graph gives each edge a direction, like one-way streets or "follows" on social media.
Handshake lemma. Picture a party where some pairs shake hands. Each handshake is an edge, and each person's degree is how many hands they shook. Now ask everyone for their count and add them up. Every handshake gets reported twice, once by each person in it, so the total is exactly , twice the number of handshakes.
That has a surprising consequence: the number of odd-degree vertices is always even. Think about why. The total is even. The even degrees add up to something even, so the odd degrees have to add up to something even too, and a sum of odd numbers is even only when there's an even number of them. So at any party, the number of people who shook an odd number of hands is even.
A common mistake. It's tempting to think the degree sum equals the number of edges, since each edge "touches" the graph once. It doesn't: each edge touches two vertices and gets counted at both. Forgetting to divide by 2 is the classic error in handshake problems.
Special graphs.
- The complete graph joins every pair of vertices. An edge is just a choice of 2 vertices, so there are edges, and each vertex has degree , one edge to each of the others.
- The cycle is a ring: every degree is 2.
- A bipartite graph splits its vertices into two sides with edges only between them; includes every such edge.
Computers store graphs as adjacency lists (each vertex's neighbors) or an adjacency matrix (a 1 in row , column when and are joined).
See it
Worked examples
Ten people each shake hands with everyone else once. How many handshakes are there?
- 1
Make each person a vertex and each handshake an edge. Everyone shakes with everyone, so the graph is and each person has degree 9.
Practice
Type your answer and check it. Solve them all to complete the lesson.
How many edges does have?
A graph has degrees . How many edges does it have?
Can a graph have exactly 3 vertices of odd degree?
What is the degree of each vertex in ?
A data center has 12 routers, and each is linked directly to exactly 5 others. How many links are there?
How many different simple graphs can be drawn on 4 labeled vertices?
The hardest one here. Get it, and you've got this lesson.
A graph has 10 vertices, every vertex has degree 3 or 4, and there are 18 edges. How many vertices have degree 4?
Where it's used
Social networks, road maps, the web and molecules are all stored and analyzed as graphs, and degree counts are the first statistic anyone computes on them.