A NEW ALGORITHM FOR COMPUTING VISIBILITY GRAPHS OF POLYGONAL OBSTACLES IN THE PLANE

. Given a set of h pairwise disjoint polygonal obstacles with a total of n vertices in the plane, the vertex-vertex visibility graph is an undirected graph whose nodes are vertices of the obstacles and whose edges are pairs of visible vertices. Ghosh and Mount gave a well-known O ( n log n + k ) time algorithm for computing the visibility graph, where k is the size of the graph. Later Kapoor and Maheshwari proposed an O ( T + n + h log h + k ) time algorithm for the problem, where T is the time for triangulating the free space. In this paper, by incorporating an extended corridor structure into Ghosh and Mount’s algorithm, we provide an alternative approach for computing the visibility graph in O ( T + n + h log h + k ) time. Like Ghosh and Mount’s algorithm, our algorithm can also compute several useful structures such as the funnel structure and the enhanced visibility graph, which have many other applications such as computing the vertex-edge visibility graphs, the edge-edge visibility graphs, the extended vertex-vertex visibility graphs, and the visibility polygons of obstacle vertices, etc.


Introduction
Given a set of h pairwise disjoint polygonal obstacles, P = {P 1 , P 2 , . . ., P h }, with a total of n vertices in the plane, the space minus the interior of all obstacles is called the free space.Each obstacle P i of P is an arbitrary simple polygon.We say two points in the plane are visible to each other if the open line segment between them lies in the free space.Two objects in the plane are visible to each other if a point of one object is visible to a point of the other object (this is usually called weakly visible in the literature; we use visible here for the sake of simplicity).
The vertex-vertex visibility graph of P is defined to be an undirected graph whose nodes are the vertices of the obstacles and whose edges are pairs of visible vertices.Similarly, the vertex-edge visibility graph of P is an undirected graph whose nodes are the vertices and edges of the obstacles, and a vertex and an obstacle edge are adjacent in the graph if the vertex is visible to the obstacle edge; the edge-edge visibility graph of P is an undirected graph whose nodes are the edges of the obstacles, and two obstacle edges are adjacent in the graph if one edge is visible to the other edge.The sizes of these three graphs are asymptotically equal [10].In this paper, we use k to denote the size of such a graph.

Journal of Computational Geometry jocg.org
Computing visibility graphs is a fundamental problem in computational geometry and has been studied extensively.For the vertex-vertex visibility graph, O(n 2 log n) time algorithms were obtained by Lee [18] and Sharir and Schorr [21].Asano et al. [1] and Welzl [23] gave O(n 2 ) time algorithms, which are worst-case optimal since k = Θ(n 2 ) in the worst case.Overmars and Welzl [20] developed an O(k log n) time algorithm.An output-sensitive O(n log n+k) time algorithm was presented by Ghosh and Mount [10], which we call the GM algorithm.The GM algorithm computes a funnel structure that is quite powerful (it actually computes an "enhanced visibility graph").For example, it was shown that the algorithm in [10] can be extended to compute the vertex-edge and edge-edge visibility graphs, each in O(n log n + k) time.Note that another O(n log n + k) time algorithm for computing the edge-edge visibility graphs is given in [17].With the linear time triangulation algorithm [3], Hershberger [12] gave an O(n + K) time algorithm for computing the vertex-vertex visibility graph in a simple polygon, where K is the size of the graph.
In this paper, we present an O(T + n + h log h + k) time algorithm for computing the vertex-vertex visibility graph of P, where T is the time for computing an arbitrary triangulation of the free space.The current best triangulation algorithms run in either O(n log n) time or O(n + h log 1+ h) time [2] for an arbitrarily small constant > 0. Therefore, T = O(min{n log n, n + h log 1+ h}).Hence, our algorithm reduces the additive O(n log n) time factor in the GM algorithm to O(T + n + h log h).
As in [10], our algorithm can compute the powerful funnel structure and enhanced visibility graph, and thus can be extended to compute the vertex-edge and edge-edge visibility graphs, each in the same amount of time as above.Also, using the funnel structure, for any obstacle vertex, our algorithm can compute its visibility polygon in O(m) time, where m is the size of the visibility polygon.Note that a visibility polygon of a point p is the set of all points in the free space that are visible to p.In addition, our algorithm can further be extended to compute the extended vertex-vertex visibility graph of P in the same amount of time, which contains not only the vertex-vertex visibility graph but also for each edge of the visibility graph its two extension endpoints on the obstacles of P (or in infinity) when extending the edge along both directions until it hits some obstacles (or infinity).The extended vertex-vertex visibility graph is useful in many applications, e.g., computing minimum link paths [19] and the weak visibility polygon of a line segment [22] among polygonal obstacles.
It should be noted that Kapoor and Maheshwari [15] have given an algorithm for computing the vertex-vertex visibility graph in O(T + n + h log h + k) time.Although its running time is essentially the same as ours, our approach is quite different from theirs and our algorithm deserves attention due to the following reasons.First, since the visibility graph is very fundamental, it may be worthwhile to have an alternative solution.Second, unlike Kapoor and Maheshwari's algorithm [15], which is quite different from the well-known GM algorithm [10], our algorithm basically follows the scheme of the GM algorithm [10].Thus, readers who are familiar with the GM algorithm will find our algorithm relatively easy to follow.Third, as the GM algorithm, our algorithm can also compute other useful structures efficiently, e.g., the funnel structure, the enhanced visibility graph, the vertexedge and edge-edge visibility graphs, the extended vertex-vertex visibility graph, and the visibility polygons of obstacle vertices, as discussed above.
Journal of Computational Geometry jocg.orgHenceforth, unless otherwise indicated, our discussion will focus on the vertex-vertex visibility graph and we simply use the term "visibility graph" for it.

Our Approach
We use the idea of computing the funnel structure as the GM algorithm [10].The additive O(n log n) time factor in the GM algorithm is due to its use of a particular plane-sweeping triangulation algorithm [13] on the free space (an arbitrary triangulation does not work for the GM algorithm).We give a new approach that avoids the O(n log n) time plane-sweeping triangulation but still computes the funnel structure as the GM algorithm.
Denote by G the sought visibility graph of P, and by F the free space of P. We first compute an arbitrary triangulation of F in O(T ) time, from which we build an extended corridor structure [4,5,7,6,8].The corridor structure was originally used to solve shortest path problems (e.g., [14,16]), and later new concepts like "ocean", "bays", and "canals" have been introduced [4,5,7,6,8], which is referred to as the "extended corridor structure".This structure partitions F into a space M (called ocean) and other regions, called bays and canals.While the ocean M may be multiply connected, every bay or canal is a simple polygon.Each bay has a common boundary edge with M, and each canal has two common boundary edges with M. But a bay or canal does not share any edge with another bay or canal.The common edges of bays (resp., canals) and M are called the gates.Thus, each bay has one gate and each canal has two gates.All vertices on the boundaries of M and the bays/canals are obstacle vertices of P.
An important property is that the boundary of the ocean M consists of O(h) convex chains with a total of O(n) vertices.This allows us to apply Hertel and Mehlhorn's planesweeping triangulation algorithm [13] to triangulate the space M in O(n + h log h) time.The resulting triangulation of M is sufficient for the GM algorithm to compute the visibility graph of the vertices of the boundary of M with respect to the space M. But, this graph is only a subgraph of G. To construct G fully, we must also consider the vertices in the space of F \ M, i.e., all bays and canals.To this end, we perform the following preprocessing on all bays and canals.For each bay or canal P , since it is a simple polygon, by modifying Hershberger's algorithm [12], we build the funnel structure and the enhanced visibility graph for P in O(k ) time, where k is the size of P 's visibility graph.Further, the enhanced visibility graphs we build for the bays and canals have some special properties that are needed by our main algorithm.Processing all bays and canals as above takes O(n + k) time in total.
Our main algorithm is guided by the plane-sweeping triangulation algorithm [13] on the ocean M.During the plane-sweeping, we follow a scheme similar to the GM algorithm, but a key difference is that when a bay/canal gate is a side of the current triangle under consideration, we use a connection procedure to handle the interaction between the funnel structure of the bay/canal and that of the subregion of M that has been triangulated, which occurs through the gate of that bay/canal.In this way, after the triangulation of M is finished, the funnel structure and the enhanced visibility graph for the entire free space F will be constructed.

