Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Let S be a finite point set in ℝn. Since S is compact, for every point x∈ℝn there exists a closest point in S (which is not necessarily unique) with respect to the Euclidean norm ∥⋅∥. The set of all points in ℝn that have a fixed point sS as their nearest “neighbor” is a polyhedron. This mapping induces a decomposition of ℝn into polyhedral “regions”, the Voronoi diagram of S. Numerous applications of computational geometry begin with the computation of a Voronoi diagram.

We will first study the geometry of single Voronoi regions. To be able to discuss the arrangement of all Voronoi regions, we will introduce the general concept of a polyhedral complex. The main result of this chapter is the relationship between Voronoi diagrams and the convex hull problem from the previous chapter. We conclude the chapter by discussing an algorithm for the computation of Voronoi diagrams in the plane and its application to the post-office problem from the introduction.

1 Voronoi Regions

In this chapter, S⊆ℝn always denotes a finite point set in ℝn and ∥⋅∥ is the Euclidean norm. The Euclidean distance between two points x,y∈ℝn is denoted by

$$\operatorname {dist}(x,y) \mathrel {\mathop {:}}=\|x-y\| = \sqrt{ \langle x-y,x-y\rangle }. $$

For each point sS we define the Voronoi region

$$\operatorname {VR}_S(s) \mathrel {\mathop {:}}=\bigl\{x \in\mathbb{R}^n:\operatorname {dist}(x,s) \le \operatorname {dist}(x,q) \text{ for all } q \in S \bigr\} $$

as the set of points in ℝn for which s is the nearest point from S. In this case, s is called a nearest neighbor (with respect to S).

Example 6.1

We study the case where S={s,t}⊆ℝn consists of exactly two distinct points. The set

$$h(s,t) \mathrel {\mathop {:}}=\bigl\{x\in\mathbb{R}^n:\operatorname {dist}(x,s)=\operatorname {dist}(x,t) \bigr\} = \operatorname {VR}_{\{s,t\}}(s)\cap \operatorname {VR}_{\{s,t\}}(t) $$

consisting of those points which have both s and t as a nearest neighbor is an affine hyperplane: We have

which implies that x is contained in h(s,t) if and only if

$$ \Biggl(\sum_{i=1}^n \bigl(s_i^2-t_i^2 \bigr),2(t_1-s_1),\dots,2(t_n-s_n) \Biggr) (1,x_1,\dots,x_n)^T = 0 . $$
(6.1)

In other words, the set \(h(s,t)=\operatorname {VR}_{\{s,t\}}(s)\cap \operatorname {VR}_{\{s,t\}}(t)\) is precisely the affine hyperplane in ℝn which has the homogeneous coordinates

$$ \Biggl[\sum _{i=1}^n\bigl(s_i^2-t_i^2 \bigr):2(t_1-s_1):\dots:2(t_n-s_n) \Biggr] . $$
(6.2)

The Voronoi regions of s and t are the affine half-spaces which are defined by this hyperplane. We always define the orientation of h(s,t) as in (6.2). Thus, we have \(\operatorname {VR}_{\{s,t\}}(s)=h(s,t)^{-}\) and \(\operatorname {VR}_{\{s,t\}}(t)=h(s,t)^{+}\). The vectors st and ts are normal to the hyperplane h(s,t) which (weakly) separates the two Voronoi regions.

The above observations about Voronoi regions of a two-element point set lead to the following statement.

Proposition 6.2

Let S⊆ℝn be finite. For sS we have

$$\operatorname {VR}_S(s) = \bigcap_{t\in S\setminus\{s\}} \operatorname {VR}_{\{s,t\}}(s) = \bigcap_{t\in S\setminus\{s\}} h(s,t)^{-} . $$

In particular, each Voronoi region is a (not necessarily bounded) polyhedron with at most |S|−1 facets.

Exercise 6.3

Give conditions which imply that all Voronoi regions are pointed polyhedra.

Exercise 6.4

Show that a point sS lies on the boundary of the convex hull \(\operatorname {conv}S\) if and only if its Voronoi region \(\operatorname {VR}_{S}(s)\) is unbounded.

2 Polyhedral Complexes

We know from the previous section that the Voronoi regions of a finite point set in ℝn are polyhedra. By construction, it is clear that these polyhedra cover the whole space ℝn. However, this alone does not reveal all of the important structural properties of Voronoi regions.

Definition 6.5

A polyhedral complex \(\mathcal {C}\) is a finite set of polyhedra in ℝn which satisfies the following conditions.

  1. (a)

    \(\emptyset\in \mathcal {C}\);

  2. (b)

    If \(P \in \mathcal {C}\), then all faces of P are also contained in \(\mathcal {C}\);

  3. (c)

    The intersection PQ of two polyhedra \(P,Q \in \mathcal {C}\) is a (possibly empty) face of P and of Q.

