Convex Polygon Triangulation Based on Planted Trivalent Binary Tree and Ballot Problem
Total Page:16
File Type:pdf, Size:1020Kb
Turkish Journal of Electrical Engineering & Computer Sciences Turk J Elec Eng & Comp Sci (2019) 27: 346 – 361 http://journals.tubitak.gov.tr/elektrik/ © TÜBİTAK Research Article doi:10.3906/elk-1805-143 Convex polygon triangulation based on planted trivalent binary tree and ballot problem Muzafer SARAČEVIĆ1,, Aybeyan SELIMI2;∗, 1Department of Computer Sciences, University of Novi Pazar, Novi Pazar, Serbia 2Department of Computer Sciences, Faculty of Informatics, International Vision University, Gostivar, Macedonia Received: 21.05.2018 • Accepted/Published Online: 01.11.2018 • Final Version: 22.01.2019 Abstract: This paper presents a new technique of generation of convex polygon triangulation based on planted trivalent binary tree and ballot notation. The properties of the Catalan numbers were examined and their decomposition and application in developing the hierarchy and triangulation trees were analyzed. The method of storage and processing of triangulation was constructed on the basis of movements through the polygon. This method was derived from vertices and leaves of the planted trivalent binary tree. The research subject of the paper is analysis and comparison of a constructed method for solving of convex polygon triangulation problem with other methods and generating graphical representation. The application code of the algorithms was done in the Java programming language. Key words: Computational geometry, triangulation, Catalan number, planted trivalent binary tree, ballot notation 1. Introduction Computational geometry is the branch of computer science which deals with finding the algorithms for solving geometric problems. The polygon triangulation is a significant problem of the polygon partition that is applied in computational geometry. In this paper, the polygon triangulation algorithms were developed based on planted trivalent binary trees (PTBT) and ballot record. These records were obtained with the selection of the particular edge of the polygon as a base and through which is entered in the tree from the starting position. Implementation of our method was realized through the following three phases: 1) Generation of a complete triangulation tree from the initial basic triangle to the given n-gon. The resulting triangulation hierarchy is based on the decomposition of the Catalan numbers (the method is described in Section 3). 2) Storage of all obtained triangulation in tree based on ballot notation (the procedure is described in Section 4). 3) Generation of individual triangles within each level of the triangulation tree based on the planted trivalent binary tree (this procedure is described in Section 5). Two new algorithms are presented. The ballot notation for PTBT to triangulation algorithm generates convex polygon triangulation based on ballot records obtained from movements through vertices and leaves of ∗Correspondence: [email protected] 346 This work is licensed under a Creative Commons Attribution 4.0 International License. SARAČEVIĆ and SELIMI/Turk J Elec Eng & Comp Sci the planted trivalent binary tree. The inverse algorithm with movements through vertices and leaves of the planted trivalent binary tree generates the ballot record for convex polygon triangulation. Other sections of the paper are organized in the following order. Sections 2 and 3 consist of some preliminary exposures related to polygonal triangulation, binary trees, and the Catalan numbers decomposition. Section 4 presents the problem of ballot records, lattice paths, and the correspondence of the Catalan numbers with the well-formed sequences of parentheses. Section 5 contains the method for construction of convex polygon triangulations based on ballot records and a planted trivalent binary. The comparative analysis of experimental results for ballot-lattice, ballot-trivalent and Hurtado-Noy trees are given in Section 6. Also in this section, the complexity of algorithms from the aspect of data storage amount for triangulations and number of operations for generating triangulations is presented. The final section provides concluding observations and possible directions for further research in this domain. 2. Preliminaries about trees and hierarchy of triangulations The Catalan numbers (Cn ) represent a sequence of numbers that are used as a solution to a large number of combinatorial problems. They are uncovered by seeking a general solution of the problem for the different polygon triangulation. The Catalan numbers are defined under the following formula [1]: ( ) (2n)! 1 n C = = ; n ≥ 0: (1) n (n + 1)!n! n + 1 k The tree, as an important class of graph theory [2], also has an important use in the triangulation of polygon and they are defined as an acyclic connected graph [3–5]. The trees with root are rooted trees. In rooted trees, the roots are drawn at the top and they grow downward. A rooted tree in which the vertices at each level are ordered as the first, second, third, and so on is an ordered tree. An ordered rooted tree isabinary tree if each vertex has a degree less than two (each vertex has two children at most; the left and the right child) [6]. The number of nonisomorphic binary trees with n vertices that can be drawn has a direct connection with the Catalan numbers and their relationship is given with the following theorem. The number of binary trees with n vertices is Cn . A binary tree is planted trivalent if the degree of its root is one and that of each internal vertex is three. By deleting the root of a planted trivalent binary tree, we get an ordinary binary tree, and by attaching a new root to the existing root of a binary tree, we get a planted trivalent binary tree. Thus, there is a bijection between set of planted trivalent binary trees with n vertices and set of binary trees with n − 1 vertices. The number of triangulation of convex n-gon is equal to the number of planted trivalent binary tree with n − 1 leaves. Let Pn stand for convex polygon with n vertices, and Tn for set of all triangulations of Pn and τn denotes a particular triangulation from Tn . Also, deg(i) denotes the degree of a vertex i in a triangulation. The vertex i satisfying deg(i) = 2 is called an ear. It is well known that the number of triangulations Tn of polygon Pn is equal to (n − 2)th Catalan number, denoted by Cn−2 : ( ) 1 2n − 4 (2n − 4)! T = C − = = ; n ≥ 3: (2) n n 2 n − 1 n − 2 (n − 1)!(n − 2)! In [7], authors Hurtado and Noy suggested an algorithm for graph of triangulations of a convex polygon and tree of triangulations, where triangulations of Pn are derived from triangulations of Pn−1 . Their procedure consists of ”spli0tting” polygon diagonals (both internal and external which are polygon edges) incident to the 347 SARAČEVIĆ and SELIMI/Turk J Elec Eng & Comp Sci highest mark vertex (n − 1 for Pn−1 ). If we perform splitting of these diagonals δi;n−1; i 2 f1; 2; : : : ; n − 2g in increasing order of i, we get an ordering of triangulations of Pn . Moreover, Hurtado and Noy defined the infinite tree of triangulations for all convex polygons whereat tree level n, we have all triangulations of Pn . Every triangulation in Tn has a parent in Tn−1 and a specific number of exactly defined descendants in Tn+1 . Hurtardo and Noy proposed an algorithm to generate the triangulations of Pn based on the triangulations of Pn−1 . Moreover, they defined the tree of triangulation where all triangulations of Pn , i.e. the triangulations from Tn , are arranged at the level n of this tree. Each triangulation at the level n has a ”father” in Tn−1 and two or more ”sons” in Tn+1 . The sons of the same father are ”brothers”. There is an ordering among the children of a triangulation, and consequently among all triangulations. Implementation of this algorithm in three programming languages (Java, Python, and C++) was analyzed in [8]. 3. Tree of triangulations and expression of the Catalan numbers The first step in our method is generating a complete triangulation tree from the initial basic triangletothe given n-gon. The resulting triangulation hierarchy is based on the decomposition of the Catalan numbers (this method is described in details in [9]). Similarly, in [10], we presented the construction of hierarchy of triangulations based on lattice path and ballot problem. Below, we will list some basics of interpretation of the Catalan numbers in the form of a set of expressions (2 + i). 2 T − l Let us denote a triangulation τn−1 n−1 satisfying deg(n 1) = l by τn−1 . Assume that diagonals − incident to n 1 are sorted from the left by δik;n−1 , k = 1; : : : ; l. Then the number of diagonals incident to − − l n 1 which are located left from δik;n−1 is equal to k 1 [11]. The sons of τn−1 are derived by ”splitting” the diagonals incident to vertex n − 1 2 f − g ··· − δik;n−1; k = 1; : : : ; l; ik 1; : : : ; n 2 ; 1 = i1 < i2 < < il = n 2 ik l in increasing order with respect to ik . If we split the diagonal δik;n−1 , we get the son S (τn−1). Then the l sons of triangulation τn−1 are i1 l i2 l il l S (τn−1);S (τn−1);:::;S (τn−1): (3) ik l − The splitting of the diagonal δik;n−1 produces the son S (τn−1) with deg(n) = 2 + k 1. We are assigning the weights of the form (2 + i) to the edges in the tree of triangulations. When numbering the edges in the tree of triangulations, we will be guided by the basic principle that each weight of an edge represents the l number of descendants for a triangulation at end of this edge [12]. The number of τn−1 descendants is between 2 and n − 2.