Three houses and three utilities: graphs, crossings and possible networks

Connect three houses to gas, water and electricity without crossings: from experiments to K₃,₃, with a guided proof, comparison with network costs and an interactive lab.

Section: Algorithms Updated:
AI assistant

Articles /planar-graphs-three-houses-three-utilities
Three houses and three utilities: graphs, crossings and possible networks

20 min

Three houses need three utilities: gas, water and electricity. It looks like a drawing challenge: find the right route for every pipe. In fact, before optimising, we must answer a more important question: does the requested solution exist?

The problem leads to graph planarity. We will distinguish what a drawing shows from what mathematics allows us to conclude, rather than settle for a convincing attempt. It also illustrates reduction: remove houses and pipes, and six points and nine relationships remain.

Illustration for the Algorithms section

Try the utilities challenge in the graph laboratory · Start with BFS, Dijkstra and Kruskal

  1. 1. The problem and its rules, before drawing
  2. 2. From the problem to a graph: what do we preserve?
  3. 3. A drawing with crossings does not prove impossibility
  4. 4. The useful observation: count faces too
  5. 5. Why K₃,₃ cannot be planar: every step
  6. 6. A general formula, but not a sufficient test
  7. 7. If zero crossings are impossible, what is the minimum?
  8. 8. K₅ and the meaning of the two fundamental obstructions
  9. 9. Optimising a network: choose the objective first
  10. 10. An experiment in the laboratory

1. The problem and its rules, before drawing

Call the houses C₁, C₂, C₃ and the utilities S₁, S₂, S₃. Every house must connect directly to every utility: 3 × 3 = 9 distinct connections, not three connections altogether.

Lines may bend and go around houses; they need not be straight segments. We may also move the points in the drawing: their positions do not change which pairs must be connected.

  • Everything must stay in one plane, without bridges or tunnels.
  • Two connections may meet only at a shared endpoint.
  • A line must not pass through a house or utility that is not one of its endpoints.
  • Overlapping two pipes or joining them at a new shared vertex changes the problem rather than solving it.

2. From the problem to a graph: what do we preserve?

A vertex represents a house or utility; an edge represents a required connection. The graph is bipartite: its vertices split into houses and utilities, and every edge goes between the groups. It is complete between these groups, hence the name K₃,₃.

Each vertex has degree 3. Counting endpoints gives 6 × 3 = 18; each edge has two endpoints, so there are 18/2 = 9 edges, agreeing with 3 × 3.

This abstraction preserves connections, not distances, pipe diameters, flow rates or excavation costs. It is not yet an engineering model of a real network.

V = 6; E = 9
6 × 3 = 18 = 2E

3. A drawing with crossings does not prove impossibility

A graph is planar if there exists a drawing in the plane without edge crossings, except at shared endpoints. “There exists” is crucial: one unsuccessful attempt does not prove that every attempt must fail.

K₄, with four mutually connected vertices, demonstrates this. A square with both diagonals has one crossing. Place three vertices on a triangle and the fourth inside: the same six edges no longer cross.

Curves must still follow the rules. Going outside the sheet and returning is allowed if it merely uses more of the same plane. Passing behind the sheet introduces a second level.

Two drawings of K₄: a square with diagonals and a triangle with an interior vertex.
The same six edges: the first drawing has one crossing, the second none.

4. The useful observation: count faces too

In a connected planar drawing, edges divide the plane into regions called faces. Include the unbounded outside region. If V counts vertices, E edges and F faces, Euler’s formula applies.

To understand it, start with a tree connecting all vertices: it has E = V − 1 and one face, the outside. Thus V − E + F = V − (V − 1) + 1 = 2.

Now add one missing edge from the planar drawing. Its endpoints are already connected, and it splits a face in two. E increases by one and F increases by one, leaving V − E + F unchanged. Repeating preserves the formula.

Do not count the regions of a drawing with crossings and apply the formula as if it were already a planar drawing of the original graph. The assumptions must hold first.

V − E + F = 2
F = 2 − V + E

5. Why K₃,₃ cannot be planar: every step

Argue by contradiction: suppose a crossing-free drawing exists. With V = 6 and E = 9, Euler’s formula would require F = 2 − 6 + 9 = 5 faces.

Consider a face boundary. In the bipartite graph, each step alternates house and utility, so a triangle is impossible. K₃,₃ has no bridges either, since every edge belongs to a four-edge cycle. Each face of the supposed planar drawing would therefore have at least four sides.

Five faces would require at least 5 × 4 = 20 edge occurrences along their boundaries. Yet every edge has two sides, giving exactly 2 × 9 = 18 occurrences. The outside face participates too.

We need at least 20 occurrences, but have only 18. This contradiction proves that a crossing-free drawing does not exist. We have not inspected every possible drawing; we have identified a property each would have to satisfy.

F = 2 − 6 + 9 = 5
4F ≤ 2E
4 × 5 = 20 > 18 = 2 × 9

6. A general formula, but not a sufficient test

The same count gives E ≤ 2V − 4 for a simple, connected, bipartite planar graph with V ≥ 3. “Simple” means no loops and no multiple edges between the same pair of vertices.

Combine F = 2 − V + E with 4F ≤ 2E. Boundary counting concerns occurrences: a bridge, if present, is traversed twice along the same face boundary. Do not count only the distinct edges on a boundary.

For K₃,₃, the limit would be 2 × 6 − 4 = 8 edges, but nine are required. The formula certifies impossibility. Satisfying it, however, does not automatically prove planarity: it is necessary, not sufficient.

