Vertices, edges and degree
Before you start: basic set notation from sets and relations is enough.
A graph \(G = (V, E)\) is a set of vertices \(V\) and a set of edges \(E\), each edge joining two vertices. Two vertices joined by an edge are adjacent; the edge is incident on both. An edge from a vertex to itself is a loop, and two edges joining the same pair are multiple edges. A simple graph has neither.
The degree \(\deg(v)\) is the number of edges at \(v\), with a loop counted twice.
In any graph, \[\sum_{v \in V} \deg(v) = 2|E|\]
Consequence
The number of vertices of odd degree is always even.
Why it works. Every edge has two ends, and each end adds 1 to the degree of some vertex. So counting degrees counts every edge exactly twice. The sum is even, and the even-degree vertices contribute an even amount, so the odd degrees must come in pairs.
Types of graphs
| Graph | What it is | Edges |
|---|---|---|
| Complete graph \(K_n\) | every pair of the \(n\) vertices joined | \(\dfrac{n(n - 1)}{2}\) |
| Cycle \(C_n\) | \(n\) vertices in a ring | \(n\) |
| \(k\)-regular on \(n\) vertices | every vertex has degree \(k\) | \(\dfrac{nk}{2}\) |
| Bipartite | vertices split into two sets, every edge goes across | depends |
| Complete bipartite \(K_{m,n}\) | every one of \(m\) vertices joined to every one of \(n\) | \(mn\) |
The regular-graph count comes straight from the handshaking lemma: \(nk = 2|E|\). A graph is bipartite exactly when it has no cycle of odd length, so any graph with a triangle is not bipartite.
Adjacency matrix and adjacency list
The adjacency matrix of a simple graph with vertices \(v_1, \ldots, v_n\) is the \(n \times n\) matrix with entry 1 in row \(i\), column \(j\) if \(v_i\) and \(v_j\) are adjacent, and 0 otherwise. It is symmetric, its diagonal is 0, and each row sum is that vertex's degree. The adjacency list just lists the neighbours of each vertex; it uses less space when the graph has few edges.
Paths, circuits, Euler and Hamilton
A walk is a sequence of vertices, each adjacent to the next. A path repeats no vertex; a circuit (closed walk) ends where it starts, and a cycle is a circuit that repeats no vertex except the first. A graph is connected if there is a path between every pair of vertices; its maximal connected pieces are its components.
An Euler circuit uses every edge exactly once and returns to the start. An Euler path uses every edge exactly once.
For a connected graph
Euler circuit \(\iff\) every vertex has even degree.
Euler path but no circuit \(\iff\) exactly two vertices have odd degree. The path starts at one of them and ends at the other.
The reason: each time the trail passes through a vertex it uses one edge in and one edge out, two at a time. Only the start and end of an open trail can be left with an odd number.
A Hamiltonian cycle visits every vertex exactly once and returns to the start. There is no simple degree test for it. A useful sufficient condition is Dirac's theorem: if a simple graph has \(n \ge 3\) vertices and every degree is at least \(n/2\), it has a Hamiltonian cycle. The converse is false: graph \(G\) above has a vertex of degree \(2 < 5/2\), yet it has the Hamiltonian cycle \(A\text{-}B\text{-}D\text{-}E\text{-}C\text{-}A\).
Isomorphism and planar graphs
Two graphs are isomorphic if there is a one-to-one correspondence between their vertices that preserves adjacency. They are the same graph drawn differently. To show two graphs are not isomorphic, find a property one has and the other lacks: number of vertices or edges, degree sequence, connectedness, a cycle of some length. To show they are, write down the correspondence and check every edge.
A graph is planar if it can be drawn in the plane with no edges crossing. Such a drawing splits the plane into regions called faces, and the unbounded outside region counts as one face.
For a connected planar graph with \(V\) vertices, \(E\) edges and \(F\) faces, \[V - E + F = 2\]
Consequence (simple graph, \(V \ge 3\))
\(E \le 3V - 6\). If there are no triangles, \(E \le 2V - 4\).
For graph \(G\): \(5 - 7 + 4 = 2\). The consequence comes from counting edges round faces: each face has at least 3 edges on its boundary and each edge borders at most 2 faces, so \(3F \le 2E\). Put \(F = 2 - V + E\) into that and you get \(E \le 3V - 6\). For \(K_{3,3}\), which has no triangles, \(E = 9 > 2(6) - 4 = 8\), so \(K_{3,3}\) is not planar.
Solved examples
Example 1: Handshaking
EasyA graph has degrees \(3, 3, 2, 2, 2\). How many edges does it have? Can a graph have degrees \(3, 3, 3, 2, 2\)?
- Sum of degrees \(= 3 + 3 + 2 + 2 + 2 = 12 = 2|E|\), so \(|E| = 6\).
- For \(3, 3, 3, 2, 2\) the sum is 13, which is odd. The sum of degrees is always even.
- Another way to see it: there would be three odd-degree vertices, and that number must be even.
Answer6 edges; no graph has degrees \(3, 3, 3, 2, 2\).
Example 2: Counting edges
EasyHow many edges do \(K_6\), \(K_{3,4}\) and a 4-regular graph on 10 vertices have?
- \(K_6\): \(\dfrac{6 \times 5}{2} = 15\).
- \(K_{3,4}\): \(3 \times 4 = 12\).
- 4-regular on 10 vertices: \(\dfrac{10 \times 4}{2} = 20\).
Answer15, 12 and 20 edges
Example 3: Adjacency matrix and list
EasyWrite the adjacency matrix and the adjacency list of graph \(G\) in the diagram, with vertices in the order \(A, B, C, D, E\).
- \[\begin{bmatrix} 0 & 1 & 1 & 0 & 0 \\ 1 & 0 & 1 & 1 & 0 \\ 1 & 1 & 0 & 1 & 1 \\ 0 & 1 & 1 & 0 & 1 \\ 0 & 0 & 1 & 1 & 0 \end{bmatrix}\]
- List: \(A: B, C\); \(B: A, C, D\); \(C: A, B, D, E\); \(D: B, C, E\); \(E: C, D\).
- Check: the row sums are \(2, 3, 4, 3, 2\), the degrees, and they add up to \(14 = 2 \times 7\).
AnswerThe matrix above; it is symmetric with zero diagonal.
Example 4: Finding an Euler path
MediumDoes graph \(G\) have an Euler circuit? An Euler path? Find one if it exists.
- Degrees: \(A = 2,\ B = 3,\ C = 4,\ D = 3,\ E = 2\). \(G\) is connected.
- Two vertices, \(B\) and \(D\), have odd degree. So there is no Euler circuit, but there is an Euler path from \(B\) to \(D\).
- One such path: \(B\text{-}A\text{-}C\text{-}B\text{-}D\text{-}C\text{-}E\text{-}D\).
- Check: it uses \(BA, AC, CB, BD, DC, CE, ED\), all 7 edges, each once.
AnswerNo Euler circuit; Euler path \(B\text{-}A\text{-}C\text{-}B\text{-}D\text{-}C\text{-}E\text{-}D\).
Example 5: The bridges of Königsberg
MediumFour land areas are joined by 7 bridges: the island \(A\) has 2 bridges to \(B\), 2 to \(C\) and 1 to \(D\); there is also one bridge \(B\)-\(D\) and one \(C\)-\(D\). Can you walk across every bridge exactly once?
- Model the land areas as vertices and the bridges as edges (multiple edges allowed).
- Degrees: \(A = 2 + 2 + 1 = 5\), \(B = 2 + 1 = 3\), \(C = 2 + 1 = 3\), \(D = 1 + 1 + 1 = 3\).
- All four vertices have odd degree. An Euler path allows at most two.
AnswerNo. There are four odd-degree vertices, so no walk crosses every bridge exactly once.
Example 6: Hamiltonian cycles
MediumFind a Hamiltonian cycle in \(G\). Show that \(K_{2,3}\) has no Hamiltonian cycle.
- In \(G\): \(A\text{-}B\text{-}D\text{-}E\text{-}C\text{-}A\) uses the edges \(AB, BD, DE, EC, CA\), all present, and visits each vertex once.
- In \(K_{2,3}\) every edge joins the 2-vertex side to the 3-vertex side, so any cycle alternates sides.
- A cycle through all 5 vertices would need equal numbers from each side. With 2 and 3, that is impossible.
Answer\(G\): \(A\text{-}B\text{-}D\text{-}E\text{-}C\text{-}A\). \(K_{2,3}\): none, because the two sides have different sizes.
Example 7: Isomorphic or not?
Exam level(a) \(G_1\) is the cycle \(1\text{-}2\text{-}3\text{-}4\text{-}5\text{-}1\). \(G_2\) is the five-pointed star with edges \(pr, rt, tq, qs, sp\). Are they isomorphic? (b) Is the cycle \(C_6\) isomorphic to two separate triangles?
- (a) Both have 5 vertices, 5 edges and every degree 2. Try \(1 \to p,\ 2 \to r,\ 3 \to t,\ 4 \to q,\ 5 \to s\).
- Edges of \(G_1\) map to \(pr, rt, tq, qs, sp\): exactly the edges of \(G_2\). So the map preserves adjacency.
- (b) Both have 6 vertices, 6 edges and every degree 2, so the counts don't separate them.
- But \(C_6\) is connected and two triangles are not. Isomorphic graphs are either both connected or both not.
Answer(a) Isomorphic, via \(1 \to p,\ 2 \to r,\ 3 \to t,\ 4 \to q,\ 5 \to s\). (b) Not isomorphic.
Example 8: Euler's formula
Exam level(a) A connected planar graph has 10 vertices, each of degree 3. How many faces does a plane drawing have? (b) Show that \(K_5\) is not planar.
- (a) Handshaking: \(2E = 10 \times 3 = 30\), so \(E = 15\).
- Euler's formula: \(F = 2 - V + E = 2 - 10 + 15 = 7\). (The pentagonal prism is such a graph: 2 pentagons and 5 squares make 7 faces.)
- (b) \(K_5\) has \(V = 5\) and \(E = 10\). A simple connected planar graph must have \(E \le 3V - 6 = 9\).
- \(10 > 9\), so \(K_5\) can't be planar.
Answer(a) 7 faces. (b) \(K_5\) breaks \(E \le 3V - 6\), so it is not planar.
For any Euler question, the first thing I write is the list of degrees. Count the odd ones: zero means a circuit, two means a path between those two, anything else means neither. And remember to check the graph is connected before you say yes.
Common mistakes
1. Forgetting the 2 in the handshaking lemma
If the degrees add up to 20, the graph has \(20/2 = 10\) edges, not 20. Each edge is counted once at each end.
2. Mixing up Euler and Hamilton
Euler is about edges (each edge once) and has an exact degree test. Hamilton is about vertices (each vertex once) and has no simple test. \(K_4\) has a Hamiltonian cycle but no Euler path, because all four degrees are 3.
3. Leaving out the outer face
For a triangle, \(V = 3\) and \(E = 3\). Counting only the inside gives \(F = 1\) and \(3 - 3 + 1 = 1\), which looks like a failure of Euler's formula. With the outside, \(F = 2\) and \(3 - 3 + 2 = 2\).
Practice questions
Try each one on paper before you open the answer.
Q1How many edges does \(K_8\) have?
\(\dfrac{8 \times 7}{2} = 28\).
Q2A graph has 12 edges and every vertex has degree 3. How many vertices does it have?
\(3n = 2 \times 12 = 24\), so \(n = 8\).
Q3Is there a simple graph with degrees \(4, 4, 3, 2, 1\)?
The sum is 14, which is even, so handshaking doesn't rule it out. But with 5 vertices, a degree-4 vertex is joined to all the others. Two such vertices are both joined to the last vertex, giving it degree at least 2, not 1. So no such simple graph exists.
Q4Does \(K_{2,4}\) have an Euler circuit? A Hamiltonian cycle?
The 2 vertices on one side have degree 4 and the 4 on the other have degree 2. All even and connected, so it has an Euler circuit. No Hamiltonian cycle: a cycle alternates sides, and the sides have sizes 2 and 4.
Q5For which \(n \ge 3\) does \(K_n\) have an Euler circuit?
Every vertex of \(K_n\) has degree \(n - 1\). This is even when \(n\) is odd. So \(K_n\) has an Euler circuit exactly when \(n\) is odd.
Q6A connected planar graph has 6 vertices, each of degree 4. How many faces does it have?
\(E = \dfrac{6 \times 4}{2} = 12\), so \(F = 2 - 6 + 12 = 8\). (This is the octahedron.)
Bring it to a free demo class and work through it with Vipul Sir. Book on WhatsApp.
Frequently asked questions
What is the handshaking lemma?
In any graph the degrees add up to twice the number of edges: \(\sum \deg(v) = 2|E|\). It follows that the number of odd-degree vertices is even.
What is the difference between an Euler path and a Hamiltonian path?
An Euler path uses every edge exactly once. A Hamiltonian path visits every vertex exactly once. Euler paths have an exact degree test; Hamiltonian paths do not.
What is Euler's formula for planar graphs?
For a connected planar graph drawn without crossings, \(V - E + F = 2\), where \(F\) counts the faces including the outer one.
How do you check whether two graphs are isomorphic?
First compare the number of vertices, the number of edges and the degree sequences. If any differ, they are not isomorphic. If they agree, try to build a vertex correspondence that sends every edge to an edge, or find a structural difference such as connectedness or a cycle length.