Voronoi Diagram Simulator: Interactive Spatial Partitioning

simulator intermediate ~10 min
Loading simulation...
20 Voronoi cells with Euclidean metric

20 seed points with standard Euclidean distance produce a Voronoi tessellation with approximately equal-area cells and 54 edges (3n − 6).

Formula

V(pᵢ) = {x : d(x, pᵢ) ≤ d(x, pⱼ) ∀j≠i} — Voronoi cell definition
d_p(x,y) = (Σ|xᵢ−yᵢ|^p)^(1/p) — Minkowski distance
E = 3n − 6, F = 2n − 4 — Euler relation for Voronoi

Partitioning Space by Proximity

Given a set of seed points scattered across a plane, the Voronoi diagram draws the boundaries of influence — every location is assigned to its nearest seed. The resulting cells tile the plane with convex polygons, their edges equidistant from neighboring seeds. This deceptively simple construction encodes deep geometric and topological relationships.

Distance Metrics Matter

The standard Voronoi diagram uses Euclidean distance (p=2), producing familiar polygonal cells. Switch to Manhattan distance (p=1) and cells become diamond-shaped; use Chebyshev distance (p=∞) and they become square. The Minkowski exponent parameter in this simulator lets you morph between these geometries continuously, revealing how the distance metric shapes spatial perception.

Lloyd Relaxation and CVT

Random seed placement creates irregular cells of wildly varying sizes. Lloyd's algorithm fixes this: compute the Voronoi diagram, move each seed to its cell's centroid, repeat. After several iterations, cells converge to nearly equal area — a centroidal Voronoi tessellation. This is equivalent to k-means clustering, connecting computational geometry to machine learning's most basic algorithm.

From Crystals to Cell Towers

Voronoi diagrams appear everywhere in nature and engineering. Crystal grain boundaries form Voronoi cells around nucleation points. Giraffe skin patterns follow Voronoi tessellations. Cell phone networks optimize tower placement using weighted Voronoi diagrams. And in robotics, Voronoi roadmaps provide collision-free navigation paths through obstacle fields.

FAQ

What is a Voronoi diagram?

A Voronoi diagram partitions space into regions (cells) such that every point in a cell is closer to its seed than to any other seed. Named after Georgy Voronoi (1908), these diagrams appear naturally in crystal growth, territorial animal behavior, cell biology, and wireless network coverage.

What is Lloyd relaxation?

Lloyd's algorithm repeatedly computes the Voronoi diagram, then moves each seed to its cell's centroid. This converges to a centroidal Voronoi tessellation (CVT) with nearly equal-area cells. It is equivalent to k-means clustering and is used in image stippling, mesh generation, and optimal quantization.

What is Fortune's algorithm?

Fortune's algorithm computes Voronoi diagrams in O(n log n) time using a sweep line and beach line data structure. As the sweep line moves across the plane, it maintains parabolic arcs that trace cell boundaries. It is the most efficient general-purpose algorithm for planar Voronoi computation.

How are Voronoi diagrams used in practice?

Applications include: nearest-facility location (hospitals, fire stations), wireless coverage optimization, mesh generation for finite elements, geographic territory analysis, protein structure analysis, and procedural texture generation in computer graphics.

Sources

Embed

<iframe src="https://homo-deus.com/lab/computational-geometry/voronoi-diagram/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub