Lecture notes in computer science: research on hybrid grid algorithm of voronoi diagram

. Characteristics and performance of two grid methods, which include the growth method and the point by point scanning method of Voronoi diagram, are analyzed qualitatively and quantitatively. The theoretical analysis and experimental results show that the growth method is faster, but the boundary of Voronoi diagram generated by the point by point scanning method is more accurate. By combining the advantages of these two grid methods, the hybrid grid algorithm is proposed: the growth method is used firstly to extend a large step, and then the point by point scanning method is used to color the remaining blank pixel. The theoretical analysis and experimental results show that the speed of the hybrid grid algorithm is close to the fastest growth algorithm, and the accuracy is as well as the point by point scanning algorithm.


Introduction
Voronoi diagram [1,2]is an important topic in computational geometry field, which is often used to solve problems of location optimization, space division and path planning in the fields of geography, meteorology and mobile communication.It has important theoretical and practical value.
The key issues of Voronoi diagram is the generating algorithm.At present, Voronoi diagram generating algorithms can be classified as the vector methods and grid methods.The vector methods have the advantage of high precision, but its data structure and calculation are more complex, and only applicable to the case of simple Voronoi diagram.The typical vector methods include incremental method [3], divided method [4] and indirect method [5].The grid method has no limitation on the generator which can be a point, a line or a surface with different partitions and weights, but it is time-consuming and the result has lower accuracy.The typical grid methods are point by point scanning method [6] and growth method which includes distance table algorithm [7] and discrete construction algorithm [8].
The divisional weighted Voronoi diagram is the most complex situation when generator is a point, and the weighted Voronoi diagram is a special case when the diagram just has one sector.And the normal Voronoi diagram is a special case when the generators in the weighted Voronoi diagram have the same weight.Therefore, the algorithm of divisional weighted Voronoi diagram also can be used to generate normal Voronoi and weighted voronoi diagrams.The existing grid methods of divisional weighted Voronoi diagram include growth method and point by point scanning method.In this paper, the advantages and disadvantages of two algorithms are analyzed.A hybrid grid algorithm of divisional weighted Voronoi diagram is proposed.The spatial complexity of the algorithm is equivalent to that of the two algorithms, and the time complexity is close to the fastest growth algorithm, but the resulting Voronoi diagram is as accurate as the point by point scanning algorithm.

2
The relative research and analysis