Journal of Computational Geometry jocg.org
In a nutshell, our approach can be viewed as a novel combination of the funnel structure based GM algorithm [10] and Hershberger's algorithm [12] for simple polygons, based on a corridor partition of the free space F. Comparing with the GM algorithm, our algorithm has four main differences: (1) We partition the free space F into the ocean M and bays/canals; (2) our algorithm performs a preprocessing step on all bays and canals; (3) our plane-sweeping triangulation is only on the ocean M (i.e., a subregion of F); (4) our main algorithm calls a collection of connection procedures to merge the visibility graph of M with those of the bays and canals through every bay/canal gate.We show that the total time of calling all connection procedures in the entire algorithm is O(n + k).
Note that Kapoor and Maheshwari's algorithm [15] also uses the corridor structure, but our algorithm is quite different from theirs.For example, they do not use the extended corridor structure, i.e., they do not partition the free space F into M and the bays and canals, and they do not compute the funnel structure.
For ease of exposition only, as in [10] we make a general position assumption that no three obstacle vertices are collinear and no two vertices lie on the same vertical or horizontal line.To distinguish the edges of the obstacles in P from the edges of the visibility graph G, we often refer to the former as obstacle edges and the latter as graph edges or visible segments.The vertices of the obstacles in P are also called obstacle vertices.
The rest of the paper is organized as follows.In Section 2, we briefly review the GM algorithm [10], in particular, the funnel structure and the enhanced visibility graph.In Section 3, we discuss the extended corridor structure and give some observations.In Section 4, we do the preprocessing for all bays and canals.The main algorithm is given in Section 5. Section 6 concludes with remarks on the extension of our algorithm to other problems, e.g., the vertex-edge, edge-edge, and extended vertex-vertex visibility graphs.

Preliminaries
In this section, we briefly review the GM algorithm [10], in particular, the funnel structure and the enhanced visibility graph.

The Funnel Structure
For two points a and b, let ab denote the line segment connecting them, and depending on the context this segment may have a direction from a to b.
We first define funnels.Let xy be a directed obstacle edge (i.e., it has a direction from x to y) such that the free space is on its left.Without loss of generality, assume x is lower than y.Let v be an obstacle vertex to the left of xy (see Fig. 1).Suppose v is visible to some point z on xy.A funnel can be formed by considering the paths vz ∪ zx and vz ∪ zy as two rubber bands and allowing them to snap to their natural shape, e.g., see Fig. 1(a).These bands then form two convex chains, one from v to x, called the lower chain, and the other from v to y, called the upper chain.The obstacle-free simple polygon bounded by the lower chain, upper chain, and xy is called a funnel whose apex is v and whose base is xy.Note that the same obstacle vertex and edge may define many different funnels (see Fig. 1(b)).A funnel can be uniquely determined by the first segment of its lower chain (or its upper chain).To see this, suppose u 0 , u 1 , . . ., u m are the clockwise sequence of obstacle vertices visible to v such that vu 0 and vu m are the two obstacle edges incident to v. Then for any adjacent pair u i−1 and u i , the vertex v can see only one obstacle edge e if looking between u i−1 and u i .Thus, there is a unique funnel with apex v and base e whose lower chain (resp., upper chain) begins with vu i (resp., vu i−1 ).In other words, given vu i (or vu i−1 ), a funnel can be uniquely determined.Due to this property, the total number of funnels for P is at most 2k [10].Denote by F (xy) the set of all funnels whose base is xy (directed from x to y).Since the free space lies to the left of xy, all funnels are on the left of xy.Suppose v is the apex of a funnel f v ∈ F (xy) and vu is the first (directed) segment of the lower chain (i.e., from v to x) of f v .Then by convexity, u is also the apex of a funnel f u and f u is contained in the funnel f v .If we view the apex u as the parent of the apex v, then the funnels in F (xy) form a tree rooted at x (see Fig. 2).We distinguish obstacle vertices from funnel apices because the same obstacle vertex can appear multiple times as apices in F (xy), whereas each apex can appear only once (e.g., in Fig. 1(b), there are two funnel apices located at the physical obstacle vertex v).Each path from the root to a leaf in this tree is a convex chain that turns counterclockwise.We call this tree the lower tree for the obstacle edge xy.Similarly, there Journal of Computational Geometry jocg.org is an upper tree for xy.There is a natural linear ordering on the funnels of F (xy) based on the clockwise preorder traversal of the lower tree, which, as shown in [10], is the same as the clockwise postorder traversal of the upper tree.The sequence of funnels in F (xy) ordered as such is called the funnel sequence of xy.Note that we treat the vertices x and y as two degenerate funnels.Below, we also use F (xy) to denote the funnel sequence of xy.

The Enhanced Visibility Graph
We first review some primitive operations that are used in the GM algorithm [10].
Consider an obstacle vertex v. Suppose Vis(v) = {u 0 , u 1 , . . ., u m } is the clockwise sequence of all obstacle vertices of P visible to v such that vu 0 and vu m are the two obstacle edges incident to v (see Fig. 3).For any u i , let its clockwise successor, denoted by CW (vu i ), be vu i+1 , and let its counterclockwise successor, denoted by CCW (vu i )), be vu i−1 .Both CCW (vu 0 ) and CW (vu m ) are undefined.We also define the clockwise extension CX(u i v) as follows.Rotate the ray originating at v and going through u i clockwise by 180 degrees about v.If this rotation encounters neither vu 0 nor vu m , then CX(u i v) is the very next visible vertex in Vis(v) encountered after the 180 degree rotation (see Fig. 3); otherwise, CX(u i v) is undefined.The counterclockwise extension CCX(u i v) is defined symmetrically.Finally, define REV (vu i ) to be the directed reversal of vu i , i.e., REV (vu i ) = u i v (by viewing vu i and u i v as directed segments).
The above five operations are called the primitive operations.
Define the enhanced visibility graph of P to be the visibility graph of P with the following additional properties: (1) For each graph edge, the five primitive operations CW , CCW , CX, CCX, and REV can be performed in constant time each; (2) the funnel sequence F (xy) of each obstacle edge xy is represented as a doubly linked list so that the operations of split, concatenation, predecessor, and successor can be performed in constant time each.Hence, the enhanced visibility graph essentially refers to the same graph as the visibility graph but is associated with more information.Henceforth, we use G to also denote the enhanced visibility graph of P.
To implement the primitive operations, note that CW, CCW , and REV are easy.For the other two, we call them extension operations, which are implemented in the following way.Let Vis l (v) be the set of vertices in Vis(v) that are to the left of the vertical line through v, and Vis r (v) = Vis(v) \ Vis l (v).The GM algorithm has two properties that help implement the two extension operations CX and CCX efficiently: (1) All vertices in Vis l (v) are identified before any in Vis r (v); (2) the vertices in Vis l (v) are cyclically ordered about v before any vertex in Vis r (v) is identified.With these two properties, the GM algorithm uses the Split-Find (a reversal of the Union-Find) data structure [9] to implement the two extension operations on the incident graph edges of v in G in constant time each.We call the vertical line through v the reference line of v.In fact, the reference lines need not be vertical, and to implement the extension operations in constant time each, the same approach as in the GM algorithm still works as long as the above two properties hold.This is summarized in the following lemma.Later in our new algorithm, for those obstacle vertices in the bays and canals, we will use some reference lines that are not necessarily vertical.
The following lemma has been proved in [10].
Lemma 2. (Ghosh and Mount [10]) If all primitive operations can be performed in constant time each, then the clockwise and counterclockwise traversals of the lower and upper trees can be carried out in time proportional to the sizes of the trees, and a funnel sequence can be traversed in time linear in its size.
A fundamental procedure of the GM algorithm is called SPLIT.This procedure takes as input the enhanced visibility graph for a subregion P of P, a directed edge xy on the external boundary of P , and a point v lying to the right of xy so that the triangle xvy is external to P (see Fig. 4).The SPLIT procedure merges xvy into P by computing the enhanced visibility graph for the enlarged region P ∪ xvy.This is accomplished by identifying all obstacle vertices in P visible to v through xy, and splitting the funnel sequence F (xy) into two funnel sequences F (xv) for xv and F (vy) for vy.Further, the Journal of Computational Geometry jocg.org(a) (b) vertices in P visible to v are identified in cyclical order about v (each of these visible vertices is connected to v by a visible segment).We say a point p is visible to a point q through a line segment ab if p is visible to q and pq intersects ab.The following lemma has been shown in [10].
Lemma 3. (Ghosh and Mount [10]) The SPLIT procedure on xy and v can be performed in time linear in the number of obstacle vertices visible to v through xy.

