An Efficient Algorithm for building a vertex Based on the binary tree and Graham Scanning Technology

Source: Internet
Author: User
Efficient building algorithm based on the binary tree and Graham Scanning Technology Abstract: In order to improve the construction speed of the irregular Triangle network, an efficient algorithm for building the Triangle network is proposed. First, the discrete point set on the plane is segmented according to a certain threshold value, and a sub-block index binary tree is established. Then, the Graham scan technology is used to construct a gridded network for each sub-block, finally, the child blocks with the same parent node are merged from the bottom up. Compared with other network construction algorithms, this algorithm has obvious advantages in network construction speed.
Key words: Binary Tree; AdaBoost Triangle network; Graham scanning technology; data segmentation
  
China Map classification: TP2 document flag code:
Article No.: 1001-3695 (2010) 03-0894-03
DOI: 10.3969/J. issn.1001-1275.2010.03.023
  
Efficient Algorithm of constructing Dirichlet triangulation based on
Binary Tree and Graham scanning technique
  
Li Gen, Zou Zhi-wen, Ju Shi-guang
(College of computer, Jiangsu University, Zhenjiang Jiangsu 212013, China)
  
Abstract: In order to enhance the speed of constructing triangulated irregular network, this paper proposed an efficient algorithm of constructing Dirichlet triangulation. firstly, split the set of discrete points into several subsets with a threshold value and built an index binary tree during that process. secondly it built Dirichlet triangulation on these subsets by Graham scanning technique. finally, merged the blocks with the same parent node from bottom to top. the result of the experiments shows that the algorithm, compared with other ways, has a distinct superiority in the speed of constructing irregular network.
Key words: Binary Tree; Dirichlet triangulation; Graham scanning technique; dataset Partition
  
Tin is a method used to represent the digital elevation model. It not only avoids data redundancy when the terrain is flat, but also better reflects the details of the original terrain than the grid, it also features high precision of surface reconstruction and strong adaptability to the distribution of data points in irregular regions. Due to its outstanding performance in this aspect, the gridded network is often used to generate tin. There are many implementation algorithms for the gridded network, including the growth method, point-by-point insertion method, and divide-and-conquer method [1 ~ 4] three types. The Growth Method of the triangular network is relatively simple, but the entire point set needs to be traversed and compared each time when finding the optimal point. The average time complexity is O (n2) [5], which is not suitable for generating a triangular network with large data volumes; point-by-point insertion method is relatively simple and occupies a small amount of memory. However, when inserting a new point, you need to search the triangle with a new point in the triangle linked list, the average time complexity of the algorithm is O (n log n). In the worst case, the time complexity is O (n2) [5]. The sharding algorithm is the most efficient, the time consumed by the construction network is basically proportional to the number of discrete points [6]. Due to Recursive Implementation, the memory requirement is high and the algorithm is relatively complicated.
Liu Yonghe and others [7] proposed a block-by-block merge algorithm. First, the discrete point set in the plane is divided into several sub-blocks, and then the sub-blocks are connected to a network by using a triangular network expansion method, then merge and optimize adjacent subnets. This algorithm uses the idea of chunking to bring the network construction time to a linear relationship with the number of points. However, when the subnet is segmented, no index is set up for the subblock, And the validity rate of subnet merging is not high, when the number of sub-blocks is large, the efficiency of the Triangle network expansion method is very low. Song Xiaoyu and others [8] use the Graham scanning method in network construction. The algorithm is simple and easy to implement, however, when looking for visible points of the points to be determined during the construction of the network, you need to judge all the points behind the points. The time complexity is close to O (n2 ). Guo zhaosheng and others [9] combined the partitioning method and point-by-point insertion method when constructing a triangle network, but the efficiency of sub-block construction is not high. Shi Song and others [10] proposed a method for building a triangle network based on the quad-tree block, which effectively solved the shortcomings of the divide and conquer algorithm in building a large amount of irregular Triangle network, and reduced the overall time complexity, however, algorithms become more complex and difficult to implement.
In view of the shortcomings of the above algorithm in constructing the network, this paper proposes an efficient algorithm for building a network based on the two-tree and Graham scanning technology. For discrete point sets on the plane, the Child block set is obtained through multiple segmentation of the smallest outsourcing rectangle of the point set. During the segmentation process, the Child block index binary tree is generated; then, the Graham scanning technology is used to construct an initial Triangle network for each sub-block and then optimize it into a knot network. Finally, the sub-blocks with the same parent node are merged from bottom to top until the root node is generated, in this case, the structure of the gridded network is complete.
1. Binary Tree segmentation of data
The premise of using the split-merge algorithm is to split the data and perform efficient search. The binary tree clearly conforms to these two points. Due to the uneven distribution of point sets, how to split point sets directly affects the merging efficiency of the subsequent subsets. The minimum outsourcing rectangle for Point Set P is r <PL, Pr> 〉. PL (x1, Y1) and PR (X2, Y2) are the points in the lower left and upper right corner of the rectangle R. If the number of points in R exceeds the specified threshold, split it: When (x2-x1)> (y2-y1), Vertical Split of R to generate equal left and right child blocks, otherwise, the vertical split will generate up and down equal sub-blocks to ensure that the horizontal vertical length of the sub-blocks is close. Continue to split the newly generated child blocks, and follow this recursion until the number of the midpoint of all split child blocks falls within the specified threshold. The final number of sub-blocks depends on the distribution of discrete points and the threshold of sub-blocks containing points. Figure 1 shows the sub-block generated by dividing the region R. The sub-block contains 10 points and the generated sub-block index binary tree 2 shows.
Each node of the index binary tree T generated during the segmentation process contains a rectangular area. The rectangular area of the parent node is the sum of the rectangular areas of its left and right subnodes, And the rectangular areas of the left and right subnodes are equal. The left and right child nodes of the parent node always have adjacent Rectangular areas. Therefore, when merging child blocks, the corresponding areas are always adjacent. The leaf node of a binary tree corresponds to the final shard. Each shard contains a certain number of discrete points. If the number of child blocks in the midpoint is less than 3, it is merged with the sibling node to form a new leaf node. The sub-block to which a vertex belongs is the process of searching for a leaf node of a binary tree. The search path is determined based on whether the vertex is in the region of the node. Because nodes at the same level of the binary tree do not contain overlapping areas, therefore, the search path is unique and the number of judgments cannot exceed the height of the binary tree.
2. Construction of a gridded Network
2.1 Data Structure
During the process of building a network based on the premise that the algorithm performance is directly affected by the design of the data structure, a reasonable data structure not only reduces the data storage capacity, but also improves the algorithm execution efficiency. This algorithm defines the following data structures:
  