Qualitative analysis
The main idea of point by point scanning method: the weighted distance between any pixel on the plane and all sectors of all generators is calculated in turn, and the generator with the nearest weighted distance is the generator that the pixel belongs to.In reference [6], weighted Voronoi diagram is generated by point by point scanning method.This idea can also be used to generate the divisional weighted Voronoi diagram by calculating the nearest generator's sector.This algorithm needs to calculate the weighted distance between any pixel on the plane and all generators.Therefore, the time complexity is constrained by the number of generators and sectors.However, the discrete construction algorithm proposed in reference [8] has the following problems: Problem 1: The rough boundary problem.The formation of the boundary is approximated by the "collision" of the generator synchronization extension process, and the final resulted edge is related to the order of the generators expansion process.Fig. 1 (a) and Fig. 1 (b) are the simulation results of the same generator in different order, and there are some differences in the boundary.Fig. 1 (c) is a comparison result of the point by point scanning method.In fact, there are inherently imprecise of the growth method on the boundary, both of the existing algorithm [7,8] have this boundary imprecision problem.The angular increment problem.In order to scan and color pixels on extended arc with all radii, the original algorithm sets a sufficiently small and fixed angular increment in order to color the arc with large radius correctly, which means that the angular increment for small radius arcs and large radius arcs are the same.This results in the slow coloring speed of the original algorithm in the early (when the radius is small) stage.The improved method is to set the angular increment as a dynamic value that decreases as the radius increases, see (2).It can satisfy the correctness of the algorithm with both small and large radius, and the efficiency of the algorithm is obviously higher.
Problem 3: The zebra stripe problem.It does not take into consideration of the large weight situation in original algorithm.For the generator with large weights, if the actual value of the radius (step) increment is greater than 1, it will result in some area that is not colored due to the large step.The principle is shown in Fig. 2 (a).Fig. 2 (b) is an example of the results, in which there are two generators with relatively large weights, one in the lower left corner and the other in the upper right corner.The result is an error.
On the other hand, when the weight of the generator is too small, the original algorithm has to compute the extended arc repeatedly, which affects the efficiency of the algorithm.The discontinuous region problem.The more important problem of this algorithm is that it does not consider the case of discontinuous Voronoi diagram (property Ⅳ of reference [2]).The algorithm is only correct in the situation when the discontinuous region is absent in the Voronoi diagram!The problem is discussed in reference [9], but the termination condition is not analyzed in detail.In order to clarify the termination condition of the growth method, the theorem 1 is given firstly.
Theorem 1: For the growth method, during the algorithm process, if a certain pixel in the drawing area is first covered by a generator, the color of the pixel will not be changed during the following process.
Inference 1: For the growth method, when the maximum weight generator covers all pixels on the panel, the algorithm ends.
Proof: The general situation is proved firstly.For any of the generator, if all the pixels on the panel can be covered by its extension area, then the color of any pixel in the drawing area is determined by the extension process or previous algorithm process.According to Theorem 1, the algorithm ends.
Therefore, the conclusion is also true for the maximum generator.Inference 2: For the growth method, the algorithm ends when all pixels of the drawing area are colored.
Proof: (omitted).Inference 1 sets the termination condition of the algorithm from the perspective of the generator, while inference 2 sets the termination condition from the perspective of the panel.According to the inference 1, when the situation in Fig. 3 occurs (the maximum weight generator is close to a corner and another relatively larger weight generator is close to another corner), although the panel has been completely covered and the color of each pixel on the panel is determined, the algorithm still needs to continue.Thus the efficiency is relatively low.According to inference 2, the algorithm would be more efficient with a counter.When the total numbers of pixels on the panel are all colored, the algorithm ends.It should be noted that the reference [7] also has problem 1 and 4. Problem 1 is the common problem of the growth method.Unless the parallel algorithm is used, any conventional algorithm of the growth method will have problem 1. Problem 4 is caused by the irrational design of the distance table algorithm [7] and the discrete construction algorithm [8].
In addition, according to the growth method, when the generator distribution is uneven or there is a super large weight generator, the boundaries of the majority of generators have been determined, but some individual generator expansion is not yet ended, because the algorithm needs to expand synchronously before it ends.It means that all generators still need to be calculated, which seriously affect the efficiency of the algorithm, as shown in

Quantitative analysis
Discrete construction algorithm [8] is that each pixel on the expansion arc of each generator is colored with the law of radius increment and the angle increment.Each pixel is calculated according to Eq. 1, in which (x0, y0) is the coordinate of the generator, r is the current expansion step of a sector of the generator, w is the weight of a sector of the generator, α is the initial angle, k is the scanned kth pixel on the extended arc, θ is the angular increment.It requires 6 times of multiplication to determine the color of each pixel in discrete construction algorithm.In particular, it also requires a sin function and a cos function as well, so the efficiency is low.
(x0+w*r*cos(α+k*θ), y0+w*r*sin(α+k*θ)) In the original discrete construction algorithm [8], the angular increment is fixed.In order to meet the accuracy requirements with large radius, the fixed angular increment must be small enough, these results in a very large repetitive workload to calculate the extended arc when the radius is small.In fact, the angular increment should be the corresponding angle of the adjacent two pixels on the extended arc.The minimum distance between two pixels on the panel is 1, and the corresponding minor arc will be slightly larger.According to the calculation relationship of radius, minor arc and angle, the angular increment should be calculated with Eq. 2 which can satisfy the correctness of the algorithm, and the efficiency of the algorithm is improved as well.
Correspondingly, according to the point by point scanning method, if there are n generators, to determine the color of any pixel on the space, it need to calculate the weighted distance between (x, y) and all the generator (xi, yi) in order to get the minimum weighted distance, as shown in Eq. 3.Where i w (i=1, 2,…, k) is the weight of each generator (divisional weighted Voronoi diagram is similar to this).The point by point scanning method requires k times of 2 times multiplications, 1 times division and 1times square root to determine the color of each pixel.
We estimate the calculation amount of Eq. 1 and Eq. 3. Eq. 4 and Eq. 5 are Taylor's expansion of sin and sqrt functions respectively.

 
If the accuracy is required as 10-9, Lagrange remainder of Eq. 4 is , Consider extreme conditions , we could get n=5.In other words, if Taylor expansion of sin function iterates 5 times, its accuracy can reach 10-9.At this point, the total calculation amount of multiplication and division in Eq. 4 is 1+4*n, which is 21.The calculation amount of cos function is the same as sin function, which is 21, too.Lagrange remainder of Eq. 5 is ,we could get n=8.At this point, the total calculation amount of multiplication and division in Eq. 5 is 1+7n, which are 57.
Therefore, according to Eq. 1 based on the discrete construction algorithm, it needs 48 times of multiplication and division to determine the color of a pixel.According to Eq. 3 based on the point by point scanning method, it needs 60*k times of multiplication and division to determine the color of a pixel.So, on the whole, the efficiency of the discrete construction algorithm is better than the point by point scanning method.S6：end.Algorithm 2 is used to color a sector of a generator.Since the initial coverage area of each generator may overlap, the algorithm will set the pixel to black if it is in the overlapped area during the progressive scanning and filling.Filling algorithm is relatively mature, such as the seed algorithm [10] and the progressive scan algorithm [11], and so on.A sector colored with filling algorithm is more special, we proposed a more efficient algorithm to do so.