4(2 − V + E) ≤ 2E
8 − 4V + 4E ≤ 2E
2E ≤ 4V − 8
E ≤ 2V − 4

7. If zero crossings are impossible, what is the minimum?

We proved that at least one crossing is necessary. That lower bound alone does not determine the minimum: we must also construct a drawing that reaches it.

The drawing below, reproducible in the lab, makes all nine connections with one crossing and no other conflicts. The two facts complement each other: the proof gives minimum ≥ 1 and the construction minimum ≤ 1. Therefore the minimum is exactly one.

Remove one of the two crossing edges and this drawing becomes planar, but a house loses a utility: it does not solve the original problem. An overpass at the crossing solves a physical problem on two levels, not the planar one.

1 ≤ min ≤ 1 ⇒ min = 1

Six K₃,₃ vertices with nine connections, four outside bends and one marked crossing.
Every required connection and just one crossing: the construction attains the proven bound.

8. K₅ and the meaning of the two fundamental obstructions

The complete graph K₅ has five vertices and 5 × 4/2 = 10 edges. Triangles are possible, so the appropriate count is 3F ≤ 2E. A simple planar graph with V ≥ 3 consequently satisfies E ≤ 3V − 6.

For V = 5, at most nine edges would be permitted. The ten required make K₅ non-planar. Equivalently, Euler would require F = 7, but 3 × 7 ≤ 2 × 10 would mean 21 ≤ 20.

K₅ and K₃,₃ are not the only non-planar graphs. Kuratowski’s theorem states that a finite graph is planar if and only if it contains no subgraph that is a subdivision of K₅ or K₃,₃. Subdividing an edge means inserting intermediate vertices along it.

The theorem is stated here, not proved. Its practical message is that adding intermediate points does not remove the obstruction. It is not enough to search a drawing for just the two exact figures with the original number of vertices.

E ≤ 3V − 6
10 > 3 × 5 − 6 = 9

Cornell CS280 · Planar graphs, Euler, Kuratowski

9. Optimising a network: choose the objective first

“Optimisation” covers different problems. A shortest path connects a start to a destination; a minimum tree connects all vertices; planarity asks whether the required connections can avoid crossings. These are not three versions of the same objective.

Prim and Kruskal do not solve the utilities puzzle: a tree on six vertices has only five edges, whereas nine are required here. A Dijkstra shortest path may also geometrically cross another connection: the algorithm does not check that constraint.

The mathematical result does not say that a town cannot receive three utilities. It says that all the puzzle’s constraints cannot hold simultaneously in the plane. Real networks require models of levels, capacities, shareable routes, technical regulations and costs: additional data and constraints.

QuestionObjectiveTool
What does it cost to get from A to B?Minimise a path’s costDijkstra, with non-negative weights
How do we connect all vertices at minimum cost?Minimise a tree’s total weightPrim or Kruskal
Can we avoid all crossings?Find a planar drawing of the required connectionsPlanarity; Euler bounds and constructions
If zero is impossible, how many crossings are necessary?Minimise crossingsA lower bound and a drawing attaining it

Shortest paths and minimum trees: Dijkstra, Prim and Kruskal

10. An experiment in the laboratory

Open “Utilities and planarity” in the existing laboratory. Start without lines and select two vertices to add a required connection. Move vertices and insert bends using mouse, touch or keyboard.

“Complete the connections” adds missing edges without deleting your bends. The counter separates connections present, crossings between edge pairs and other geometric conflicts. Making two lines coincide is not the same as eliminating a crossing.

Compare K₃,₃ with K₂,₃, K₄ and K₅. Then open “Show an optimal drawing” and the explanation. These are prepared examples with proven minima for these four cases, not a general algorithm for deciding the planarity of any network.

Try the utilities challenge in the graph laboratory

Four problems: try before opening the solution

Two houses and three utilities: how many vertices and edges? Is the network planar?

Show the explained solution

V = 2 + 3 = 5 and E = 2 × 3 = 6. It is planar: place the houses left and right, and the three utilities on a vertical line between them. Left connections stay in the left half and right connections in the right half. The lab shows this construction.

A drawing of K₄ has one crossing. Does that prove non-planarity?

Show the explained solution

No. Planarity concerns the existence of a crossing-free drawing, not one attempt’s appearance. Three vertices on a triangle and the fourth inside allow all six edges without crossings.

Someone counts only four faces in the hypothetical planar drawing of K₃,₃. Which face is missing?

Show the explained solution

The outside face. Euler would require five faces, not four. Including the outside boundary in the edge-occurrence count gives the contradiction 20 ≤ 18.

Insert one intermediate vertex into an edge of K₃,₃. Now V = 7 and E = 10. Have you solved the problem?

Show the explained solution

No: one connection has merely become two consecutive segments. If the new graph were planar, removing the degree-two vertex and rejoining the segments would give a planar K₃,₃, which is impossible. Vertex count alone does not measure difficulty. In this case, subdividing a single edge also destroys bipartiteness: do not automatically apply the bipartite bound.

The right observation can also prove impossibility

Sometimes improving a solution means drawing better; sometimes it means recognising incompatible constraints. Here the decisive observation is to count face boundaries in two ways. An attempt suggests; a construction proves possibility; a contradiction proves impossibility.

Sources and connections

Inspired by Peter M. Higgins, Divertirsi con la matematica. Curiosità e stranezze del mondo dei numeri, Edizioni Dedalo, pp. 233–234. The text, examples and diagrams have been reworked.

Oscar Levin · Discrete Mathematics: An Open Introduction · Planar Graphs