• Keine Ergebnisse gefunden

5. Layout 29

5.4. Analytical method

5.4.2. The Fortune Algorithm

The Algorithm conceptually moves a sweep-line upwards across the plain. We keep in mind which regions and edges of the transformed Voronoi diagram V are intersected by the sweep-line. A region Rp appears the first time when the sweep-line reaches a point p of the region. Regions disappear when two edges intersect and thus close the region. The events where we have to stop the sweep-line are the sites in V and the vertices. The first kind of events are site events and the second kind of events are intersection events. The coordinates of the site events are already given by the coordinates of the sites. The coordinates of the intersection events have to be computed when two sites become neighbours the first time on the sweep-line.

Let Rp and Rq be two regions which are neighbours along the sweep-line. We also have that py < qy. In this case ∗p(Bpq) is a hyperbola with minimum at p.

For simplicity we call the monotonic decreasing part left from p of the hyperbola Cpq. The monotonic increasing part of the hyperbola, which is right from p is calledCpq+. Cpq andCpq+ are boundaries. If py =qy then∗p(Bpq) is an open vertical half-line. In this case Cpq =∅and Cpq+ =∗p(Bpq).

Cpq is a synonym for Cpq and Cpq+ and is used when it is not important which one or when it is clear from the context which one is meant.

Fortune assumes that there is a unique bottommost site when starting the al-gorithm. That is why he does not have to consider the initialisation of Q and L explicitly. This of course does not have to be like this, because there can be sev-eral sites which have the same bottommost coordinate. That is why the following initialisation step has to be done.

Initialization of Q and L: Let S = {p1, p2, ..., pn} be a set of sites. For i, j ∈ {1, ..., n} we have that pi < pj if i < j, where the lexicographical ordering for p, q ∈S is defined as

p < q ⇐⇒ (py < qy)∨(py =qy ∧px < qx). (5.28) Case 1 (p1)y <(p2)y : If (p1)y <(p2)y then the initialization is straight forward.

46 5 LAYOUT

Algorithm 4: Computation of V(s)

1

Input: Set S with n sites.

Output:V with its bisectors and vertices.

Data: Q: event queue with the events for the sweep-line. Event points are marked either as site events or intersection events. The ordering is lexicographically.

L: Sorted list data structure which stores the regions and boundaries ordered from left to right. L consists of a sequence (R1, C1, R2, ..., Rk1, Rk) with alternating regions of V and the corresponding boundaries. One region can be contained several times on L.

InitialiseQ and L

2 while Q not empty do

3 p← extract min(Q)

4 if p is a site event then

5 Find a region Rq on L which contains p

6 Create bisector Bpq

7 Replace Rq with Rq, Cpq, Rp, Cpq+, Rq

8 Delete the intersection between the left and right boundary of Rq if there is one in Q

9 Insert intersection of Cpq with its left and of Cpq+ with its right neighbour on L if there is one respectively.

10 else if p is intersection event then

11 Let p be the intersection of the boundaries Cqr and Crs 12 Create bisector Bqs

13 Replace the sequence Cqr, Rr, Crs with the boundary Cqs

14 Delete intersection of Cqr (Crs) with its left (right) neighbour on L from Q where applicable

15 Compute intersection points of Cqs its left and right neighbour on L and insert them into Q

16 Store p as a vertex of Bqr , Brs and Bqs

5.4 Analytical method 47

• initialize Q with S\p1

• initialize L with Rp

Case 2 (p1)y = (p2)y =· · ·= (pk)y : In this case we have to initialize the bisectors a bit differently. Note that 2 ≤k ≤n.

• create bisectors Bpipi+1 for i∈ {1, . . . , k−1}

• initialize Q with S\ {p1, . . . , pk}

• initialize L with

Rp1, Cp+1p2, Rp2, . . . , Rpk−1, Cpk−1pk, Rpk

Algorithm 4 even takes care of degenerated cases without explicitly handling them.

But by not handling them it can create edges with zero length. These edges can be removed on a post processing step, which does not influence the run-time complexity of the algorithm. Figure 5.12 shows two degenerate cases which are handled correctly. Figure 5.12a shows a cocircular arrangement of some sites which then causes zero-length edges.

Figure 5.12.: Two degenerate cases which are implicitly handled by the Fortune Algorithm. (a) cocircular sites which cause zero-length edges, (b) collinear sites

Theorem 5.12. Algorithm 4 can be implemented to run in time O(nlogn) and space O(n).

Proof. The while-loop is passed O(n) times, so there are at most O(n) bisectors generated. There will be no more than O(n) events in the Queue Q, at most two events for each boundary and one event for each vertex. Since the complexity of the bisectors is in O(n) this leads to O(n) events. The Operations needed for Q are: insert, delete and extract min. These operations can be implemented using the heap data structure [55] with time cost O(logn) per operation and storage cost O(n).

L can also contain at most O(n) entries. A new region on L can only appear through a site event and each site event can split exactly one region into at most two pieces. Thus we have O(n) regions and their corresponding boundaries on L. L needs the operations insert, delete, search and can be implemented using a binary balanced tree, e.g. an AVL-Tree [55], which has time cost O(logn) per operation and needs space O(n). We also think that a skip-list could fulfill the required guarantees. For more information on skip-lists we refer to [76].

48 5 LAYOUT For each while-loop we need O(logn) time, so in total we need O(nlogn) time and O(n) space.

Theorem 5.13. Algorithm 4 can be modified to directly compute V instead of V in time O(nlogn) and space O(n).

Proof. An edge is computed by first generating the corresponding bisector and later marking the endpoints of the edge. This operation can also be done with the untransformed bisectors and sites. The event queue contains site events and vertex events (intersection events). Site events are mapped to themselves. Vertex events represent intersections of bisectors. These intersections can also be computed by intersecting the untransformed bisectors and adding the distance to one of the two sites to the y-coordinate of the intersection point. L can also contain untransformed regions and boundaries which has to be considered when searching for a region. The sequence of untransformed regions and boundaries is not a line any more but a continuous sequence of hyperbola segments which change when the sweep-line moves on. This sequence is also called beach-line because it looks like waves on the beach. Note that the beach-line is not stored explicitly but has to be considered on the search operation of Algorithm 4 at line 5.

5.4.3. The Fortune-Algorithm for the weighted Voronoi