DiscreteMathTextbook/Chapter 10 - Graphs/10.5 Euler and Hamilton Paths.md
14.8 KB · commit a9602da
10.5 Euler and Hamilton Paths
Can we travel along the edges of a graph starting at a vertex and returning to it while visiting every vertex of the graph exactly once? Similarly, can we travel along the edges of a graph starting at a vertex and returning to it while using every edge of the graph exactly once?
Although these questions seem similar, the first question—which asks whether a graph has an Euler circuit—is relatively easy to solve, while the second question—which asks whether a graph has a Hamilton circuit—is notoriously difficult.
Euler Paths and Circuits
The town of Königsberg, Prussia (now Kaliningrad, Russia), was divided into four sections by the Pregel River. Seven bridges connected these sections, as depicted below:
The townspeople wondered whether it was possible to start at some point in town, take a walk that crossed each of the seven bridges exactly once, and return to the starting point.
The problem can be modeled as a multigraph where vertices represent landmasses (A,B,C,D) and edges represent the bridges connecting them:
The question becomes: Does this multigraph contain a circuit that uses every edge exactly once?
Examples of Euler Circuits and Paths
Necessary and Sufficient Conditions for Euler Circuits and Paths
Suppose that a graph G has an Euler circuit C starting and ending at vertex a. Every time the circuit passes through a vertex, it enters on one edge and exits on another, contributing 2 to the degree of that vertex. The starting vertex a has 1 contributed when leaving initially, 1 when returning finally, and 2 for each intermediate visit. Thus, if a connected graph has an Euler circuit, every vertex must have even degree.
To show that this condition is also sufficient, we construct an Euler circuit:
Start at an arbitrary vertex a and form a simple path by successively adding unused edges until no further edge is available. Because every vertex has even degree, whenever we enter a vertex other than a, an unused edge remains to leave it. Hence, this path can terminate only at a, forming a simple circuit.
If this circuit contains all edges of G, it is an Euler circuit.
Otherwise, remove the edges of this circuit from G, leaving a subgraph H. Since G is connected, H shares at least one vertex w with the circuit. Every vertex in H still has even degree.
Construct another circuit in H starting and ending at w. Splice this new circuit into the original circuit at w.
Repeat this process until all edges in G are included.
Resolution of the Königsberg Bridge Problem
In the multigraph modeling the seven bridges (Figure 2):
deg(A)=5,deg(B)=3,deg(C)=3,deg(D)=3
Because all four vertices have odd degree, this multigraph has no Euler circuit. It is impossible to walk across every bridge exactly once and return to the starting point.
Algorithm for Constructing Euler Circuits
The worst-case time complexity of Algorithm 1 is O(m), where m is the number of edges of G.
Euler Paths
Proof:
Necessity: Suppose a connected multigraph has an Euler path from a to b (a=b). The first edge incident with a contributes 1 to deg(a), and every intermediate visit contributes 2. Thus, deg(a) is odd. Similarly, the last edge contributes 1 to deg(b), making deg(b) odd. Every other vertex is visited by entering and leaving, contributing 2 each time, so all other vertices have even degree.
Sufficiency: Suppose G has exactly two vertices of odd degree, a and b. Add a temporary edge {a,b} connecting them. In the resulting graph G′, every vertex has even degree, so G′ has an Euler circuit by Theorem 1. Removing the added edge {a,b} from this circuit leaves an Euler path from a to b in G. ■
Returning to Königsberg
Could a person start at one point, cross every bridge exactly once, and end at a different point? This requires an Euler path. Because the multigraph has four vertices of odd degree (not two), no Euler path exists either.
Applications of Euler Paths and Circuits
Routing and Street Sweeping: Traversing every street in a neighborhood, utility grid connection, or communication link exactly once. Finding a minimal circuit that covers every edge when no Euler circuit exists is known as the Chinese postman problem (posed by Guan Meigu in 1962).
Circuit Layout: Designing paths for lithography or routing.
Molecular Biology: Euler paths are applied in DNA sequencing by reconstructing nucleotide sequences from overlapping fragments.
Hamilton Paths and Circuits
While Euler paths and circuits involve traversing every edge of a graph, Hamilton paths and circuits involve visiting every vertex.
The Icosian Puzzle
The term originates from the Icosian puzzle invented in 1857 by Sir William Rowan Hamilton. It used a wooden regular dodecahedron with pegs at its 20 vertices representing world cities:
The object was to travel along edges visiting each of the other 19 cities exactly once and returning to the start. Modeling the dodecahedron as a planar graph reveals the puzzle's solution:
Conditions for the Existence of Hamilton Circuits
Unlike Euler circuits, there are no known simple necessary and sufficient conditions for the existence of Hamilton circuits. Determining whether an arbitrary graph contains a Hamilton circuit is an NP-complete problem.
However, several useful structural properties and sufficient conditions exist:
Properties that Preclude Hamilton Circuits
If a graph has a vertex of degree 1, it cannot have a Hamilton circuit (a Hamilton circuit must enter and leave each vertex via distinct edges).
If a vertex has degree 2, both incident edges must be included in any Hamilton circuit.
Once a Hamilton circuit passes through a vertex, all other edges incident with that vertex can be removed from consideration.
A Hamilton circuit cannot contain a smaller cycle within itself.
Sufficient Conditions: Dirac's and Ore's Theorems
Adding edges to a graph makes the existence of a Hamilton circuit more likely. When degrees are sufficiently large, Hamilton circuits are guaranteed:
Applications of Hamilton Circuits
The Traveling Salesperson Problem (TSP)
The traveling salesperson problem asks for the route of shortest total distance that visits every city in a given set and returns to the starting city. This corresponds to finding a Hamilton circuit of minimum total edge weight in a weighted complete graph.