Euler Path and Circuit Finder for Graphs

Enter an undirected or directed graph to find a trail that uses every edge exactly once. The finder checks connectivity and degree conditions, constructs the full Euler path or circuit, and explains any failure—all locally in your browser.

Enter a graph

Directions matter only in directed mode.

Separate labels with commas, semicolons, or lines. Include isolated vertices here.4 listed
Use A,B. Repeated lines are separate parallel edges.6 lines

Private by design: graph data is processed on this device. It is not uploaded, saved, or added to the page URL.

Euler result

The sample graph is analyzed below.

Advertisement

Euler path and circuit conditions

An Euler trail uses every edge exactly once. A closed Euler trail is an Euler circuit; an open Euler trail is commonly called an Euler path. Vertices may be visited more than once. That is the key difference from a Hamiltonian path, which concerns visiting vertices.

Undirected circuit

odd-degree vertices = 0

Every non-isolated vertex must also belong to one connected component.

Undirected open path

odd-degree vertices = 2

The two odd vertices are forced to be the path's start and end.

Directed trail

out(v) − in(v) ∈ {−1, 0, 1}

A circuit is balanced everywhere; an open path has one +1 start and one −1 end.

For directed graphs, vertices incident to edges must be connected after edge directions are ignored. Combined with the displayed indegree/outdegree conditions, this is sufficient for the tool's directed Euler test.

How Hierholzer's algorithm works

1. Choose the start

Use an odd-degree endpoint or +1 imbalance when an open path exists. Otherwise begin at any vertex incident to an edge.

2. Follow unused edges

Move along unused edges, marking each edge by its unique input-line ID. Parallel edges therefore remain distinct.

3. Backtrack when stuck

When the current vertex has no unused edge, add it to the completed route and return to the previous vertex.

4. Reverse the route

Backtracking builds the answer in reverse. Reversing it produces a trail containing exactly |E| + 1 vertex visits.

The algorithm runs in O(|V| + |E|) time with adjacency lists. The finder keeps every edge line as a separately identifiable edge, including repeated endpoint pairs and self-loops.

Euler circuit example

The sample undirected graph has edges A–B, B–C, C–D, D–A, A–C, C–A. The final two lines are parallel edges between A and C. Degrees are deg(A)=4, deg(B)=2, deg(C)=4, and deg(D)=2.

All degrees are even and every vertex with an edge is connected, so an Euler circuit exists. One valid answer is A → B → C → D → A → C → A. The repeated A–C pair appears twice because those two input lines represent two different edges.

  • Deleting one A–C edge makes A and C odd, producing an open Euler path between them.
  • Deleting both A–C edges leaves the four-cycle, which still has an Euler circuit.
  • Adding a separate edge X–Y makes the edge-bearing graph disconnected, so no single Euler trail can cover it.

Input rules, assumptions, and limits

Vertex labels are case-sensitive text. The optional vertex field accepts commas, semicolons, or line breaks. Edge endpoints are detected automatically, but isolated vertices must be listed explicitly. Labels may contain spaces but cannot contain commas, semicolons, arrows, or line breaks.

For an undirected graph, enter each edge as A,B. For a directed graph, use A -> B, A → B, or A,B; the first endpoint is the start and the second is the end. Every nonempty line is an edge, so repeated lines are retained as parallel edges. Self-loops are valid. An undirected self-loop contributes two to degree; a directed self-loop contributes one to both indegree and outdegree.

Isolated vertices do not affect whether the edges have an Euler trail. If the graph has no edges, the tool reports a trivial zero-edge circuit at the first listed vertex. The constructed route is deterministic and follows vertex and edge input order, but a graph may have many other valid Euler trails.

The finder accepts up to 500 vertices, 20,000 nonempty edge lines, 20,000 edges, and labels up to 80 characters. The on-page traversal table is capped at 2,000 steps to protect rendering performance; copy and CSV export retain the full calculated trail.

Terminology follows the U.S. National Institute of Standards and Technology's Euler cycle, path, and graph entries. The construction uses Hierholzer's edge-splicing method in an iterative backtracking form.

Calculation note: undirected and directed circuits, open paths, disconnected graphs, isolated vertices, parallel edges, self-loops, degree failures, empty inputs, and export fields checked by the Starlight Tools editorial team. Last reviewed: .

Euler path and circuit finder FAQ

What is the difference between an Euler path and an Euler circuit?

Both traverse every edge exactly once. An Euler circuit returns to its starting vertex. An open Euler path starts and ends at different vertices. Vertices can appear more than once in either trail.

When does an undirected graph have an Euler path?

Ignoring isolated vertices, all vertices with edges must be connected. Zero odd-degree vertices gives a circuit; exactly two odd-degree vertices gives an open path; any other number gives neither.

When does a directed graph have an Euler path?

The edge-bearing vertices must be connected when directions are ignored. A circuit requires equal indegree and outdegree at each vertex. An open path requires one vertex with one extra outgoing edge, one with one extra incoming edge, and balance everywhere else.

Are repeated edges and self-loops allowed?

Yes. Each line is a separate edge, so repeated lines are parallel edges rather than duplicates to remove. Self-loops are kept and can be part of a valid Euler trail.

Does an isolated vertex prevent an Euler circuit?

No. An Euler trail covers edges, so connectivity is tested only among vertices incident to an edge. Isolated vertices are included in the degree table but do not break an otherwise valid trail.

Why might my valid graph produce a different trail from another solver?

Euler trails are often not unique. This finder chooses the first available edge in input order. A different valid edge choice can produce a different trail with the same classification.

Does this tool upload my graph?

No. The graph is parsed and analyzed in your browser. Copying and CSV creation also happen locally, and this tool does not save entered vertices or edges.

Explore more tools