Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Eulerian vs. Hamiltonian -- every edge once, or every vertex once?

The two questions sound alike and behave completely differently -- one is a clean if-and-only-if, the other only has one-way tests.

"Use every EDGE exactly once" is Eulerian, and it's fully decidable by degree parity alone -- no search required. "Visit every VERTEX exactly once" is Hamiltonian, and there's no known if-and-only-if test at all -- only sufficient conditions (Dirac's, Ore's) that can confirm existence but never rule it out.

Every edge once (Eulerian) -- decidable by degree

A graph that has a closed walk using every edge exactly once.

A connected graph G (with at least one edge) has an Euler circuit — a closed walk that uses every edge exactly once — if and only if every vertex of G has even degree.

More generally, a connected graph G has an Euler trail (an open walk using every edge exactly once, not necessarily closed) if and only if G has exactly zero or exactly two vertices of odd degree — an Euler circuit in the zero case, and an Euler trail between the two odd-degree vertices in the two-vertex case.

Show proof

Necessity. Suppose G has an Euler circuit C. Every time C passes through a vertex v (other than at the very start/end, which is the same vertex for a circuit), it uses one edge to arrive at v and a different edge to leave v, since C never repeats an edge. So every visit to v accounts for exactly 2 of the edges at v, and since C uses every edge of G exactly once, \deg(v) must be even for every vertex v.

Sufficiency. Suppose G is connected and every vertex has even degree. Build a circuit by the following argument. Start at any vertex v_0 and follow edges, never reusing one, until stuck. Because every vertex has even degree, arriving at any vertex other than v_0 always leaves an unused edge to leave by (each visit uses up an "in" and an "out" edge in pairs, and the degree is even, so the walk cannot get stuck anywhere except back at v_0). So this walk is forced to return to v_0, forming a closed circuit C_1 using no edge twice.