The third condition is sometimes called the intersection condition. The elements of \(\mathcal {C}\) are called faces and the dimension of \(\mathcal {C}\) is the highest dimension of a face of \(\mathcal {C}\). A polyhedral complex whose faces are polytopes is called a polytopal complex. A simplicial complex is a polytopal complex whose faces are simplices.

For a polyhedral complex \(\mathcal {C}\) in ℝn let

$$|\mathcal {C}| \mathrel {\mathop {:}}=\bigcup_{F\in \mathcal {C}}F \subseteq \mathbb{R}^n $$

be the set covered by \(\mathcal {C}\). A polyhedral (respectively polytopal or simplicial) decomposition of a set M⊆ℝn is a polyhedral (respectively polytopal or simplicial) complex \(\mathcal {C}\) such that \(|\mathcal {C}|=M\). A simplicial decomposition is also called a triangulation.

Example 6.6

Let P⊆ℝn be an n-polyhedron. Then the face lattice \(\mathcal {F}(P)\) is an n-dimensional polyhedral complex. The set of all proper faces defines an (n−1)-dimensional polyhedral complex that covers the boundary ∂P. This second complex is called the boundary complex of P.

The faces of a polyhedral complex \(\mathcal {C}\) are partially ordered by inclusion; this is the face poset of \(\mathcal {C}\). This notion agrees with the face lattice of a polytope if we view that polytope as a trivial polytopal complex as in the previous example.

Let \(\mathcal {V}(S)\) be the set of all Voronoi regions of a finite set S⊆ℝn.

Theorem 6.7

The set \(\mathcal {V}(S)\) satisfies the intersection condition.

Proof

Let s,tS be two distinct points. We can assume that the intersection

$$F \mathrel {\mathop {:}}=\operatorname {VR}_S(s)\cap \operatorname {VR}_S(t) $$

is non-empty. Proposition 6.2 states that \(\operatorname {VR}_{S}(s)\subseteq h(s,t)^{-}\) and that \(\operatorname {VR}_{S}(t)\subseteq h(s,t)^{+}\). This implies that Fh(s,t)h(s,t)+=h(s,t). Since we assumed F≠∅, we know that h(s,t) is a supporting hyperplane of \(\operatorname {VR}_{S}(s)\) and also of \(\operatorname {VR}_{S}(t)\). Thus, \(F=\operatorname {VR}_{S}(s)\cap \operatorname {VR}_{S}(t)=\operatorname {VR}_{S}(s)\cap \operatorname {VR}_{S}(t)\cap h(s,t)\) is a non-empty face of both Voronoi regions. □

Every non-empty finite set \(\mathcal {C}\) of polyhedra in ℝn that satisfies the intersection condition generates a polyhedral complex

$$[\mathcal {C}] \mathrel {\mathop {:}}=\{F:F \text{ is the face of a polyhedron in } \mathcal {C}\} . $$

The previous theorem motivates the following definition.

Definition 6.8

The polyhedral complex

$$\operatorname {VD}(S) \mathrel {\mathop {:}}=\bigl[ \{\operatorname {VR}_S(s):s\in S \} \bigr] $$

is called the Voronoi diagram of a finite set S⊆ℝn.

The faces of a Voronoi diagram are called Voronoi cells. The Voronoi regions are the maximal Voronoi cells (with respect to inclusion or dimension). Figure 6.1 depicts an example of a Voronoi diagram of a point set in the plane.

Fig. 6.1
figure 1

The Voronoi diagram of a point set in the plane

Remark 6.9

The definition of f-vectors can be extended to arbitrary polyhedral complexes.

3 Voronoi Diagrams and Convex Hulls

As we will see in the following chapters, Voronoi diagrams play a key role in several applications. Many interesting algorithms, e.g., the curve reconstruction algorithm NN-Crust from Chapter 11 below, have the computation of a Voronoi diagram as their very first step. This motivates the questions of how a Voronoi diagram should be computed and what a suitable data structure would be for Voronoi diagrams.

A first observation is that convex hull algorithms are useful for the computation of Voronoi diagrams: Every region is given as a polyhedron in the \(\mathcal {H}\)-description. For m given points in ℝn we obtain, by computing m dual convex hulls in ℝn, a \(\mathcal {V}\)-description of all Voronoi regions. Regardless of the efficiency of this method, the main disadvantage of it is that it does not directly provide a description of the relative position of the different Voronoi regions to one another. The main result of this chapter is the statement that a Voronoi diagram in ℝn is a projection of an unbounded polyhedron in ℝn+1. Specifically, this reduces the construction of a Voronoi diagram to a single convex hull problem in ℝn+1.

