Eulerian and Hamiltonian Graphs

Decide whether routes can cover every edge or visit every vertex, then optimize weighted routes.

Every edge exactly once

A street inspector needs to cover roads. A visitor may instead need to stop at every building. These are different requirements: one concerns edges, the other vertices. Identify the task before choosing a theorem.

Euler trail and Euler circuit

An Euler trail uses every edge exactly once. It may revisit vertices. An Euler circuit is an Euler trail that returns to its starting vertex. A graph is Eulerian when it has an Euler circuit. The common term “Euler path” means Euler trail, even though an ordinary path cannot repeat vertices.

Seven distinct edges join a, b, c, d and e. An Euler route must use all seven; vertices may repeat.
Seven distinct edges join a, b, c, d and e. An Euler route must use all seven; vertices may repeat.

Check a proposed Euler route

Does a–c–d–e–b–d–a–b use every edge exactly once?
Show worked solution

The traversed edges are ac, cd, de, eb, bd, da and ab. These are exactly the seven displayed edges, without repetition. It is an open Euler trail from a to b. It is not an ordinary path because a, b and d recur.

Count before tracing

An Euler circuit traverses a graph with 12 edges. How many edge traversals and how many entries in its vertex sequence occur?

Hint

A sequence with k traversed edges has k + 1 vertex entries.

Show worked solution

There are 12 traversals and 13 vertex entries, with the first and last equal. The number of different vertices can be much smaller.

Euler’s degree criterion

Undirected Euler criterion

After isolated vertices are ignored, all vertices with edges must belong to one connected component. An Euler circuit exists exactly when every vertex has even degree. An open Euler trail exists exactly when there are two odd-degree vertices; these must be its endpoints. More than two odd vertices prevents any Euler trail.

At an intermediate visit you enter on one edge and leave on another, pairing incident ends. Only the start and finish of an open route can have an unpaired end. This proves the necessity of the parity rule. To build a circuit when degrees are even, follow unused edges until returning, then splice in unused closed routes at visited vertices.

Apply the criterion to the seven bridges

Can the historical bridge network be crossed using each bridge once?
Show worked solution

The network is connected but has four odd vertices. It has neither an Euler circuit nor an open Euler trail. Changing how the map is drawn does not change those degrees.

Find the mistake: parity alone

Two separate triangles have all degrees even. A learner concludes that the whole graph has an Euler circuit. Repair the argument.

Hint

Can one route travel between components?

Show worked solution

No. There are two edge-containing components and no joining edge. Each triangle has its own Euler circuit, but no single route covers both. Connectedness of the edge-containing part is required.

Königsberg bridges and graph

Even degrees need connected edges

Constructing and repairing Euler routes

A degree test proves existence but does not supply the order of edges. Keep a list of unused edges and cross each off as it is used. If you close a route while unused edges remain at a visited vertex, build another closed route there and insert it into the first.

A new bridge changes parity

The seven-edge graph has odd vertices a and b. What happens when one new edge joins a to b?
Show worked solution

Both odd degrees become even and the graph stays connected. The new graph has an Euler circuit. One circuit is a–c–d–e–b–d–a–b–a, where the last two ab traversals use the two different parallel edges. Edge identities matter.

Repair four odd vertices

A connected multigraph has four odd vertices. What is the fewest added edges needed to make all degrees even if you may join any pair of vertices?

Hint

Each added edge can change the parity of at most two vertices.

Show worked solution

At least two edges are needed. Pair the four odd vertices and add an edge between each pair. Two edges suffice; loops do not help because they add two to one degree without changing its parity.

Every vertex exactly once

Hamilton path and cycle

A Hamilton path visits every vertex exactly once. A Hamilton cycle visits every vertex once and returns to its start. “Hamilton circuit” is another common name for Hamilton cycle. Unused edges are allowed. We use the simple-graph cycle convention: at least three distinct vertices.

RequirementEulerHamilton
Must coverEvery edgeEvery vertex
May repeat vertices?YesOnly shared start/end in a cycle
May skip edges?NoYes
General degree test?Exact parity criterion for undirected graphsNo equivalent all-purpose odd/even test

Airline itinerary

Find a round trip visiting Portland, Boise, Butte, Salt Lake City, Reno and Sacramento exactly once using the available direct flights.
Show worked solution
Lines represent available direct flights; the layout is schematic and contains no distance information.
Lines represent available direct flights; the layout is schematic and contains no distance information.

One Hamilton cycle is Portland–Boise–Butte–Salt Lake City–Reno–Sacramento–Portland. Check each consecutive pair against the available edges and count each city once before returning. This does not claim the itinerary is shortest.

Hamilton but not Euler

For K₄, determine whether there is a Hamilton cycle and an Euler circuit.

Hint

Compare vertex visitation with the parity of degree three.

Show worked solution

A–B–C–D–A is a Hamilton cycle in K₄. Each vertex has odd degree three, so four odd vertices prevent an Euler trail. A Hamilton cycle uses four of the six edges.

Ruling out Hamilton cycles

A vertex on a Hamilton cycle needs two distinct incident cycle edges. Therefore a pendant vertex prevents a Hamilton cycle. A bridge also prevents a Hamilton cycle spanning both sides: crossing to the other side and returning would reuse the only connection. An articulation vertex separating the graph likewise obstructs such a cycle.