Struct point {// vertex class
Double PX; // vertex abscissa double py; // vertex ordinate
};
Struct edge {// directed edge class
Point * begpt; // start point of the edge
Point * endpt; // The End Of The Edge.
Triangle * lefttri; // left adjacent triangle of the edge
Triangle * righttri; // right adjacent triangle of the edge };
Struct triangle {// triangle class
Edge * edge [3]; // three sides of a triangle
Point * PT [3]; // three vertices of a triangle
};
To facilitate the expansion of triangles and the automatic construction of topological relationships, the edges and vertices are stored in a counter-clockwise direction, and the vertices and edges have a certain ing relationship (Figure 3 ). The start point of the directed edge [0] of the Triangle ABC corresponds to PT [0], and the end point corresponds to PT [1, likewise, the starting points of edge [1] and edge [2] correspond to PT [1] and PT [2] respectively, and the ending points correspond to PT [2] and PT [0] respectively. When a triangle T is generated, the corresponding three directed edges can be determined based on the three vertices, and the left adjacent triangle of each edge is the triangle T.
  
2.2 using Graham scan technology to build a triangle of each sub-block
2.2.1 Algorithm for creating a sub-block Triangle network
After the binary tree of the Point Set area is split, the child blocks corresponding to each leaf node are constructed using Graham scan technology. In the process of constructing the network, after the visible point of the point to be determined is searched, the visible point is pushed into the convex packet vertex set C, and the newly generated triangle T is inserted into the triangle linked list, t inserts a directed edge linked list into the three directed edges, and updates the right adjacent triangle corresponding to the directed edges to T.
Definition 1 sort discrete points by means of Graham scanning and horizontal angle to get p = {P0, P1, P2 ,..., Pn-1}, Pi is the point to be judged, pipeline pipj + 1 and segment p0pj intersection (j> I), when J to take the minimum value, called PJ PI visible point, the visible point whose pi is PJ.
To build a sub-block Triangle network, follow these steps:
A) Find out the minimum point of the ordinate value in the vertex set to P0, connect P0 with other points in the vertex set to find the angle θ I between the linear p0pi and the horizontal direction, number a point in the ascending order of θ I. After sorting, P = {P0, P1, P2 ,..., Pn-1 }. Press P0 and P1 into the convex hull vertex set C, and the index T initial value is 1.
B) determine the final point in C as the PI to be determined, find the visible point PK of Pi, press the PK into C, connect Pipi + 1, Pipi + 2 ,..., PiPK, generated into Delta p0pipi + 1, t plus 1.
C) if t ≥ K, convert to Step D), the connection line segment ptpt + 1, generate a new Delta p0ptpt + 1 and Delta ptpipt + 1, t plus 1, and switch to Step C ).
D) if the number of the midpoint in C is less than 4, go to Step E), set the last three vertices in C to Pi, PJ, and PK, respectively, if the p0pj and piPK of a line segment intersect, PJ is the convex hull vertex, Which is switched to Step E); otherwise, PJ is deleted from C, and the connection line segment piPK generates a new △pjpipk, Which is switched to step d ).
E) If t 2.2.2 sub-block network instances
The following uses the Point Set P as an example to describe the process of generating an initial triangular network using Graham scanning technology. The Graham scanning method is used to sort discrete points according to the angle with the horizontal direction. P = {P0, P1, P2, p3, P4, P5, P6}, 4 (.
  
A) Initially, the convex hull vertex set C = {P0, P1} takes P1 as the point to be judged. Because the p1p5 line segment and p0p4 intersect, p4 is the visible point of P1, connect P1P2, p1p3, p1p4, generate △p0p1p2, and press point P4 into C. Connect p2p3 to generate △p0p2p3 and △p2p1p3; connect p3p4 to generate △p0p3p4 and p3p1p4 (Figure 4 (B )).
B) C = {P0, P1, P3}, search for the visible point P6 with P4 as the judgment point, connect p4p5 and p4p6 to a new Delta p0p4p5, and press point P5 into C; connect p5p6 to generate a new Delta p0p5p6 and Delta p5p4p6 (Figure 4 (c )).
C) The last three vertices in C = {P0, P1, P4, P6} and C are p1, P4, and P6, respectively, because the p0p4 and p1p6 line segments do not overlap, it is determined that P4 is not a convex hull vertex, and P4 is deleted from C. When p1p6 is connected, it is generated as △p4p1p6. The number of point C is 3. End the judgment. Finally, the convex hull vertex c = {P0, P1, P6} is obtained, as shown in Figure 4 (d.
2.2.3 subnet Optimization
The sub-Triangle network constructed by Graham scan technology does not fully conform to the two properties of the sub-Triangle network, that is, the characteristics of the null outer circle and the principle of the smallest angle and the maximum angle, and needs to be optimized for the sub-Triangle network. According to the data structure designed above, the left and right adjacent triangles are stored in the directed edge. Therefore, it is more efficient to perform subnet Optimization Based on the directed edge.
The subnet optimization method is to determine whether the sum of the diagonal values of the left and right adjacent triangles with a directed edge is greater than 180 ° (Figure 5). If yes, the relationship is satisfied. Otherwise, the diagonal line is exchanged, generate two new triangles and insert them into the triangle linked list. insert them into the directed edge List, delete the original directed edge and triangle, and update the adjacent triangles directed to the directed edge.
2.3 merging subnets based on binary trees
Subnet merging starts from bottom-up merging of leaf nodes of a binary tree. Leaf nodes with the same parent node are merged to generate new nodes to replace their parent nodes. Then, the new nodes are merged to form leaf nodes. Repeat the preceding merging process until the root node of the binary tree is generated. At this time, all subnets are merged and the gridded networks of the discrete point set are generated. Take Figure 2 as an example. A) 1000 and 1001 are merged into 1101, 110 and 00,100 are merged into 101, B) 10,110 and 001 are merged into 111 and into 11. c) 00 and 01 are merged into 0, 10 and 11 into 1; d) 0 and 1 are merged into the root node, and the merging process ends.
When the sub-block is built into a triangle network, the convex hull vertex of the sub-block is stored. When the sub-block is merged, the associated points are the vertices on the convex hull, therefore, to merge subnets, you must first find the top tangent and bottom tangent of the subnet corresponding to the convex hull, determine the point set to be considered during the merging process, and then gradually construct a tin, finally, the newly generated triangle is optimized to conform to the properties of the Cartesian network. As shown in 6, first find the top tangent p1p5 and the lower tangent p4p8 of the convex hull, and use p1p5 as the starting extension edge to find P6. The most advantage obtained from p1p6 extension is P2, merge ends until P4 or P8.
  