To clarify the notation, we will embed ℝn in ℝn+1 by adding the coordinate x n+1. In particular, we will sometimes denote a point in ℝn+1 by (x,x n+1) for x∈ℝn and x n+1∈ℝ.

Let

$$ U \mathrel {\mathop {:}}=\bigl\{x \in\mathbb{R}^{n+1} :x_{n+1} = x_1^2 + x_2^2 + \cdots+ x_n^2 \bigr\} $$
(6.3)

be the standard paraboloid in ℝn+1. For a point p∈ℝn let T(p) denote the tangent hyperplane to the paraboloid U at p U  :=(p,∥p2).

Lemma 6.10

For every point p∈ℝn we have

$$T(p) = \bigl[-\|p\|^2 : 2p_1 : \dots: 2p_n : -1\bigr] . $$

Proof

We know from calculus that the tangent hyperplane to the graph of a differentiable function u:ℝn→ℝ at a point (p,u(p)) can be described by the linear equation

$$x_{n+1} = u(p) + \bigl\langle u'(p), x-p\bigr\rangle $$

(see, e.g., [73]). In our case, we have \(u(p) = p_{1}^{2} + p_{2}^{2} + \dots+ p_{n}^{2}=\|p\|^{2}\), and thus the gradient satisfies u′(p)=(2p 1,…,2p n )=2p. Substituting yields

$$x_{n+1} = \|p\|^2+\langle2p,x-p\rangle = -\|p \|^2 + 2\langle p,x\rangle, $$

and thus we obtain the desired representation of the tangent hyperplane in homogeneous coordinates. □

In the following, we imagine that the x n+1-direction of the coordinate system points vertically upwards.

Lemma 6.11

Let p,x∈ℝn and x U =(x,∥x2) be the point lying above x on U. Then x U lies above T(p), i.e., in the affine half-space T(p)+ with respect to the homogeneous coordinates from Lemma 6.10. The vertical distance from x U to T(p) isxp2.

Proof

The x n+1-coordinate of x U is \(\sum_{i=1}^{n} x_{i}^{2}\), and by Lemma 6.10 the x n+1-coordinate of the point on the hyperplane T(p) above x is

$$2 p_1 x_1 + \cdots+ 2 p_n x_n - p_1^2 - \cdots- p_n^2 . $$

The distance from x U to T(p) is (x 1p 1)2+⋯+(x n p n )2=∥xp2. Figure 6.2 illustrates this computation.

Fig. 6.2
figure 2

The distance computation for n=1. Due to the rotation invariance of U, the 2-dimensional figure suggests the proper intuition for higher dimensions. Here, we have δ=∥xp

 □

Let S be an m-element subset of ℝn. For a point sS we have that T(s)+ is the affine half-space above the tangent hyperplane at U.

Due to the monotonicity of the function δδ 2 on the positive half-line, we can interpret Proposition 6.2 using Lemma 6.11 in the following way: A point x∈ℝn is contained in the Voronoi region \(\operatorname {VR}_{S}(s)\) if and only if for all T(t), where tS, the hyperplane T(s) is the one that has the smallest vertical distance from the point x U . This implies the following statement; see Fig. 6.3.

Fig. 6.3
figure 3

A Voronoi diagram obtained by an orthogonal projection

Theorem 6.12

The Voronoi diagram of S is the orthogonal projection of the boundary complex of the polyhedron \(\operatorname {\mathcal {P}}(S)\mathrel {\mathop {:}}=\bigcap_{s \in S} T(s)^{+}\) to the hyperplane x n+1=0.

Corollary 6.13

The total number of cells of a Voronoi diagram of an m-element point set inn is of order O(m n/2⌉).

Proof

The total number of cells of a Voronoi diagram can be bounded by the maximal number of faces of an \(\mathcal {H}\)-polyhedron with m facets in ℝn+1. The dual version of the asymptotic Upper-bound Theorem, Theorem 3.46, therefore implies that the total number of faces is of order O(m n/2⌉), since ⌊(n+1)/2⌋=⌈n/2⌉. □

Theorem 6.12 specifically states that the space is partitioned by the relative interior of the cells of \(\operatorname {VD}(S)\). For an arbitrary point x∈ℝn let

$$ \mathbb{B}_S(x) \mathrel {\mathop {:}}=\bigl\{y\in \mathbb{R}^n:\operatorname {dist}(x,y)<\operatorname {dist}(x,s)\text{ for all $s\in S$} \bigr\} $$
(6.4)

be the largest open ball with center x which does not contain a point of S. Furthermore, let

$$S(x) \mathrel {\mathop {:}}=\partial\mathbb{B}_S(x)\cap S . $$

Theorem 6.14

The uniquely determined relatively open cell of  \(\operatorname {VD}(S)\) that contains a given point x∈ℝn has dimension \(n-\dim \operatorname {aff}S(x)\).