The Plane-Sweeping Triangulation and the Overall GM Algorithm
The GM algorithm is guided by a particular plane-sweeping triangulation algorithm [13].
The obstacle vertices are first sorted by increasing x-coordinates and are included into the triangulation in this order.Let v 1 , v 2 , . . ., v n be the sorted list of the obstacle vertices.In a general step, the first i − 1 obstacle vertices have been processed, and we have available a triangulation of a subregion P i−1 of P as well as the enhanced visibility graph of P i−1 .
To process the vertex v i , we add visible segments between v i and all vertices on the boundary of the triangulated region P i−1 that are visible to v i (see Fig. 5).As shown in [10,13], these new triangles (with v i as a common vertex) form either one or two connected sequences around v i such that the sides opposite to v i in each such sequence form an inwardconvex chain with respect to v i ; when there are two such sequences, they are separated by the boundary of P (see Fig. 5).In this way, we obtain the triangulated subregion P i .
We then compute the enhanced visibility graph for P i by updating that for P i−1 , as follows.For each connected sequence of vertices visible to v i , if the sequence contains only one segment xy, then we call the SPLIT procedure on xy and v i .Otherwise, let u 0 , u 1 , . . ., u m be the sequence (see Fig. 6).Our objective is to compute the funnel sequences F (u 0 v i ) for u 0 v i and F (v i u m ) for v i u m .To this end, for each 1 ≤ j ≤ m, we call the SPLIT procedure on u j−1 u j and v i , which splits the funnel sequence F (u j−1 u j ) into two funnel sequences, L j for u j−1 v i , and U j for v i u j .Note that the funnel sequence F (u j−1 u j ) for each 1 ≤ j ≤ m has already been computed.The following lemma has been proved in [10].
Lemma 4. (Ghosh and Mount [10]) The funnel sequence F (u 0 v i ) (resp., F (v i u m )) in P i is the concatenation of the L j 's (resp., U j 's) for j = 1, 2, . . ., m, followed (resp., preceded) by the trivial funnel whose apex is v i .

Journal of Computational Geometry
jocg.orgBy Lemma 3, the time for computing the enhanced visibility graph for P i from that for P i−1 is proportional to the number of vertices in P i−1 that are visible to v i .
The total time of the GM algorithm is O(n log n + k), where the O(n log n) time is due to the plane-sweeping triangulation and the O(k) time is for all calls to the SPLIT procedure.

The Extended Corridor Structure and Observations
In this section, we discuss the extended corridor structure, which partitions the free space F into the ocean M, bays, and canals.We also give some observations, which are used to show the correctness of our algorithm presented later.
The corridor structure was originally used to solve shortest path problems (e.g., [14,16]), and later new concepts like "ocean", "bays", and "canals" have been introduced [4,5,7,6,8], which is referred to as the "extended corridor structure".This structure is a subdivision of the free space on which algorithms for specific problems rely.While the extended corridor structure itself is relatively simple, the main difficulty is to discover new observations and techniques that can be used to solve the problem.We briefly review the extended corridor structure below.

The Extended Corridor Structure
For simplicity of discussion, we assume all obstacles are contained in a large rectangle R (see Fig. 7).In fact, our algorithm works for any arbitrary simple polygon R. Let F be the free space inside R.
Denote by Tri(F) an arbitrary triangulation of F. The line segments of Tri(F) that are not obstacle edges are referred to as diagonals.Let G(F) denote the (planar) dual graph of Tri(F), i.e., each node of G(F) corresponds to a triangle in Tri(F) and each edge connects two nodes of G(F) corresponding to two triangles sharing a diagonal of Tri(F).The degree of each node in G(F) is at most three.Based on G(F), we compute a planar 3-regular graph, denoted by G 3 (the degree of each node in G 3 is three), possibly with loops and multi-edges, as follows.First, we remove every degree-one node from G(F) along with its Journal of Computational Geometry jocg.orgincident edge; repeat this process until no degree-one node remains.Second, remove every degree-two node from G(F) and replace its two incident edges by a single edge; repeat this process until no degree-two node remains.The resulting graph is G 3 (e.g., see Fig. 7).By Euler's formula, the graph G 3 has h + 1 faces, 2h − 2 nodes, and 3h − 3 edges [16].Each node of G 3 corresponds to a triangle in Tri(F), which is called a junction triangle (e.g., see Fig. 7).The removal of all junction triangles from G 3 results in O(h) corridors, each of which corresponds to one edge of G 3 .
The boundary of a corridor C consists of four parts (see Fig.  c, d) joining the two apices of the two funnels, called the corridor path of C. To distinguish from the funnels in the GM algorithm, we call the two funnels of H C corridor-funnels, or c-funnels for short.Each side of a c-funnel is also convex.We process each corridor as above.After Tri(F) is computed, the time for processing all corridors is O(n).visibility graph for the obstacle vertices on ∂M with respect to the space M. Denote by G M this visibility graph on M. Since M ⊆ F, the graph G M is a subgraph of the visibility graph G for P.
To construct G, we need to know the portions of G which are not in G M , i.e., G \ G M .For this, we first examine the space F \ M. Generally, the space F \ M consists of two types of regions, called bays and canals.The details are given below.
Consider the hourglass H C of a corridor C. We first discuss the case when H C is open (see Fig. 8).H C has two sides.Let S 1 (H C ) be an arbitrary side of H C .The obstacle vertices on S 1 (H C ) all lie on the same obstacle, say P ∈ P. Let w and z be any two adjacent vertices on S 1 (H C ) such that the line segment wz is not an edge of P (see the left figure in Fig. 8, with P = P j ).The free region enclosed by wz and a boundary portion of P between w and z is called the bay of wz and P , denoted by bay(wz), which is a simple polygon.We call wz the bay gate of bay(wz).
If the hourglass H C is closed, then let f and g be the two apices of its two c-funnels.Consider two adjacent vertices w and z on a side of a c-funnel such that the line segment wz is not an obstacle edge.If neither w nor z is a c-funnel apex, then w and z must both lie on the same side of the corridor C and thus wz defines a bay.However, if one of w and z is a c-funnel apex, say, f = w, then f and z may lie on different sides of C. If they both lie on the same side of C, then they also define a bay; otherwise, we call f z the canal gate at f (see Fig. 8).Similarly, there is also a canal gate at the c-funnel apex g, say gr.The region of the corridor C bounded by the two canal gates f z and gr that contains the corridor path of H C is called the canal of H C , denoted by canal(f, g), which is also a simple polygon.The following observation on the canal canal(f, g) has already been discussed in [5].

Observation 1.
[5] Given a point p on the gate f z and a point q on the gate gr, the shortest path from p to q in canal(f, g) is the concatenation of pf , the corridor path of canal(f, g), and gq.The corridor path of canal(f, g) is the shortest path from f to g in canal(f, g).
It is easy to see that F \ M consists of all bays and canals thus defined.

Journal of Computational Geometry
jocg.org

