Voronoi diagrams, perpendicular bisectors and graph theory
IB Math AI · Geometry and Trigonometry
Building a Voronoi diagram
Given sites $A$ and $B$, every point closer to $A$ than to $B$ lies on one side of the perpendicular bisector of $AB$. That single fact generates the whole diagram: each cell is the intersection of half-planes, each edge is part of a perpendicular bisector, and each vertex is equidistant from three sites.
To find the bisector of $A(x_1,y_1)$ and $B(x_2,y_2)$: take the midpoint $M\left(\dfrac{x_1+x_2}{2},\dfrac{y_1+y_2}{2}\right)$, compute $m_{AB}$, then use gradient $-\dfrac{1}{m_{AB}}$ through $M$.
The toxic waste dump problem
"Find the point in the region that is as far as possible from every site." The answer is always either a Voronoi vertex or a point on the boundary of the region. A vertex is the centre of a circle through three sites containing no site inside — the largest empty circle in that neighbourhood. Checking every vertex and comparing radii is the whole method.
Graph theory
An adjacency matrix $M$ records edges. The $(i,j)$ entry of $M^{k}$ counts walks of length exactly $k$ from $i$ to $j$ — walks, so repeated vertices and repeated edges are allowed.
A minimum spanning tree connects all $n$ vertices using $n-1$ edges of least total weight. Kruskal: sort edges by weight, add the cheapest that does not create a cycle. Prim: grow outwards from one vertex, always taking the cheapest edge leaving the tree built so far.
An Eulerian circuit exists exactly when every vertex has even degree; with exactly two odd vertices there is an Eulerian trail between them. The Chinese postman problem repeats the cheapest pairing of odd vertices.
Worked example: perpendicular bisectors, Voronoi cells and the location of the dump
Three transmission stations are placed at $A(1,\,2)$, $B(7,\,4)$ and $C(3,\,8)$, with units in km.
(a) Find the equation of the perpendicular bisector of $AB$. (b) Determine the coordinates of the common Voronoi vertex of the three cells. (c) A waste storage site must be placed as far from every station as possible, inside triangle $ABC$. State the location and the distance to the nearest station.
Solution
(a) The midpoint of $AB$ is $M\left(\dfrac{1+7}{2},\dfrac{2+4}{2}\right)=(4,\,3)$. The gradient
$$m_{AB}=\frac{4-2}{7-1}=\frac{2}{6}=\frac{1}{3}\;\Longrightarrow\;m_{\perp}=-3$$$$y-3=-3(x-4)\;\Longrightarrow\;y=-3x+15$$(b) The Voronoi vertex is equidistant from all three stations so it lies on all three perpendicular bisectors; intersecting two of them is enough. Perpendicular bisector of $AC$: midpoint $(2,\,5)$, $m_{AC}=\dfrac{8-2}{3-1}=3$, so $m_{\perp}=-\dfrac13$ and
$$y-5=-\tfrac13(x-2)\;\Longrightarrow\;y=-\tfrac13 x+\tfrac{17}{3}$$Solve the system with $y=-3x+15$:
$$-3x+15=-\tfrac13 x+\tfrac{17}{3}\;\Longrightarrow\;-\tfrac83 x=-\tfrac{28}{3}\;\Longrightarrow\;x=3.5,\quad y=-3(3.5)+15=4.5$$So the vertex is $V(3.5\,;\,4.5)$.
Mandatory check: compute all three distances, not just two.
$$VA=\sqrt{2.5^{2}+2.5^{2}}=3.54,\quad VB=\sqrt{3.5^{2}+0.5^{2}}=3.54,\quad VC=\sqrt{0.5^{2}+3.5^{2}}=3.54$$Three equal numbers confirm that $V$ is indeed the common vertex. If you only intersect two lines and skip this step, a small arithmetic slip in part (a) will go straight through to the final answer.
(c) Inside the triangle there is only one Voronoi vertex, so the dump goes at $V(3.5\,;\,4.5)$, $3.54$ km from each station. The circle centered at $V$ with radius $3.54$ passes through all three stations and is empty inside, so no point in the triangle is farther away than that.
Be careful to distinguish it from the centroid $\left(\dfrac{11}{3},\dfrac{14}{3}\right)\approx(3.67\,;\,4.67)$, which is the point often chosen by mistake. The distance from the centroid to $A$ is $3.80$ but to $B$ only $3.40$, so the nearest station is even closer than if placed at $V$. This problem maximizes the distance to the nearest station; it does not maximize the total distance.
Worked example: adjacency matrix and minimum spanning tree
Five villages $A$, $B$, $C$, $D$, $E$ are connected by roads with upgrade costs (unit: hundred million VND): $AB=6$, $AC=9$, $AD=12$, $BC=5$, $BD=8$, $BE=14$, $CD=7$, $CE=11$, $DE=4$.
(a) Use Kruskal's algorithm to find the minimum spanning tree and the total cost. (b) Explain why the solution must have exactly $4$ roads.
Solution
(a) Sort the edges by increasing weight: $DE=4$, $BC=5$, $AB=6$, $CD=7$, $BD=8$, $AC=9$, $CE=11$, $AD=12$, $BE=14$.
| Considered | DE (4) | BC (5) | AB (6) | CD (7) | BD (8) |
|---|---|---|---|---|---|
| Decision | accept | accept | accept | accept | reject |
| Reason | — | — | — | connects $E$ | creates a cycle |
After accepting $DE$, $BC$, $AB$ we have two components $\{D,E\}$ and $\{A,B,C\}$. The next edge is $CD=7$: it joins two different components so it can be accepted, and at this point all five villages are connected.
$$\text{Total}=4+5+6+7=22$$that is, $2.2$ billion VND. The edge $BD=8$ is rejected because $B$ and $D$ are by then already in the same component, and adding it would create the cycle $B\!-\!C\!-\!D\!-\!B$ without connecting any new village.
(b) A spanning tree on $n$ vertices always has exactly $n-1$ edges. With $n=5$ that is $4$. The reason: each edge accepted reduces the number of separate components by exactly one, starting from $5$ components and ending at $1$ component, so exactly $4$ edges must be accepted. Any fifth edge is certain to join two vertices that are already connected, that is, to create a cycle.
A common mistake is “take the cheapest edge at each vertex”; doing that usually gives $5$ edges and a cycle, with a total greater than $22$. It is the condition of creating no cycle that makes the algorithm, not the sorting by cost.