When searching for the optimal vertex, The subnet merge algorithm only searches for the generated convex packet vertex sets, reducing the Traversal Time for finding the optimal vertex, the combination of subnet time and the number of vertices in the convex hull are linearly related when the data volume is large and the number of chunks is large.
3. Performance analysis and time-consuming testing
Assume that the number of discrete points in a plane is N. On average, each sub-block contains M points. Then, at least the point set is divided into N/m sub-blocks, therefore, the height of the binary tree established during the split process is log (N/m ). When constructing a network using Graham scan technology for sub-blocks containing M points, sort the points in the sub-blocks first and use the quick sorting method, it is recommended that the time complexity be O (m log m ). In the process of creating a sub-block network, when determining the convex hull vertex, the search range is relatively small. You do not need to judge all vertices in the vertex set. The average time complexity is O (m ), subnet optimization is only used to judge or optimize directed edges several times. The complexity is O (K), and K is the number of directed edges. Based on the above analysis, when the point set is reasonably divided, so that the number of sub-blocks is within a certain threshold, the time required to build the gridded network is approximately linear with the number of points. In VC 6.0, I used the C ++ language to implement the network construction program and run the program correctly. Figure 7 shows the gridded networks built by randomly generated points. The following compares the running results by randomly generated points based on the sub-block threshold. The microcomputer environment is pentium4 1.8 GHz CPU and 256 MB memory. For randomly generated discrete point sets, it can be considered to be evenly distributed on the plane. The number of subblocks generated by using the binary tree segmentation method is only related to the threshold of the subblock inclusion points. The larger the threshold, the smaller the number of sub-blocks, the larger the number of sub-blocks. The test data is as follows: the random number of points is 500, and the sub-block inclusion points are set to 400, 300, 200, 150, 100, and 50 respectively, record the time consumed by the respective network structures and the number of segmented sub-blocks. As shown in table 1, when the threshold is 200, the number of sub-blocks is 14, and the network construction time is the shortest. When the threshold is less than 200, the network construction speed begins to decrease. After analysis, the following conclusions are drawn: When the threshold is large, the number of child blocks generated by segmentation is small, and the network construction time for a single sub-block is long. When the threshold is small, the number of child blocks generated by segmentation is large, although the network construction time for a single sub-block is relatively short, it is necessary to merge adjacent sub-blocks multiple times, and the overall efficiency is not high. Table 1 discrete point network time consumption and number of sub-blocks with different thresholds
  
Threshold construction time/MS generation of sub-blocks threshold value construction time/MS generation of sub-blocks
1 0001 440320063714
5001 176515064317
4001 024610066824
30083595067349
  
When constructing a triangle network for a flat point set, only a reasonable threshold value can ensure the fastest network construction speed. The threshold value is determined based on experience. For a randomly generated point set, it can be considered that the value is evenly distributed on the plane. Generally, the threshold value ranges from [N/15, N/10, N indicates the total number of points. In order to verify the superiority of the proposed algorithm, the time required for constructing a certain number of point sets is compared with that required by other algorithms. The sub-block threshold value is empirical value n/12, result 8 is displayed.
  
4 Conclusion
In this paper, we propose the algorithm for generating a gridded area network that is used to segment the smallest outsourcing rectangle of a point set in a plane, establish a sub-block index Binary Tree, and use Graham scan technology to build a triangle network for each sub-block, finally, the child blocks with the same parent node are merged from the bottom to the top to finally obtain the points set's gridded network. The algorithm uses binary tree blocks to improve the efficiency of subnet merging. The Graham scan technology is used to construct a subblock Triangle network to accelerate the network construction speed, so that the time and number of points are close to linear relationship, it is suitable for the generation of large-volume irregular triangle networks. At the same time, compared with other block algorithms, the algorithm proposed in this article is relatively simple and easy to implement.
References:
[1] Xu Wen, Wu baichao. Algorithm for rapid generation of triangular networks based on a balanced binary tree [J]. Journal of Liaoning University of Engineering and Technology, 2007,26 (4): 513-517.
[2] Zhao Yan, Zhang Ziping. An algorithm for dynamically constructing a Cartesian network [J]. ing engineering, (3): 24-28.
[3] Dwyer r a. A fast divide and conquer algorithm for constructing Dirichlet triangulations [J]. algorithmica, 1987 (2): 137-151.
[4] Sloan s w. A fast algorithm for constructing Dirichlet triangulation in the plane [J]. Advanced engineering software, 1987,9 (1): 34-55.
[5] Yan Xiaoyan. Tin generation algorithm and 3D display [J]. ing Science, (5): 39-41.
[6] Xiang chuanjie, Zhu Yuwen. An efficient technology for combining and generating the Cartesian networks [J]. Computer Application, (11): 34-36.
[7] Liu Yonghe, Xie Hongbo, Yuan Ce. A new algorithm based on the area-by-area merge of the area-by-area structure of the area-by-area algorithm based on the area-by-area expansion method [J]. ing science, 2007,32 (3): 52-55.
[8] Song Xiaoyu, Li Dong, and Wang Yonghui. An algorithm based on Graham triangle segmentation to generate a gridded network [J]. Journal of Shenyang Emy of architecture, 2007,23 (2): 328-332.
[9] Guo zhaosheng, Zhang dengrong. An improved efficient algorithm for generating the inde Triangle network [J]. Remote sensing information, 2005 (1): 15-17.
[10] Design and Implementation of an interactive editing algorithm for shisong, Chen chongcheng, Tang LiYu, and AdaBoost Triangle network [J]. ing science, 113 (6): 116.

[Previous Page] 1 2 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.