19Maths

The seven bridges of Königsberg

A river town with seven bridges and one puzzle: can you walk over every bridge exactly once? Try it, count the bridges, change the town, and see how Euler solved it in 1736.

By the river Pregel

A walk over every bridge

In the 1700s the town of Königsberg had a river with two islands in it and seven bridges. People liked to ask a puzzle: can you take a walk that crosses every bridge exactly once? Nobody could find one. In 1736 the mathematician Leonhard Euler showed why, and in doing so he started a new kind of maths about dots and lines.

The map below is a simple drawing of the town, with four pieces of land called A, B, C and D. Each panel lets you try something. Without a script, each panel shows the map and its numbers.

Try one

Try the walk

Press a piece of land to start there. Then press a bridge next to you to cross it. A bridge can only be crossed once, so the ones you have used are marked. Can you cross all seven?

You can try as often as you like. Nobody can do it, and the next panels show why.

1234567ABCD

Press a piece of land to start there. Then press a bridge next to you to cross it.

There are seven bridges. Land A has 3 bridges, B has 3, C has 5 and D has 3. No walk crosses every bridge exactly once.

Try two

Count the bridges

Euler noticed that only one thing matters about each piece of land: how many bridges touch it. Press a piece of land to count its bridges. Here the counts are 3, 3, 5 and 3, and all four are odd.

Every bridge has two ends, so if you add up the counts you get twice the number of bridges: 3 + 3 + 5 + 3 = 14, and 14 is 2 × 7. That means the number of odd counts is always even.

1234567A3B3C5D3
Bridges at each piece of land
LandBridgesOdd or even
A, the north bank3odd
B, the south bank3odd
C, the island in the middle5odd
D, the east island3odd

The counts are 3, 3, 5 and 3. Their sum is 14, which is twice the 7 bridges, because every bridge has two ends.

Try three

Change the town

Here you can build and take away bridges. Press a bridge to remove it, or press a faint one to build it. The panel says whether a walk over every bridge is possible, and why.

The rule Euler found: a walk over every bridge once exists if the bridges are all joined up and the number of lands with an odd count is 0 or 2. With 2, the walk has to start at one of them and end at the other. With 0 it can start anywhere and end where it began.

1234567891011A3B3C5D3

The old town has 4 lands with an odd number of bridges, so there is no walk over every bridge.

Try four

Find a walk

Choose where to start and the page works out a walk over every bridge in your town, if there is one. It uses the town from the last panel.

When the town has two odd lands, only those two work as a start. Choose any other and the page tells you there is no walk from there.

1234567891011ABCD

Choose a piece of land to start from. The town is the one you built in the last panel.

Key takeaways

  1. Euler solved the puzzle in 1736 by throwing away the map and keeping only the lands and which bridges join them.
  2. What matters about a land is how many bridges touch it. Königsberg had four lands with 3, 3, 5 and 3 bridges.
  3. The counts add up to twice the number of bridges, so the number of odd counts is always even.
  4. A walk over every bridge exactly once is possible if the bridges are joined up and 0 or 2 lands have an odd count.
  5. Königsberg had 4 odd lands, so the walk was impossible. Dots and lines like these are called graphs.

Sources

Most of these sites could not be opened while this page was written, so the facts were checked through search results that quote them. Euler’s 1736 proof, the seven bridges and four lands with 3, 3, 3 and 5 bridges, the rule that a walk needs 0 or 2 odd lands, and the fact that the counts add up to twice the number of edges each appeared in at least two places. Hierholzer is credited with proving that the rule is enough. Sources disagree about which bridges Kaliningrad has today, so the page does not say. The map is a simple drawing made for this page and is not to scale.