Observations
The fact that each bay has only one gate allows us to handle a bay relatively easily.Intuitively, an observer outside a bay cannot see any point outside the bay "through" its gate.But, each canal has two gates, which could potentially give us trouble.The next lemma (proved in [5]) shows an important property of the canals, which essentially says that an observer outside a canal cannot see any point outside the canal through the canal (and its two gates).
Lemma 5. [5] For any canal, suppose a line segment pq is in F (i.e., p is visible to q) such that neither p nor q is in the canal.Then pq cannot contain any point of the canal that is not on its two gates.
As shown later, Lemma 5 allows us to deal with each canal (almost) as simply as a bay.For example, our algorithm can process each gate of a canal independently.
Next, we consider the (missing) graph portion G \ G M .For a bay or a canal, if a vertex v of it does not lie on a gate of it, then we call v a non-gate vertex; otherwise, v is a gate vertex.Note that the vertices of G that are not in G M are non-gate vertices of all bays and canals.For each graph edge e = uv in G \ G M , since e ∈ G, u is visible to v with respect to F (i.e., uv ⊂ F).Since e ∈ G M , there are two possible cases: (1) at least one of u and v is not in G M ; (2) both u and v are in G M but uv ⊂ M (i.e., u and v are not mutually visible with respect to M).
For case (1), suppose u is a non-gate vertex of a bay/canal and v is not a vertex of the same bay/canal (v may be either a non-gate vertex of another bay/canal or a vertex of G M ); then since e = uv ⊂ F, uv must intersect a gate of that bay/canal.If both u and v are vertices of the same bay and uv is not a bay gate (i.e., at least one of u and v is a non-gate vertex), then e must be contained in the bay.But, if both u and v are vertices of the same canal and at least one of u and v is a non-gate vertex, then since a canal has two gates, either e is contained in the canal or e intersects both its gates and has a portion outside the canal (i.e., the portion of e between its two intersections with the two canal gates is outside the canal).
For case (2), the next lemma shows that it is actually a nonissue.Lemma 6.For any two vertices u and v of G M , if uv ⊂ F and uv ⊂ M, then u and v are the two c-funnel apices of the same canal whose corridor path is the line segment uv (see Fig. 9).
Proof.Since uv ⊂ M, uv must intersect the space F \ M. In other words, uv must intersect the inside of a bay or a canal (we say that a point p in a bay/canal is in the inside of the bay/canal if and only if p is not on any gate of the bay/canal).Since uv ⊂ F and both u and v are vertices of G M , uv cannot intersect the inside of any bay because a bay has only one gate.Below, we discuss the case when uv intersects the inside of a canal canal(f, g).
Because both u and v are vertices of G M , neither of them is a non-gate vertex of canal(f, g).Since uv intersects the inside of canal(f, g), when moving from u to v along uv, we must move into the inside of canal(f, g) through one of its gates and move out of  its inside through the other gate.Let f z and gr be these two gates.The above discussion implies that there is a point u ∈ f z ∩ uv and a point v ∈ gr ∩ uv such that u = v and the open line segment of u v is in the inside of canal(f, g).By Observation 1, the shortest path π(u , v ) from u to v in canal(f, g), which is u v , is the concatenation of u f , the corridor path of canal(f, g), and gv .Thus, the corridor path is f g ⊆ u v .Since the open line segment of u v is in the inside of canal(f, g), f g intersects the inside of canal(f, g), and hence f = g.If u = f , then u f is a line segment contained in u v , implying that f z is collinear with g, a contradiction with the general position assumption that no three obstacle vertices are collinear.Thus, u = f .Similarly, we can show v = g.Hence, both u and v are vertices of G M , and u = u and v = v (due to the general position assumption).Therefore, it must be that uv = f g, which is also the corridor path connecting the two c-funnel apices u = f and v = g in canal(f, g).The lemma thus follows.
If the above case (2) occurs, then by Lemma 6, u and v are the two c-funnel apices of the same canal and its corridor path is uv (i.e., uv is contained in the canal).Hence, uv is an edge of the visibility graph of the canal.
The following lemma summarizes our discussions above.Lemma 7.Each graph edge e = uv ∈ G \ G M belongs to one of the following three cases (see Fig. 10).
(I) Both u and v are vertices of the same bay/canal but uv is not a gate, and uv is contained in that bay/canal (i.e., u and v are mutually visible within that bay/canal).
(II) Both u and v are vertices of the same canal and at least one of u and v is a non-gate vertex, and uv intersects both gates of that canal and has a portion outside the canal.
(III) u is a non-gate vertex of a bay/canal, v is not a vertex of the same bay/canal, and uv intersects a gate of that bay/canal.
Henceforth, we call the edges of G \ G M the missing edges.We need to compute all three cases of missing edges.More specifically, the missing edges of Case (I) are computed Journal of Computational Geometry jocg.org in the preprocessing in Section 4 and those of the other two cases are computed in the main algorithm in Section 5. Actually, our algorithm does not first compute the graph G M and then add G \ G M to it; instead, it constructs both G M and G \ G M simultaneously.

The Preprocessing of the Bays and Canals
In this section, we perform a preprocessing step on all bays and canals.More specifically, for each bay/canal, we compute the enhanced visibility graph (and the funnel structure) for it.Further, the enhanced visibility graph is not built in an arbitrary manner but has some special properties that are needed by the main algorithm.
Our preprocessing algorithm is based on a modification of Hershberger's algorithm [12].In Section 4.1, we compute an enhanced visibility graph for an arbitrary simple polygon.In Section 4.2, we compute a specific enhanced visibility graph for each bay/canal by modifying the algorithm in Section 4.1, which has some properties useful to our main algorithm.

Computing the Enhanced Visibility Graph of a Simple Polygon
Let P be a simple polygon of n vertices, and k be the number of edges in the visibility graph of P .Our goal is to compute an enhanced visibility graph (and the funnel structure) of P in O(n + k ) time, by modifying Hershberger's algorithm [12], which computes the visibility graph of P in O(n + k ) time.We first briefly review the algorithm in [12].
Let v 1 , v 2 , . . ., v n be the vertices of P along its boundary counterclockwise.The algorithm first computes the shortest path map in P with respect to the vertex v 1 , denoted by SPM (v 1 ), in O(n ) time [11].Using SPM (v 1 ), we can easily find all vertices of P visible to v 1 in O(1) time each.Then, the algorithm computes the shortest path map SPM (v 2 ) by updating SPM (v 1 ).From SPM (v 2 ), we find all vertices of P visible to v 2 in constant time each.This process is repeated until SPM (v n ) is computed.The visibility graph of P is thus constructed.
To analyze the running time, it was shown in [12] that computing SPM (v 2 ) from SPM (v 1 ) can be done in time proportional to the size of differences between SPM (v 1 ) and SPM (v 2 ).More specifically, denote by diff (v 1 , v 2 ) the set of interior edges each of which is in one of SPM (v 1 ) and SPM (v 2 ) but not in both.In other words, diff (v 1 , v 2 ) is the symmetric difference between the two sets of interior edges of SPM (v 1 ) and SPM (v 2 ).Denote by P vis (v 1 v 2 ) the edge-visibility polygon of the edge v 1 v 2 , i.e., the subpolygon of P each of whose points is visible to some point on v 1 v 2 .It was proved in [12] that the edges in diff [12].It was also proved [12] that the total number of differences between the shortest path maps of all adjacent vertices of P is O(k ).Hence, the time of the entire algorithm is O(k + n ).
Next, we describe our algorithm for computing an enhanced visibility graph of P , denoted by EG P .Let G P be the (ordinary) visibility graph of P .Recall that EG P is G P which has the following two additional properties: (1) For each edge of EG P , the primitive Journal of Computational Geometry jocg.org operations CW, CCW, CX, CCX, and REV can be performed in constant time each; (2) the funnel sequence F (xy) of each edge xy of P is represented as a doubly linked list.
To compute EG P , we first apply the algorithm in [12] to obtain G P .Then, we use exactly the same approach as the GM algorithm to implement the primitive operations in constant time each.(In fact, since the graph G P is available, this can be done much more easily.)Specifically, for each vertex v, we use a doubly linked list to represent all its incident edges in G P in a cyclical order to implement the operations CW and CCW .The operation REV is trivial.For the two extension operations CX and CCX, recall that for each vertex v, the GM algorithm uses a vertical line through v as a reference line to help implement them.Here, since G P is already available, we know all edges incident to v, and thus can use any line passing through v as a reference line to implement CX and CCX.
Consider the problem of constructing the funnel sequence F (xy) for each edge xy of P .Since we can implement all primitive operations in constant time each, by Lemma 2, for any edge xy of P , we can perform a clockwise preorder traversal of the lower tree of xy in time proportional to the size of its funnel sequence.Recall that the obstacle vertices visited by the clockwise preorder traversal of the lower tree of xy are exactly the ordered apices of the funnel sequence of xy.Thus, during the traversal, we can easily build a doubly linked list for F (xy).Therefore, we construct F (xy) in time proportional to the size of its funnel sequence.We compute this for each edge of P , after which all funnel sequences are obtained.Lemma 8.The total time for constructing the funnel sequences for all edges of P is O(k ).
Proof.For any edge xy of P , we have shown that constructing its funnel sequence can be done in linear time in the size of the funnel sequence.According to the result in [10], the total size of the funnel sequences of all edges of P is at most 2k .Hence, the lemma follows.
We thus have the following result.
Theorem 1.For any simple polygon P of n vertices, we can build the enhanced visibility graph of P in O(n + k ) time, where k is the number of edges in the graph.

