Ma · Mathematics

Can You Draw This Figure Without Lifting the Pen? (Euler Paths)

Published By the 9to5Science editorial team

At a glance

  1. 1. Mark the vertices

    Treat every corner, end and junction of the figure as a vertex.

  2. 2. Count each degree

    Count how many line-ends meet at each vertex.

  3. 3. Count the odd vertices

    Zero odd vertices: start anywhere. Exactly two: start at one of them. More: impossible.

  4. 4. Trace the path

    Use Fleury's rule: never cross a bridge to the unused part unless you must.

“Draw this without lifting your pen and without going over any line twice” is a classic puzzle. It has a complete answer, found by Leonhard Euler in 1736, and you can check any figure in under a minute.

Turn the figure into a graph

  • Every point where lines meet or end is a vertex.
  • Every line segment between two vertices is an edge.
  • The degree of a vertex is the number of edge-ends that meet there.

Drawing the figure in one stroke means finding an Euler path: a route that uses every edge exactly once. If the route also ends where it started, it is an Euler circuit.

The rule

For a connected figure, count the vertices with odd degree:

Odd-degree verticesOne-stroke drawing?
0Yes, and you can start anywhere. You will finish where you started.
2Yes, but you must start at one odd vertex and finish at the other.
4, 6, 8, …No. You need at least (number of odd vertices) / 2 strokes.

The number of odd vertices is always even, because every edge adds 2 to the total of all degrees.

Why it works

Every time your pen passes through a vertex, it arrives along one edge and leaves along another, using up two edge-ends. So every vertex you pass through must have even degree. Only the starting and finishing points can be odd: you leave the start once without arriving, and you arrive at the end once without leaving. If the start and end are the same point, even those two are balanced, so every degree must be even.

The other direction also holds: in any connected graph with 0 or 2 odd vertices, an Euler path exists. Hierholzer’s algorithm, below, actually constructs one.

Worked example: the “house” figure

The well-known house is a square with both diagonals and a triangular roof on top. Label the bottom corners AA (left) and BB (right), the top corners CC (left) and DD (right), and the roof peak EE.

Edges: AB,AC,BD,CDAB, AC, BD, CD (the square), AD,BCAD, BC (the diagonals), CE,DECE, DE (the roof), so 8 edges in total.

VertexEdgesDegree
AAAB,AC,ADAB, AC, AD3 (odd)
BBAB,BD,BCAB, BD, BC3 (odd)
CCAC,CD,BC,CEAC, CD, BC, CE4
DDBD,CD,AD,DEBD, CD, AD, DE4
EECE,DECE, DE2

There are exactly two odd vertices, AA and BB, so the house can be drawn in one stroke, but only from one bottom corner to the other. One route is:

A→C→E→D→C→B→D→A→BA \to C \to E \to D \to C \to B \to D \to A \to B

It uses all 8 edges once each. If you start at CC, DD or EE, you will always get stuck.

Counterexample: the bridges of Königsberg

Euler’s original problem asked whether you could walk across all seven bridges of Königsberg exactly once. As a graph, the four land masses have degrees 5,3,3,35, 3, 3, 3. That is four odd vertices, so no such walk exists, and at least two separate “strokes” would be needed.

How to actually find the path

Knowing that a path exists is not the same as finding one. Two standard methods:

  • Fleury’s algorithm (good by hand): start at an odd vertex if there is one. At each step, take any unused edge, but don’t take a bridge (an edge whose removal would cut the unused part of the figure in two) unless it is your only option.
  • Hierholzer’s algorithm (good for programs, linear time): walk until you get stuck, which will be at your starting point. Then, from any vertex on your loop that still has unused edges, walk another loop and splice it in. Repeat until every edge is used.

Common mistakes

  • Counting crossings as vertices when they aren’t. If two lines simply cross (as in a drawn X), you may treat the crossing as a vertex of degree 4. That doesn’t change the answer, because it adds an even degree.
  • Forgetting connectivity. Two separate shapes can never be drawn in one stroke, even if every degree is even.
  • Starting at an even vertex when there are two odd ones. The figure is drawable, but not from there.

References

  1. Euler, L. (1736). Solutio problematis ad geometriam situs pertinentis (the Königsberg bridges paper).
  2. West, D. B. (2001). Introduction to Graph Theory (2nd ed.), Section 1.2. Prentice Hall.

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.