Seven bridges and a Sunday walk
About three hundred years ago, the city of Königsberg sat on both banks of a river. In the middle of the river was an island, and the river split in two around a piece of land to the east. Seven bridges joined the four pieces of land.
People liked to stroll around the city on Sundays, and a puzzle went round: can you go for a walk that crosses every bridge exactly once? You may start and finish anywhere, but you must not cross any bridge twice. Many people tried. Nobody managed it — but nobody could explain why not, either.
Here is a puzzle you can try with a pencil right now. Draw this "house" — a square with both diagonals and a roof — without lifting your pencil and without going over any line twice.
Try it: trace the figures
In each explorer below, click the lines one after another to walk along them. The explorer tells you when you have used every line exactly once. Keep a little table: figure, can I trace it?, where did I start?
First, the house. Try starting at the roof top E, and then at the bottom corner A.
The house
Dots joined by lines: count degrees, walk along edges, colour vertices, grow spanning trees and count walks with a matrix.
No walk yet.
2 vertices have odd degree: A, B.
So an Euler trail exists but no Euler circuit: it must start at one of A and B and end at the other.
Now take away the roof. A square with both diagonals looks simpler than the house. Is it easier to trace?
The envelope
Dots joined by lines: count degrees, walk along edges, colour vertices, grow spanning trees and count walks with a matrix.
No walk yet.
4 vertices have odd degree: A, B, C, D.
So no Euler trail is possible. A trail enters and leaves each vertex in its middle in pairs, so only its two ends can have odd degree, and this graph has 4 such vertices.
And here are the bridges of Königsberg, drawn as a network: each piece of land is a dot (North, South, Island, East) and each bridge is a line.
The seven bridges
Dots joined by lines: count degrees, walk along edges, colour vertices, grow spanning trees and count walks with a matrix.
No walk yet.
4 vertices have odd degree: N, S, I, E.
So no Euler trail is possible. A trail enters and leaves each vertex in its middle in pairs, so only its two ends can have odd degree, and this graph has 4 such vertices.
Now open the Degrees tab of each explorer. Write the number on each dot into your table. Can you see a pattern that tells you which figures work?
Networks, dots and degrees
Definition— network
A network is a collection of dots with lines joining some pairs of dots. Mathematicians also call a network a graph, the dots vertices and the lines edges. Two dots may be joined by more than one line, like the two bridges from the island to the north bank.
Only the connections matter. We may draw the lines curved or straight, long or short, and move the dots around: as long as the same dots are joined by the same number of lines, it is the same network. That is why we could turn the map of Königsberg into four dots and seven lines.
Definition— degree
The degree of a dot is the number of line ends at that dot. A dot is odd if its degree is an odd number (1, 3, 5, …) and even if its degree is even (0, 2, 4, …).
Definition— tracing in one stroke
To trace a network in one stroke means to walk along its lines, from dot to dot, using every line exactly once. You may start and finish at any dots, and you may pass through a dot as often as you like.
Definition— connected
A network is connected if you can get from any dot to any other dot by walking along lines.
Counting line ends
Example— The house
Count the line ends at each corner of the house:
| Dot | A | B | C | D | E |
|---|---|---|---|---|---|
| Degree | 3 | 3 | 4 | 4 | 2 |
Two dots are odd: A and B, the two bottom corners. Did you notice? The tracings that work start at one bottom corner and finish at the other — for example A B C D A C E D B.
Example— The envelope and the bridges
In the envelope (the house without its roof) every corner has degree 3: four odd dots. Nobody can trace it in one stroke.
In Königsberg the island has 5 bridges, and each of the other three pieces of land has 3. Again four odd dots. And again nobody could find the walk.
Example— A careful non-example
Draw two triangles that do not touch. Every dot has degree 2, so there are no odd dots at all — yet you cannot trace both triangles in one stroke, because you cannot get from one triangle to the other without lifting your pencil. The network is not connected. The pattern we are about to prove only talks about connected networks.
Why the odd dots decide everything
Theorem— The handshake rule
In every network, the degrees of all the dots add up to twice the number of lines.
Proof
Every line has exactly two ends, and every end sits at exactly one dot. When we add up the degrees, we count every line end once — so we count every line twice.
∎
The house has 8 lines, and its degrees add up to . Königsberg has 7 bridges and .
Note
It is called the handshake rule because of a party: if everyone counts how many hands they shook, the counts add up to twice the number of handshakes, since every handshake involves two hands. One surprising consequence: the number of odd dots is always even. (A sum of numbers is even only when it has an even number of odd numbers in it.) So no network has exactly one odd dot, or exactly three.
Now the big question: why do the odd dots matter for tracing?
Theorem— Euler's observation
If a network can be traced in one stroke, then every odd dot is either where the route starts or where it ends. So a network with more than two odd dots can never be traced in one stroke.
Proof
Follow the route and look at one dot that is neither the start nor the end. Every time the route arrives at this dot along one line, it must leave along a different line — it cannot stop there, because it does not end there. So the route uses the line ends at this dot in pairs: one in, one out. Since the route uses every line exactly once, it uses every line end at the dot, and all of them come in pairs. So the degree of the dot is even.
That means an odd dot must be the start or the end. A route has only one start and one end, so there can be at most two odd dots. Königsberg and the envelope have four odd dots: they can never be traced, however clever we are.
∎
The same argument tells us more. If the route finishes where it started, then the start dot also uses its line ends in pairs (the first line out pairs with the last line in). So a route that returns home is possible only if every dot is even.
And it tells you where to start: in the house, the odd dots A and B must be the two ends of the route. Starting at the roof top E can never work.
What about the other direction? Here is the full answer, which Leonhard Euler described in his paper of 1736.
Theorem— Euler's rule for one-stroke figures
A connected network can be traced in one stroke exactly when it has no odd dots or exactly two odd dots. With two odd dots, the route must start at one of them and end at the other. With no odd dots, you can start anywhere, and you will finish where you started.
We proved one half: more than two odd dots means it is impossible. The other half — that with 0 or 2 odd dots a connected network can always be traced — is also true. Here is the idea, as a sketch rather than a full proof: start at an odd dot (or anywhere, if there are none) and walk along unused lines until you are stuck. By the in-and-out argument you can only get stuck at the other odd dot (or back at the start). If some lines are still unused, they form loops that touch your route somewhere, because the network is connected; walk each loop when you reach it, and splice it into the route. A complete proof was first published by Carl Hierholzer in 1873.
Shortest routes
Networks are also maps. Wanjiru cycles from her home to the market. Each road on her map is marked with its length in kilometres.
Example— Fewest roads or fewest kilometres?
The route Home → Well → Market uses only 2 roads: km.
The route Home → School → Bridge → Market uses 3 roads: km.
The route with more roads is 4 km shorter. "Fewest roads" and "shortest" are different questions!
How can we be sure 9 km is the shortest? On a small map we can list every route in an organised way and add up each one. There are only four routes from Home to Market that never visit a place twice, and 9 km is the smallest total.
On a big map there are far too many routes to list. In 1956 the Dutch computer scientist Edsger Dijkstra invented a cleverer method (published in 1959): spread out from home like ripples in a pond, always settling the nearest place not yet settled, and keep a note of the best distance found to each place. The School (2 km) is settled first, then the Bridge ( km), then the Well (7 km, both ways), and finally the Market ( km). Route-finding apps use ideas like this every day.
Gideon's true-or-false game
Gideon likes statements that are exactly true or exactly false. Decide for each one, and give a reason.
- "In every network, the degrees add up to an even number." — True. They add up to twice the number of lines.
- "There is a network with exactly three odd dots." — False. The number of odd dots is always even.
- "A route that traces the house can start at the roof top E." — False. The odd dots A and B must be the start and the end.
- "The bridges of Königsberg can be crossed in one walk if you start on the island." — False. Four odd dots: no starting place works.
For grown-ups · the same ideas in Lean, a proof checker
The Lean proof assistant checks every step of a proof. Below, a network is a list of lines, and each line is a pair of dot numbers. For Königsberg, dot 0 is the island, 1 and 2 are the north and south banks and 3 is the eastern land.
/-- The seven bridges of Königsberg. Dot `0` is the island in the middle (Kneiphof), dots `1`
and `2` are the north and south banks, and dot `3` is the eastern land between the two arms of
the river. Two bridges join the island to each bank. -/
def konigsberg : Network :=
[(0, 1), (0, 1), (0, 2), (0, 2), (0, 3), (1, 3), (2, 3)]/-- The degree of the dot `v`: the total number of line ends at `v`. -/
def degree (g : Network) (v : Nat) : Nat :=
(g.map (ends v)).sumLean computes the four degrees itself:
/-- The degrees in Königsberg are `5, 3, 3, 3`: all four dots are odd. Lean counts them. -/
theorem konigsberg_degrees :
degree konigsberg 0 = 5 ∧ degree konigsberg 1 = 3 ∧
degree konigsberg 2 = 3 ∧ degree konigsberg 3 = 3 := by
decideThe handshake rule is proved for every network, not just checked for examples. total n f means , adding up over the dots :
/-- **The handshake rule.** If every line of `g` joins dots among `0, …, n - 1`, then the degrees
of these dots add up to twice the number of lines: each line has two ends, and each end is
counted at exactly one dot. -/
theorem handshake (g : Network) (n : Nat) (h : ∀ e ∈ g, e.1 < n ∧ e.2 < n) :
total n (degree g) = 2 * g.length := by
induction g with
| nil =>
show total n (fun _ => 0) = 0
induction n with
| zero => rfl
| succ n ih => simp [total, ih]
| cons e es ih =>
have he := h e (List.mem_cons_self ..)
have hes : ∀ x ∈ es, x.1 < n ∧ x.2 < n := fun x hx => h x (List.mem_cons_of_mem e hx)
have split : degree (e :: es) =
fun v => ((if e.1 = v then 1 else 0) + (if e.2 = v then 1 else 0)) + degree es v := by
funext v
simp [degree, ends]
rw [split, total_add, total_add, total_one_dot, total_one_dot, ih hes]
simp [he.1, he.2]
omegaNext, the in-and-out argument. A route is a list of dots. This theorem says: at any dot , the line ends used by the route, plus one if is the start, plus one if is the end, make exactly twice the number of visits — an even number.
/-- **Every visit uses two line ends.** Along a route, each time we pass through a dot we
arrive on one line and leave on another. Only the start and the end lose one of the two. So
the line ends at `v` used by the route, plus one if `v` is the start, plus one if `v` is the
end, make exactly twice the number of visits to `v`. -/
theorem route_degree (v : Nat) (rest : List Nat) : ∀ x : Nat,
degree (steps (x :: rest)) v + (if x = v then 1 else 0)
+ (if lastDot x rest = v then 1 else 0) = 2 * visits v (x :: rest) := by
induction rest with
| nil =>
intro x
by_cases hx : x = v <;> simp [steps, lastDot, visits, degree, hx]
| cons y rest ih =>
intro x
have h := ih y
simp only [steps, lastDot, visits, degree, ends, List.map, List.sum_cons] at h ⊢
-- Decide, for each of the three dots `x`, `y` and the last dot, whether it is `v`.
by_cases hx : x = v <;> by_cases hy : y = v <;> by_cases hl : lastDot y rest = v <;>
simp only [hx, hy, hl, ite_true, ite_false] at h ⊢ <;> omegaA route traces a network when the lines it walks are exactly the network's lines, each used once, in some order and in either direction:
/-- The route that starts at `x` and then visits the dots of `rest` **traces `g` in one
stroke** when the lines it walks along are exactly the lines of `g`, each used once: the two
lists of lines are rearrangements of each other (`List.Perm`), ignoring direction. -/
def Traces (g : Network) (x : Nat) (rest : List Nat) : Prop :=
List.Perm ((steps (x :: rest)).map norm) (g.map norm)From these, Lean proves Euler's observation for every network, and then that the Königsberg walk is impossible, wherever it starts and however long it is:
/-- **Euler's observation.** If a route traces `g` in one stroke, every dot of odd degree is the
start or the end of the route. (Every other dot is passed through, and each visit uses an even
number, two, of line ends.) -/
theorem odd_dot_is_an_end {g : Network} {x : Nat} {rest : List Nat}
(h : Traces g x rest) (v : Nat) (odd : degree g v % 2 = 1) :
v = x ∨ v = lastDot x rest := by
have hv := route_degree v rest x
rw [degree_eq_of_traces h v] at hv
by_cases h1 : x = v
· exact Or.inl h1.symm
· by_cases h2 : lastDot x rest = v
· exact Or.inr h2.symm
· simp only [h1, h2, ite_false] at hv
omega/-- **The bridges of Königsberg cannot all be crossed in one walk** that uses each bridge exactly
once, wherever it starts. All four dots have odd degree, so all four would have to be the start
or the end — but a route has only one start and one end. -/
theorem konigsberg_impossible (x : Nat) (rest : List Nat) : ¬ Traces konigsberg x rest := by
intro h
obtain ⟨d0, d1, d2, d3⟩ := konigsberg_degrees
have h0 := odd_dot_is_an_end h 0 (by rw [d0])
have h1 := odd_dot_is_an_end h 1 (by rw [d1])
have h2 := odd_dot_is_an_end h 2 (by rw [d2])
have h3 := odd_dot_is_an_end h 3 (by rw [d3])
omega/-- A route that traces `g` and comes back to where it started leaves **no** dot of odd degree:
with the start equal to the end, every dot has even degree. -/
theorem closed_route_all_even {g : Network} {x : Nat} {rest : List Nat}
(h : Traces g x rest) (closed : lastDot x rest = x) (v : Nat) : degree g v % 2 = 0 := by
have hv := route_degree v rest x
rw [degree_eq_of_traces h v, closed] at hv
by_cases h1 : x = v
· simp only [h1, ite_true] at hv
omega
· simp only [h1, ite_false] at hv
omegaFor the house, Lean checks one successful route, and proves that no route can start at the roof top (dot 4):
/-- The route `0, 1, 2, 3, 0, 2, 4, 3, 1` traces the house in one stroke: it starts at one odd
dot and ends at the other. Lean checks that the eight lines walked are exactly the eight lines
of the house. -/
theorem house_traced : Traces house 0 [1, 2, 3, 0, 2, 4, 3, 1] := by
unfold Traces
decide/-- A route tracing the house must start or end at dot `0`, and also at dot `1`: the odd dots
are forced to be its two ends. So starting at the roof top `4` can never work. -/
theorem house_needs_odd_start (rest : List Nat) : ¬ Traces house 4 rest := by
intro h
obtain ⟨d0, d1, _, _, _⟩ := house_degrees
have h0 := odd_dot_is_an_end h 0 (by rw [d0])
have h1 := odd_dot_is_an_end h 1 (by rw [d1])
omegaFinally, the road map, with Home = 0, Well = 1, School = 2, Bridge = 3, Market = 4:
/-- **Fewest roads is not the same as shortest.** Home → Well → Market uses 2 roads and is
13 km; Home → School → Bridge → Market uses 3 roads but is only 9 km. -/
theorem fewest_roads_not_shortest :
routeLength [0, 1, 4] = some 13 ∧ routeLength [0, 2, 3, 4] = some 9 := by
decideWhat is not formalised here: the other half of Euler's rule (that 0 or 2 odd dots and connectedness are enough), and the fact that Dijkstra's method always finds the shortest route. Mathlib, Lean's large mathematics library, has graphs (SimpleGraph), the handshake lemma and Eulerian walks for networks without repeated lines.
Margaret tries every route
"""Which figures can be traced in one stroke? Search every route, then compare.
For each small figure (a network of dots and lines) the program counts the
line ends at every dot (the degree), and then searches *every* possible route
that uses each line exactly once, starting from every dot. The search is
exhaustive, so for these figures its answer is certain. We then compare the
search with Euler's rule: a connected figure can be traced in one stroke
exactly when it has 0 or 2 dots of odd degree.
Runs unchanged in the browser (Pyodide) using only the standard library.
"""
import textwrap
#: Each figure is a list of lines; a line joins two dots (letters).
FIGURES = {
"square": ["AB", "BC", "CD", "DA"],
"square + diagonal": ["AB", "BC", "CD", "DA", "AC"],
"envelope (2 diagonals)": ["AB", "BC", "CD", "DA", "AC", "BD"],
"house": ["AB", "BC", "CD", "DA", "AC", "BD", "DE", "EC"],
"bow tie": ["AB", "BC", "CA", "CD", "DE", "EC"],
"two triangles apart": ["AB", "BC", "CA", "DE", "EF", "FD"],
"Konigsberg bridges": ["IN", "IN", "IS", "IS", "IE", "NE", "SE"],
}
def dots(lines):
"""Return the sorted list of dots that appear on some line."""
return sorted({d for line in lines for d in line})
def degrees(lines):
"""Return {dot: number of line ends at that dot}."""
deg = {d: 0 for d in dots(lines)}
for a, b in lines:
deg[a] += 1
deg[b] += 1
return deg
def odd_dots(lines):
"""Return the sorted list of dots of odd degree."""
return [d for d, k in degrees(lines).items() if k % 2 == 1]
def is_connected(lines):
"""True if every dot can be reached from every other dot along lines."""
all_dots = dots(lines)
if not all_dots:
return True
seen, todo = {all_dots[0]}, [all_dots[0]]
while todo:
here = todo.pop()
for a, b in lines:
for x, y in ((a, b), (b, a)):
if x == here and y not in seen:
seen.add(y)
todo.append(y)
return len(seen) == len(all_dots)
def find_one_stroke(lines):
"""Search every route that uses each line once; return one or None.
A route is returned as a string of dots, e.g. "ABCA". Every starting dot
and every order of lines is tried (depth-first search with backtracking).
"""
used = [False] * len(lines)
def extend(route):
if all(used):
return route
here = route[-1]
for i, (a, b) in enumerate(lines):
if used[i] or here not in (a, b):
continue
used[i] = True
found = extend(route + (b if here == a else a))
used[i] = False
if found:
return found
return None
for start in dots(lines):
found = extend(start)
if found:
return found
return None
def euler_rule_says_yes(lines):
"""Euler's rule: connected, with 0 or 2 dots of odd degree."""
return is_connected(lines) and len(odd_dots(lines)) in (0, 2)
def main():
print("Figure degrees odd rule search finds")
agree = 0
for name, lines in FIGURES.items():
deg = degrees(lines)
shown = " ".join(str(deg[d]) for d in dots(lines))
rule = euler_rule_says_yes(lines)
route = find_one_stroke(lines)
agree += rule == (route is not None)
answer = route if route else "no route"
print(f"{name:<23} {shown:<16} {len(odd_dots(lines)):>3} "
f"{'yes' if rule else 'no':<4} {answer}")
print("(Degrees are listed in alphabetical order of the dots.)")
print()
print(f"The rule and the search agree on {agree} of {len(FIGURES)} figures.")
print("Each route starts and ends at the odd dots, when there are two.")
print("'Two triangles apart' has no odd dots but is not connected,")
print("so the rule needs the word 'connected'.")
print()
print(textwrap.fill(
"Epistemic status: for each of these seven figures the search tried "
"every route, so its yes or no is certain (exhaustive-finite). The "
"agreement with Euler's rule is evidence for the rule, not a proof: "
"the lesson explains why odd dots must be the ends of a route, and "
"the Lean module proves that half of the rule for every figure.",
width=78,
))
if __name__ == "__main__":
main()For each of these seven figures the search is complete, so its answer is certain. But seven figures are not all figures: the agreement is evidence for Euler's rule, and the proof above is what tells us it is always true. Look at the "two triangles apart" line: no odd dots, but no route — which is why the rule says connected.
"""Shortest routes on a small road map: list every route, then be clever.
Wanjiru cycles from home to the market. The map has five places and six
roads, each marked with its length in kilometres. First the program lists
*every* route that never visits a place twice, with its number of roads and
its length: an exhaustive check. Then it runs Dijkstra's method, which finds
the shortest distance from home to every place without listing all routes,
by always settling the nearest place not yet settled.
Runs unchanged in the browser (Pyodide) using only the standard library.
"""
import textwrap
#: (place, place, kilometres)
ROADS = [
("Home", "Well", 7),
("Well", "Market", 6),
("Home", "School", 2),
("School", "Bridge", 3),
("Bridge", "Market", 4),
("Well", "Bridge", 2),
]
def neighbours(roads):
"""Return {place: {neighbour: km}} for roads that work in both directions."""
near = {}
for a, b, km in roads:
near.setdefault(a, {})[b] = km
near.setdefault(b, {})[a] = km
return near
def all_routes(roads, start, goal):
"""Every route from start to goal that never visits a place twice."""
near = neighbours(roads)
found = []
def extend(route):
here = route[-1]
if here == goal:
found.append(route)
return
for nxt in sorted(near[here]):
if nxt not in route:
extend(route + [nxt])
extend([start])
return found
def route_length(roads, route):
"""Total kilometres along a route (a list of places)."""
near = neighbours(roads)
return sum(near[a][b] for a, b in zip(route, route[1:]))
def dijkstra(roads, start):
"""Shortest distance from start to every place, and the settling order.
Repeatedly settle the unsettled place with the smallest known distance,
then update the distances of its neighbours.
"""
near = neighbours(roads)
best = {start: 0}
settled = []
while len(settled) < len(near):
here = min((d, p) for p, d in best.items() if p not in settled)[1]
settled.append(here)
for nxt, km in near[here].items():
if nxt not in best or best[here] + km < best[nxt]:
best[nxt] = best[here] + km
return best, settled
def main():
routes = all_routes(ROADS, "Home", "Market")
print("Every route from Home to Market that never repeats a place:")
for route in sorted(routes, key=lambda r: (len(r), route_length(ROADS, r))):
roads_used = len(route) - 1
km = route_length(ROADS, route)
print(f" {' - '.join(route):<38} {roads_used} roads {km:>2} km")
fewest = min(routes, key=len)
shortest = min(routes, key=lambda r: route_length(ROADS, r))
print(f"Fewest roads: {' - '.join(fewest)}"
f" ({route_length(ROADS, fewest)} km)")
print(f"Shortest route: {' - '.join(shortest)}"
f" ({route_length(ROADS, shortest)} km)")
print()
best, settled = dijkstra(ROADS, "Home")
print("Dijkstra's method settles the nearest unsettled place each time:")
for place in settled:
print(f" {place:<7} {best[place]:>2} km from Home")
print()
print(textwrap.fill(
"Epistemic status: exact. All four routes on this small map were "
"listed, so the 9 km route is certainly the shortest here, and "
"Dijkstra's method agrees. That the method always gives the shortest "
"distance (when no road has negative length) is a theorem proved in "
"later courses; this run checks one map only.",
width=78,
))
if __name__ == "__main__":
main()Your turn
Take your time. A pencil and paper will help — and you can ask for a hint whenever you like.
1. Dots and lines: networks and puzzles
Warm-upHumanA network has one centre dot joined by lines to 5 outer dots, and no other lines. What is the degree of the centre dot?
2. Dots and lines: networks and puzzles
Warm-upHumanThe dots of a network have degrees 3, 3, 2, 4 and 2. How many lines does the network have?
3. Dots and lines: networks and puzzles
CoreHumanAmaru says he has drawn a network whose four dots have degrees 3, 2, 2 and 2. Is that possible?
4. Dots and lines: networks and puzzles
CoreHumanEach figure below is connected, and the numbers are the degrees of its dots. Which figures can be traced in one stroke? Select all that apply.
5. Dots and lines: networks and puzzles
CoreHumanA connected figure has five dots with these degrees: P has 2, Q has 3, R has 4, S has 3 and T has 2. Where must a one-stroke tracing start?
6. Dots and lines: networks and puzzles
CoreHumanAma walks from her house to the swimming pool. The roads are: house–library 4 km, library–pool 5 km, house–park 3 km, park–pool 7 km, park–shop 3 km, shop–pool 2 km. What is the shortest distance from her house to the pool, in kilometres?
7. Dots and lines: networks and puzzles
StretchHumanThe people of Königsberg decide to build new bridges so that a walk crossing every bridge exactly once becomes possible. (The walk may start and finish in different places.) What is the smallest number of new bridges they need?
8. Dots and lines: networks and puzzles
CoreFormalLean has checked the theorem odd_dot_is_an_end: if a route traces a network in one stroke, then every odd dot is the start or the end of the route. Which statement can Gideon conclude from this theorem alone?
9. Dots and lines: networks and puzzles
StretchComputationalMargaret writes a network as a list of lines, each line a string of two dot letters, like ["AB", "BC", "CA"] for a triangle. Complete the function degree(lines, dot) so that it returns the number of line ends at dot. Two lines may join the same two dots (like bridges).
Things that trip people up
Misconception
"Whether I can trace it depends on how complicated it looks." It depends only on the degrees of the dots (and on the figure being connected). The envelope looks simple and is impossible; the house looks harder and is possible. Count the odd dots before you start.
Misconception
"If it can be traced, I can start anywhere." With two odd dots you must start at one odd dot and finish at the other. Only when every dot is even can you start anywhere.
Misconception
"The shortest route is the one with the fewest roads." The number of roads and the total distance are different things. On Wanjiru's map the 2-road route is 13 km and a 3-road route is 9 km.
Misconception
"A dot's degree is the number of dots it touches." Degree counts line ends. In Königsberg the island touches only three other pieces of land, but it has five bridges, so its degree is 5.
Other ways of seeing
Topology— Only the connections matter
Euler said the bridges problem belonged to the "geometry of position": distances, angles and shapes play no part. You may stretch, bend and move the lines as much as you like, and the answer does not change, as long as you do not cut a line or join new ones. Ideas that survive stretching and bending belong to topology. Euler's later formula for the corners, edges and faces of a solid is another early example — see surfaces and the Euler characteristic.
Computation— Checking a rule versus trying everything
To decide whether a figure can be traced, a computer could try every route — but the number of routes grows enormously as figures get bigger. Counting the odd dots takes just one look at each line. Good mathematics often turns a huge search into a quick check. For shortest routes on real road maps with millions of places, listing routes is hopeless; methods like Dijkstra's are what make route-finding possible (algorithm design).
Where networks lead
In set language, a simple network is a set of dots together with a set of lines, where each line is a pair of dots. Königsberg needs a little more, because two different bridges join the same two pieces of land: we must remember the bridges as separate lines, not just which pairs of dots are joined. That is why the Lean code uses a list of lines.
Later, in graphs and graph theory, you will meet trees, colouring, matchings and much more — all built from dots and lines.
Wonder Trails
Optional, and never graded: a question that leads somewhere further.
Wonder Trail · Optional · never gradedKnots and coloursTie a knot in a piece of string and glue the two ends together. How could you prove that it really is knotted — that no amount of wiggling, without cutting, will turn it into a plain loop?Follow the trailHistory and global context
- Leonhard Euler, a Swiss mathematician working in St Petersburg, solved the Königsberg puzzle in a paper dated 1736 (printed in 1741). He showed that a walk crossing every bridge once is impossible and stated when such walks exist. This paper is often called the beginning of graph theory. The complete proof that 0 or 2 odd dots are enough was published by Carl Hierholzer in 1873.
- In Angola, Zambia and the Democratic Republic of the Congo, storytellers of the Chokwe people draw sona (singular lusona) in the sand: a grid of dots with a line that winds around them, often drawn in one continuous stroke while a story is told. The mathematician Paulus Gerdes studied the geometry of these drawings.
- In Tamil Nadu and other parts of South India, many families draw kolam at their doorsteps each morning: lines looped around a grid of dots, some made of a single closed line.
- The word graph for a network was introduced by the English mathematician James Joseph Sylvester in 1878. Today networks describe roads, the internet, friendships, food webs and molecules.
For grown-ups: further reading
- Robin J. Wilson, Introduction to Graph Theory (first edition 1972) — a clear first course, starting from Königsberg.
- Norman L. Biggs, E. Keith Lloyd and Robin J. Wilson, Graph Theory 1736–1936 (1976) — includes an English translation of Euler's bridges paper.
- Paulus Gerdes, Geometry from Africa: Mathematical and Educational Explorations (1999) — includes sona drawings and classroom activities.