Proof

The point x is contained in a relatively open k-cell C of \(\operatorname {VD}(S)\) if and only if there exists a series of facets F 1,…,F nk+1 of the polyhedron ⋂ sS T(s)+ for which:

$$ G_1 \supsetneq G_2 \supsetneq \dots\supsetneq G_{n-k+1} =: G , $$
(6.5)

where G i  :=F 1∩…∩F i and C is the orthogonal projection of G to ℝn; see Exercise 3.59. The decreasing chain condition in (6.5) is satisfied for the facets F 1,…,F nk+1 if and only if G=F 1∩…∩F nk+1 is non-empty and the normals of the facets are linearly independent.

By Lemma 6.10 we have that (2s 1,…,2s n ,−1)T is a normal vector to the facet T(s) for sS. Therefore, the normal vectors to the facets corresponding to a subset S′⊆S are linearly independent if and only if the points of S′ are affinely independent. Altogether, this proves the statement. □

In the next section we will focus on the planar case n=2. Therefore, we are interested in the following special cases of Theorem 6.14.

Corollary 6.15

Let S⊆ℝ2 be finite.

  1. (a)

    A point x∈ℝ2 is a vertex of the Voronoi diagram \(\operatorname {VD}(S)\) if and only if S(x) contains at least three points.

  2. (b)

    A point x∈ℝ2 lies in the relative interior of an edge of \(\operatorname {VD}(S)\) if and only if S(x) consists of exactly two points.

For a vertex x of the Voronoi diagram \(\operatorname {VD}(S)\) we call the ball \(\mathbb{B}_{S}(x)\) from (6.4) the Voronoi disk around x. The boundary \(\partial\mathbb{B}_{S}(x)\) is called the Voronoi circle.

Exercise 6.16

Show that if every (n+2)-element subset of S⊆ℝn does not lie on a common (n−1)-sphere, then the lifted polyhedron is simple and therefore every Voronoi region is simple.

If this condition is satisfied, we say that the points in S are in general position. Note that we defined “general position” slightly differently in Chapter 3 and in Section 5.3; the term is always dependent on the context.

4 The Beach Line Algorithm

As in the computation of convex hulls in Section 5.3, there exist special algorithms for the computation of Voronoi diagrams in the planar case. We introduce here an algorithm due to Fortune [42]. First, we discuss the geometric idea, and then approach the question of determining its complexity. In this particular case, the complexity depends significantly on the data structures employed. With respect to this property, this algorithm is an exception within this text.

Fortune’s beach line algorithm is a so-called sweep line method. The idea is to construct the Voronoi diagram of a finite point set S⊆ℝ2 step-by-step. Here, we can imagine the vertical axis as a time-scale that is traversed from top to bottom. In this interpretation, at a certain time τ only a part of the Voronoi diagram has been revealed by the algorithm. For a point s from the input set S we then have that s is known at time τ if s 2τ. The horizontal line H τ =[−τ:0:1] is the sweep line for time τ and the affine half-space [−τ:0:1]+ contains the previously detected points from S. The next natural question is which part of the Voronoi diagram is actually known at time τ.

The set of points in ℝ2 that have the same distance from a point p and a (non-incident) line G is a parabola, which we denote here by \(\operatorname {Par}(p,G)\) (see Exercise 6.18 below). For every point sS with s 2>τ which is known at time τ, all points which are closer to s than to any possible unknown point of S lie above the parabola \(\operatorname {Par}(s,H_{t})\). The term “above” makes sense here since the symmetry axis of \(\operatorname {Par}(s,H_{\tau})\) is parallel to the vertical axis. The time τ is called generic if H τ S=∅. If we denote the points on or above the parabola by \(\operatorname {Par}(s,H_{\tau})^{+}\), then, according to our notation for affine half-spaces, we get the following lemma.

Lemma 6.17

The part of the Voronoi diagram which is known at time τ is contained in the set

$$\bigcup_{s\in S} \operatorname {Par}(s,H_{\tau})^{+} $$

for each generic time τ∈ℝ.

If τ is generic, the set \(\bigcup_{s\in S} \operatorname {Par}(s,H_{\tau})^{+}\) is homeomorphic to an affine half-space. Its boundary B τ is a union of parabolic arcs that resembles the appearance of waves approaching a beach; see Fig. 6.4. This is the reason why the boundary curve is called the “beach line”, and this term gives the algorithm its name. Note that each vertical line intersects the beach line B τ in exactly one point; this property is inherited from the individual parabolas.

Fig. 6.4
figure 4

Eight snapshots of the beach line algorithm

Exercise 6.18

Determine a parametrization of the parabola \(\operatorname {Par}(s,H_{\tau})\) for a given s and τ∈ℝ. That is, search for a,b,c∈ℝ such that

