Title: Greedy Algorithm to Find Minimum Length Triangulation
1Greedy Algorithm to Find Minimum Length
Triangulation
- CSC6520 Algorithm
- Graduate Student Project
- Instructor Dr. Alexander Zelikovsky Student
Yan Liu - Spring 2001
2Introduction
- Definition of Triangulation
- -- a set T of chords of a convex polygon P that
divide the polygon into disjoint triangles. - Minimum length triangulation(MLT)
- -- Given a convex polygon P(v1, , vn)
- -- Form Triangles by sides and
- chords of P.
- -- Find a triangulation that minimizes the sum
of the lengths of the triangles in the
triangulations.
3Example of triangulating a convex polygon
v7
v7
v1
v1
v6
v6
v2
v2
v5
v5
v3
v3
v4
v4
Figure 1. Two ways of triangulating a convex
polygon.
4Data Structure
- Heap a complete binary tree to hold all of
diagonals. - -- Build-Heap(E)
- -- Heapify (E, i)
- HeapSort algorithm
- -- to get the minimum length triangulation.
- Remove diagonals from set E.
- -- Heap-delete(E,i)
- Add new diagonals
- -- Heap-Insert(E)
-
5Algorithms for MLT
- Given a convex polygon P(v1v n)
- Find the minimum length triangulation for P(v1v
n) - Algorithms
- -- Greedy-1 Algorithm
- -- Greedy Algorithm
6Greedy-1 Algorithm for MLT
- Step 1. Put all of vertices of convex
- polygon P into set V.
- Step 2. Put all of next-neighbor diagonals
- into set E. For example, (k, k2) is the
- next-neighbor diagonal between the
- vertices v k and v k2.
- Step 3. Find the minimum diagonal (k,
- k2) in E, and insert it into the result set M
- of the minimum length triangulation of the
- convex polygon P.
7Greedy-1 Algorithm for MLT -- continue
- Step 4. Remove the vertex v k1 from set
- V.
- Step 5. Remove all diagonals which are
- related to the removed vertex in set V in
- the last step.
- Step 6. Update E to add unexisted next-
- neighbor diagonals for the vertices v k
- and v k2 such as (k, k3), (k2, k-1).
- Step 7. Check if E is NOT empty, go
- back step 3 to repeat otherwise return
- the result M.
8 Example for Greedy 1 Algorithm
v7
v1
v6
v2
v5
v4
v3
E (1,3), (2,4),(3,5),(4,6), (5,7), (6,1),
(7,2) Vv1, v2,v3,v4,v5,v6,v7 M Ø
9Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E(1,3), (2,4),(3,5),(4,6), (5,7), (6,1) Vv1,
v2,v3,v4,v5,v6,v7 M(7, 2)
10Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E (1,3),(1,6),(2,4),(3,5),(4,6),
(5,7) Vv2,v3,v4,v5,v6,v7 M(7, 2)
11Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E(2,4),(3,5),(4,6), (5,7) Vv2,v3,v4,v5,v6,v7
M(7, 2)
12Example for Greedy 1 Algorithm --continue
v7
Add new next diagonals
v1
v6
v2
v5
v3
v4
E(2,4),(3,5),(4,6), (5,7), (6,2), (7,3)
Vv2,v3,v4,v5,v6,v7 M(7, 2)
13Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E(2,4),(3,5),(4,6), (6,2), (7,3) Vv2,v3,v4,v5
,v6,v7 M(7, 2), (5,7)
14Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E(2,4),(3,5), (4,6), (6,2), (7,3) Vv2,v3,v4,v
5,v6,v7 M(7, 2), (5,7)
15Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E(2,4),(3,5), (7,3) Vv2,v3,v4,v5,v7
M(7, 2), (5,7)
16Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
Add new next-diagonals
v3
v4
E(2,4),(3,5), (7,3), (5, 2),(7,4) V
v2,v3,v4,v5,v7 M(7, 2), (5,7)
17Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E(3,5), (5, 2),(7,3), (7,4) V
v2,v3,v4,v5,v7 M(7, 2), (5,7), (2,4)
18Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E(3,5), (7,3), (5, 2),(7,4) V
v2,v3,v4,v5,v7 M(7, 2), (5,7), (2,4)
19Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E (5, 2), (7,4) V v2,v4,v5,v7 M(7, 2),
(5,7),(2,4)
20Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E (v5, v2) V v2,v4,v7 M(7, 2),
(5,7),(2,4), (4,7)
21Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E (v5, v2) V v2,v4,v7 M(7, 2),
(5,7),(2,4), (4,7)
22Example for Greedy 1 Algorithm --continue
v7
v1
v6
v2
v5
v3
v4
E Ø V v2,v4,v7 M(7, 2), (5,7),(2,4),
(4,7)
23Greedy Algorithm for MLT
- Step 1. Insert all diagonals between any two
vertices (exclude any two neighbor vertices on
the polygon P) into set E. - For example, (i, j) is the diagonal between
the vertices v i and v j.
24Greedy Algorithm for MLT -- continue
- Step 2. Find the minimum diagonal in E and
- insert it into the result set M of the
- minimum length triangulation for graph G.
- Step 3. Remove those diagonals from E,
- which cross the chosen minimum diagonal
- in the last step.
- Step 4. Check if E is NOT empty, go back
- step 2 to repeat otherwise return the result
- M.
25 Example for Greedy Algorithm
v7
v1
v6
v2
v5
v4
v3
E(1,3), (1,4), (1,5), (1,6), (2,4),(2,5),(2,6),
(2,7), (3,5),(3,6), (3,7),(4,6), (5,7), (4,6),
(4,7) M Ø
26 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E(1,3), (1,4), (1,5), (1,6), (2,4),(2,5),(2,6),
(2,7), (3,5),(3,6), (3,7),(5,7), (4,7) M
(4,6)
27 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E(1,3), (1,4), (1,5), (1,6), (2,4), (2,5),
(v2,v6), (2,7), (3,5), (3,6), (3,7), (5,7),
(4,7) M (4,6)
28 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E(1,3), (1,4), (1,6), (2,4), (2,6), (2,7),
(3,6), (3,7),(4,7) M (4,6)
29 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E(1,3), (1,4), (1,6), (2,4), (2,6), (3,6),
(3,7), (4,7) M (4,6), (2,7)
30 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E(1,3), (1,4), (1,6), (2,4), (2,6), (3,6),
(3,7), (4,7) M (4,6), (2,7)
31 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E(2,4), (2,6), (3,6), (3,7), (4,7) M (4,6),
(2,7)
32 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E(2,6), (3,6), (3,7), (4,7) M (4,6),
(2,7),(2,4)
33 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E(2,6), (3,6), (3,7), (4,7) M (4,6),
(2,7),(2,4)
34 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E(2,6), (4,7) M(4,6), (2,7),(2,4)
35 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E(4,7) M (4,6), (2,7),(2,4), (2,6)
36 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E(4,7) M (4,6), (2,7),(2,4), (2,6)
37 Example for Greedy Algorithm --continue
v7
v1
v6
v2
v5
v4
v3
E Ø M (4,6), (2,7),(2,4), (2,6)
38Summary
- Performance
- -- Greedy algorithm is between O(n2)
- and O(n3)
- -- Greedy-1 algorithm is O(nlgn)
- Result of MLT
- -- For a convex polygon P(V),
- using different algorithms may
- get different results.