This site is only a doorway

Everything here is gathered from things other people actually researched, thought through, and built: books, papers, historical records, and the people behind them. If something here catches your interest, go look at the original sources listed at the bottom of the page. They carry more depth than a page like this ever can.

Can You Walk Every Road Between Four Towns Exactly Once?

Category: Technology

Picture four towns with a straight road between every pair of them. That takes six roads. Now try to walk along every road exactly once, without repeating any. You cannot, and you do not have to try every route to know it. You only have to count how many roads meet at each town. In Japan this kind of puzzle is called hitofude-gaki, "drawing in one brush stroke"; in English it is usually "tracing a shape without lifting your pencil." This article gives the answer, explains why the counting works, and shows how the mathematician Leonhard Euler used the same idea on a famous puzzle about seven bridges.

1. How many roads does it take to join four towns?

Call the towns A, B, C and D. Each town needs a road to the other three, so counting from each town gives 3 + 3 + 3 + 3 = 12. But the road from A to B is the same road as the one from B to A, so every road was counted twice. Divide by two and you get 6 roads.

The same reasoning works for any number of towns. If every pair of n towns is joined, each has n − 1 roads, and the total is n × (n − 1) ÷ 2. Five towns need 10 roads and six towns need 15. Mathematicians call a picture where every pair of points is joined a complete graph, and the four-town picture is written K4.

Four towns joined by six roads Four points labeled A, B, C and D. Six straight lines join every pair of points. Three lines meet at each point. The two diagonal lines cross in the middle, but the crossing is not a town. ABCD
Four towns, six roads. The two diagonals cross in the middle, but the crossing is only where roads pass, not a town.

2. Why can't you walk all six roads without repeating one?

Try it with a pencil. However you try, you cannot cover all six roads without repeating one. The answer is that it is impossible, and the reason is hidden in the counts. Look at how many roads meet at each town. In this picture it is 3 at every one of them. Three roads cannot be split into pairs: one is always left over.

The rule that decides these puzzles is this. You can walk every road exactly once only if the roads are all connected in one piece and the number of towns with an odd number of roads is 0 or 2 [1]. Our four towns are all odd, so the count of odd towns is 4. That is neither 0 nor 2, so no route exists. This answers the question in the title; the rest of the article explains why the rule is true and where it came from.

Note that the rule has nothing to do with how long the roads are or how they bend. Only the pattern of which town connects to which matters. That is the big idea behind this whole topic.

3. Why do towns with an odd number of roads cause the trouble?

Imagine you are walking and pass through a town in the middle of your trip. You arrive by one road and leave by another, so each pass through uses up two roads of that town. If you use every road exactly once, the roads of a pass-through town must pair up neatly, so the number of roads there has to be even.

Only two towns can be different. At the town where you start, your first step uses one road with nothing to pair it with, so that town can have an odd number. At the town where you stop, your last arrival works the same way. Everything else must be even. If you start and stop in the same town, then every town is even, and you end up back where you began.

That explains "0 or 2." One more fact comes from simple counting. Add up the roads at all the towns and every road gets counted twice, once at each end, so the total is always even. That means the number of odd towns can never be 1 or 3. It is always 0, 2, 4 and so on, and a picture with exactly one odd town cannot be drawn at all.

All of this shows that having at most two odd towns is necessary. Is it also enough? Euler stated that it is, but he did not give a full proof. According to the Wikipedia article on Eulerian paths, the first complete proof was published in 1873 by Carl Hierholzer, after Hierholzer's death [1]. I could not check that date against a second source, so treat it as reported rather than settled.

4. How did Euler use this idea on the bridges of Königsberg?

Königsberg was a city in Prussia, on the Pregel river. Today it is the Russian city of Kaliningrad. The river divided the city into four pieces of land: two banks and two islands. Seven bridges linked them. A puzzle asked whether a walker could cross each bridge exactly once [2].

Euler's step was to throw away everything except the connections. He pictured each piece of land as a point and each bridge as a line between two points. The shape of the land, the length of the bridges and the route taken on each island do not matter [2]. His paper on this, "Solutio problematis ad geometriam situs pertinentis" ("The solution of a problem relating to the geometry of position"), was written in 1735 and published in 1741. The Euler Archive's record describes it as often cited as the earliest paper in both topology and graph theory [3].

The seven bridges drawn as points and lines Four points labeled A, B, C and D. Point C is joined to A by two lines, to B by two lines and to D by one line. Points A and D are joined by one line, and B and D by one line. Five lines meet at C and three lines at each of the other points. CABD
The seven bridges as a simple diagram (not a map). Five bridges meet at the island C, and three meet at each of the other pieces of land.