$$\operatorname {Par}(s,H_{\tau}) = \biggl\{ \begin{pmatrix}{x}\\ {ax^2+bx+c} \end{pmatrix} :x\in\mathbb{R} \biggr\} , $$

subject to the condition that s 2>τ.

A point sS with the property that \(\operatorname {Par}(s,H_{\tau})\) is part of the beach line is said to be active at time τ.

Now we briefly discuss what happens at a non-generic time τ. For sufficiently small ϵ>0 we have that τϵ is a generic time. The smaller ϵ is, the steeper the parabola \(\operatorname {Par}(s,H_{\tau -\epsilon})\) will be. This is rigorously formulated in the following exercise.

Exercise 6.19

Let s=(s 1,s 2)TS be a point with τ=s 2. Show that

$$\lim_{\epsilon\to0^{+}}\operatorname {Par}(s,H_{\tau-\epsilon}) = \biggl\{ \begin{pmatrix}{s_1}\\ {\sigma} \end{pmatrix} \in\mathbb{R}^2:\sigma\ge s_2 \biggr\} . $$

Here, we mean convergence with respect to the Hausdorff metric. How is it possible to use this to define the beach line for non-generic times? [Hint: Look at Snapshot 2 in Fig. 6.4.]

Lemma 6.20

If τ is generic, then each parabolic arc in \(\operatorname {Par}(s,H_{\tau})\cap B_{\tau}\), for sS, is contained in the corresponding Voronoi region \(\operatorname {VR}_{S}(s)\).

The set \(\operatorname {Par}(s,H_{\tau})\cap B_{\tau}\) may consist of several parabolic arcs, e.g., snapshot 2 in Fig. 6.4. Here the parabolic arc for b is divided as soon as the point d becomes known, i.e., at time d 2.

Proof

For \(x\in \operatorname {Par}(s,H_{\tau})\cap B_{\tau}\) let \(\delta \mathrel {\mathop {:}}=\operatorname {dist}(x,s)=\operatorname {dist}(x,H_{\tau})\) and assume \(x\not\in \operatorname {VR}_{S}(s)\). By Corollary 6.15 the open disk B around x with radius δ contains a point rS. Since \(B\subseteq H_{\tau}^{+}\), we have that r is known at time τ. But x is above the parabola \(\operatorname {Par}(r,H_{\tau})\), which contradicts x being contained in the beach line B τ . □

The next question is to determine how the beach line changes as the time τ changes (in the direction of smaller values). Here, of course, the relevant times are those when a certain point s=(s 1,s 2)TS is first detected; see Snapshot 2 in Fig. 6.4. This time s 2 will be called a point event. It is a consequence of Lemma 6.20, and of the convexity of the Voronoi regions, that new parabolic arcs can only arise at point events; the beach line cannot be pierced from behind by a parabola. For a generic τ we have that, by construction, the beach line has only finitely many points where it is not differentiable, since it is the union of finitely many parabolic arcs; these points are called breakpoints.

Lemma 6.21

If τ is generic then every breakpoint of B τ lies on an edge of the Voronoi diagram.

Proof

Let x be a breakpoint of the beach line B τ at time τ. Then there exist two active points r,sS with \(x\in \operatorname {Par}(r,H_{\tau} )\cap \operatorname {Par}(s,H_{\tau})\) and the statement follows from Lemma 6.20. □

We assume that the vertical line [−s 1:1:0] through s intersects the beach line \(B_{s_{2}}\) at a point x which is contained in a unique parabolic arc \(\operatorname {Par}(r,H_{s_{2}})\); here rS is an active point. By construction we have that \(x\in \operatorname {VR}_{S}(r)\cap \operatorname {VR}_{S}(s)\) and \(\operatorname {VR}_{S}(r)\cap \operatorname {VR}_{S}(s)\) is an edge of the Voronoi diagram; this edge is detected (partly) for the first time at time s 2. For a sufficiently small ϵ>0, a part of the parabola \(\operatorname {Par}(s,H_{s_{2}-\epsilon})\) lies on the beach line, say with the breakpoints x and y. Then, the segment [x,y] is the intersection of the Voronoi edge \(\operatorname {VR}_{S}(r)\cap \operatorname {VR}_{S}(s)\) and the set above the beach line. Thus, new edges are discovered at point events.

By Corollary 6.15, every vertex v of \(\operatorname {VR}(S)\) lies on a circle through at least three points of S. The point in time at which a circle through at least three points from S is detected is called a circle event. In other words, we have a circle event at time τ if the sweep line H τ is the lower tangent to a circle through at least three points of S. By Corollary 6.15 only those circle events create vertices whose circular disks have no points of S in their interior.

