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.

Construction

MethodTimeNote
Flip algorithmstart anywhere, flip illegal edges until none remain
Bowyer-Watson expectedincremental; conceptually the simplest
Divide and conquer (Guibas-Stolfi) worst casequad-edge structure
Sweep line (Fortune)build Voronoi and dualise
Lift to 3D + convex hullthe 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 long and beyond double’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-tested boost::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

ProblemHow
Euclidean MSTDelaunay has edges and contains the EMST Kruskal on those
Closest pairthe shortest Delaunay edge
Nearest neighbour grapha subgraph
Largest empty circlecentred at a Voronoi vertex = a Delaunay circumcentre
Terrain / mesh generationmaximising the minimum angle avoids numerical trouble
Interpolation (natural neighbour)uses the Voronoi structure
Point locationwalk the triangulation

Euclidean MST, concretely

  1. Build the Delaunay triangulation, .
  2. Take its edges with Euclidean weights.
  3. Run Kruskal, .

Versus on the complete graph. For that is the difference between feasible and not.

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):

  1. Start with a super-triangle large enough to contain every input point.
  2. 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.
  3. At the end, delete every triangle touching a super-triangle vertex.

Delaunay construction methods compared

MethodTimeNotes
Bowyer-Watson expectedeasiest to understand
Divide and conquer (Guibas-Stolfi) worst casequad-edge structure
Sweep line (Fortune)see [[#Fortune, conceptually
Lift to 3D + convex hulllift ; the lower hull is the Delaunay triangulation
Flip algorithmstart 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

  1. Sweep a horizontal line downward across the plane.
  2. 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.
  3. 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).
  4. 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.
  5. 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.
  6. Continue until both queues are empty. The final beach line traces the diagram’s unbounded edges, completing the Voronoi diagram.

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:

QuantityValue
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.

Construction

MethodTimeNote
Half-plane intersection per cellsimple, fine for
Fortune’s sweepthe classic
Dual of Delaunaybuild Delaunay, then take the dual
Lift to 3D + convex hullelegant; 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

VoronoiDelaunay
cell (a site)vertex
edge (between 2 cells)edge
vertex (meeting of 3 cells)triangle
unbounded cella hull vertex
Voronoi vertex positionthe triangle’s circumcentre

What it answers

QueryVia Voronoi/Delaunay
Nearest site to a query pointpoint location in the Voronoi diagram,
Closest pairthe shortest Delaunay edge
Euclidean MSTa subgraph of Delaunay — run Kruskal on edges
Nearest neighbour grapha subgraph of Delaunay
Largest empty circlecentred at a Voronoi vertex (or on the hull boundary)
Farthest-point Voronoigives the minimum enclosing circle
All nearest neighboursone pass over Delaunay edges
Motion planning with maximum clearancetravel 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:

  1. Nearest-site queries a KD-tree is simpler and fast enough.
  2. Euclidean MST build Delaunay, then Kruskal.
  3. 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.