Eulerian Graphs and Circuits
Can you cross every bridge of a city exactly once and return to where you started? This question was asked of the seven bridges of Königsberg in 1736. It launched graph theory as a subject. Leonhard Euler answered it not by trial and error. Instead, he extracted a simple numerical invariant of the underlying structure. He showed that the answer depends only on the degrees of the vertices. This is one of the earliest examples of a mathematical proof. It shows that a combinatorial search is doomed before it even begins. The idea matters because it exemplifies a recurring theme in discrete mathematics. Local, easily checked conditions can completely determine a global property. Here, the condition is the parity of vertex degrees. The global property is the existence of a circuit traversing every edge exactly once. This property seems hard to verify at first. Unlike its cousin problem — deciding when a graph has a cycle through every vertex — the Eulerian question has a complete answer. That answer is also efficiently checkable. This contrast is itself instructive. It sets up the harder theory of Hamiltonian Graphs. The big picture is this: Eulerian graphs sit at a boundary. That boundary lies between "obviously easy" and "surprisingly deep" problems in graph theory. The characterization theorem is proved by an elegant edge-deletion induction. The same ideas power efficient algorithms for actually constructing an Euler circuit. These include Fleury's algorithm and Hierholzer's algorithm. They apply once you know a circuit exists. These algorithms underlie applications from DNA fragment assembly to street-sweeping route optimization. This article gives the precise definitions of Euler trails and circuits. It states and completely proves the degree-parity characterization. This covers both directed and undirected settings. It works through two non-trivial examples. It shows why every hypothesis in the theorem is load-bearing. It also surveys where Eulerian ideas resurface across mathematics and computer science.
- An Euler circuit is a closed walk using every edge of a graph exactly once; an Euler trail does the same but need not close up.
- A connected graph has an Euler circuit iff every vertex has even degree.
- A connected graph has an Euler trail (not a circuit) iff it has exactly two vertices of odd degree.
- The Königsberg bridge graph has four odd-degree vertices, so no Euler trail exists — this is Euler's original 1736 result.
- The proof is constructive: it produces the circuit by an induction that repeatedly splices in cycles, and this idea becomes Hierholzer's linear-time algorithm.
- Key idea: parity of degree is the exact obstruction to traversing every edge exactly once.
Where this lives today
Algorithms and routing. Hierholzer's algorithm, a direct descendant of the splicing construction in the proof above, finds an Euler circuit in time. It underlies solutions to the Chinese Postman Problem (finding the shortest closed walk covering every edge, relevant to mail delivery, street sweeping, and snow-plow routing), where the degree-parity obstruction tells planners exactly which edges must be duplicated to make a route exist.
Bioinformatics. In DNA sequencing by the de Bruijn graph method, short reads are represented as edges (or vertices, depending on convention) of a large directed graph, and reconstructing the original genome sequence reduces to finding an Euler trail through this graph — a reformulation that replaced the Hamiltonian-path formulation (via overlap graphs) precisely because Eulerian trails are checkable and constructible efficiently, unlike Hamiltonian paths.
Computer science and circuit design. Eulerian circuits appear in the design of universal cycles and de Bruijn sequences (used in cryptographic key-space enumeration and rotor positioning sensors), where a cyclic sequence containing every possible substring of a given length exactly once is built from an Euler circuit of an associated de Bruijn graph.
Topology and combinatorics. The parity argument in the proof — pairing incident edges at each visited vertex — is a prototype for more general "local-to-global" parity arguments seen throughout combinatorics, including arguments about T-joins, matchings, and the structure of Walks, Paths, and Cycles in graph decompositions. The contrast with the NP-complete Hamiltonian Graphs problem is one of the most-cited illustrations in complexity theory of how superficially similar problems can have wildly different computational difficulty.
Puzzle and game design. "Draw this figure without lifting your pen and without retracing a line" puzzles are literally Euler-trail existence questions; the degree criterion gives an instant answer without any trial-and-error tracing.
Ask the tutor: How does the proof's edge-splicing induction turn directly into Hierholzer's linear-time algorithm for constructing an Euler circuit?
Let be a finite graph (loops and multiple edges allowed). A walk is a trail if are pairwise distinct edges (vertices may repeat). A trail is an Euler trail if , i.e. it uses every edge of exactly once. A trail is closed if . An Euler circuit is a closed Euler trail. A graph is Eulerian if it admits an Euler circuit, and semi-Eulerian if it admits an Euler trail (which may or may not be closed). The directed analogue: in a directed graph , a directed trail using every arc exactly once, respecting arc direction, is a directed Euler trail; a closed one is a directed Euler circuit. Throughout, the degree of a vertex (undirected case) counts incident edges with loops counted twice, as in the Handshake Lemma; in the directed case we use in-degree and out-degree .
Intuition
Picture a graph as a network of rooms (vertices) connected by doors (edges), and imagine you must walk through every door exactly once. Each time you pass through a vertex that is not your start or end point, you use up exactly two of its incident edge-slots: one to enter, one to leave. So every visit to an intermediate vertex consumes edges in pairs. If a vertex is to be fully "used up" by a walk that does not start or end there, its degree must be even — otherwise one edge is left dangling with no partner to leave on. This is the entire idea of the theorem, and it is worth internalizing before reading the proof: degree parity records whether a vertex can be passed through completely. A circuit starts and ends at the same vertex, so even that vertex needs an even degree (the final departure pairs with the initial entry). A trail that is not closed has two special vertices — the start and the end — which are each allowed one unpaired edge, hence odd degree; every other vertex must have even degree.
Central theorem
Let be a finite, connected graph with at least one edge (loops and multiple edges permitted, isolated vertices excluded since is connected with edge). 1. has an Euler circuit if and only if every vertex of has even degree. 2. has an Euler trail that is not closed if and only if has exactly two vertices of odd degree; in that case every Euler trail begins at one of these two vertices and ends at the other.
Part 1, forward direction (necessity of even degree). Suppose has an Euler circuit with , using every edge of exactly once. Fix any vertex . Consider all occurrences of in the sequence . If occurs at some interior position with , the circuit enters via edge and leaves via edge ; these are two distinct edges (a trail has distinct edges) both incident to , and they are used up by this single visit. If (the basepoint), the circuit leaves via at the start and enters via at the end; these too are two distinct edges incident to contributed by the "closing up" of the circuit. Every edge of appears exactly once in the list , and each edge incident to is counted in exactly one of these visit-pairs (either as an "enter/leave" pair at an interior visit, or as the "leave-at-start/enter-at-end" pair if is the basepoint). Hence the edges incident to are partitioned into pairs, so their number — namely — is even. (A loop at contributes to by convention and corresponds to one traversal that both enters and leaves , consistent with this pairing.) Since was arbitrary, every vertex has even degree.
Part 1, converse (sufficiency), by strong induction on . Claim: if is connected, has at least one edge, and every vertex has even degree, then has an Euler circuit. Base case. If , connectivity with even degrees forces that single edge to be a loop at some vertex (a non-loop edge would give its two endpoints degree , which is odd). The loop itself, traversed once, is an Euler circuit. Inductive step. Suppose and the claim holds for all connected graphs with fewer than edges in which every vertex has even degree. Let satisfy the hypotheses with . Step A: contains a closed trail. Since is connected with edges, some vertex has degree ; since all degrees are even, in fact every vertex of positive degree has degree . Start at any vertex and build a trail greedily: having arrived at via an unused edge, if some incident edge at is unused, traverse it to ; repeat. Because degrees are all even, we argue this process cannot get stuck except by returning to : suppose the trail reaches a vertex . Each prior visit to (if any) used two of its incident edges (one in, one out); since is even, the number of unused edges at is even after any number of full in/out pairs have been consumed, hence at least one unused edge remains if the count of used edges at has not reached , and in particular right after arriving we have used one more edge (the arriving one) than we have departing, so an even total forces at least one more unused edge to depart on. Thus the walk can always continue from any vertex other than possibly . Since is finite, the process must terminate, and by the argument above it can only terminate by returning to with no more available edges there being unnecessary — indeed it terminates precisely when we return to (a vertex never terminates the walk because an unused incident edge is always available there, as shown). This produces a closed trail based at . Step B: remove and apply induction. Let be the graph on vertex set with edge set (deleting isolated vertices produced, if any, does not affect what follows). For every vertex , the edges of incident to number an even amount (by the same pairing argument as in Part 1's forward direction, applied to the closed trail ), so
is even, being a difference of two even numbers. Thus every vertex of has even degree. may be disconnected; let be its connected components that contain at least one edge (components with no edges are single leftover vertices and are ignored, as they contribute nothing to traverse). Each is connected, has all-even degrees, and since has been removed. By the induction hypothesis, each has an Euler circuit . Step C: splice. Because is connected and together with covers all edges of , each must share at least one vertex with : if some shared no vertex with , then since has at least one edge, there would be no path in from a vertex of to a vertex of that avoids... more directly, connectivity of guarantees a path from (on ) to any vertex of ; the first edge of this path leaving the vertex set of must belong either to (impossible, it would already be in 's vertex set on both ends only if it's a edge) or to some component of — tracing this path shows the path must pass through a vertex lying on both and , since all edges of lie in or in some and a path cannot jump between disjoint vertex sets without an edge connecting them. Hence and share a vertex . Now build the Euler circuit of by walking starting at , and each time we arrive at a vertex that lies on some not-yet-inserted circuit , we detour: traverse all of (starting and ending at , since is a closed trail based there) before continuing along . After all detours are spliced in, every edge of and every edge of every has been traversed exactly once, the walk starts and ends at , and together these account for every edge of . This is an Euler circuit of , completing the induction.
Part 2, forward direction. Suppose has an Euler trail with , using every edge exactly once. For any interior vertex (including possibly or if they recur mid-trail), each occurrence of strictly between the two endpoints pairs up two distinct incident edges exactly as in Part 1. For : it contributes one unpaired "departure" edge at the very start, plus one paired in/out edge for each subsequent visit to (if any); hence is odd (one unpaired edge, plus an even number from repeat visits). Symmetrically is odd. Every other vertex has all its incident-edge occurrences paired as interior visits, so is even. Thus has exactly two odd-degree vertices, namely and .
Part 2, converse. Suppose is connected and has exactly two odd-degree vertices, and . Form by adding one new edge between and (if already, add a parallel edge; this is permitted since may have multiple edges). In , the degrees of and each increase by , becoming even, and all other degrees are unchanged, hence even. Also is connected (adding an edge to a connected graph keeps it connected) and has at least one edge. By Part 1 (already proved), has an Euler circuit . Since is one edge of , we may write starting immediately after traversing edge : that is, visits (or ) consecutively via edge at some point; deleting that single edge occurrence from the circular sequence and "cutting" the circuit open there yields a trail from to (or to ) that uses every edge of except exactly once — that is, every edge of exactly once. This is the desired Euler trail of , and it runs between and . Finally, we already showed (forward direction) that any Euler trail of a graph with exactly two odd vertices must start and end at those two odd vertices, so the endpoints are forced to be in either order.
∎Let be a finite, connected (as an undirected graph, i.e. weakly connected) directed multigraph with at least one arc.
- has a directed Euler circuit iff for every vertex .
- has a directed Euler trail (not closed) iff there are vertices with , , and for every other vertex ; every such trail runs from to .
The proof is the directed analogue of the undirected argument above: at each interior visit to a vertex, one in-arc pairs with one out-arc, so a full traversal of all arcs incident to requires unless is an endpoint of a non-closed trail, contributing the stated imbalance of exactly . The sufficiency direction again proceeds by an edge(arc)-deletion induction identical in structure to Part 1's converse, respecting arc orientation throughout.
Worked examples
Example 1 — a graph with parallel edges and a loop. Let have vertices and edges: two parallel edges between and (call them ), one edge – (), one edge – (), one edge – (), and a loop at (). Degrees: . Wait — recompute carefully. is incident to , so . is incident to , so . is incident to , and the loop contributes , so . is incident to , so . Check the Handshake Lemma: . ✓. Odd-degree vertices: (degree 3) and (degree 3) — exactly two. is connected (all four vertices reachable from each other via the listed edges). By Part 2 of the theorem, has an Euler trail from to (or to ), and no Euler circuit. Explicit trail: . Check: edges used in order — all six, each once — and the trail starts at , ends at , exactly as predicted.
Example 2 — testing and repairing a non-Eulerian graph. Let have vertices with edges: . Degrees: . . . . . Sum of degrees . ✓ (.) Odd-degree vertices: (degree 3 each) and (degree 1) — four odd vertices. Since Part 2 requires exactly two, has neither an Euler circuit nor an Euler trail. This matches the diagnosis Euler gave Königsberg (four odd-degree landmasses), just on a different graph. To repair into an Eulerian graph minimally, we can add edges to pair up odd vertices: adding edge makes and , leaving only odd; adding edge -parallel (a second copy of edge ) then fixes to even as well. The resulting multigraph on with edges has all even degrees and, being connected, has an Euler circuit by Part 1. This "minimum edge additions to make Eulerian" idea is exactly the combinatorial core of the Chinese Postman Problem, which asks for the shortest closed walk covering every edge at least once.
The theorem requires to be connected. Drop this hypothesis and consider consisting of two disjoint triangles, on vertices and on vertices , with no edges between them. Every vertex has degree , which is even — the degree condition of Part 1 is satisfied perfectly. Yet has no Euler circuit: any single closed trail is confined to the connected component in which it starts (a trail cannot jump between components, since there is no edge connecting them), so it can traverse the edges of at most one triangle, never both. Since has edges in both components, no single trail covers all of . This shows the even-degree condition alone is not sufficient; connectivity is doing indispensable work in the theorem, precisely in Step C ("splice") of the proof, where we relied on every component of sharing a vertex with — a fact that used connectivity of the original graph essentially.
Scope, edge cases & common traps
| Situation | Eulerian status | Why |
|---|---|---|
| Connected, all degrees even | Euler circuit exists | Part 1 |
| Connected, exactly two odd-degree vertices | Euler trail (not circuit) exists, between the two odd vertices | Part 2 |
| Connected, four or more odd-degree vertices | Neither exists | Handshake Lemma forces an even number of odd vertices, but more than blocks both |
| Disconnected, even degrees in each nonempty-edge component but such components | Neither a single circuit nor trail exists | See counterexample above |
| Graph with isolated vertices (degree 0) plus one nontrivial connected piece | Still Eulerian in the sense of the nontrivial component; isolated vertices are usually excluded from the statement or ignored | Convention issue, not a mathematical failure |
| Directed graph, in-degree out-degree somewhere by more than | No directed Euler trail | Corollary |
Note that the number of odd-degree vertices in any graph is always even, by the Handshake Lemma (the sum of degrees is , forcing an even number of odd summands). So "exactly one odd vertex," "exactly three odd vertices," etc. can never occur — the only possibilities compatible with connectivity for Eulerian-type traversals are (circuit) or (trail); odd vertices all yield graphs with neither.
The mathematician behind it
Origins · 1 minLeonhard Euler and how this was discovered
Euler was the most prolific mathematician of the eighteenth century, contributing foundational work across analysis, number theory, mechanics, and what would become graph theory. His 1736 paper on the Königsberg bridges — written for the St. Petersburg Academy — is widely regarded as the founding document of graph theory, though the word "graph" would not be coined for another century. Euler recast a recreational geographic puzzle into a question about parity of degree, a level of abstraction typical of his work: strip a problem to its combinatorial skeleton and answer the skeleton once and for all.
Why does the Handshake Lemma guarantee the number of odd-degree vertices is always even?
The Handshake Lemma states that the sum of all vertex degrees equals , an even number. If we split vertices into those of even degree and those of odd degree, the sum over even-degree vertices is automatically even (sum of even numbers). For the total sum to be even, the sum over odd-degree vertices must also be even. But a sum of odd numbers is even only if there is an even count of them (an odd count of odd numbers sums to an odd number). Hence the number of odd-degree vertices is always even — — which is exactly why the Euler trail theorem's "exactly two odd vertices" case is the unique nontrivial possibility beyond the all-even circuit case.
Does Euler's theorem tell us anything about how many distinct Euler circuits a graph has?
No — the theorem is purely an existence statement (via degree parity) and says nothing about counting. Counting Euler circuits is a much harder problem in general. The BEST theorem (named for de Bruijn, van Aardenne-Ehrenfest, Smith, and Tutte) gives a formula for the number of Euler circuits in a connected Eulerian directed graph in terms of the number of arborescences (spanning in-trees) rooted at any fixed vertex, multiplied by a product of factorials of over all vertices. No equally clean closed formula is known for general undirected Eulerian graphs; counting them is computationally hard (#P-complete) in that setting.
How is finding an Euler circuit different in difficulty from finding a Hamiltonian cycle?
Enormously different. Euler's theorem gives an instant, linear-time-checkable certificate for existence (just compute degrees) and an efficient constructive algorithm (Hierholzer's, running in time). By contrast, deciding whether a graph has a Hamiltonian cycle — a cycle visiting every vertex exactly once — is NP-complete: no efficient general characterization or algorithm is known, and none is expected to exist unless P = NP. The superficial similarity of the two questions (visit every edge vs. every vertex exactly once) masks a total asymmetry in tractability, which is one of the most memorable lessons Eulerian graph theory teaches about computational complexity.
Can a graph with loops or multiple edges still be Eulerian, and does the theorem change?
Yes, and no change is needed. The theorem as stated already allows loops (each loop contributes to the degree of its vertex, by the standard convention used with the Handshake Lemma) and multiple edges (parallel edges between the same pair of vertices, each counted separately in degree and each usable once in a trail). The proof's edge-pairing argument works identically: a loop traversed at vertex uses up two of the "slots" at (entering and leaving via the same physical edge, conceptually), consistent with its degree-2 contribution. Example 1 above explicitly uses both a loop and a parallel edge pair.
What is Fleury's algorithm, and is it the same as the proof's construction?
Fleury's algorithm is a different (older, less efficient) method for constructing an Euler circuit once existence is known: at each step, traverse an available edge that is not a "bridge" (cut-edge) of the remaining unused-edge subgraph, unless no other choice exists. This greedy bridge-avoidance rule prevents disconnecting the untraversed part of the graph prematurely. It is correct but requires repeatedly testing whether edges are bridges, costing time overall in a naive implementation. The proof given here instead uses the "find a closed trail, then splice in circuits from remaining components" idea, which is the basis of Hierholzer's algorithm and runs in linear time — asymptotically faster than Fleury's method.
Is there a version of Euler's theorem for graphs where you're allowed to repeat edges?
If repeating edges is allowed, the question changes entirely and becomes the Chinese Postman Problem (also called the Route Inspection Problem): find the shortest closed walk that covers every edge at least once, possibly retracing some edges. Euler's theorem tells you exactly which graphs need no repeats at all (the Eulerian ones); for non-Eulerian connected graphs, the Chinese Postman solution works by finding a minimum-weight way to duplicate edges so as to make all degrees even (pairing up odd-degree vertices via shortest paths, a problem solved using minimum-weight perfect matching), after which Euler's theorem guarantees the augmented multigraph has a circuit covering everything.
Why is connectivity assumed rather than derived from the degree condition?
Because it genuinely cannot be derived: the degree condition (all degrees even, or exactly two odd) is a purely local, vertex-by-vertex property, while connectivity is a global property about reachability between vertices. The counterexample of two disjoint triangles shows a graph satisfying the degree condition perfectly while being disconnected and having no Euler circuit. Connectivity must therefore be checked and assumed separately; it is not implied by degree data alone, and the theorem's proof (specifically the "splice" step) genuinely uses it to guarantee that the deleted-circuit's leftover components can be sewn back into a single traversal.