Now we can examine how a parabolic arc γ vanishes from the beach line. Let γ′ and γ″ be, respectively, the left and the right neighbor of γ in the beach line. Let s,s′,s″∈S be the points corresponding to these three parabolic arcs. We assume now that the parabolic arc γ vanishes at time τ. At the slightly later generic point in time τϵ, γ′ and γ″ are neighbors in the beach line. Hence, by Lemma 6.21, we know that the Voronoi regions \(\operatorname {VR}_{S}(s')\) and \(\operatorname {VR}_{S}(s'')\) are neighbors in \(\operatorname {VD}(S)\). At time τ, γ contracts to a point v. By construction, we have that \(\delta \mathrel {\mathop {:}}=\operatorname {dist}(v,s)=\operatorname {dist}(v,s')=\operatorname {dist}(v,s'')\) and that v is a Voronoi vertex. Also, the distance between v and the sweep line is δ at time τ. This means that τ is a circle event for the triple of points (s,s′,s″). This is illustrated in Snapshots 4 and 7 in Fig. 6.4.

Exercise 6.22

Show that there are at most 2|S|−2 breakpoints in the beach line B τ for a generic time τ.

Data Structures

The way in which geometric data is stored is crucial for the run-time analysis of the beach line algorithm. Here we only outline the most important ideas and refer the reader to the original work of Fortune [42], and to the books [31] and [71], for more details of the implementation.

First, we have to decide in which way we want to store the output, i.e., the Voronoi diagram of a point set in the plane. One special feature of the planar case is that we can restrict ourselves to the Voronoi edges. Every Voronoi region is a (not necessarily bounded) polygon whose edges can be cyclically ordered. Every edge is contained in exactly two regions. Therefore, if we store each edge twice with its vertices and orientation, then the regions are implicitly given by the sequence of their edges. Thus, each oriented edge stands for an incident pair of a Voronoi edge and a Voronoi region, and the Voronoi vertices are implicitly given as the endpoints of the edges.

Depending on the specific construction of the data structure, it can be problematic that some Voronoi regions are unbounded, and thus the cyclic sequence of edges does not form a complete circle. However, this can be easily addressed by using the ideal points of lines on which the unbounded edges lie as artificial Voronoi vertices. These ideal points can then be connected by artificial Voronoi edges on the ideal line so that every Voronoi region can be represented as a closed circle of (original or artificial) Voronoi edges.

In practical applications, it is common to use points on a sufficiently large bounding box, rather than artificial Voronoi vertices on the ideal line. This bounding box should be large enough to contain all points of S and all vertices of \(\operatorname {VD}(S)\).

The data structure itself is then a doubly linked list of oriented edges, which are also called half-edges, such that each edge is stored with its two endpoints and with a reference to the next half-edge in the cyclic order. Furthermore, we store a reference to the parallel half-edge, i.e., the same edge with the opposite orientation. This data structure is also known as the half-edge data structure. We refer to [27, §10.2] for the implementation of doubly linked lists.

Note also that the half-edge data structure is useful for storing arbitrary planar graphs and arbitrary cell decompositions of oriented surfaces.

Before we study the beach line algorithm in detail, we have to determine a suitable way in which to code the beach line itself. Here, it is not necessary to trace the exact trajectory of each parabolic arc. We need only store the combinatorial information, i.e., the number of parabolic arcs in the beach line, the points of S to which they correspond, and the order in which they occur.

Example 6.23

The beach line from Fig. 6.5 can be coded, for example, by the ordered sequence of points (s (1),s (2),s (3),s (4),s (5)) and the breakpoints correspond to neighboring pairs of points.

Fig. 6.5
figure 5

A beach line consisting of five parabolic arcs and a representation as a search tree

Some points can occur multiple times. For example, we see that the beach line in Snapshot 2 of Fig. 6.4, which appears shortly after a point event, can be written as (a,c,a,b,d,b).

However, coding the beach line as an ordered list is not beneficial for the run-time complexity. It is better to use a binary search tree. The leaves of this search tree contain points from S that each correspond to one parabolic arc on the beach line. An interior vertex stands for a breakpoint (r,s) if r is the biggest leaf in the left subtree, and s the smallest in the right subtree; see Fig. 6.5. In particular, we have that here, in contrast to the list description, the breakpoints are explicitly represented.

For further details on the implementation of the search tree representation of the beach line, we refer to the book [31]. General binary search trees are described in [27, §12].

The search tree structure of the beach line is not sufficient to guarantee a good run-time of the algorithm. We also need the height of the search tree to be of size O(logm), where m=|S|, at every step of the algorithm. A search tree with this property is said to be balanced. Note that the coding length of the beach line, i.e., the number of parabolic arcs and breakpoints, is linear in m; see Exercise 6.22. Hence, it is possible to add or delete parabolic arcs in O(logm) time.

Various concepts are associated with the balance of search trees, for example, the so-called “red black trees” [27, §13].