Computing the Enhanced Visibility Graphs of Bays and Canals
We discuss a specific implementation of the enhanced visibility graphs for bays and canals.The reason for this is that in the main algorithm we will need to combine the funnel sequences of a bay/canal with those outside the bay/canal through its gates and this specific implementation of the enhanced visibility graph for the bay/canal will be helpful for the main algorithm.More precisely, for each bay/canal, we choose specific reference lines for implementing the two extension operations CX and CCX, based on some observations on the structure of the bay/canal.The details are given below.Recall that G is the visibility graph of P.
We first discuss the case of a bay bay(wz).Later in the main algorithm we will identify the vertices outside bay(wz) that are visible to the non-gate vertices of the bay.Each visible segment between such a vertex pair must intersect the gate wz of bay(wz).The next lemma determines a reference line for each non-gate vertex of bay(wz) to be used in the main algorithm.
Lemma 9.For each non-gate vertex v of bay(wz), the line through v and parallel to the gate wz can be used as a reference line for implementing the two extension operations for the edges of G incident to v in constant time each in the main algorithm (see Fig. 11).
Proof.If the vertex v is not visible to any point outside the bay, then v cannot be visible to any obstacle vertex outside the bay, and thus we can use any line through v to be its reference line as in the case of an arbitrary simple polygon in Section 4.1.In the following, we assume v is visible to at least one point outside the bay.Denote the line specified in the lemma by l (see Fig. 11).We need to show that l has the two properties required in Lemma 1.
The line l divides the plane into two half-planes.Let L be the open half-plane of l that does not contain wz.Denote by R the other (closed) half-plane of l.Let V L (resp., V R ) be the set of vertices of bay(wz) visible to v in L (resp., R).Let V R be the set of obstacle vertices visible to v that will be identified in the main algorithm.In other words, V R is the set of obstacle vertices visible to v that are outside the bay.Consider any vertex u ∈ V R .As discussed earlier, uv must intersect wz.Since l is parallel to wz and v is a non-gate vertex of the bay, u must be in R. Therefore, all vertices of V R are in R.
Since the visibility graph of bay(wz) is computed in the preprocessing, we can process the vertices of V R later than those in V L when implementing the extension operations (i.e., we may view V R as being identified later than V L in the main algorithm).Since the vertices in V R will be found in the main algorithm, they are identified later than those in V L (which are found in the preprocessing).Since all vertices in V R and V R are in R, property (1) of Lemma 1 is satisfied.Since the visibility graph of bay(wz) is available, the vertices of V L are cyclically ordered before the main algorithm; thus property (2) of Lemma 1 is satisfied too.Hence, the lemma follows.
We then consider the case of a canal.Our task is to determine a reference line for each canal non-gate vertex to implement the two extension operations in constant time each in the main algorithm.To this end, as in the bay case, the key is to determine, for each Journal of Computational Geometry jocg.org Figure 13: The line l is in the union of the cones C1 and C2; g1 and g2 are the two canal gates.
canal non-gate vertex v, a reference line through v such that all obstacle vertices visible to v to be found in the main algorithm lie in the same half-plane of the line.In the case of a bay, this is easy since it has only one gate.In Lemma 10 below, we show that such a reference line for each vertex in a canal still exists.Later in Lemma 11, we give an algorithm based on the proof of Lemma 10 that computes the reference lines for all vertices of a canal in linear time.
Lemma 10.For each non-gate vertex v in a canal, there exists a reference line through v for implementing the two extension operations in constant time each in the main algorithm.
Proof.Consider a non-gate vertex v in a canal C. Our goal is to prove that there exists a reference line l through v such that all obstacle vertices visible to v to be identified in the main algorithm lie on the same (closed) side of l.Note that for any vertex u visible to v identified in the main algorithm, the line segment uv must intersect a gate of the canal, say, at a point p, such that p is visible to v with respect to C (i.e., pv is contained in C). (Note that uv may be a Case (II) or Case (III) type missing edge in Lemma 7.) Thus, it suffices to show the following claim: There exists a reference line l through v such that all points on the two canal gates of C visible to v with respect to C lie on the same (closed) side of l.
In the proof of this claim below, "visible" always means "visible with respect to C".
If v is not visible to any point on the two canal gates, then the claim trivially holds.
If v is visible to only one gate of C, then as in the case of a bay, the claim follows.
If v is visible to both canal gates, then for each gate, we can determine a 2-D cone that has v as the apex and is bounded by two half-lines such that the portion of the gate visible to v is the intersection of the cone and the gate [11] (to be exact, the two half-lines are those containing the first segments on the shortest paths in C from v to the two endpoints of the gate, and such a half-line may degenerate into a single point if v is an endpoint of the gate).See Fig. 12.Let g 1 and g 2 be the two canal gates.Denote by C 1 and C 2 the two cones intersecting the two gates g 1 and g 2 , respectively.To prove the claim, it suffices to show that there exists a line l through v such that these two cones both lie on the same (closed) side of l, as follows.
Assume to the contrary that there exists no such line.Then we can find a line l contained in C 1 ∪ C 2 such that l does not contain any bounding half-line of a cone, say, C 1 (see Fig. 13).Let g 1 be the intersection of g 1 and C 1 .Then, l intersects g 1 at an interior point of g 1 , say p 1 ; thus p 1 is not an endpoint of the gate g 1 .Note that v is also not an endpoint of g 1 (otherwise, the cone C 1 consists of the single half-line containing the gate g 1 , and the line l must contain the single bounding half-line of C 1 , which contradicts with the assumption that l does not contain any bounding half-line of C 1 ).Let p 2 be the intersection of l and g 2 (see Fig. 13).Thus, vp 1 (resp., vp 2 ) is contained in the cone C 1 (resp., C 2 ).Since v ∈ p 1 p 2 ⊂ l , the line segment p 1 p 2 is contained in the canal C, and thus the shortest path from p 1 to p 2 in C is the line segment p 1 p 2 .Let g 1 = gr such that g is the apex of a c-funnel of C. By Observation 1, the shortest path from p 1 to p 2 in the canal, which is p 1 p 2 , contains p 1 g.Since p 1 is an interior point of gr, we obtain that p 1 p 2 is collinear with gr.Since v is not an endpoint of g 1 = gr and v ∈ p 1 p 2 , the three obstacle vertices g, r, and v are collinear, which contradicts with our general position assumption.
Therefore, there exists a line l through v such that the two cones C 1 and C 2 are both on the same side of l.Consequently, for the case that v is visible to both canal gates of C, a reference line through v also exists.The lemma thus follows.
Lemma 11.For any canal of n vertices, the reference lines for all non-gate vertices of the canal can be computed in O(n ) time.
Proof.Let g 1 and g 2 be the two gates of a canal C. We compute the edge-visibility polygon C(g 1 ) for g 1 in O(n ) time [11].For each vertex v in C(g 1 ), we can determine two line segments such that all points on g 1 visible to v are exactly those seen by an observer located at v looking between these two line segments (i.e., the two line segments are contained in the half-lines bounding the cone C 1 defined in the proof of Lemma 10).In other words, one (resp., the other) line segment is the first line segment in the shortest path in C from v to one (resp., the other) endpoint of g 1 .Note that these two line segments are readily available after we compute C(g 1 ) [11].Similarly, we compute the edge-visibility polygon C(g 2 ) for the gate g 2 , and for each vertex in C(g 2 ), determine two such line segments as in the case for C(g 1 ).
Then, for each vertex v in C, there are at most four line segments thus determined.By Lemma 10, there exists a line such that these four line segments all lie on the same (closed) side of the line.We then find an arbitrary such line in constant time as a reference line for v.
Therefore, we can compute the reference lines for all vertices of C in O(n ) time.
Since the total number of vertices in all bays and canals is O(n), the total time for processing all bays and canals is O(n + k ), where k is the total number of edges in the visibility graphs within all bays and canals (note that k ≤ k).

Lemma 12. The running time of the preprocessing on all bays and canals is O(n + k).
In the main algorithm given next, we assume the preprocessing has been done and thus the specific enhanced visibility graphs for all bays and canals have been computed.Note Journal of Computational Geometry jocg.org that all Case (I) missing edges in Lemma 7 have also been computed in the preprocessing.The Cases (II) and (III) edges will be computed in the main algorithm.

The Main Algorithm
As the GM algorithm, our main algorithm is guided by Hertel and Mehlhorn's plane-sweeping triangulation algorithm [13].The difference is that the triangulation in the GM algorithm is on the space F whereas ours is on the space M. As discussed before, since the boundary of M consists of O(h) convex chains with a total of O(n) vertices, applying Hertel and Mehlhorn's plane-sweeping triangulation algorithm on M takes O(n + h log h) time [13] (instead of O(n log n) time on F; e.g., sorting all vertices M can be done in O(n + h log h) time).As in the GM algorithm, the funnel sequences are built during the triangulation.Further, during the triangulation, we also take the space F \ M, i.e., all bays and canals, into consideration, by combining the funnel sequences in all bays and canals with those in M through the gates of the bays and canals (this is partially done by so-called connection procedures).
In the general step of the triangulation algorithm, we consider a vertex, say v.The vertex v will be connected to either one or two connected vertex sequences about v such that the sides opposite to v form an inward-convex chain with respect to v (e.g., v = v i in Fig. 5).

