Upload
others
View
6
Download
0
Embed Size (px)
Citation preview
1
Chapter 04: Minimum Weight
triangulation of Polygons
Design & Analysis of Algorithms WS 2019/20
2 ii
Outline
• Algorithm for Minimum Weight Triangulation Dynamic Programming Convex Polygons Simple Polygons
• Triangulations of convex Polygons Minimum Weight Triangulation (MWT) Number of Triangulations of a convex Polygon Duality to binary trees
3
Overview
Geometric problems are incrisingly relevant for the design ofalgorithms. Motivation comes from areas such as computergraphics, numerical analysis, optimization, and CAD.Triangles are a simple, basic element which can be easily handeledby computer. A problem investigated by many researchers is thebreaking down of geometric objects in ‘simple parts‘.
4
Simple Polygon
Simple polygon: A flat shape, consisting of n ≥ 3 straight,non-intersecting, line segments that are joined pair-wise to form aclosed path.
5 ii
Convex Polygon
Convex polygon: A convex polygon P does not have reflexcorners.Formally: ∀x, y ∈ P : xy ⊂ P .
A convex polygon alwayscontains all its diagonals.
y
x
corner, vertex
edge
diagonal
6 ii
Triangulation of convex polygons
A triangulation of a (convex) polygon P results in a set ofnon-intersecting (inner) diagonals, which completely partition theinterior of the convex hull of P into triangles.
Given a simple polygon P with n sides,every (!) triangulation of P has n− 3diagonals and n− 2 triangles.(Excercise: Proof by Induction over n).
7 ii
Triangulation of convex polygons
The left picture is a triangulation of a convex polygon.
Applied to simple (not necessarily convex) polygons, this will looksimilar, although only diagonals which are completely inside thepolygon may be used (see right picture).
8 ii
Triangulation of convex polygons
For an arbitrarily chosen set S of points in the plane atriangulation is defined as follows:The area bounded by the convex hull of S is partitioned intodisjoint triangles by segments defined by S × S (that is, allbounded faces have to be triangles and are not allowed to overlap).
Alternative but equivalent definition: A triangulation of a point setS is a maximal, planar, straight-line graph on S.
9
Triangulation of convex polygons
Because of its fundamental structure,the concept of triangulations plays acentral role in many areas, forexample for visualizing of terrain or3-Dimensional objects, geometricalgorithms, numerical simulations,optimizations, ... (more ontriangulations in the lectures”Geometric Algorithms“ and ”Discreteand Computational Geometry“).
10 ii
Minimum Weight Triangulation
The minimum weight triangulation (short MWT) is, among allpossible triangulations, the triangulation that has the minimumtotal edge length. It has been shown that the MWT is the besttriangulation for 3-Dimensional area interpolations.
Overview of the complexity status of different triangulationproblems:
Object →↓ Triangulation
convexpolygon
simplepolygon
generalpoint set
arbitrary O(n), trivialO(n3), easyO(n), 1990
O(n log n)Ω(n log n)
optimal O(n3) O(n3)NP-complete(2006)
11 ii
Number of triangulations of a convex polygon
Next we count the number of possible triangulations of a convexpolygon with n corners. The triangulation for a convex polygon Pcan be associated with a binary tree as follows:
Root = Edge e of P .e is incident to a triangle ed1d2, whichsplits P into two convex polygons P1 andP2. If d1(d2) is a diagonal of P , thend1(d2) is the root of the binary tree ofP1(P2). If d1(d2) is not a diagonal, it isan edge of P and represents a leaf in thebinary tree.
d1d2
Roote
12
Number of triangulations of a convex polygon
The resulting tree has n− 1 leafs (all edges expect the root-edges)and n− 2 inner nodes (root (1) plus diagonals (n− 3)). Differenttriangulations result in different binary trees (with same root edge)⇒ number of trees ≥ number of triangulations.
d1d2
Roote
2
5
31 4
6
1
2
3
45
6
13
Number of triangulations of a convex polygon
Inverse process: Form a convex polygon with n edges from a(complete) binary tree consisting of n− 1 leafs (working bottomup): By combining two leafs (diagonals) we obtain an inner node,which marks another diagonal and thus the three edges of ourtriangle.
n-1=5Leafs from left to right
n=6 cornerscounterclockwise
12
3
45
e
2 3
4
1
5
14
Number of triangulations of a convex polygon
Different binary trees result in different triangulations (assumingsame root edge) ⇒ number of triangulations ≥ number of trees.
1 k k+1 m
Root
Together this shows, that the number of triangulations of a convexpolygon with n edges, is the same as the number of completebinary trees with n− 1 leafs.
Let β(m) be the number of complete binary trees with m leafs.
︸ ︷︷ ︸β(k) β(m− k)
︸ ︷︷ ︸
15 ii
Number of triangulations of a convex polygon
If we look at all possible partitions into left and right subtrees, weobtain the following recursive formula.
β(m) =m−1∑k=1
β(k)β(m− k), β(1) = 1
This is the relation of the Catalan-numbers, as already seen in aprevious chapter:
β(m) = C(m− 1) =1
m
(2m− 2
m− 1
)= Θ(
4m
m1.5) = Θ∗(4m)
16
Number of triangulations of a convex polygon
If we estimate the sum only with its first (k = 1) and last(k = m− 1) term, we obtain the following lower bound:
β(m) > β(1)β(m− 1) + β(m− 1)β(1)
= 2β(m− 1)
= 4β(m− 2) = ... =
= 2m−1β(1)
= Ω(2m)
17
Idea for Minimum Weight Triangulation
Due to the convexity of P , we derive the following observationabout the minimum weight triangulation T (P ) :
Let 4 be a triangle in T (P ). Then T (P ) = T (P1) ∪4 ∪ T (P2)
This follows from the optimality of sub-problems!
P1 P2
4
18 iii
Idea for Minimum Weight Triangulation
Idea: Reduction of the problem to smaller polygons!
• Select any edge e of P . (e has a unique triangle 4 in T (P )).
• Since 4 is unknown: For all n− 2 possible triangles with baseede e, solve the problem recursively for the two inducedsub-polygons and take the best solution.
Algorithm:
19 ii
Idea for Minimum Weight Triangulation
An application of this simple idea as recursion does not make sense:
T (n) = O(n) + 2n−1∑i=2
T (i) > 2(T (n− 1)) = 2n−1T (1) = Ω(2n)
Thus, recursion needs at least exponential running time.⇒ Use dynamic programming.
T (n) =n−1∑i=2
(O(1) + T (i) + T (n− i+ 1))
∑n−1i=2 ... All possibilities for 4
O(1) ... Time to splitT (i) ... Time for left sub-areaT (n− i+ 1) ... Time for right sub-area
20 ii
Dynamic Programming
The method of dynamic programming as discussed in a previouschapter is used as a special case of divide and conquer.
Because many sub-problems occur repeatedly, but need to beresolved only once, dynamic programming isway more efficient thanrecursion.
n
n-1
n-2
21 iii
Minimum Weight Triangulation
Indices for dynamic programming:
v1, ..., vn vertices of polygon PPij = (vi, vi+1, ..., vj) partial polygonof PLij ”length” (=sum of edge lengths)of T (Pij) (MWT)u(i, j, k) circumference of the trianglevivjvk
We obtain:Lij = min
i<k<ju(i, j, k) + Lik + Lkj with Li,i+1 = 0
We therefore compute the values Lij in order of the increasingdifference between i and j (where j − i+ 1 is the number ofinvolved vertices) starting with Li,i+1 = 0
vi+1
vi
vk
vj
22
Minimum Weight Triangulation
matrix L[1..n, 1..n]Similar matrix S with thesame dimension, for splittingindex S[i, j] ∼= third trianglevertex for base vivj
i = 1n2
2
n0 0 0 0
x x
j = 1
j
i
L
23 ii
Pseudocode MWT
Analysis:
• Running time Θ(n3),much better than Θ(4n)
• Space requirement:Θ(n2)
for i := 1 to n− 1 doL[i, i+ 1] = 0
odfor l := 2 to n− 1 do
for i := 1 to n− l doj := i+ lL[i, j] =∞for k := i+ 1 to j − 1 do
x := L[i, k] + L[k, j] + u(i, j, k)if x < L[i, j] then
L[i, j] := xS[i, j] := k
fiod
odod
24
Reconstructing MWT
T (P ) can be reconstructed from S in O(n) time. Starting with4 = (1, n, S[1, n]), the triangles of the triangulation are builtiteratively. In each step, two points a and b are used to determinethe base of a triangle and its third point as S[a, b]:
S[1, S[1, n]]S[1, n]
S[S[1, n], S[S[1, n], n]]
S[S[1, n], n]
n
1
S[1, S[1, S[1, n]]]
25 iii
Final evaluation
By using u(i, j, k), too many edges are counted:
• Each diagonal of P twice
• Each edge of P once
L1n =∑
edges of P︸ ︷︷ ︸Ci(P)
+2∑
diagonals
Since the circumference Ci(P ) is independent of the computedtriangulation, L1n is minimal if and only if
∑diagonals is minimal.
Therefore the algorithm actually produces the minimum weighttriangulation T (P ).
Theorem: The minimum weight triangulation of a convex polygoncan be computed in O(n3) time and O(n2) space.
26 iii
Simple Polygons
Even for simple (not necessarily convex) polygons, the minimumweight triangulation can be computed in O(n3) time and O(n2)space:
Idea: When the subpolygon Pij is considered, we first have to test(in O(n) time), whether the base edge vivj is outside the polygonor leads to a self overlap (i.e., an intersection).If that is the case, we set L[i, j] =∞.In all other cases the computation is done as in the convex case.Due to the ∞-weighting of self-intersecting parts, only validtriangulations will be examined.
Theorem: The minimum weight triangulation of a simple polygoncan be computed in O(n3) time and O(n2) space.
27 viii
Conclusion
Theorem: The minimum weight triangulation of a convex polygoncan be computed in O(n3) time and O(n2) space.
Theorem: The minimum weight triangulation of a simple polygoncan be computed in O(n3) time and O(n2) space.
Every triangulation of a simple polygon with n vertices has n− 3diagonals and n− 2 triangles.
A triangulation is a maximal, planar, straight-line graph.
The minimum weight triangulation (MWT) minimizes the totaledge length.
Triangulations of convex polygons on n vertices are in on-to-onerelation with complete binary trees with n− 1 leaves.
For a convex polygon with n vertices there areC(n− 2) = 1
n−1
(2n−4n−2
)= Θ∗(4n) triangulations.
Computing the MWT for general point sets is NP-complete.