Definitions
Walk
A sequence of vertices where consecutive vertices are adjacent.
Length: number of edges
Trail
A walk with no repeated edges.
Path
A walk with no repeated vertices (and thus no repeated edges).
Circuit (Closed Walk)
A walk that starts and ends at the same vertex.
Cycle
A circuit with no repeated vertices except start/end.
Connectivity
Distance
= length of shortest path between and (or if no path exists).
Diameter
Maximum distance between any two vertices:
Eccentricity
For vertex :
Radius
Center
Vertices with eccentricity equal to radius.
Euler Paths and Circuits
Euler Path
A trail that visits every edge exactly once.
Euler Circuit
An Euler path that starts and ends at the same vertex.
Existence Conditions
Undirected Graph:
| Type | Condition |
|---|---|
| Euler circuit | Connected + all vertices have even degree |
| Euler path (not circuit) | Connected + exactly 2 vertices have odd degree |
Directed Graph:
| Type | Condition |
|---|---|
| Euler circuit | Strongly connected + for all |
| Euler path | Weakly connected + one vertex has , one has , all others have |
Fleury's Algorithm (Finding Euler Path/Circuit)
- Start at appropriate vertex
- Walk edges, removing them as you go
- Only cross a bridge if no other option
Hierholzer's Algorithm (More Efficient)
- Start at any vertex, follow edges until returning to start
- If unvisited edges remain from vertices in current path:
- Start new cycle from such a vertex
- Splice into main path
- Repeat until all edges visited
Time complexity:
Hamiltonian Paths and Circuits
Hamiltonian Path
A path that visits every vertex exactly once.
Hamiltonian Circuit (Cycle)
A Hamiltonian path that starts and ends at the same vertex.
No Simple Conditions!
Unlike Euler paths/circuits, there's no simple criterion.
Sufficient Conditions
Ore's Theorem: If has vertices and for every pair of non-adjacent vertices : then has a Hamiltonian circuit.
Dirac's Theorem: If has vertices and every vertex has: then has a Hamiltonian circuit.
Necessary Conditions
If has a Hamiltonian circuit:
- is connected
- Every vertex has degree
- Removing any vertex leaves a connected graph
Complexity
Finding Hamiltonian paths/circuits is NP-complete.
Comparison: Euler vs. Hamilton
| Property | Euler | Hamilton |
|---|---|---|
| Visits | Every edge once | Every vertex once |
| Easy to check? | Yes (degree conditions) | No (NP-complete) |
| Named after | Leonhard Euler (1736) | William Hamilton (1859) |
The Seven Bridges of Königsberg
Classic problem solved by Euler (1736):
- City with 2 islands
- 7 bridges connecting landmasses
- Can you walk crossing each bridge exactly once?
Answer: No. The graph has 4 vertices, all with odd degree. Euler path requires 0 or 2 odd-degree vertices.
This problem initiated graph theory.
Applications
Euler Paths/Circuits
- Snow plow routing (cover all streets)
- DNA sequencing (de Bruijn graphs)
- Drawing figures without lifting pen
Hamiltonian Paths/Circuits
- Traveling Salesman Problem
- Circuit board design
- Scheduling problems
Traveling Salesman Problem (TSP)
Given a weighted complete graph, find the minimum-weight Hamiltonian circuit.
Complexity
- NP-hard
- No known polynomial algorithm
Approximations
- Nearest neighbor heuristic
- 2-opt improvement
- Christofides algorithm (3/2 approximation for metric TSP)