Image: Unknown author, public domainThree houses, three utilities, no crossings
Three houses stand in a row, and below them are the water company, the gas company, and the electricity company. Each house needs a pipe or cable from each of the three suppliers, nine connections in all, and the connections may not cross. Henry Dudeney printed the puzzle in the Strand Magazine in 1913 and again in his book Amusements in Mathematics of 1917, under the title Water, Gas, and Electricity, with the remark that it was as old as the hills, much older than gas or electric light. He also gave the answer: it cannot be done. His proof was a sketch. The real proof takes a page and uses a formula of Euler.
The graph
The puzzle is a graph with six vertices, three houses and three suppliers, and nine edges, one from every house to every supplier. Graph theorists call it K3,3, the complete bipartite graph with three vertices on each side. The puzzle asks whether K3,3 can be drawn in the plane so that no two edges cross, which is what it means for a graph to be planar. Eight of the nine connections are easy. Draw the houses as the corners of a hexagon alternating with the suppliers, join each house to the two suppliers beside it, and six edges run around the hexagon without trouble. The seventh and eighth can go inside and outside. The ninth always crosses something, and no amount of rerouting helps.
Trying for an hour convinces most people. It convinces nobody who asks for a proof, because there are infinitely many ways to draw nine curves, and failing at all the ones one has tried is not an argument.
Euler's formula
Suppose a connected graph is drawn in the plane without crossings, and count three things: the vertices v, the edges e, and the faces f, where the faces are the regions into which the drawing cuts the plane, including the unbounded region outside. Euler's formula says that v minus e plus f = 2, always. A triangle has 3 vertices, 3 edges, and 2 faces (inside and outside), and 3 minus 3 plus 2 = 2. The cube drawn flat has 8, 12, and 6, and 8 minus 12 plus 6 = 2. Unit 6 of the Graph Theory Masterclass proves the formula by removing one edge at a time and checking that the quantity does not change.
Now suppose K3,3 had a crossing-free drawing. It has v = 6 and e = 9, so the formula forces f = 2 minus 6 plus 9 = 5 faces. Count the edges around the faces. Every face is bounded by a closed walk in the graph, and every closed walk in K3,3 has even length, because the walk alternates between houses and suppliers; there are no triangles, so every face has at least 4 edges on its boundary. Each edge borders at most 2 faces. So 4 times 5 = 20 is at most 2 times 9 = 18. It is not, and the drawing cannot exist.
The same counting kills the other classic. The complete graph K5, five points all joined, has v = 5 and e = 10, so a plane drawing would have f = 7 faces; each face has at least 3 edges, each edge borders at most 2 faces, so 21 is at most 20, which is false. In general a planar graph with v vertices has at most 3v minus 6 edges, and at most 2v minus 4 if it has no triangles; K5 exceeds the first bound by one and K3,3 exceeds the second by one. Both are as close to planar as a non-planar graph can be.
Why these two graphs are the whole story
In 1930 Kazimierz Kuratowski proved that K5 and K3,3 are the only obstacles. A graph is planar if and only if it contains no subdivision of either, where a subdivision is the same graph with some edges replaced by paths. So whenever a graph cannot be drawn without crossings, the reason can be exhibited as a copy of the utilities graph or of the five-point graph hiding inside it, with some edges stretched. The Petersen graph, for example, contains a subdivision of K3,3, and Unit 6 marks its six branch vertices. Klaus Wagner gave an equivalent statement in 1937 in terms of minors, which lets one also contract edges, and that formulation is the seed of the graph minors theorem of Robertson and Seymour, the research spotlight of Unit 6.
The coffee mug
Dudeney's puzzle has a solution if the houses stand on the surface of a doughnut, and a coffee mug with a handle is a doughnut for this purpose. Draw the hexagon of houses and suppliers around the body of the mug, so that six connections run around it. Of the remaining three, route one across the top, one across the bottom, and the last one over the handle. The handle lets a pipe pass over the others without touching them. Euler's formula on the torus reads v minus e plus f = 0, and with v = 6 and e = 9 that allows f = 3, which the counting no longer forbids.
K5 can be drawn on a torus as well. There are graphs that need a surface with two handles, and three, and so on. The smallest number of handles a graph needs is its genus, and finding it is NP-hard in general. The plane, with no handles, is the only surface on which the question is easy: Hopcroft and Tarjan showed in 1974 that planarity can be tested in time proportional to the number of edges.
Why engineers care
A printed circuit board is a drawing of a graph in the plane, and a connection that must cross another needs a second layer, which costs money. Chip designers face the same question with millions of vertices. Road networks are nearly planar, with bridges and tunnels as the exceptions, and that near-planarity is what makes fast route planning possible. Map colouring, the subject of another post on this blog, is a question about planar graphs and nothing else.
Dudeney's readers in 1913 wanted to know whether there was a trick. There is none in the plane, and the proof is a count: 20 is not at most 18.


