Our naïve algorithm checks for intersection for all pairs of vertices against all obstacles edges. However, there will be economy if we check for intersection in a certain order. In this algorithm, we check if other vertices are visible to a vertex by their cyclic order around that vertex. The best way to illustrate this algorithm will be to give an example of the execution for a certain vertex.
Step 1 : For a certain point p, sort all obstacle vertices according to he clockwise angle that the halfline from p to each obstacle vertex makes with the positive xaxis.
Step 2 : Let P be the halfline parallel to the positive xaxis starting at p. Find the obstacle edges, e_{i}, that are properly intersected by P, and store them in a balanced search tree T (shown right below) in the order in which they are intersected by P. This step takes O(n).
Step 3 : for all vertices w_{i}_{ }where i = 1 to n
1.  if pwi intersects the interior of the obstacle of which w_{i} is a vertex then return false 
2.  else if i = 1 or w_{i1} is not on the segment pw_{i} 
3. 

4. 

5. 

6. 

7. 

8. 

9. 

10. 

The consequences of this step on w_{1} is that lines 24 of VISIBLE gets executed because i = 1 and e_{i}_{ }in T intersects pw_{1}. w_{1} is not visible from p. This step takes O(log n) time because of search on the binary tree.
We now turn to w_{2}. The consequences of this step on w_{2} is that lines 24 gets executed because w_{1} is not on the segment pw_{2}, and that pw_{2} intersects e_{1}. w_{2} is not visible from p.
At w_{3}, something interesting happens. e_{6} and e_{3}, which are incident to w_{3} on the counterclockwise side of the halfline from p to w_{3}, are deleted from T, the binary tree.
Similarly, at w_{4}, e_{4} is deleted from T while e_{7}_{ }is inserted into T.
This algorithm goes on until all the run for w_{10} has finished. This algorithm allows the storage of the obstacle edges that will possibly intersect the next pw_{i} pair. It therefore does not search for all obstacle edges unnecessarily. Moreover, these edges are stored in a binary search tree, so even if all obstacle edges are potential candidates, searching for one that does intersect will only cost O(log n). Lines 610 of VISIBLE deals with special cases when w_{i1} is on the segment pwi, that is, p, w_{i1} and w_{i} are collinear. I do not intend to go into the details, which can be found in M. deBerg et al, 1997. My purpose here to convince you that this algorithm runs in O(n^{2} log n) time.
The
most timeconsuming step in the run for each vertex p is the sorting
of obstacle vertices around p by angularity, which takes O(n
log n). Since we repeat all this process for each of n vertex of
the set of obstacles, the overall runtime is O(n^{2}
log n).