The Single Triangle Case
We first consider the case of adding only a single triangle vxy to the triangulation involving v.That is, v is to the right of the directed edge xy with x lower than y.Denote by M(v) the triangulated subregion of M right after the triangle vxy is incorporated into the triangulation.Denote by BC(v) the union of all bays and canals each of which has at least one gate on the boundary of M(v).Note that in the GM algorithm, xv (resp., vy) is either a triangulation diagonal or an obstacle edge, whereas in our algorithm, it may also be a bay/canal gate.
Depending on whether xv is a bay/canal gate, we define a funnel sequence F (xv) as follows.If xv is a triangulation diagonal or an obstacle edge, then we let F (xv) be the funnel sequence of xv with respect to the region M(v) ∪ BC(v); in other words, F (xv) consists of all funnels whose bases are xv and whose apices are either vertices of M(v) or non-gate vertices of the bays and canals in BC(v).But if xv is a bay/canal gate, then we let F (xv) be the funnel sequence of xv with respect to that bay/canal, which has been computed in the preprocessing.
Define the funnel sequence F (vy) for vy similarly.Our algorithm maintains the invariant that after the triangle vxy is processed, the two funnel sequences F (xv) and F (vy) are computed.
We assume the corresponding funnel sequence F (xy) for xy has been computed.Initially, if xy is an obstacle edge or a triangulation diagonal, then F (xy) = ∅; otherwise, xy is a bay/canal gate, and F (xy) has been computed in the preprocessing.Our task is to Journal of Computational Geometry jocg.orgcompute the two funnel sequences F (xv) and F (vy).Depending on whether xv and vy are bay/canal gates, there are three cases.

The rst case
The first case is when neither xv nor vy is a bay/canal gate.The algorithm for this case is the same as the GM algorithm.That is, we call the SPLIT procedure on xy and v to split F (xy) and obtain two funnel sequences F (xv) and F (vy).By Lemma 3, the time of this computation is proportional to the number of vertices visible to v through xy.

The second case
The second case is when exactly one of xv and vy is a bay/canal gate.Without loss of generality, assume xv is a bay/canal gate but vy is not.Denote by P (xv) the bay/canal bounded by xv (see Fig. 14).
We first call the SPLIT procedure on xy and v to split the funnel sequence F (xy) and obtain two funnel sequences: F xy (xv) for xv and F xy (vy) for vy.Again by Lemma 3, the time for this is proportional to the number of vertices visible to v through xy.Since xv is a bay/canal gate, F (xv) has been computed in the preprocessing.Further, there are two other key differences from the first case, as follows.
• First, F (vy) may not be F xy (vy) any more since some non-gate vertices in the bay/canal P (xv) may be visible to vy through the gate xv.Note that such non-gate vertices of P (xv) may possibly define some missing edges of Cases (II) and (III) in Lemma 7. In other words, it is possible that there is a funnel whose apex is at a non-gate vertex of P (xv) and whose base is vy, and clearly this funnel should be in F (vy).
• Second, it is possible that the apex of a funnel in F xy (xv) is visible to a non-gate vertex of P (xv) through xv, and each such visible vertex pair defines a missing edge of Case (II) or Case (III) in Lemma 7. Since our triangulation of M will not be performed on P (xv), we compute such missing edges right in this step.Below, we show how to handle these two differences.

Journal of Computational Geometry jocg.org
To avoid confusion, we let F P (xv) (xv) denote F (xv), i.e., the funnel sequence of xv with respect to P (xv), which has been computed in the preprocessing.
To deal with the first difference, we call the SPLIT procedure on xv and y to split F P (xv) (xv) and obtain two funnel sequences: F P (xv) (vy) for vy and F P (xv) (xy) for xy.By Lemma 3, the time for this is proportional to the number of vertices of P (xv) visible to y.Actually, we only need F P (xv) (vy).We have the following observation.
Observation 2. The funnel sequence F (vy) is the concatenation of F P (xv) (vy) and F xy (vy).
Proof.This is a special case of Lemma 4.
Since both F P (xv) (vy) and F xy (vy) have been computed, F (vy) can thus be obtained.
To handle the second difference, we use a connection procedure, as follows.
First, we connect the apices of the funnels in F xy (xv) by line segments following their funnel order in F xy (xv) from x to v. Since the funnel order in F xy (xv) follows the clockwise preorder of the lower tree of xv, the line segment connecting any two adjacent funnel apices is in the free space F (Lemma 5.1 in [10] gives similar results).Thus, the region bounded by these line segments and xv is a simple polygon, denoted by P .Note that since an obstacle vertex may serve as the apices of multiple funnels, a same physical point location may serve as multiple vertices of the polygon P , but P can still be viewed as a (degenerate) simple polygon.The number of vertices of P is exactly the number of funnels in F xy (xv) (recall that we treat the two vertices v and x as two degenerate funnels); let m be this number.Then, we merge P with the bay/canal P (xv) by removing xv to form a new simple polygon, denoted by P .Let n be the number of vertices of P (xv).Thus, P has O(m + n ) vertices.
Let V (xv) be the set of all vertices of the bay/canal P (xv).Let G(P ) be the visibility graph of P , and let E be the set of the edges of G(P ) incident to the vertices of V (xv).In the following, we will compute the set E (note that we do not compute all edges of G(P ) but only the edges of E).To this end, since P is a (degenerate) simple polygon, we apply Hershberger's algorithm [12] on P but only on the vertices of V (xv), as follows.
Suppose the obstacle vertices of V (xv) ordered cyclically along the boundary of P (xv) are x = v 1 , v 2 , . . ., v n = v.We apply Hershberger's algorithm [12] on the vertices of V (xv) in their index order.Specifically, we first compute the shortest path map SPM (v 1 ) of v 1 in P .Then, the edges of G(P ) incident to v 1 are known.Next, we compute SPM (v 2 ) by updating SPM (v 1 ) and using Hershberger's algorithm [12], after which the edges of G(P ) incident to v 2 are known.We continue this until SPM (v n ) is computed, after which all edges of E are computed.
The above algorithm is our connection procedure, which can be viewed as a process of "propagating" the funnels in F xy (xv) into P (xv) through the gate xv.We have the following lemma.
Lemma 13.The connection procedure runs in O(n + m + k ) time, where k is the sum of the sizes of the funnel sequences of the obstacle edges v i−1 v i for i = 2, 3, . . ., n with respect to P .The total time of all connection procedures in the entire algorithm is O(n + k).

