LightMySky
به انگلیسی

Euler Trails and Hamilton Cycles

Use connectivity and degree parity to decide Euler trail existence. Apply sufficient conditions for Hamilton cycles and compare what is known about the two decision problems.

No account needed. Progress saves in this browser.

What a learner can do afterwards

  • State and prove the degree condition for an Euler circuit and for an Euler trail
  • Give sufficient conditions for a Hamilton cycle and explain why they are not necessary
  • Contrast the two problems in terms of how hard each is to decide

1 · Read

As with trees, we use vertices, edges and connected components. Here graphs are finite and undirected and have at least one edge. Degree counts incident edge ends; a loop counts twice. Adding all degrees counts each edge twice, so the number of edges is half the degree sum. For a triangle, 2 + 2 + 2 = 6 edge ends give 3 edges.

Tap each dot and count out loud.

Each pair represents the two ends of one edge. These dots count ends; they do not draw the triangle.

An Euler trail uses every edge once; it may be open or closed. A closed Euler trail is an Euler circuit. A circuit exists exactly when all vertices with edges are in one connected component and every degree is even. Isolated vertices have no edges to cover. For necessity, pair each arrival with a departure. At the start, pair the first departure with the final arrival. Every edge end is paired, so every degree is even.

For sufficiency, follow unused edges until you cannot continue. Even degrees prevent stopping away from your start, so the trail closes. Removing its edges leaves even degrees. If edges remain, connectivity gives a vertex on the current trail with unused incident edges. Build another closed trail there and insert it into the route. Repeat. Each insertion uses more edges, so a finite graph eventually has every edge covered.

PQRPSTP

For edges PQ, QR, RP, PS, ST, TP, join the two closed trails at P. The resulting route uses all six edges once.

An Euler trail exists exactly when all vertices with edges are in one component and the odd-degree count is zero or two. Zero gives a circuit. Two gives an open trail whose endpoints are the odd vertices. At intermediate visits, arrivals pair with departures. An open route leaves one unpaired departure at its start and one unpaired arrival at its end.

Tap each dot and count out loud.

An odd endpoint can have pairs of edge ends plus one unpaired end. The picture counts ends at one vertex.

To prove existence with two odd vertices, add a temporary edge between them. Allow a parallel edge if they are already adjacent. Both odd degrees become even. The circuit result now applies. Write an Euler circuit with the temporary edge last, then delete that edge. The remaining route uses every original edge once and runs between the original odd vertices.

A Hamilton cycle visits every vertex once, then returns to its start. Only the start repeats in its written route. A Hamilton path visits every vertex once without closing back to the start. In a simple graph, a Hamilton cycle has at least three vertices. It uses n edges on n vertices and can skip other edges. Euler circuits cover every edge but may repeat vertices.

UVWXU

Vertices U, V, W, X; edges UV, VW, WX, XU, UW. This Hamilton cycle skips UW, so it is not an Euler circuit.

For the following degree rules, the graph is simple and undirected, with n >= 3 vertices. Simple means no loops or parallel edges. Dirac's theorem guarantees a Hamilton cycle if every degree is at least n/2. Ore's theorem guarantees one if deg(u) + deg(v) >= n for every pair of distinct nonadjacent vertices u and v. These conditions are sufficient: meeting either bound guarantees a cycle.

Try it together

Dirac's bound is sufficient: for a simple undirected graph with n >= 3, every degree at least n/2 guarantees a Hamilton cycle. The cycle graph on seven vertices has one around its ring, yet every degree is 2, below 7/2. Nonadjacent vertices have degree sum 4, below Ore's bound 7. Thus neither condition is necessary. Failing either bound alone does not decide whether a Hamilton cycle exists.

JKLMNOPJ

The graph has exactly the edges JK, KL, LM, MN, NO, OP, PJ. The strip shows route order, not graph geometry.

A necessary condition differs from a sufficient condition. Every vertex on a Hamilton cycle needs two distinct incident edges, one to enter and one to leave. Degree 0 or 1 rules out a Hamilton cycle.

Adjacency lists record incident edge ends at each vertex; a loop appears twice. Start at a vertex with edges and mark it. Repeatedly scan a reached vertex's list once, marking unseen neighbors to explore next. Check all vertices with edges were reached, and count list entries for degrees.

<

Compare one available incident edge with the two needed at a cycle vertex. These dots compare counts, not graph connections.

With adjacency lists, scan V vertices and 2E listed edge ends, where V counts vertices and E counts edges. Marking each vertex and scanning each list once checks connectivity and degrees in O(V + E) time. This decides Euler trail existence. Hamilton cycle existence on general simple undirected graphs is NP-complete. No polynomial-time algorithm is known, but none has been proved impossible: whether P = NP is open. A proposed Hamilton cycle can be checked in polynomial time.

Check edge connectivityCount odd degreesConnected + 0 or 2 odds

The Euler decision test needs connectivity among vertices with edges as well as zero or two odd degrees.

To check an Euler circuit, list its consecutive undirected edges. Check each is present, none repeats, every graph edge is used, and the route closes. A closed route that omits an edge is not Euler. For a Hamilton cycle in a simple undirected graph, require at least three vertices. Check every graph vertex occurs exactly once before the repeated start, the route closes, and every consecutive edge is present with no edge repeated, including the closing edge.