Hybrid algorithm performance analysis and correctness proof 4.1 The performance analysis of the algorithm
The preprocessing stage of algorithm 1 calculates the color of each sector of each generator by a large step with weight r synchronously using algorithm 2 in which the main calculation is the boundary of a sector.Obviously, from the macroscopic point of view, this algorithm is faster than the discrete construction algorithm which calculates the extended arc pixel by pixel, and also faster than the point by point scanning method.
In addition, due to the use of the point by point scanning method in the later stage of hybrid grid algorithm, it solves the repetitive calculation problem in the later stage of growth method when the generator distribution is uneven or there is a super large weight generator, and the inherently imprecise of growth method (problem 1) are solved as well.
One of the key issues affecting the efficiency of this algorithm is the design of the initial step size.If the initial step is too large, the overlap area in preprocessing will be large, which means requiring more recalculation of the overlapping area color by the point by point scanning method; On the other hand, if the initial step is too small, there will be too many blank areas, the advantages of the preprocessing stage of this algorithm will be loosed.Ideally, the coverage area of all sector of each generator is just a balance between the blank area and the overlap area.
Without loss of the generality, we assume that the generators are equidistribution (Uneven distribution means that there are more generators in some space, and less generators in the other, which does not affect the correctness of the algorithm).Assuming that the total area is m, then the maximum value of k which meet Eq. 6 is basically the requirement for first step in algorithm 1.

4.2
The correctness proof of the algorithm In the preprocessing stage, firstly, each sector of generators extends in a large step, according to the principle of discrete construction algorithm, the area which is not overlapped has already determines the color, the area which is not yet processed will be colored according to point by point scanning method in late stage, in which the accuracy of the hybrid grid algorithm is the same as the point by point scanning method.How about the correctness of the overlapped area?Because the algorithm 2 sets the overlapped area to black, and S3 in algorithm 1 replace all the black pixels to white.In S4 of the algorithm 1, the color of each pixel in the overlapped area is determined by the point by point scanning method.So, the accuracy of the overlapped area is the same as the point by point scanning method.