Journal of Computational Geometry
jocg.org Proof.Recall that P is the union of P and P (xv).As already discussed above, computing P can be done in O(m ) time by traversing the funnel sequence F xy (xv).Hence, we can obtain P in O(n + m ) time.
Consider our algorithm for computing the edges of E by using Hershberger's algorithm [12].The first step computes the shortest path map SPM (v 1 ), which takes O(n + m ) time.As discussed in Section 4.1, computing SPM (v 2 ) is done by updating SPM (v 1 ), which takes O(|dif f (v 1 , v 2 )|) time, where dif f (v 1 , v 2 ) is the symmetric difference between the sets of edges in SPM (v 1 ) and SPM (v 2 ).
. Indeed, since P is a simple polygon, for any vertex u of P , F (v 1 v 2 ) has at most one funnel whose apex is u.Thus, each vertex of P can serve as the apex of at most one funnel in F (v 1 v 2 ).Hence, the size of F (v 1 v 2 ) is exactly the number of vertices of P that are visible to v 1 v 2 .Let P vis (v 1 v 2 ) denote the edge-visibility polygon of v 1 v 2 in P .The above discussions show that |P vis (v 1 v 2 )|, i.e., the size of P vis (v 1 v 2 ), is bounded by O(|F (v 1 v 2 )|).On the other hand, the results in [12] imply that the |dif In general, for any According to the above discussion, after SPM (v 1 ) is computed, the total time for computing SPM (v i ) for 2 ≤ i ≤ n is O(k ).Hence, the total time of the algorithm for computing E is O(n + m + k ), and total time of the connection procedure is also O(n + m + k ).
To prove the lemma, in the sequel we show that the sums of all such n , m , and k in all connection procedures in the entire algorithm are O(n), O(k), and O(k), respectively.
For the case of n , this is easy.Indeed, if P (xv) is a bay, then P (xv) is only involved in at most one connection procedure since it has only one gate; if P (xv) is a canal, then P (xv) is involved in at most two connection procedures since it has two gates.In either case, the sum of all such n in the entire algorithm is O(n).
To prove the other two cases for m and k , we first argue that the funnels in F xy (xv) will not be involved in any other connection procedure later in the algorithm.If P (xv) is a bay, this is obviously true since P (xv) has only one gate (intuitively, the funnels in F xy (xv) cannot be propagated out of P (xv) and they all "terminate" inside P (xv)).
If P (xv) is a canal, one may wonder that some funnels in F xy (xv) could be involved in other connection procedures since P (xv) has another gate.This actually cannot happen due to Lemma 5. Indeed, consider the apex u of a funnel f u in F xy (xv).If u is outside the canal (and thus u may form some Case III missing edges), then in light of Lemma 5, u cannot be visible to a vertex outside the canal through the canal (and its two gates).In other words, after the funnel f u is propagated into the canal through the gate xv, it cannot be propagated out of the canal through the other gate.If u is a gate vertex of the gate xv, then the funnel f u is the only vertex u, which is a degenerate funnel and can be ignored.The remaining case is that u is a vertex of P (xv) and u is neither x nor v, which implies that the funnel f u had been propagated out of P (xv) through the other gate, say g 1 .Thus, Journal of Computational Geometry jocg.org • If ua is a k 1 -type segment, then it is computed only in the current connection procedure because no other connection procedures will be called on the gate xv.Hence, ua is computed only once in all connection procedures of the entire algorithm.Thus, the sum of all such k 1 in the entire algorithm is O(k).
• If ua is a k 2 -type segment, then it can be computed at most twice in all connection procedures of the entire algorithm: once in the current connection procedure and once in the connection procedure for the other gate if P (xv) is a canal.Hence, the sum of all such k 2 in the entire algorithm is O(k).
• If ua is a k 3 -type segment, then ua corresponds to a funnel of F xy (xv).Since the funnels of F xy (xv) will never be involved in any connection procedure later in the algorithm, the sum of all such k 3 in the entire algorithm is O(k).
Therefore, the sum of all k in all connection procedures in the entire algorithm is O(k).
This proves the lemma.
We give some comments on a few technical details for implementing the primitive operations.We have computed the funnel sequence F (vy) as a concatenation of F P (xv) (vy) and F xy (vy).Later in the algorithm, we may identify a vertex visible to a non-gate vertex in P (xv) through xv and vy.For each non-gate vertex of P (xv), to implement the primitive operations in constant time each, as in the GM algorithm, the operations CW, CCW , and REV are quite straightforward.For the two extension operations CX and CCX, recall that our preprocessing for computing the enhanced visibility graphs for all bays and canals has found a particular reference line for each non-gate vertex of P (xv) that can make sure that the two extension operations are implemented in constant time each (see Lemmas 9 and 10).
In addition, for each of the two gate vertices x and v, again the operations CW, CCW , and REV are trivial.For the two extension operations CX and CCX, consider the gate vertex v.As in the GM algorithm, we can still use the vertical lines through v as the reference line.However, since the connection procedure may have found some vertices in P (xv) visible to v that are to the right of v, in order to fulfill the two conditions of the reference line in Lemma 1, we can process those vertices (i.e., insert them to the Split-Find data structure) after we process the rest of the vertices visible to v (i.e., those visible vertices that are to the left of v).This is in fact consistent with the GM algorithm.The other gate vertex x can be handled in the same way.This finishes the discussion for the second case where xv is a bay/canal gate but vy is not.

The third case
The third case is when both xv and vy are bay/canal gates (see Fig. 15).The process for this case is similar to the second case except that there is one more connection procedure (because there is one more bay/canal gate involved).The details are given below.

Journal of Computational Geometry
jocg.org Denote by P (xv) (resp., P (vy)) the bay/canal bounded by xv (resp., vy).In this case, the two funnel sequences F (xv) and F (vy) have been computed in the preprocessing, and again we re-denote them by F P (xv) (xv) and F P (vy) (vy), respectively.The remaining task is to compute the Cases (II) and (III) missing edges, as in the second case.
We first do the same things as in the second case, i.e., compute the funnel sequences F xy (xv) and F xy (vy), compute the funnel sequence F (vy) (which is F (vy) in the second case) that is the concatenation of F P (xv) (vy) and F xy (vy), and apply the connection procedure to F xy (xv) and P (xv) through the gate xv.
Since now vy is also a bay/canal gate, the new funnel sequence F (vy) needs to be propagated into P (vy) through vy.In other words, we need to identify all visible vertex pairs between the apices of the funnels in F (vy) and the vertices in P (vy).To do so, we use another connection procedure on F (vy) and P (vy) similarly to that on F xy (xv) and P (xv).Specifically, we connect the apices of the funnels in F (vy) to form a (degenerate) simple polygon and merge it with P (vy) to obtain another simple polygon, denoted by P .Then, we compute the edges of the visibility graph of P incident to the vertices of P (vy) in the same way as before.

The General Case
In the general case, v may be connected to a convex chain of vertices, as shown in Fig. 6.As in the GM algorithm [10], this case can be handled by an easy generalization of the algorithm for the single triangle case.Comparing with the GM algorithm, as in the single triangle case, our algorithm makes one or two connection procedure calls.The details are given below.
Let the involved sequence of vertices be u 0 , u 1 , . . ., u m (see Fig. 6, with v = v i ).Note that the funnel sequences F (u i−1 u i ) for 1 ≤ i ≤ m have all been computed.The segments vu i , i = 1, 2, . . ., m − 1, are all triangulation diagonals.But vu 0 and vu m can be triangulation diagonals, obstacle edges, or bay/canal gates.As the single triangle case, depending on whether vu 0 and vu m are bay/canal gates, there are three cases.
In the first case, if neither vu 0 nor vu m is a bay/canal gate, then the algorithm is the same as the GM algorithm (as discussed in Lemma 4).
The second case is when exactly one of vu 0 and vu m is a bay/canal gate.Without Journal of Computational Geometry jocg.orgloss of generality, we assume vu 0 is a bay/canal gate but vu m is not.Denote by P (vu 0 ) the bay/canal bounded by vu 0 .We first apply the same approach as in the GM algorithm to obtain two funnel sequences, F (vu 0 ) for vu 0 and F (vu m ) for vu m , by splitting the funnel sequences F (u i−1 u i ) for all 1 ≤ i ≤ m and connecting v to all visible vertices thus found.Since vu 0 is a bay/canal gate, we have a funnel sequence F P (vu 0 ) (vu 0 ) with respect to P (vu 0 ), which has been computed in the preprocessing.We use the SPLIT procedure to split F P (vu 0 ) (vu 0 ) into two funnel sequences: F P (vu 0 ) (vu m ) for vu m and another one for the convex chain from u 0 to u m (the latter one is actually not needed), in the following way.
Note that since u 0 is connected to u m by a convex chain instead of a line segment, we cannot directly apply the SPLIT procedure on vu 0 and u m to compute the funnel sequence F P (vu 0 ) (vu m ).Instead, we use the following approach to compute F P (vu 0 ) (vu m ) without affecting the overall O(n + k) time complexity, and the approach is a modification of the SPLIT procedure.We apply the SPLIT procedure on vu 0 and u m to split the funnel sequence F P (vu 0 ) (vu 0 ) by assuming u 0 is connected to u m by a line segment and by scanning the funnel sequence F P (vu 0 ) (vu 0 ) from v.However, the modification is that during the SPLIT procedure whenever we find a visible segment added to u m (i.e., a vertex of P (vu 0 ) visible to u m is identified) that is actually "blocked" by the line segment u m u m−1 , we stop the procedure and F P (vu 0 ) (vu m ) is thus obtained.Recall that the visible segments added to u m in the SPLIT procedure are found in the cyclical order about u m from v [10].Thus, the time for computing F P (vu 0 ) (vu m ) above is linear in the number of visible segments added to u m , i.e., the number of vertices of P (vu 0 ) visible to u m through the gate vu 0 .
As in the single triangle case, the funnel sequence F (vu m ) for vu m is the concatenation of F P (u 0 v) (vu m ) and F (vu m ).
Next, as in the single triangle case, the apices of the funnels in F (u 0 v) may be visible to some non-gate vertices of P (u 0 v).To identify these visible vertex pairs, we also apply a connection procedure in the same way as the single triangle case.Although in this case we have a convex chain from u 0 to u m instead of a single line segment, if we connect the apices of all funnels in F (u 0 v) by line segments, we still have a (degenerate) simple polygon (similar results have been shown in [10]), and we merge it with P (u 0 v) to form a new simple polygon, say P .Again, we can use the same algorithm as before to compute the edges of the visibility graph of P incident to the vertices of P (u 0 v).
The third case is when both vu 0 and vu m are bay/canal gates.Denote by P (vu 0 ) (resp., P (vu m )) the bay/canal bounded by vu 0 (resp., vu m ).As in the second case, we compute F (u 0 v) and F (vu m ) that is the concatenation of F P (u 0 v) (vu m ) and F (vu m ).We also call the connection procedure on F (u 0 v) and P (vu 0 ) through the gate vu 0 .Then, as in the single triangle case, we make another connection procedure call on the funnel sequence F (vu m ) and P (vu m ) through the gate vu m .
We have finished the discussions of all cases.All connection procedures in the entire algorithm take O(n + k) time.The proof of the next theorem summarizes the time analysis of the overall algorithm.
Theorem 2. The enhanced visibility graph for P can be computed in O(n + h log h + k) time, after an arbitrary triangulation of the free space is computed.