Check connectivity and odd degrees for Euler trails. Hamilton degree bounds give guarantees, not a complete test. No polynomial-time general Hamilton algorithm is known.

Original lesson, questions and flashcards written for this learning dataset.

Original readings, questions and flashcards written for this learning dataset. Contemporary Mathematics sections 12.5 through 12.8 informed the study of mathematical facts and question design. No textbook prose or images are reproduced.

More to read

Building an Euler circuit

Suppose the only graph edges are KL, LM, MN and NK. There is also an isolated vertex H. The route K-L-M-N-K covers every edge once and closes. It is an Euler circuit. H does not obstruct it because H has no incident edges to cover.

For a finite undirected graph with at least one edge, an Euler circuit exists exactly when every degree is even and all vertices incident with edges lie in one connected component. A loop contributes two to its vertex's degree.

The route proves the necessity of even degrees. Every arrival has a matching departure. At the starting vertex, the first departure matches the final arrival. Because every edge is used once, all incident edge ends belong to pairs.

Existence needs a separate argument. Starting at a vertex with an edge, keep taking unused edges until none is available. You cannot stop at a different vertex: an arrival there would leave an unused departure because its degree is even. The trail therefore closes at its start.

Remove the used edges. All remaining degrees are even. If unused edges remain, connectedness gives a vertex on the current route with an unused incident edge. Build a closed trail from that vertex using only unused edges, then insert it into the route. Each insertion covers more edges. Finiteness makes the process end with an Euler circuit.

The two endpoints of an open Euler trail

In this topic, an Euler trail uses every graph edge exactly once and may be closed. An open Euler trail has different starting and ending vertices.

Assume the graph is finite and undirected, has at least one edge, and has all its edge-containing vertices in one component. Zero odd-degree vertices gives an Euler circuit. Exactly two gives an open Euler trail. More than two prevents an Euler trail.

At each intermediate visit, an arriving edge pairs with a departing edge. At the start of an open trail, one departure has no matching arrival. At its end, one arrival has no matching departure. The two endpoints are therefore the only odd-degree vertices.

To prove that the conditions suffice, add one temporary edge between the two odd vertices. This is allowed even when an edge already joins them: the proof can use an undirected multigraph with parallel edges. The two odd degrees become even, and every other degree stays even.

The augmented graph has an Euler circuit. Choose its written starting point so that the temporary edge comes last. Delete that edge. The remaining route uses each original edge once, starts at one original odd vertex and ends at the other.

Connectivity is still required. Two separate components that both contain edges cannot be covered by one walk, regardless of their odd-degree counts.

When a degree bound guarantees a Hamilton cycle

Take a simple undirected graph with n >= 3 vertices. A Hamilton cycle visits every vertex once before returning to its start. It can leave other graph edges unused.

Dirac's theorem gives one guarantee: if every vertex has degree at least n/2, the graph has a Hamilton cycle. Ore's theorem gives another: for every pair of distinct nonadjacent vertices u and v, require deg(u) + deg(v) >= n. Meeting that condition also guarantees a Hamilton cycle.

These are sufficient conditions, not necessary ones. Consider the cycle graph on nine vertices. Its ring is already a Hamilton cycle. Every degree is 2, below Dirac's bound 9/2. Nonadjacent vertices have degree sum 4, below Ore's bound 9. The graph fails both conditions and still has the cycle.

There are useful necessary conditions too. Every vertex on a Hamilton cycle needs two distinct incident edges. A degree-0 or degree-1 vertex rules out a Hamilton cycle. Failing this necessary condition proves impossibility; failing a sufficient condition does not.

Euler and Hamilton coverage do not imply one another. The complete graph on four vertices has Hamilton cycles but four odd degrees, so it has no Euler trail. Two triangles sharing just one vertex have an Euler circuit. They have no Hamilton cycle: reaching both triangles and returning would require repeating the shared vertex.

Checking a route and deciding whether one exists

A proposed route gives you a particular object to check. For a Hamilton path, check that it lists every graph vertex exactly once and that each consecutive pair is joined by an edge. For a Hamilton cycle in a simple undirected graph, require at least three vertices. List every graph vertex once, then append the first vertex to close the route. Check every consecutive undirected edge, including the closing edge, is present and none repeats. These checks take polynomial time.

Rejecting one proposed route does not prove that every possible route fails. Deciding existence asks whether any valid route is available.

Euler trail existence has a direct decision test. With adjacency lists, check connectivity among vertices incident with edges and count odd degrees. This takes O(V + E) time, where V counts vertices and E counts edges. Under that connectivity condition, zero odd degrees gives a circuit and exactly two gives an open trail. A larger odd count rules out an Euler trail. Isolated vertices have no edges to cover.

For general simple undirected graphs, Hamilton path existence and Hamilton cycle existence are NP-complete decision problems. No polynomial-time algorithms for these general problems are known. Whether P = NP remains open, so a polynomial-time algorithm has not been proved impossible.

There are exact algorithms. One can enumerate vertex orders and check each order's required edges. That search can grow factorially with the vertex count. Special graph families and sufficient degree conditions allow some instances to be settled quickly without settling every general instance.

2 · Watch

به انگلیسی

Take it off screen

Print a worksheetA4 with an answer key page for grown-ups. No screen, no internet.

Where it sits

Then practise

14 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.

Spotted a problem on this page? Tell us
Euler Trails and Hamilton Cycles · Mathematics, ages 21 to 22 · LightMySky