Two classic questions: can you travel every edge exactly once, and can you visit every vertex exactly once? The first has a neat test; the second does not.
Euler paths and circuits
An Euler path uses every edge exactly once. An Euler circuit is an Euler path that starts and ends at the same vertex. The idea comes from the Königsberg bridge puzzle, which Euler showed to be impossible in 1736.
Rules for a connected graph:
- It has an Euler circuit if and only if every vertex has even degree.
- It has an Euler path (but no circuit) if and only if exactly two vertices have odd degree. The path starts at one odd vertex and ends at the other.
- With more than two odd vertices there is neither.
Example: A square with one diagonal has degrees 3, 3, 2, 2. Exactly two odd vertices, so an Euler path exists but not a circuit.
Hamiltonian paths and cycles
A Hamiltonian path visits every vertex exactly once. A Hamiltonian cycle is such a path that returns to the start.
There is no simple necessary and sufficient test. Some useful facts:
- Every complete graph Kₙ (n ≥ 3) has a Hamiltonian cycle.
- Dirac's theorem: a simple graph with n ≥ 3 vertices where every vertex has degree at least n/2 has a Hamiltonian cycle (a sufficient condition only).
- The travelling salesman problem asks for the cheapest Hamiltonian cycle in a weighted graph, and it is hard for large graphs.
Comparison
| Euler | Hamiltonian | |
|---|---|---|
| Visits every | Edge once | Vertex once |
| Easy test | Yes, by degrees | No |
| Application | Route inspection, garbage collection | Delivery routing, scheduling |
Worked example
Does K₄ have an Euler circuit? Each vertex has degree 3 (odd), so no. Does it have a Hamiltonian cycle? Yes: A → B → C → D → A.
Common mistakes
- Mixing up the two: Euler is about edges, Hamilton about vertices.
- Forgetting that the graph must be connected for the Euler rules.
Practice questions
- State the condition for an Euler circuit.
- When does a graph have an Euler path but no circuit?
- Define a Hamiltonian cycle.
- Does K₅ have an Euler circuit?
- State Dirac's theorem.
Answers to the practice questions
- The graph is connected and every vertex has even degree.
- When exactly two vertices have odd degree.
- A cycle that visits every vertex exactly once.
- Yes, because each vertex has degree 4 (even).
- If a simple graph with n ≥ 3 vertices has every degree at least n/2, it has a Hamiltonian cycle.
Sources
- Official BCA syllabus Mathematics Foundations to Computer Science I, course code CC101, Unit III
- Kolman, Busby and Ross, Discrete Mathematical Structures, 6th edition, Pearson
