Euler Path Generator
Can you trace the whole graph without lifting your pen or repeating an edge? Euler answered it in 1736 with the Königsberg bridges, and the answer is entirely about odd degrees: every time a trail passes through a node it uses two edges, so a node with an odd number of edges can only be a start or an end. Zero odd nodes gives a closed circuit, two gives an open trail, and more gives nothing at all.
What this generator does
Counts odd-degree nodes to decide which of the three cases the graph is in, then constructs the trail with Hierholzer's algorithm where one exists: walk until stuck, then splice in side-trips from nodes that still have unused edges.
How to use this tool
- Choose the graph size and density.
- Count how many nodes have an odd number of edges.
- Predict whether a circuit, a trail, or neither is possible.
- Compare with the trail shown, and trace it edge by edge.
Understanding the controls
- How many nodes
- Between 4 and 12. Density matters more than size for whether a trail exists.
- Extra edge density (%)
- Changes the degree parities and therefore the answer. Very dense graphs on an even number of nodes often have no trail at all.
- Seed
- Reproduces the same graph, which matters because whether a trail exists changes from graph to graph.
Common use cases
- Teaching the Königsberg bridges result with fresh examples
- Showing that a whole class of problems reduces to counting odd degrees
- Practice at tracing a trail without repeating an edge
- Test instances for a route-inspection implementation
- Setting the same graph from a seed
How this generator works
Hierholzer keeps a stack, walks along unused edges until none remain at the current node, and pops finished nodes onto the trail. The check confirms the odd-degree count matches the verdict, and where a trail is claimed, that it has exactly one more node than the graph has edges and uses no edge twice.
Randomness and fairness
The graph is random; whether a trail exists follows from its degrees and is verified. Seeded graphs reproduce exactly and are therefore explicitly not cryptographically secure. Without a seed the browser's cryptographically secure generator supplies the graph.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Only connected graphs are generated, since a disconnected graph trivially has no Euler trail.
- Hamiltonian paths — every node once rather than every edge once — are a different and much harder problem, and are not offered.
- The trail shown is one of possibly many; no attempt is made to find a canonical one.
- Edge weights are generated but ignored by the algorithm.
- Graphs are not stored between visits; seed one you want to reuse.
Privacy and your data
The graph and any trail are computed in your browser. Nothing is transmitted or retained between visits.
Related generators
- Graph Traversal GeneratorThe same graph visited breadth-first and depth-first side by side, with the hop count each node sits at.
- Hamiltonian Path Challenge GeneratorGraphs where the puzzle is to visit every node exactly once, with every such path counted by exhaustive search.
- Random Graph GeneratorRandom graphs at a density you choose, drawn and exported as an edge list or DOT, with connectivity measured rather than assumed.
- Maze GeneratorPrint a maze with exactly one route from start to finish — three textures from long corridors to short dead ends, any size up to 40 by 40.
- Minimum Spanning Tree GeneratorWeighted graphs with the cheapest spanning tree found by Kruskal and, at small sizes, confirmed against every other spanning tree.