Euler does not imply Hamilton

Two triangles share exactly one vertex O. Can the graph be Eulerian? Can it have a Hamilton cycle?
Show worked solution

O has degree four and the other vertices degree two; the connected graph is Eulerian. A Hamilton cycle cannot visit vertices in both triangles without using O more than once before closing. The shared vertex is an articulation vertex.

Endpoints in a tree

Can a tree with four pendant vertices have a Hamilton path? Compare a simple chain.

Hint

A pendant vertex on a spanning path must be an endpoint.

Show worked solution

No: four pendant vertices would require four endpoints, but a path has only two. A simple chain itself is a Hamilton path, though a nontrivial tree has no Hamilton cycle.

Weights and shortest paths

A weighted route

Edge weights can represent distance, time or cost. Add the weights of traversed edges to obtain route weight. Use one consistent unit. Geometric lengths in the drawing do not replace the numerical weights.

With nonnegative weights, Dijkstra’s method permanently labels the unvisited vertex having the smallest tentative distance. Update its neighbors by comparing the current estimate with the distance through that vertex. A directed edge may be followed only in its arrow direction.

Shortest route from S to T

Use the directed weighted network. Find the shortest S-to-T route and justify it.
Show worked solution
Directed edges have the displayed weights. Arrowheads indicate allowed travel; all weights are nonnegative.
Directed edges have the displayed weights. Arrowheads indicate allowed travel; all weights are nonnegative.
Settled vertexFinal distance from SImportant update
S0A 7, B 4, C 9, D 7
B4A becomes 5; C becomes 7
A5T becomes 11
C and D7C gives T = 10; D gives 11
T10Final

The shortest route is S–B–C–T, weight 4 + 3 + 3 = 10. The direct-looking S–A–T route weighs 13. This is a shortest path, not a Hamilton tour.

A local choice can fail

In the displayed network, would choosing the smallest outgoing edge at every step necessarily find the shortest path?

Hint

A locally smallest edge does not compare complete remaining costs.

Show worked solution

No general guarantee exists. Dijkstra compares total tentative distances from S, not merely the next edge. For example an edge of weight 1 can lead to a required edge of weight 100, while another first edge of weight 2 can lead to weight 2.

Shortest Hamilton tours

A shortest Hamilton tour must visit every vertex and return while minimizing total weight. This is different from finding a shortest route between two endpoints. For a small complete undirected graph, list tours systematically: fix one starting vertex and treat reversals as the same tour.

\[\text{Distinct tours in }K_n=\frac{(n-1)!}{2}\quad(n\ge3)\]

Check the best complete tour

Find a shortest Hamilton tour in the five-location network.
Show worked solution
Weights are travel times. Every pair has a direct link; crossing lines without circles are not extra locations.
Weights are travel times. Every pair has a direct link; crossing lines without circles are not extra locations.

Fix A. There are 4!/2 = 12 tours after reversals are identified. Comparing only a handful of plausible routes is not enough to prove a minimum.

Exhaustive comparison gives A–B–E–C–D–A, total 36. The reverse tour has the same cost.

Tour from A (reversal omitted)Weight
A–B–E–C–D–A36
A–B–E–D–C–A37
A–C–B–E–D–A40
A–B–C–E–D–A41
A–C–E–B–D–A41
A–B–D–E–C–A43
A–D–C–B–E–A49
A–B–C–D–E–A51
A–C–D–B–E–A51
A–B–D–C–E–A52
A–D–B–C–E–A55
A–C–B–D–E–A56

All twelve cases have been checked, so the minimum is established. Nearest-neighbor routes may be useful candidates, but their cost alone does not certify optimality.

A bound before enumerating

For each vertex in a weighted complete graph, sum its two least incident weights. Why does half the total give a lower bound for any Hamilton tour?

Hint

Each tour uses two incident edges per vertex, and every tour edge is counted at both ends.

Show worked solution

At each vertex, a tour’s two incident weights sum to at least the two least available. Adding these local bounds counts each tour edge twice. Dividing by two yields a lower bound. A tour attaining the bound is optimal; otherwise the bound alone does not identify the optimum.

Explore and compare route requirements

Use the network explorer to change an edge and predict how the Euler classification changes. Then consider the Hamilton question separately. A successful Euler route is not evidence of a Hamilton cycle.

Choose the right model

A worker must inspect every road; a courier must visit every office; a traveler wants the cheapest connection from S to T. Which problem does each describe?

Hint

Identify the object that must be covered and whether returning is required.

Show worked solution

Road inspection is an Euler-style edge-coverage task (or a repeated-edge optimization if exact coverage is impossible). Office visitation is Hamilton-style, with a cycle only if returning is required. The last task is a weighted shortest-path problem. None can be substituted for another merely because all use graphs.

Interactive exploration

References

R. N. Aufmann, J. S. Lockwood, R. D. Nation and D. K. Clegg, Mathematical Excursions, 3rd ed., graph theory chapters. Further reading: OpenStax, Contemporary Mathematics, Graph Theory. Figures are redrawn for this lesson; vertex positions are schematic.

HM Math Studio

Opening your learning space…