Journal of Computational Geometry
jocg.org Proof.Given any triangulation of the free space, we can compute the extended data structure, i.e., identifying the ocean M as well as all bays and canals, in O(n) time [16].Then, we do the preprocessing for all bays and canals, which takes O(n + k) time.We perform the plane-sweeping triangulation on M in O(n + h log h) time [13].Following the triangulation of M, we compute the enhanced visibility graph in the same way as the GM algorithm, applying the connection procedures if needed.The total time of all SPLIT procedures and connection procedures is O(n + k).

Concluding Remarks
We have presented a new algorithm for computing the vertex-vertex visibility graph of P.
Our algorithm follows a similar scheme to the GM algorithm but avoids the O(n log n) time triangulation used in the GM algorithm.This is done with the help of the extended corridor structure.More specifically, instead of performing triangulation in the entire free space, we only do so in the ocean, and then use connection procedures to connect the visibility graph in the ocean with that in all bays and canals.This reduces the O(n log n) time factor in the GM algorithm to O(T + n + h log h), and thus provides an alternative O(T + n + h log h + k) time algorithm for the problem to the one that was already given by Kapoor and Maheshwari [15].
The enhanced visibility graph and funnel structures of P are quite useful and have many other applications.For example, we can extend our algorithm to compute the vertexedge, edge-edge, and extended vertex-vertex visibility graphs in an output-sensitive manner.Some of these have been discussed in [10] and we give some details below for the completeness of this paper.
Note that not all obstacle edges of P have its funnel sequences computed in the algorithm, e.g., those on the left of the free space.But after the enhanced visibility graph is computed, we can easily construct the funnel sequences for all obstacle edges in additional O(n + k) time by using the primitive operations to traverse either the lower trees or upper trees, as discussed in Lemma 2.
The vertex-edge visibility graph.To compute the vertex-edge visibility graph, as discussed in [10], we can label each funnel apex by the unique obstacle edge that can be seen by the apex through its funnel.Specifically, for each obstacle edge e, by Lemma 2, we can traverse the lower tree of e in time proportional to the size of the tree, which is the number of apices visible to e. Hence, we can label each funnel apex of the tree by e.Since the total number of funnels is O(k), we can finish this labeling for all obstacle edges in totally O(n + k) time and construct the vertex-edge graph.Thus, the vertex-edge visibility graph can be constructed in O(n + h log h + k) time, given any triangulation of the free space.
The visibility polygons of obstacle vertices.For any obstacle vertex v, let u 0 , u 1 , . . ., u m be the clockwise sequence of obstacle vertices visible to v such that vu 0 and vu m are the two obstacle edges incident to v. Then for any adjacent pair of u i−1 and u i , we have a funnel whose apex is v and whose lower chain (resp., upper chain) begins with vu i (resp., vu i−1 ).Since we have already associated every funnel with its base, we know the obstacle Journal of Computational Geometry jocg.orgedge that v can see between u i−1 and u i .Thus, we can simply scan u 0 , u 1 , . . ., u m clockwise to construct the visibility polygon of v in O(m) time, where m is the size of the visibility polygon.
The extended vertex-vertex visibility graph.To build the extended vertex-vertex visibility graph (i.e., for every edge of the vertex-vertex visibility graph, extend it along both directions until hitting an obstacle or infinity and record the two extension endpoints), consider any obstacle edge e.For any edge of the lower tree of e, one of its two extension endpoints is on e.Thus, after we traverse the lower trees of all obstacle edges, we can identify the extension endpoints of all edges of the vertex-vertex visibility graph.Hence, the extended vertex-vertex visibility graph can be built in O(n + h log h + k) time, given any triangulation of the free space.
The edge-edge visibility graph.For the edge-edge visibility graph, as discussed in [10], two obstacle edges e 1 and e 2 are mutually visible if and only if there exist vertices u and v such that the funnel whose lower chain begins with uv sees the edge e 1 and the funnel whose lower chain begins with vu sees the edge e 2 .Hence, in addition to the vertex-vertex and vertex-edge relations (on the corresponding obstacle edges), for each edge of the vertexvertex visibility graph of P, if its two extension endpoints are on two obstacle edges e 1 and e 2 , then e 1 is visible to e 2 .Therefore, the edge-edge visibility graph can also be built in O(n + h log h + k) time, given any triangulation of the free space.

Figure 1 :
Figure 1: Illustrating some funnels: The apices are v and the bases are xy.

Figure 2 :
Figure 2: Illustrating the lower tree (with dashed segments) of xy.

Figure 4 :
Figure 4: Illustrating an example of the SPLIT procedure performed on xy and an obstacle vertex v.

Lemma 1 .
(Ghosh and Mount [10]) For any obstacle vertex v, suppose there exists a line l through v such that: (1) all obstacle vertices visible to v in one (open) half-plane H(l) of l are identified before any vertices visible to v in the other (closed) half-plane of l; (2) the obstacle vertices visible to v in H(l) are ordered cyclically about v before any vertices visible to v in the other (closed) half-plane of l are identified.Then the line l can be used as a reference line of v to implement the two extension operations for the edges of G incident to v in constant time each.

Figure 5 :
Figure 5: Incorporating an obstacle vertex vi into the triangulation.

Figure 6 :
Figure 6: Connecting vi to a visible inward-convex chain.

Figure 7 :
Figure 7: Illustrating a triangulation of the free space among two obstacles and the corridors (with red solid curves).There are two junction triangles indicated by the large dots inside them, connected by three solid (red) curves.Removing the two junction triangles results in three corridors.
8): (1) A boundary portion of an obstacle P i ∈ P, from a point a to a point b; (2) a diagonal of a junction triangle from b to a boundary point c on an obstacle P j ∈ P (P i = P j is possible); (3) a boundary portion of the obstacle P j from c to a point d; (4) a diagonal of a junction triangle from d back to a.The two diagonals bc and ad are called the doors of C, and the other two parts of the boundary of C are two sides of C. The corridor C is a simple polygon whose interior does not intersect any obstacle.Let |C| denote the number of obstacle vertices on the boundary of C. In O(|C|) time, we can compute the shortest path π(a, b) (resp., π(c, d)) from a to b (resp., c to d) inside C. The region H C bounded by π(a, b), π(c, d), and the two diagonals bc and da is called an hourglass, which is open if π(a, b) ∩ π(c, d) = ∅ and closed otherwise (see Fig. 8).If H C is open, then both π(a, b) and π(c, d) are convex chains and are called the sides of H C ; otherwise, H C consists of two "funnels" and a path π C = π(a, b) ∩ π(

Figure 8 :
Figure 8: Illustrating an open hourglass (left) and a closed hourglass (right) with a corridor path connecting the apices f and g of the two c-funnels.The dashed segments are diagonals.The paths π(a, b) and π(c, d) are shown with thick solid curves.A bay bay(wz) in the open hourglass (left) and the canal canal(f, g) in the closed hourglass (right) are also indicated (with green backslash segments).

Figure 9 :
Figure 9: Illustrating a canal: the two gates are shown with (red) dashed segments and the corridor path is uv.

Figure 10 :
Figure 10: Illustrating the three cases of Lemma 7 with a canal (the two red dashed segments are its gates): an edge of Case (I) is shown with (green) solid segment; an edge of Case (II) is shown with (green) dotted segment; an edge of Case (III) is shown with (green) dashed dotted segment.

Figure 11 :
Figure 11: Illustrating the reference line l of a non-gate vertex v in a bay.

Figure 12 :
Figure 12: Illustrating a canal with two gates g1 and g2.The two cones C1 and C2 of a non-gate vertex v are shown.

Figure 14 :
Figure 14: Illustrating an example that xv is a gate of a bay/canal P (xv).

Figure 15 :
Figure 15: Illustrating an example that both xv and vy are bay/canal gates.