5
The experimental results and analysis The experiment environment is the software of Visual Studio 2010 C#，the hardware of Intel ®Core(TM)i5 with CPU 2.4GHz and 2.0GB RAM.We reproduce the original discrete construction algorithm [6] (ODCA) and point by point scanning method [7] (PPSM) respectively, and implement the improved discrete construction algorithm (IDCA) and the proposed hybrid grid algorithm (HGA).It can be seen from the experimental results in Fig. 5, Table 1 and Fig. 5 that the original discrete construction algorithm is not correct and the efficiency is not high.The improved discrete construction algorithm is ideal implementation of the growth method, in which the result is correct and algorithm is more efficient, but the result of Voronoi diagram boundary is not accurate.The hybrid grid algorithm is faster than the point by point scanning method, and quite the same as the improved discrete construction algorithm.The trend is that the improved discrete construction algorithm is better.
When those algorithms are in application, if the accuracy requirement for Voronoi diagram boundary is not high, the improved discrete construction algorithm can be used, otherwise, the hybrid grid algorithm is a better choice.

Summary
In this paper, the properties and performance of growth method and point by point scanning method are analyzed from qualitative and quantitative aspects.A hybrid grid algorithm is proposed, which combines the advantages of growth method and point by point scanning method.At the same time, a special algorithm is proposed to improve the efficiency of filling the sector color of generators, which further improves the generation efficiency of the hybrid grid algorithm while processing divisional weighted Voronoi diagram.The problems need further research is as follows: Firstly, the determination of the initial step k can be further refined.Secondly, the overlapped area determined color according to the point by point scanning method only related to the generators that overlaps each other.Thirdly, after a color of a pixel is defined by point by point scanning method, all pixels on the line between the pixel and a generator maybe can easily calculate.These studies can further improve the performance of the hybrid grid algorithm.

Figure. 1
Figure.1 the results of the rough boundary problemProblem 2: The angular increment problem.In order to scan and color pixels on extended arc with all radii, the original algorithm sets a sufficiently small and fixed angular increment in order to color the arc with large radius correctly, which means that the angular increment for small radius arcs and large radius arcs are the same.This results in the slow coloring speed of the original algorithm in the early (when the radius is small) stage.The improved method is to set the angular increment as a dynamic value that decreases as the (a)The principle diagram (b) Example diagram

Figure 2 .
Figure 2. The zebra stripes problem Problem 4:The discontinuous region problem.The more important problem of this algorithm is that it does not consider the case of discontinuous Voronoi diagram (property Ⅳ of reference[2]).The algorithm is only correct in the situation when the discontinuous region is absent in the Voronoi diagram!The problem is discussed in reference[9], but the termination condition is not analyzed in detail.In order to clarify the termination condition of the growth method, the theorem 1 is given firstly.Theorem 1: For the growth method, during the algorithm process, if a certain pixel in the drawing area is first covered by a generator, the color of the pixel will not be changed during the following process.Proof: (omitted).Inference 1: For the growth method, when the maximum weight generator covers all pixels on the panel, the algorithm ends.Proof: The general situation is proved firstly.For any of the generator, if all the pixels on the panel can be covered by its extension area, then the color of any pixel in the drawing area is determined by the extension process or previous algorithm process.According to Theorem 1, the algorithm ends.Therefore, the conclusion is also true for the maximum generator.Inference 2: For the growth method, the algorithm ends when all pixels of the drawing area are colored.Proof: (omitted).Inference 1 sets the termination condition of the algorithm from the perspective of the generator, while inference 2 sets the termination condition from the perspective of the panel.According to the inference 1, when the situation in Fig.3occurs (the maximum weight generator is close to a corner and another relatively larger weight generator is close to another corner), although the panel has been completely covered and the color of each pixel on the panel is determined, the algorithm still needs to continue.Thus the efficiency is relatively low.According to inference 2, the algorithm would be more efficient with a counter.When the total numbers of pixels on the panel are all colored, the algorithm ends.

Figure 3 .
Figure 3. Cover the drawing area with the largest generator as the termination condition

Fig. 4 .Figure 4 .
Figure 4.The influence problem of the growth method later steps pixel is white){ according to the point by point scanning method, calculate the color of pixel, and set the pixel with the color; } } S5://calculate the boundary stage Scanning the panel, and extracting boundaries of the divisional weighted Voronoi diagram.

Figure 5 .
Figure 5.The result contrast of four algorithms Fig.5 is the result of the ODCA, IDCA, PPSM and HGA with 800 * 800 grid size and 10 generators.

Table 1
the time efficiency of these methods with different panel size and number of generators.