Now count. One piece of land has 5 bridges and the other three have 3 each. All four are odd, so there are 4 odd points, not 0 or 2. Euler's conclusion was that no such walk exists [3]. It is the same situation as our four towns: a map that looks nothing like the road picture turns into a problem with the same answer. The Euler Archive's record describes his paper as reducing the problem to an analysis of the degrees of the vertices on a graph [3]. In graph language, a point is a vertex, a line is an edge, and the number of lines meeting at a point is its degree.

5. What changes if you remove a road, or add a fifth town?

Go back to the four towns and remove just the road between A and B. Now A and B have two roads each, and C and D still have three. Only two odd towns remain, so a route should exist. Here is one: start at C and go C → A → D → B → C → D. That uses all five roads exactly once and ends at D.

Now add a fifth town and join every pair. There are 10 roads, and each town has 4, which is even. So there should be a walk that returns to its start. Number the towns 1 to 5 and go 1 → 2 → 3 → 4 → 5 → 1 → 3 → 5 → 2 → 4 → 1. You use all 10 roads once and finish where you began.

So more towns do not simply make the puzzle harder. With n towns all joined to each other, every town has n − 1 roads. For 3, 5 or 7 towns, that is even, and the walk works. For 4, 6 or 8 towns, it is odd at every town, and the walk fails. Two towns with one road between them is a small special case that works, since it has exactly two odd towns.

Königsberg itself changed too. MathWorld notes that two of the original bridges no longer exist and two others have been merged into one. In the modern layout there is still no walk that crosses every bridge and returns to the start, but there is one that crosses them all if it may end in a different place [4]. The rule gave a yes or no for the old city, and it still gives the right answer for the new one.

6. How can you test the rule yourself?

Draw some shapes on paper: a star, a square with both diagonals, a house outline with a cross inside. For each, mark the points where lines meet, write the number of lines at each, and count the odd ones. Make a prediction first. Then try to trace it without lifting your pencil and see whether you were right. If it works, notice where you started and finished. With two odd points, you must start at one of them.

For a bigger challenge, make a table for complete graphs with 2, 3, 4, 5, 6 and 7 towns. List the number of roads, the number of roads at each town, and whether a walk exists. See if you can spot the pattern before reading the explanation in section 5 again.

To go further, the Euler Archive page lists Euler's original paper in Latin, and the Wikipedia article on the bridges has an account of how his argument works. Reading how someone first solved a problem often shows steps that textbooks leave out.

Sources

  1. Wikipedia, "Eulerian path" https://en.wikipedia.org/wiki/Eulerian_path (Read the opening section only, in truncated form. Source for the 0-or-2 odd-degree condition, Euler stating without proof that the condition is sufficient, and Hierholzer's 1873 posthumous proof. The Hierholzer date rests on Wikipedia alone, which is why the article says it is "reported.")
  2. Wikipedia, "Seven Bridges of Königsberg" https://en.wikipedia.org/wiki/Seven_Bridges_of_K%C3%B6nigsberg (Read the opening and the sections on the problem and Euler's analysis; the page was truncated by the reader, so later sections were not read. Source for the city, the four pieces of land, the seven bridges and the idea of ignoring everything but the connections. Wikipedia dates Euler's proof to 1736, while the Euler Archive gives 1735 as the writing date; this article follows the Euler Archive. Wikipedia is a general reference, not a primary source.)
  3. The Euler Archive (University of the Pacific), record for E53, "Solutio problematis ad geometriam situs pertinentis" https://scholarlycommons.pacific.edu/euler-works/53/ (Read in full, but it is a catalogue record with a content summary, not the paper itself. Source for the title, the 1735 writing date, the 1741 publication in Commentarii academiae scientiarum Petropolitanae, and the description of the paper as an early work in topology and graph theory. The PDF of the paper itself did not load, so the details of Euler's own argument are not taken from it.)
  4. Wolfram MathWorld, "Königsberg Bridge Problem" https://mathworld.wolfram.com/KoenigsbergBridgeProblem.html (Read in full, a short entry. Source for the answer "no," the beginning of graph theory, and the present-day bridges where two no longer exist and two have merged. The entry cites J. Kåhre for the modern layout; I did not check that reference. The counting arguments in sections 3 and 5 are ordinary arithmetic worked out here, not quoted from any source.)