Lastly, we need to establish a data structure for the point and circle events. An important aspect here is the (time-wise) order, which would suggest a list, or a search tree as a suitable representation. However, here it is crucial to immediately see the next event at every step, without having to perform a search. Therefore, a search tree is not suitable. It is also important to be able to quickly add new events at the right position in the sorted order. Thus, a list is also not suitable. The solution is a heap, which allows us to immediately see the next event (i.e., in constant time), and to delete this event after processing it in logarithmic time. Furthermore, we need to be able to guarantee that arbitrary new events can be added in O(logm) time. An example of a suitable data structure is a binomial heap [27, §19].

4.1 The Algorithm

Using the data structures described above, we can now detail the actual algorithm. Let \(\mathcal {B}\) be a balanced search tree that represents the beach line. The queue Q stores unprocessed events, which are listed in order of their appearance. Every event in the queue Q is represented by point coordinates. The sweep line is only implicitly represented by the next event at a given time.

The order defined by the queue, and thus the heap structure, corresponds precisely to the ordering of the events by their y-coordinate. Since the sweep line is moving from top to bottom, points with a large y-coordinate represent early events. Here, a point event corresponding to sS is coded by the point s itself. A circle event is represented by the lowest point of the circle; when the sweep line reaches the lowest point of the circle, the whole circular disk is visible.

For a correct implementation it is crucial that the events in Q are not stored in an isolated way. It is necessary to be able to distinguish between point and circle events. Moreover, it is also useful that a point that represents a circle event also refers to the points of S that define the circle. There are a few additional references of this kind between the data structures \(\mathcal {B}\) and Q, but we restrict ourselves to the presentation of the crucial ideas. We mainly ignore the processing of the actual Voronoi diagram in the half-edge model in our pseudo-code. This has the consequence that Algorithm 6.1 lists \(\operatorname {VD}(S)\) as output, but we never state a return value in the code.

Algorithm 6.1
figure 6

The beach line algorithm

For our analysis, we first assume that the points in S are in general position, i.e., at most three on one circle at a time. The case where this condition is not satisfied is discussed at the end of this section.

Before we discuss the two subroutines to process point and circle events on p. 95, we will estimate the complexity of the steps of the main program. Initializing the heap Q has time complexity O(mlogm) (this can be reduced to O(m) when a suitable implementation is used), since there are exactly m point events. Estimating the number of possible circle events is more difficult, since there may be circle events that do not lead to Voronoi vertices. An analysis of Steps 10 to 12 of the subroutine Handle-Point-Event shows that every Voronoi edge can trigger at most two (potential) circle events. Therefore, by Corollary 6.13, there are at most O(m) events in total; Steps 3 to 8 in Algorithm 6.1 are hence performed at most O(m) times. If Q is realized as a binomial heap, it takes O(logm) time to delete an event from Q. We will show below that each point and each circle event only requires logarithmic time. This implies that the total time complexity of the beach line algorithm is O(mlogm).

Every parabolic arc γ is implicitly coded in the search tree \(\mathcal {B}\) as a triple [(r,s),s,(s,t)], where r,s,tS are as in Fig. 6.5. The pairs of points (r,s) and (s,t) represent the breakpoints that bound the parabolic arc. In particular, we have that the parabolic arc on the left side of γ corresponds to r and the one on the right corresponds to t.

When checking the correctness of this subroutine, note that each circle event is matched to the lowest point of the corresponding Voronoi circle. Therefore, the point events that correspond to points on a Voronoi circle, i.e., that trigger a circle event, are always correctly processed at a time prior to the circle event. This is also true for the special case where the third point of S on a Voronoi circle is simultaneously the lowest point, i.e., when a circle event and the corresponding point event occur at the same time. In this case, the following occurs: the parabolic arc corresponding to the lowest point is generated and immediately afterwards deleted by the simultaneously occurring circle event. In particular, Algorithm 6.1 always begins with at least three point events before the first circle event can occur.

Simultaneously occurring point events can be processed in arbitrary order. The same is true for simultaneously occurring circle events, since we assumed the points to be in general position. Thus, two circle events may occur at the same time, but at different places. Simultaneous point and circle events that are unrelated do not pose a problem. The only critical case, i.e., when a circle event is triggered by a simultaneous point event, was discussed above.

Step 3 in Handle-Circle-Event can be seen as the reverse of Step 8 in Handle-Point-Event. There, only those parabolic arcs are deleted which were previously generated by a point event. Step 11 of Handle-Point-Event can also trigger redundant circle events, but these are detected and deleted in Step 4 of Handle-Circle-Event.

figure a
figure b

Example 6.24

We want to show how the point event illustrated in Snapshot 2 in Fig. 6.4 affects the event queue Q. Before the point event corresponding to the point d is processed, the queue contains three point events and one circle event:

