Delaunay
A triangulation of a point set in which no point lies inside the circumcircle of any triangle. It is the dual of the Voronoi diagram, and it is unique when no four points are concyclic.
Why it is the “right” triangulation
Among all triangulations of the same points, Delaunay:
- maximises the minimum angle (avoids skinny triangles) — and in fact maximises the whole sorted angle vector lexicographically;
- minimises the maximum circumcircle radius;
- contains the closest pair as an edge;
- contains the Euclidean minimum spanning tree as a subgraph;
- contains the nearest-neighbour graph as a subgraph.
The last two are the reasons it matters algorithmically.
Proof: Delaunay maximises the minimum angle, and contains the closest pair
Minimum angle. Consider two triangles sharing an edge , with opposite vertices forming a (possibly non-convex) quadrilateral. The Delaunay flip lemma: if is convex and is inside the circumcircle of (i.e. the diagonal is the “wrong” one), flipping to diagonal strictly increases the minimum of the six angles of the two triangles. This is a direct computation: the sum of the two angles at and (opposite the shared edge ) is when is inside circle (by the inscribed angle theorem — the locus where is exactly the circle through , and being inside makes the angle at larger, pushing the sum over), and swapping the diagonal is known to replace the two largest-angle-sum triangles with the configuration whose minimum angle is provably no smaller (a classical inequality on the six angles). Since any non-Delaunay triangulation has some edge violating the in-circle test, repeatedly flipping (each flip strictly increases the lexicographic angle vector, so there’s no cycling) terminates only at the Delaunay triangulation, which must therefore be a global — not just local — maximum of the minimum angle, since every other triangulation is connected to it by a sequence of flips, each non-decreasing the minimum angle.
Contains the closest pair. Suppose the closest pair is not an edge of some triangulation . Then the segment crosses some edge of , say , with on opposite sides. By the triangle inequality in the two triangles formed, either or or similar (one of the four “other” distances among is shorter than ) — contradicting that is the closest pair overall. So the closest pair must be an edge of every triangulation, Delaunay included.
Construction
| Method | Time | Note |
|---|---|---|
| Flip algorithm | start anywhere, flip illegal edges until none remain | |
| Bowyer-Watson | expected | incremental; conceptually the simplest |
| Divide and conquer (Guibas-Stolfi) | worst case | quad-edge structure |
| Sweep line (Fortune) | build Voronoi and dualise | |
| Lift to 3D + convex hull | the most elegant, and reuses [[19-geometry/19-3d-geometry |
The lifting map
Send onto the paraboloid. Then: the lower convex hull of the lifted points, projected back to the plane, is the Delaunay triangulation. A point is inside a circumcircle in 2D exactly when its lift is below the corresponding plane in 3D — so the in-circle predicate becomes an orientation test in 3D (proved in Primitives, via the same lifting argument). If you have a 3D hull routine, you get Delaunay for free, and it inherits the 3D hull’s exactness.
The in-circle predicate — the hard part
with counter-clockwise; positive means is strictly inside. (Proved via the paraboloid lifting in Primitives.)
This determinant is degree 4
With coordinates up to it reaches — far beyond
long longand beyonddouble’s 53-bit mantissa. Getting the sign wrong produces a non-triangulation, not a slightly wrong one.Options: restrict coordinates to and use
__int128; use exact rational or big-integer arithmetic; or use adaptive-precision predicates (Shewchuk). This is the single biggest obstacle to implementing Delaunay correctly — in practice it is also the single most common source of a subtly broken from-scratch implementation, which is why this note gives the algorithm and the predicate in full but does not publish a hand-rolled Bowyer-Watson or Fortune implementation as “tested code”: getting every degenerate case (near-cocircular points, collinear hull boundaries, duplicate points) exactly right needs the adaptive-precision machinery referenced above, and a version without it is a liability dressed up as a solution. If you need Delaunay in a contest, reach for a library implementation (e.g. a well-testedboost::polygon/ CGAL-style routine, or a vetted competitive-programming library snippet with its own stress-tested history) rather than deriving one under time pressure.
Uses
| Problem | How |
|---|---|
| Euclidean MST | Delaunay has edges and contains the EMST Kruskal on those |
| Closest pair | the shortest Delaunay edge |
| Nearest neighbour graph | a subgraph |
| Largest empty circle | centred at a Voronoi vertex = a Delaunay circumcentre |
| Terrain / mesh generation | maximising the minimum angle avoids numerical trouble |
| Interpolation (natural neighbour) | uses the Voronoi structure |
| Point location | walk the triangulation |
Euclidean MST, concretely
- Build the Delaunay triangulation, .
- Take its edges with Euclidean weights.
- Run Kruskal, .
Versus on the complete graph. For that is the difference between feasible and not.
Proof: the Delaunay triangulation contains the Euclidean MST
Let be an edge of the EMST, and suppose it is not a Delaunay edge. Then there exists a circle through with no other point inside it only if is Delaunay (an edge is Delaunay iff some empty circle passes through its two endpoints) — so if is not Delaunay, every circle through contains some other point inside it. Taking the circle with as diameter (the smallest such circle), inside it means , which implies (the side opposite the largest angle in a triangle is the longest; since is obtuse, it’s the triangle’s largest angle, so — opposite it — is the longest side, meaning both and are shorter than ). But then replacing edge in the MST with and (removing disconnects the tree into two components; is in one of them, say with , so adding reconnects with strictly smaller total weight than keeping and whichever of ‘s existing tree edges — more carefully, the standard cycle-property argument: being the maximum-weight edge on some cycle formed with a shorter path would contradict MST-optimality) contradicts minimality. So every EMST edge must be Delaunay.
Constrained Delaunay
Forces certain edges to appear (for meshing a polygon with fixed boundaries). The result is no longer strictly Delaunay — triangles may violate the empty-circle property, but only because of the forced edges.
3D and beyond
Delaunay tetrahedralisation exists in 3D but can have tetrahedra, and its construction is much harder. The lifting map still works (to 4D), and the in-sphere predicate has degree 5.
The contest reality
Full Delaunay implementations are long and precision-critical. Before writing one, check whether you actually need it:
- Euclidean MST with the complete graph is edges; just run Kruskal.
- Nearest neighbour queries a KD-tree.
- Closest pair the sweep.
- Largest empty circle enumerate candidate centres.
Delaunay earns its place at with a genuine Euclidean MST requirement.
Bowyer-Watson, conceptually
Build incrementally, expected with randomised insertion order ( worst case):
- Start with a super-triangle large enough to contain every input point.
- Insert points one at a time (in random order). For each new point :
- find all triangles whose circumcircle contains (the in-circle predicate above) — the “bad” triangles;
- their union is a star-shaped cavity; collect its boundary edges (edges belonging to exactly one bad triangle);
- delete the bad triangles, and create one new triangle from to each boundary edge.
- At the end, delete every triangle touching a super-triangle vertex.
Proof: Bowyer-Watson is correct
Invariant. After inserting a prefix of the points (plus the super-triangle), the current triangle set is exactly the Delaunay triangulation of those points (and the super-triangle’s vertices). Finding bad triangles. A triangle’s circumcircle containing the new point is exactly the condition that makes that triangle not Delaunay once is added (violating the empty-circle property) — so it must be removed. The cavity is star-shaped from . Because the bad triangles’ union is the set of points whose Delaunay-defining circumcircle is invalidated by , and circumcircles vary continuously across adjacent triangles sharing an edge, the bad region is connected and — crucially — every boundary edge of the cavity is visible from (no other bad-region geometry occludes it), which is what makes “connect directly to every boundary edge” produce a valid, non-self-intersecting retriangulation. Boundary edges via counting. An edge shared by two bad triangles is interior to the cavity and disappears; an edge belonging to exactly one bad triangle is on the cavity’s boundary — the standard “appears exactly once” trick (the same idea used for 3D hull’s horizon edges).
Delaunay construction methods compared
| Method | Time | Notes |
|---|---|---|
| Bowyer-Watson | expected | easiest to understand |
| Divide and conquer (Guibas-Stolfi) | worst case | quad-edge structure |
| Sweep line (Fortune) | see [[#Fortune, conceptually | |
| Lift to 3D + convex hull | lift ; the lower hull is the Delaunay triangulation | |
| Flip algorithm | start from any triangulation, flip illegal edges |
Fortune, conceptually
Constructs the Voronoi diagram of points in using a sweep line and a “beach line” of parabolic arcs — one of the most intricate standard algorithms in computational geometry to implement fully (hundreds of lines in a production-quality version), presented here for the technique and its correctness, not as code to hand-roll under contest time pressure (same caveat as the in-circle predicate above).
Algorithm
- Sweep a horizontal line downward across the plane.
- Maintain a beach line: an ordered sequence of parabolic arcs, where each arc is the set of points equidistant from one site and the sweep line.
- Maintain two event queues ordered by sweep position: site events (the line reaches a new point) and circle events (three consecutive arcs are about to converge to nothing).
- On a site event, find the arc directly above the new site, split it in two around a new zero-width arc for the site, and check the newly formed arc triples for potential circle events.
- On a circle event, the middle arc of the converging triple vanishes; its convergence point is a Voronoi vertex. Record the diagram edges meeting there, remove the arc, and check the newly adjacent arcs for fresh circle events.
- Continue until both queues are empty. The final beach line traces the diagram’s unbounded edges, completing the Voronoi diagram.
Proof: Fortune's algorithm is correct
Invariant. At sweep position , the beach line is exactly the lower envelope of parabolas focused at all already-processed sites with directrix at the sweep line — i.e. every point below the beach line is strictly closer to some processed site than to the sweep line, so its Voronoi cell assignment is already finalised and will never change (any site below the current sweep line, not yet processed, cannot be closer, since it’s farther from every point above the sweep line than the sweep line itself is).
Site events. When the sweep reaches a new site , the arc directly above belongs to the closest already-processed site at that -coordinate (by the invariant). Splitting that arc and inserting a zero-width arc for correctly extends the invariant to include .
Circle events. A Voronoi vertex is a point equidistant from three (or more) sites with no site closer. This occurs exactly when three consecutive beach-line arcs converge to a single point as the sweep advances — precisely the condition a circle event detects, since the circle through those three sites has its bottommost point exactly on the sweep line at that moment, with no other site inside it (by the beach-line invariant).
Completeness and termination. Each of the sites generates exactly one site event, and each Voronoi vertex corresponds to exactly one valid circle event (the circle through its three defining, mutually adjacent sites, empty of any other site — at most such vertices in a planar Voronoi diagram). Since every event either inserts, splits, or removes a bounded piece of beach-line structure, the queues hold total events and the algorithm terminates having constructed every edge and vertex exactly once.
Variants / Use Cases
- Delaunay triangulation — the dual graph of the Voronoi diagram, obtainable directly as a byproduct of Fortune’s sweep.
- Nearest-neighbour search / closest pair of points — Voronoi diagrams answer nearest-site queries directly.
- Weighted Voronoi diagrams — additively or multiplicatively weighted variants for uneven site “importance”.
- Higher-order Voronoi diagrams — generalisation to -th nearest neighbour regions.
Voronoi
Partition the plane by “which site is nearest”. The Voronoi cell of a site is
Each cell is a convex polygon (possibly unbounded) — the intersection of the half-planes defined by the perpendicular bisectors to every other site.
Structure
For sites in general position:
| Quantity | Value |
|---|---|
| Cells | |
| Edges | |
| Vertices | |
| Total complexity |
Voronoi vertices are circumcentres of triples of sites, and each is equidistant from three sites with no fourth inside that circle.
Proof: a Voronoi cell is a convex polygon, and the edge/vertex bounds
Convexity. , an intersection of half-planes (each “closer to than to ” region, bounded by the perpendicular bisector of ) — an intersection of convex sets (half-planes) is convex.
Complexity bounds. The Voronoi diagram’s edges and vertices are the dual of the Delaunay triangulation’s, which (as a planar graph) satisfies Euler’s formula ; a triangulation of points has at most interior triangles and edges (standard planar-graph bounds for a maximal planar graph, since each face other than the outer one is a triangle), and dualising maps Delaunay triangles to Voronoi vertices, giving the matching bounds on the Voronoi side.
Construction
| Method | Time | Note |
|---|---|---|
| Half-plane intersection per cell | simple, fine for | |
| Fortune’s sweep | the classic | |
| Dual of Delaunay | build Delaunay, then take the dual | |
| Lift to 3D + convex hull | elegant; via the paraboloid | |
| Divide and conquer |
Build Delaunay instead
The Voronoi diagram and the Delaunay triangulation are duals: a Voronoi edge separates two sites exactly when those sites are joined by a Delaunay edge. Delaunay is the one to build if you need the explicit structure — but see the precision caveat above before committing to a from-scratch implementation.
The duality in detail
| Voronoi | Delaunay |
|---|---|
| cell (a site) | vertex |
| edge (between 2 cells) | edge |
| vertex (meeting of 3 cells) | triangle |
| unbounded cell | a hull vertex |
| Voronoi vertex position | the triangle’s circumcentre |
What it answers
| Query | Via Voronoi/Delaunay |
|---|---|
| Nearest site to a query point | point location in the Voronoi diagram, |
| Closest pair | the shortest Delaunay edge |
| Euclidean MST | a subgraph of Delaunay — run Kruskal on edges |
| Nearest neighbour graph | a subgraph of Delaunay |
| Largest empty circle | centred at a Voronoi vertex (or on the hull boundary) |
| Farthest-point Voronoi | gives the minimum enclosing circle |
| All nearest neighbours | one pass over Delaunay edges |
| Motion planning with maximum clearance | travel along Voronoi edges |
The Euclidean MST reduction is the most valuable: it takes an complete-graph problem down to .
Variants
- Weighted (power) Voronoi — cells defined by ; still polygonal, dual to the regular triangulation.
- Multiplicatively weighted — cells bounded by Apollonius circles, no longer polygonal.
- Farthest-point Voronoi — “which site is farthest”; only hull vertices have non-empty cells.
- Order- Voronoi — regions with the same set of nearest sites.
- Voronoi under / — cells are still polygonal but with axis-parallel and diagonal edges.
- Voronoi of segments — cells bounded by parabolic arcs; substantially harder.
In competitive programming
Explicit Voronoi construction is rare — it is long, precision-sensitive, and usually avoidable. The three things worth knowing:
- Nearest-site queries a KD-tree is simpler and fast enough.
- Euclidean MST build Delaunay, then Kruskal.
- Largest empty circle its centre is a Voronoi vertex, a hull edge midpoint, or determined by the bounding region; enumerate the candidates.
For small , the per-cell half-plane intersection is entirely acceptable and far easier to get right.