If C_1 already uses every edge of G, it is the desired Euler circuit. Otherwise, since G is connected, some vertex w on C_1 has an unused edge incident to it. Remove the edges of C_1 from G; every vertex still has even degree in what remains (each vertex's degree dropped by an even amount — 0 or 2 — as C_1 passed through it). Repeat the same construction starting at w in the remaining graph to get a second closed circuit C_2 through w using only unused edges, then splice C_2 into C_1 at w (traverse C_1 up to w, detour around all of C_2, then finish C_1) to get a longer closed walk using no edge twice. Repeating this splicing process — always possible while unused edges remain, by connectivity — eventually uses every edge, producing an Euler circuit.

The trail case. If G has exactly two odd-degree vertices u and v, add a new edge \{u,v\} to form G^+ (a multigraph is fine here); every vertex of G^+ now has even degree, so G^+ has an Euler circuit by the case just proved. Deleting the added edge \{u,v\} from that circuit leaves an Euler trail of G from u to v. Conversely, an Euler trail from u to v in G forces \deg(u) and \deg(v) to be odd (the trail uses one unmatched edge at each endpoint) and every other vertex's degree to be even (same pairing argument as in necessity above), so exactly two vertices have odd degree.

Every vertex once (Hamiltonian) -- sufficient conditions only

A graph that has a cycle visiting every vertex exactly once.
Two sufficient (not necessary) degree conditions that guarantee a graph is Hamiltonian: Dirac's checks every vertex's own degree, Ore's checks the degree sum of every non-adjacent pair.

Let G be a simple graph on n \ge 3 vertices. If every vertex of G has degree at least n/2, that is \deg(v) \ge \frac{n}{2} \quad \text{for every vertex } v, then G has a Hamiltonian cycle.

Show proof

Dirac's theorem is the special case of Ore's theorem (ores-theorem) where every single vertex, not just every non-adjacent pair, already meets half the degree bound: if \deg(v) \ge n/2 for every vertex v, then for any two vertices u,v (adjacent or not), \deg(u) + \deg(v) \ge \frac{n}{2} + \frac{n}{2} = n, so Ore's degree-sum condition holds for every non-adjacent pair in particular, and Ore's theorem gives a Hamiltonian cycle.

The self-contained argument (not leaning on Ore's theorem) runs identically to Ore's proof: assume for contradiction a maximal non-Hamiltonian graph G^+ \supseteq G on n vertices where every vertex still has degree \ge n/2 (adding edges only increases degrees), take a Hamiltonian path v_1 \cdots v_n guaranteed to exist between two non-adjacent vertices v_1, v_n of G^+, and note |A| + |B| = \deg(v_1) + \deg(v_n) \ge \frac{n}{2} + \frac{n}{2} = n > n - 1 for the index sets A = \{i : v_1 \sim v_i\} and B = \{i : v_n \sim v_{i-1}\}, both subsets of \{2,\dots,n\}. The pigeonhole overlap between A and B produces the same rotation — v_1 \cdots v_{i-1}\, v_n\, v_{n-1} \cdots v_i\, v_1 — that closes a Hamiltonian cycle, contradicting G^+'s assumed non-Hamiltonicity.

Let G be a simple graph on n \ge 3 vertices such that \deg(u) + \deg(v) \ge n \quad \text{for every pair of non-adjacent vertices } u, v. Then G has a Hamiltonian cycle.

Show proof

Suppose, for contradiction, that G satisfies the degree-sum condition but has no Hamiltonian cycle. Add edges to G one at a time — each new edge joining two non-adjacent vertices, which keeps the degree-sum condition true (degrees only go up) — for as long as the graph stays non-Hamiltonian, until no more edges can be added without creating a Hamiltonian cycle. Call the result G^+: a maximal non-Hamiltonian graph on n vertices still satisfying the degree-sum condition, where adding any missing edge creates a Hamiltonian cycle.

G^+ is not complete (a complete graph on n\ge3 vertices is trivially Hamiltonian), so pick two non-adjacent vertices u,v of G^+. Because G^+ is connected (the degree-sum condition with n\ge3 forces every vertex to have degree \ge 1, and a short argument rules out disconnected components under this bound) and not Hamiltonian, but adding edge \{u,v\} would create a Hamiltonian cycle, G^+ must already contain a Hamiltonian path v_1 v_2 \cdots v_n with v_1 = u and v_n = v (the only way adding one edge closes a Hamiltonian cycle is if a Hamiltonian path already runs between its two endpoints).

Consider the index sets A = \{\, i : v_i \text{ is adjacent to } v_1 \,\}, \qquad B = \{\, i : v_{i-1} \text{ is adjacent to } v_n \,\}. Both A and B are subsets of \{2, \dots, n\} (neither counts v_1 itself), so |A| = \deg(v_1) and |B| = \deg(v_n), and |A| + |B| = \deg(v_1) + \deg(v_n) \ge n by the degree-sum condition applied to the non-adjacent pair v_1, v_n. Since A, B \subseteq \{2,\dots,n\}, a set of size n-1, and |A|+|B| \ge n > n-1, the sets A and B must overlap: some index i lies in both.

That means v_1 is adjacent to v_i, and v_{i-1} is adjacent to v_n. But then v_1 \; v_2 \; \cdots \; v_{i-1} \; v_n \; v_{n-1} \; \cdots \; v_i \; v_1 is a Hamiltonian cycle of G^+: it follows the path from v_1 to v_{i-1}, jumps to v_n (valid, since v_{i-1} \sim v_n), follows the path backwards from v_n down to v_i, and closes back to v_1 (valid, since v_i \sim v_1) — using every vertex exactly once. This contradicts G^+ being non-Hamiltonian.

So no such maximal non-Hamiltonian G^+ can exist, and every graph satisfying the degree-sum condition is Hamiltonian.

Dirac's theorem as a corollary. If every vertex of G has \deg(v) \ge n/2, then for any two vertices u,v — adjacent or not — \deg(u) + \deg(v) \ge n/2 + n/2 = n, so Ore's condition holds in particular for every non-adjacent pair, and Dirac's theorem follows immediately from Ore's.

Side by side

Graph settings

Calculator