$$Q = \bigl(d,(a,b,c),e,f\bigr) . $$

The point event d triggers two new circle events. After this, at the generic time τ=d 2ϵ, we have:

$$Q = \bigl((a,b,d),(a,c,d),e,f \bigr) . $$

Later, the two circle events (a,b,d) and (a,c,d) will generate Voronoi vertices. The circle event (a,b,c) vanishes at time d 2 (Handle-Point-Event, Step 7), since we then know that d is contained in the circumcircle of a, b and c.

It remains to be discussed what occurs when the points in S are not in general position. It is perhaps surprising that our algorithm works here with only a few modifications. Actually, we have that the beach line algorithm produces a valid Voronoi diagram that may contain some edges of length 0. It is simple to detect and delete these edges in linear time after the algorithm has terminated.

5 Determining the Nearest Neighbor

We now discuss the problem of finding the nearest neighbor, or the nearest post office respectively, which we mentioned in the introduction. Given a finite point set S⊆ℝ2 and a point p∈ℝ2, we want to determine the point sS which minimizes \(\operatorname {dist}(p,s)\). This problem has, of course, a very simple solution, i.e., we can compare each distance from p to every point of S. If S consists of m points, this method needs O(m) steps.

But, when the configuration of the point set S is always the same and only the point p changes with each call, a different approach may be better. If we expect many calls, it pays off to invest more time in the beginning to be able to process each later call more quickly. In the following, let m be the cardinality of S.

Our goal is to describe a data structure that enables the answer of each call in logarithmic time. To do this, we compute the Voronoi diagram of S using Fortune’s beach line algorithm in O(mlogm) steps.

Then, we draw a vertical line through each Voronoi vertex as depicted in Fig. 6.6. These additional lines divide the Voronoi diagram into triangles and trapezoids, and into unbounded polyhedra in the outer regions. These vertical layers are ordered from left to right. If these are stored in a balanced search tree, we can detect the layer of each point p∈ℝ2 via its first coordinate p 1 in O(logm) time.

Fig. 6.6
figure 7

Vertical layers in the Voronoi diagram for answering the nearest neighbor problem

By construction we can guarantee that no vertical layer contains a vertex in its interior, so that all Voronoi edges are vertically ordered within each layer. If we also store the edges in each layer in a balanced search tree, we can detect the pair of edges that lies directly above and below p in O(logm) steps using the second coordinate p 2.

Theorem 6.25

For an m-element point set S⊆ℝ2 it is possible to generate a data structure in O(m 2logm) time such that the solution to the nearest neighbor problem in S can be found in O(logm) time.

Proof

It is possible to compute the Voronoi diagram \(\operatorname {VD}(S)\) in O(mlogm) time. Since there exist linearly many Voronoi vertices, there exist linearly many vertical layers. In each layer there are at most linearly many edges. In total, we have to initialize O(m) balanced search trees each with O(m) vertices. □

6 Exercises

Exercise 6.26

Let S be the vertex set of the n-dimensional cross-polytope. Determine the f-vector of the Voronoi diagram \(\operatorname {VD}(S)\).

Exercise 6.27

Let e (1),…,e (n) denote the standard basis vectors of ℝn. The vertices of the standard cube [0,1]n are precisely the sums of pairwise distinct standard basis vectors. Show that the n! simplices

$$\varDelta(\sigma) \mathrel {\mathop {:}}=\operatorname {conv}\bigl\{0,e^{(\sigma(1))},e^{(\sigma(1))}+e^{(\sigma(2))}, \dots ,e^{(\sigma(1))}+e^{(\sigma(2))}+\dots+e^{(\sigma(n))}\bigr\} $$

generate a triangulation of [0,1]n, where σ runs through all elements of the symmetric group \(\operatorname {Sym}\{1,\dots,n\}\). Show that every simplex Δ(σ) has the same volume (i.e., 1/n!).

Exercise 6.28

Let m∈ℕ be arbitrary. Describe an m-element point set in ℝ2 (in general position) for which the beach line algorithm first treats all point events and then all circle events.

7 Remarks

Voronoi diagrams have appeared independently over the last few centuries in different scientific disciplines. Their methodical usage in mathematics can be traced back to Dirichlet (1850) and Voronoi (1908), who used the diagrams to study quadratic forms. The presentation of a Voronoi diagram can be found as early as in Descartes’ (1644) work on visualizing the mass distribution in our solar system.

Detailed discussions of this topic can be found in the books of Edelsbrunner [38], Boissonat and Yvinec [15] and de Berg et al. [31].

polymake computations with Voronoi diagrams will be explained in Section 7.6 below. CGAL offers a variety of methods to compute Voronoi diagrams and their generalizations, including the beach line algorithm.