triangulaons,and,mst, - bryn mawr · definition. a triangulation of a polygon p is a decomposition...
TRANSCRIPT
Polygon
2 CHAPTER 1. POLYGONS
Figure 1.1. (a) A polygon. (b)–(d) Objects that are not polygons.
circumstances (such as in Chapter 2) it will be useful to recognize “flatvertices.” The set of vertices and edges of P is called the boundary ofthe polygon, denoted as !P. Figure 1.1(a) shows a polygon with nineedges joined at nine vertices. Diagrams (b)–(d) show objects that fail tobe polygons.
The fundamental “Jordan curve theorem,” formulated and proved byCamille Jordan in 1882, is notorious for being both obvious and difficultto prove in its full generality. For polygons, however, the proof is easier,and we sketch the main idea.
Theorem 1.1 (Polygonal Jordan Curve). The boundary !P of a polygonP partitions the plane into two parts. In particular, the two compo-nents of R2 \!P are the bounded interior and the unbounded exterior.2
Sketch of Proof. Let P be a polygon in the plane. We first choose a fixeddirection in the plane that is not parallel to any edge of P. This isalways possible because P has a finite number of edges. Then any pointx in the plane not on !P falls into one of two sets:
1. The ray through x in the fixed direction crosses !P an even numberof times: x is exterior. Here a ray through a vertex is not counted ascrossing !P.
2. The ray through x in the fixed direction crosses !P an odd number oftimes: x is interior.
Notice that all points on a line segment that do not intersect !P mustlie in the same set. Thus the even sets and the odd sets are connected.And moreover, if there is a path between points in different sets, thenthis path must intersect !P.
This proof sketch is the basis for an algorithm for deciding whether agiven point is inside a polygon, a low-level task that is encountered everytime a user clicks inside some region in a computer game, and in manyother applications.
2 The symbol ‘\’ indicates set subtraction: A\ B is the set of points in A but not in B.
Diagonal
1.1 DIAGONALS AND TRIANGULATIONS 3
Figure 1.2. (a) A polygon with (b) a diagonal; (c) a line segment; (d) crossingdiagonals.
Exercise 1.2. Flesh out the proof of Theorem 1.1 by supplying argumentsto (a) justify the claim that if there is a path between the even- andodd-crossings sets, the path must cross !P; and (b) establish that fortwo points in the same set, there is a path connecting them that doesnot cross !P.
Algorithms often need to break polygons into pieces for processing. Anatural decomposition of a polygon P into simpler pieces is achieved bydrawing diagonals. A diagonal of a polygon is a line segment connectingtwo vertices of P and lying in the interior of P, not touching !P exceptat its endpoints. Two diagonals are noncrossing if they share no interiorpoints. Figure 1.2 shows (a) a polygon, (b) a diagonal, (c) a line segmentthat is not a diagonal, and (d) two crossing diagonals.
Definition. A triangulation of a polygon P is a decomposition of P intotriangles by a maximal set of noncrossing diagonals.
Here maximal means that no further diagonal may be added to theset without crossing (sharing an interior point with) one already inthe set. Figure 1.3 shows a polygon with three different triangulations.Triangulations lead to several natural questions. How many differenttriangulations does a given polygon have? How many triangles arein each triangulation of a given polygon? Is it even true that everypolygon always has a triangulation? Must every polygon have at leastone diagonal? We start with the last question.
Figure 1.3. A polygon and three possible triangulations.
Triangula)on
• A triangula)on of a polygon is a decomposi)on into triangles with maximal non-‐crossing diagonals.
• Every polygon of n>3 ver)ces has at least one diagonal
1.1 DIAGONALS AND TRIANGULATIONS 3
Figure 1.2. (a) A polygon with (b) a diagonal; (c) a line segment; (d) crossingdiagonals.
Exercise 1.2. Flesh out the proof of Theorem 1.1 by supplying argumentsto (a) justify the claim that if there is a path between the even- andodd-crossings sets, the path must cross !P; and (b) establish that fortwo points in the same set, there is a path connecting them that doesnot cross !P.
Algorithms often need to break polygons into pieces for processing. Anatural decomposition of a polygon P into simpler pieces is achieved bydrawing diagonals. A diagonal of a polygon is a line segment connectingtwo vertices of P and lying in the interior of P, not touching !P exceptat its endpoints. Two diagonals are noncrossing if they share no interiorpoints. Figure 1.2 shows (a) a polygon, (b) a diagonal, (c) a line segmentthat is not a diagonal, and (d) two crossing diagonals.
Definition. A triangulation of a polygon P is a decomposition of P intotriangles by a maximal set of noncrossing diagonals.
Here maximal means that no further diagonal may be added to theset without crossing (sharing an interior point with) one already inthe set. Figure 1.3 shows a polygon with three different triangulations.Triangulations lead to several natural questions. How many differenttriangulations does a given polygon have? How many triangles arein each triangulation of a given polygon? Is it even true that everypolygon always has a triangulation? Must every polygon have at leastone diagonal? We start with the last question.
Figure 1.3. A polygon and three possible triangulations.
Theorem
• Every polygon admits a triangula)on. • Proof by strong induc)on
• Every triangula)on of a polygon P with n ver)ces has n-‐2 triangles and n-‐3 diagonals.
• Proof by strong induc)on
The Art Gallery Problem
• Polygon models the floor plan • Guards are sta)onary and have 360° visibility unless blocked by walls
• What is the minimum number of guards needed to cover an arbitrary polygon of n ver)ces?
Visibility
• Ver)ces do not block vision • xy∈P → x sees y 14 CHAPTER 1. POLYGONS
Figure 1.12. Examples of the range of visibility available to certain placement ofguards.
A point x in polygon P is visible to point y in P if the line segment xylies in P. This definition allows the line of sight to have a grazing contactwith the boundary !P (unlike the definition for diagonal). A set of guardscovers a polygon if every point in the polygon is visible to some guard.Figure 1.12 gives three examples of the range of visibility available tosingle guards in polygons.
A natural question is to ask for the minimum number of guardsneeded to cover polygons. Of course, this minimum number depends onthe “complexity” of the polygon in some way. We choose to measurecomplexity in terms of the number of vertices of the polygon. But twopolygons with n vertices can require different numbers of guards to coverthem. Thus we look for a bound that is good for any polygon with nvertices.3
Exercise 1.27. For each polygon in Figure 1.8, find the minimum numberof guards needed to cover it.
Exercise 1.28. Suppose that guards themselves block visibility so thata line of sight from one guard cannot pass through the position ofanother. Are there are polygons for which the minimum of our morepowerful guards needed is strictly less than the minimum needed forthese weaker guards?
Let’s start by looking at some examples for small values of n.Figure 1.13 shows examples of covering guard placements for polygonswith a small number of vertices. Clearly, any triangle only needs oneguard to cover it. A little experimentation shows that the first time twoguards are needed is for certain kinds of hexagons.
Exercise 1.29. Prove that any quadrilateral needs only one guard to coverit. Then prove that any pentagon needs only one guard to cover it.
3 To find the minimum number of guards for a particular polygon turns out to be, in general,an intractable algorithmic task. This is an instance of another NP-complete problem; see theAppendix.
Examples
1.3 THE ART GALLERY THEOREM 15
Figure 1.13. Examples of guard placements for different polygons.
Exercise 1.30. Modify Lemma 1.18 to show that one guard placedanywhere in a convex polygon can cover it.
By the previous exercise, convex polygons need only one guard forcoverage. The converse of this statement is not true, however. Thereare polygons that need only one guard but which are not convex. Thesepolygons are called star polygons. Figure 1.8(c) is an example of a starpolygon.
While correct placement avoids the need for a second guard forquadrilaterals and pentagons, one can begin to see how reflex verticeswill cause problems in polygons with large numbers of vertices. Becausethere can exist only so many reflex angles in a polygon, we can construct auseful example, based on prongs. Figure 1.14 illustrates the comb-shapeddesign made of 5 prongs and 15 vertices. We can see that a comb ofn prongs has 3n vertices, and since each prong needs its own guard,then at least !n/3" guards are needed. Here the symbols ! " indicatethe floor function: the largest integer less than or equal to the enclosedargument.4 Thus we have a lower bound on Klee’s problem: !n/3" guardsare sometimes necessary.
Figure 1.14. A comb-shaped example.
4 Later we will use its cousin, the ceiling function # $, the smallest integer greater than or equalto the argument.
The Necessity of ⎣n/3⎦
• The comb
1.3 THE ART GALLERY THEOREM 15
Figure 1.13. Examples of guard placements for different polygons.
Exercise 1.30. Modify Lemma 1.18 to show that one guard placedanywhere in a convex polygon can cover it.
By the previous exercise, convex polygons need only one guard forcoverage. The converse of this statement is not true, however. Thereare polygons that need only one guard but which are not convex. Thesepolygons are called star polygons. Figure 1.8(c) is an example of a starpolygon.
While correct placement avoids the need for a second guard forquadrilaterals and pentagons, one can begin to see how reflex verticeswill cause problems in polygons with large numbers of vertices. Becausethere can exist only so many reflex angles in a polygon, we can construct auseful example, based on prongs. Figure 1.14 illustrates the comb-shapeddesign made of 5 prongs and 15 vertices. We can see that a comb ofn prongs has 3n vertices, and since each prong needs its own guard,then at least !n/3" guards are needed. Here the symbols ! " indicatethe floor function: the largest integer less than or equal to the enclosedargument.4 Thus we have a lower bound on Klee’s problem: !n/3" guardsare sometimes necessary.
Figure 1.14. A comb-shaped example.
4 Later we will use its cousin, the ceiling function # $, the smallest integer greater than or equalto the argument.
The Sufficiency of ⎣n/3⎦
• A coloring of a graph is an assignment of colors to nodes so that no adjacent nodes have the same color
1.3 THE ART GALLERY THEOREM 17
Figure 1.15. Triangulations and colorings of vertices of a polygon with n = 18vertices. In both figures, red is the least frequently used color, occurring five times.
Since there are n vertices, by the pigeonhole principle, the leastfrequently used color appears on at most !n/3" vertices. Place guardsat these vertices. Figure 1.15 shows two examples of triangulations ofa polygon along with colorings of the vertices as described. Becauseevery triangle has one corner a vertex of this color, and this guardcovers the triangle, the museum is completely covered.
Exercise 1.33. For each polygon in Figure 1.16, find a minimal set ofguards that cover it.
Exercise 1.34. Construct a polygon with n = 3k vertices such that plac-ing a guard at every third vertex fails to protect the gallery.
The classical art gallery problem as presented has been generalized inseveral directions. Some of these generalizations have elegant solutions,some have difficult solutions, and several remain unsolved problems. Forinstance, the shape of the polygons can be restricted (to polygons withright-angled corners) or enlarged (to include polygons with holes), or themobility of the guards can be altered (permitting guards to walk alongedges, or along diagonals).
Figure 1.16. Find a set of minimal guards that cover the polygons.
Every Planar Graph Can be 4-‐colored PERSONALIZED FOR
Figure 3.6: A map of Europe and its corresponding representation by a planargraph, along with a four-coloring of the vertices.
To illustrate how complications can easily sneak into mathematics, itturns out that it is relatively easy to prove that the chromatic number ofa planar graph is less than or equal to 5. Before we give this proof, we needto prove the following:
Theorem 3.7: Every planar graph G has a vertex v with d(v) 5.
Proof. For all planar graphs with n 6 vertices, the theorem is obviouslytrue. For planar graphs with n > 6, we prove the theorem by contradiction.To this end, consider a planar graph G for which n > 6. Let m be the numberof edges of G. We know that Âv2V(G) d(v) = 2m. Therefore, if there is novertex with degree 5 or less, then 6n 2m. In addition, from Theorem 2.9we know that m 3n � 6, and thus that 6n 6n � 12. Obviously, this isfalse, meaning that our assumption that there is no vertex with degree 5 orless must be false as well.
75
Every Triangula)on Can be 3-‐colored 1.3 THE ART GALLERY THEOREM 17
Figure 1.15. Triangulations and colorings of vertices of a polygon with n = 18vertices. In both figures, red is the least frequently used color, occurring five times.
Since there are n vertices, by the pigeonhole principle, the leastfrequently used color appears on at most !n/3" vertices. Place guardsat these vertices. Figure 1.15 shows two examples of triangulations ofa polygon along with colorings of the vertices as described. Becauseevery triangle has one corner a vertex of this color, and this guardcovers the triangle, the museum is completely covered.
Exercise 1.33. For each polygon in Figure 1.16, find a minimal set ofguards that cover it.
Exercise 1.34. Construct a polygon with n = 3k vertices such that plac-ing a guard at every third vertex fails to protect the gallery.
The classical art gallery problem as presented has been generalized inseveral directions. Some of these generalizations have elegant solutions,some have difficult solutions, and several remain unsolved problems. Forinstance, the shape of the polygons can be restricted (to polygons withright-angled corners) or enlarged (to include polygons with holes), or themobility of the guards can be altered (permitting guards to walk alongedges, or along diagonals).
Figure 1.16. Find a set of minimal guards that cover the polygons.
Dual Graph 1.3 THE ART GALLERY THEOREM 17
Figure 1.15. Triangulations and colorings of vertices of a polygon with n = 18vertices. In both figures, red is the least frequently used color, occurring five times.
Since there are n vertices, by the pigeonhole principle, the leastfrequently used color appears on at most !n/3" vertices. Place guardsat these vertices. Figure 1.15 shows two examples of triangulations ofa polygon along with colorings of the vertices as described. Becauseevery triangle has one corner a vertex of this color, and this guardcovers the triangle, the museum is completely covered.
Exercise 1.33. For each polygon in Figure 1.16, find a minimal set ofguards that cover it.
Exercise 1.34. Construct a polygon with n = 3k vertices such that plac-ing a guard at every third vertex fails to protect the gallery.
The classical art gallery problem as presented has been generalized inseveral directions. Some of these generalizations have elegant solutions,some have difficult solutions, and several remain unsolved problems. Forinstance, the shape of the polygons can be restricted (to polygons withright-angled corners) or enlarged (to include polygons with holes), or themobility of the guards can be altered (permitting guards to walk alongedges, or along diagonals).
Figure 1.16. Find a set of minimal guards that cover the polygons.
Defini)on
• A triangula)on of a planar point set S is a subdivision of the plane determined by a maximal set of non-‐crossing edges whose vertex set is S.
Euler’s Formula
• Let G be a connected planar graph with V ver)ces, E edges and F faces, then V-‐E+F = 2
• The outer face is unbounded • Proof by induc)on on the number of edges
Theorem
• Let S be a point set with h points on the hull and k in the interior. If all points are in general posi)on, then any triangula)on of S has exactly 2k+h-‐2 triangles and 3k+2h-‐1 edges.
• Proof
Defini)on
• For a point set S, a flip graph of S is a graph whose nodes are the set of triangula)ons of S. Two nodes T1 and T2 are connected by an edge if one diagonal of T1 can be flipped to obtain T2.
Angle Sequence
• Let T be a triangula)on of a point set S, and suppose T has n triangles. The angle sequence {a1, a2, …, an} lists all 3n angles of T in sorted order.
• A triangula)on T1 is fafer than T2 (T1 > T2) if the angle sequence of T1 is lexicographically greater than T2’s. – {20°, 30°, 45°, 65°, 120°} > {20°, 30°, 45°, 60°, 120°}
Delaunay Triangula)on
• For each convex quad in a triangula)on T1 with diagonal e, if a diagonal flip results in a triangula)on T2, s.t. T1 ≥ T2, then e is legal.
• A Delaunay triangula)on is a triangula)on with all legal edges.
When Edges Have Weights
• A minimum spanning tree (MST) of a graph is a tree that connects every vertex and minimizes the total edge weights (lengths).
Two Greedy Algorithms
• Kruskal’s: An algorithm that always chooses the next shortest edge that does not result in a cycle.
• Prim’s: Similar, but maintains a connected tree at all )mes – start with VMST = {vx} and EMST = {} – repeat un)l VMST = V: find min e = {vi, vj} such that vi is in VMST and vj is not. Add vj to VMST and add e to EMST
Edge Weight Comment
(3, 4) 1 selec)on 1
(1, 5) 5 selec)on 2
(1, 4) 13 selec)on 3
(3, 7) 23 selec)on 4
(7, 8) 26 selec)on 5
(1, 7) 38 cycle (1,7,3,4,1)
(5, 7) 46 cycle (1,5,7,3,4,1)
(2, 6) 50 selec)on 6
(5, 8) 65 cycle (1,5,8,7,3,4,1)
(6, 8) 72 selec)on 7
PERSONALIZED FOR
101
73
81
161
13
1
5
140
117
190
38
23
117
145
147
46
73
122
65
136
90
147
80
131
72
50
112
26
1
2
3
4
5
6
7
8
original network selection 1
selection 2 selection 3 selection 4
selection 5 selection 6 selection 7
Figure 5.5: Applying Kruskal’s algorithm to finding a minimal spanning tree.
117
Kruskal’s
Vertex Edge Weight Comment
4 selec)on 0
3 (3, 4) 1 selec)on 1
1 (1, 4) 13 selec)on 2
5 (1, 5) 5 selec)on 3
7 (3, 7) 23 selec)on 4
8 (7, 8) 26 selec)on 5
6 (6, 8) 72 selec)on 6
2 (2, 6) 50 selec)on 7
Prim’s
Minimum Weight Triangula)on
• A minimum weight triangula)on (MWT) is a triangula)on of a point set that minimizes the total edge lengths (weights).