• Nenhum resultado encontrado

number of individual rebucketing operations will not be larger by more than a constant factor. The reason is that (as argued above) each new insertion only results in a constant number of edge flips, and hence the number of individual rebucketings per insertion is also a constant. But a careful proof should consider this. Such a proof is given in our text book.

Thecombinatorial complexityof an arrangement is the total number of vertices, edges, and faces in the arrange-ment. The following shows that all of these quantities areO(n2).

Theorem: Give a set ofnlinesLin the plane in general position, (i) the number of vertices inA(L)is¡n

2

¢, (ii) the number of edges inA(L)isn2, and (iii) the number of faces inA(L)is¡n

2

¢+n+ 1.

Proof: The fact that the number of vertices is¡n

2

¢is clear from the fact that each pair of lines intersects in a single point. To prove that the number of edges isn2, we use induction. The basis case is trivial (1 line and 1 edge). When we add a new line to an arrangement ofn−1lines (having(n1)2edges by the induction hypothesis) we splitn−1existing edges, thus creatingn−1new edges, and we addnnew edges from then−1intersections with the new line. This gives a total of(n1)2+ (n1) +n=n2. The number of faces comes from Euler’s formula,v−e+f = 2(with the little trick that we need to create one extra vertex to attach all the unbounded edges to).

Incremental Construction: Arrangements are used for solving many problems in computational geometry. But in order to use arrangements, we first must be able to construct arrangements. We will present a simple incremental algorithm, which builds an arrangement by adding lines one at a time. Unlike most of the other incremental algorithms we have seen so far, this one is not randomized. Its asymptotic running time will be the same, O(n2), no matter what order we insert the lines. This is asymptotically optimal, since this is the size of the arrangement. The algorithm will also requireO(n2), since this is the amount of storage needed to store the final result. (Later we will consider the question of whether it is possible to traverse an arrangement without actually building it.)

As usual, we will assume that the arrangement is represented in any reasonable data structure for planar graphs, a DCEL for example. LetL ={`1, `2, . . . , `n}denote the lines. We will simply add lines one by one to the arrangement. (The order does not matter.) We will show that thei-th line can be inserted inO(i)time. If we sum overi, this will giveO(n2)total time.

Suppose that the firsti−1lines have already been added, and consider the effort involved in adding`i. Recall our assumption that the arrangement is assumed to lie within a large bounding box. Since each line intersects this box twice, the firsti−1lines have subdivided the boundary of the box into2(i1)edges. We determine where`i intersects the box, and which of these edge it crosses intersects. This will tell us which face of the arrangement`ifirst enters.

Next we trace the line through the arrangement, from one face to the next. Whenever we enter a face, the main question is where does the line exit the face? We answer the question by a very simple strategy. We walk along the edges face, say in a counterclockwise direction (recall that a DCEL allows us to do this) and as we visit each edge we ask whether`iintersects this edge. When we find the edge through which`iexits the face, we jump to the face on the other side of this edge (again the DCEL supports this) and continue the trace. This is illustrated in the figure below.

l l

Traversing the arrangement The zone Figure 71: Traversing an arrangement and zones.

Once we know the points of entry and exit into each face, the last matter is to update the DCEL by inserting edges for each entry-exit pair. This is easy to handle in constant time, by adjusting the appropriate pointers in the DCEL.

Clearly the time that it takes to perform the insertion is proportional to the total number of edges that have been traversed in this tracing process. A naive argument says that we encounteri−1lines, and hence pass throughi faces (assuming general position). Since each face is bounded by at mostilines, each facial traversal will take O(i)time, and this gives a totalO(i2). Hey, what went wrong? Above we said that we would do this inO(i) time. The claim is that the traversal does indeed traverse onlyO(i)edges, but to understand why, we need to delve more deeply into a concept of azoneof an arrangement.

Zone Theorem: The most important combinatorial property of arrangements (which is critical to their efficient con-struction) is a rather surprising result called thezone theorem. Given an arrangementAof a setLofnlines, and given a line`that is not inL, thezoneof`inA(`), denotedZA(`), is the set of faces whose closure intersects

`. The figure above illustrates a zone for the line`. For the purposes of the above construction, we are only interested in the edges of the zone that lie below`i, but if we bound the total complexity of the zone, then this will be an upper bound on the number of edges traversed in the above algorithm. The combinatorial complexity of a zone (as argued above) is at mostO(n2). The Zone theorem states that the complexity is actually much smaller, onlyO(n).

Theorem: (The Zone Theorem) Given an arrangementA(L)ofnlines in the plane, and given any line`in the plane, the total number of edges in all the cells of the zoneZA(`)is at most6n.

Proof: As with most combinatorial proofs, the key is to organize everything so that the counting can be done in an easy way. Note that this is not trivial, because it is easy to see that any one line ofLmight contribute many segments to the zone of`. The key in the proof is finding a way to add up the edges so that each line appears to induce only a constant number of edges into the zone.

The proof is based on a simple inductive argument. We will first imagine, through a suitable rotation, that

`is horizontal, and further that none of the lines ofLis horizontal (through an infinitesimal rotation). We split the edges of the zone into two groups, those that bound some face from the left side and those that bound some face from the right side. More formally, since each face is convex, if we split it at its topmost and bottommost vertices, we get two convex chains of edges. Theleft-bounding edgesare on the left chain and theright-bounding edges are on the right chain. We will show that there are at most3nlines that bounded faces from the left. (Note that an edge of the zone that crosses`itself contributes only once to the complexity of the zone. In the book’s proof they seem to count this edge twice, and hence their bound they get a bound of4ninstead. We will also ignore the edges of the bounding box.)

For the base case, whenn = 1, then there is exactly one left bounding edge in`’s zone, and1 3n.

Assume that the hypothesis is true for any set ofn−1lines. Consider the rightmost line of the arrangement to intersect`. Call this`1. (Selecting this particular line is very important for the proof.) Suppose that we consider the arrangement of the othern−1lines. By the induction hypothesis there will be at most 3(n1)left-bounding edges in the zone for`.

Now let us add back`1and see how many more left-bounding edges result. Consider the rightmost face of the arrangement ofn−1lines. Note that all of its edges are left-bounding edges. Line`1will intersect

` within this face. Let ea andeb denote the two edges of this that `1 intersects, one above` and the other below `. The insertion of`1 creates a new left bounding edge along `1 itself, and splits the left bounding edgesea andeb into two new left bounding edges for a net increase of three edges. Observe that`1cannot contribute any other left-bounding edges to the zone, because (depending on slope) either the line supportingea or the line supportingeb blocks`1’s visibility from`. (Note that it might provide right-bounding edges, but we are not counting them here.) Thus, the total number of left-bounding edges on the zone is at most3(n1) + 33n, and hence the total number of edges is at most6n, as desired.

l ea

eb

l1

Figure 72: Proof of the Zone Theorem.