Bicriteria Rectilinear Shortest Paths among Rectilinear Obstacles in the Plane

Given a rectilinear domain $\mathcal{P}$ of $h$ pairwise-disjoint rectilinear obstacles with a total of $n$ vertices in the plane, we study the problem of computing bicriteria rectilinear shortest paths between two points $s$ and $t$ in $\mathcal{P}$. Three types of bicriteria rectilinear paths are considered: minimum-link shortest paths, shortest minimum-link paths, and minimum-cost paths where the cost of a path is a non-decreasing function of both the number of edges and the length of the path. The one-point and two-point path queries are also considered. Algorithms for these problems have been given previously. Our contributions are threefold. First, we find a critical error in all previous algorithms. Second, we correct the error in a not-so-trivial way. Third, we further improve the algorithms so that they are even faster than the previous (incorrect) algorithms when $h$ is relatively small. For example, for the minimum-link shortest paths, we obtain the following results. Our algorithm computes a minimum-link shortest $s$-$t$ path in $O(n+h\log^{3/2} h)$ time. For the one-point queries, we build a data structure of size $O(n+ h\log h)$ in $O(n+h\log^{3/2} h)$ time for a source point $s$, such that given any query point $t$, a minimum-link shortest $s$-$t$ path can be determined in $O(\log n)$ time. For the two-point queries, with $O(n+h^2\log^2 h)$ time and space preprocessing, a minimum-link shortest $s$-$t$ path can be determined in $O(\log n+\log^2 h)$ time for any two query points $s$ and $t$; alternatively, with $O(n+h^2\cdot \log^{2} h \cdot 4^{\sqrt{\log h}})$ time and $O(n+h^2\cdot \log h \cdot 4^{\sqrt{\log h}})$ space preprocessing, we can answer each two-point query in $O(\log n)$ time.


Introduction
Let P be a rectilinear domain with a total of h holes and n vertices in the plane, i.e., P is a multiplyconnected region whose boundary is a union of n axis-parallel line segments, forming h + 1 closed polygonal cycles (i.e., h holes plus an outer boundary). A simple rectilinear polygon is a special case of a rectilinear domain with h = 0. A rectilinear path is a path consisting of only horizontal and vertical line segments.
For a rectilinear path π, we define its length as the total sum of the lengths of the segments of π, and we define its link distance as the number of edges of π (each edge is also called a link). We use the measure of π to refer to both its length and its link distance. For any two points s and t in P, a shortest rectilinear path from s to t is a rectilinear path connecting s to t in P with the minimum length, and a minimum-link rectilinear path is a rectilinear s-t path with the minimum link distance. Among all shortest rectilinear s-t paths, the one with the minimum link distance is called a minimum-link shortest s-t path; among all minimum-link s-t paths, the one with the minimum length is called a shortest minimum-link s-t path. We define the cost of π as a non-decreasing function f of both the length and the link distance of π. We assume that given the number of links of π and the length of π, its cost can be computed in constant time. Depending on the context, the measure of π may also refer to its cost. A minimum-cost path from s to t is a rectilinear s-t path in P with the minimum cost (with respect to the cost function f ).
All the three types of paths discussed above (i.e., minimum-link shortest paths, shortest minimumlink paths, and minimum-cost paths) are called bicriteria shortest paths. In order to differentiate between "bicriteria shortest paths" and "shortest paths", we will use optimal paths to refer to these bicriteria shortest paths. Since some observations and algorithmic schemes may be applicable to all three types of optimal paths, unless otherwise stated, a statement made to "optimal paths" should be applicable to all three types of optimal paths.
In this paper, we study the problem of computing all three types of optimal paths between two points s and t in P. Their one-point and two-point queries are also considered.

Previous Work
These problems have been studied before. The following results are applicable to all three types of optimal paths.
Yang et al. [28] first presented an O(nr + n log n) time algorithm, where r is the number of extreme edges of P (an edge e of P is extreme if its two adjacent edges lie on the same side of the line containing e; r = Ω(n) in the worst case). Later, Yang et al. [29] proposed an algorithm of O(n log 2 n) time and O(n log n) space and another algorithm of O(n log 3/2 n) time and space; Chen et. al. [6] improved the algorithm to O(n log 3/2 n) time and O(n log n) space.
The one-point optimal path query problem, where s is the source and t is a query point, was also studied. Based on the algorithm of Yang et al. [29], Chen et. al. [6] built a data structure of O(n log n) size in O(n log 3/2 n) time such that for each query point t, the measure of the optimal s-t path can be computed in O(log n) time and an actual path can be output in additional time linear in the number of edges of the path. For simplicity, in the following, when we say that the query time of a data structure for finding a path is O(g(n)), we mean that the measure of the path can be computed in O(g(n)) time and an actual path can be output in additional time linear in the number of edges of the path.
The two-point optimal path query problem, i.e., both s and t are query points, was also studied by Chen et. al. [6], where a data structure of O(n 2 log 2 n) size was built in O(n 2 log 2 n) time such that each two-point query can be answered in O(log 2 n) time.

Our Results
We provide a comprehensive study on these problems. Our contributions are threefold.
First, we show that all the algorithms in the previous work mentioned above are incorrect. More specifically, we find a critical error in the algorithm of Yang et al. [29]. Since the algorithms and data structures of Chen et. al. [6] are all based on the method of Yang et al. [29], the above results of Chen et. al. [6] are not correct either. A similar error also appears in the algorithm of [28]. We should point out that the technique of Chen et. al. [6], which follows the similar idea in Chen et al. [8] for computing L 1 shortest paths in arbitrary polygonal domains, would work if it was based on a correct algorithm (for example, it still works in our new algorithm).
Second, we fix the error of Yang et al. [29] in a not-so-trivial way. However, the complexities are not the same as before for all three types of optimal paths. Specifically, for computing a minimumlink shortest path, our corrected algorithm runs in O(n log 3/2 n) time and O(n log n) space (with the help of the technique of Chen et. al. [6] to reduce a factor of log 1/2 n). For the other two types of optimal paths, however, the complexities have one more O(n) factor, i.e., O(n 2 log 3/2 n) time and O(n 2 log n) space. Third, we further improve the algorithms in the way that the complexities only linearly depend on n (in addition to g(h) for some functions g(h) of h). For computing a minimum-link shortest path, our algorithm runs in O(n + h log 3/2 h) time and O(n + h log h) space. For computing other two types of optimal paths, our algorithm runs in O(n + h 2 log 2 h) time and O(n + h 2 log h) space. We also obtain data structures for one-point and two-point queries. Our results are summarized in Table 1. Note that for two-point queries, we give two data structures for each problem with tradeoff between the preprocessing and the query time. We also consider the two-point query problem for minimum-link paths (without considering the lengths) since the problem was not studied before (but its one-point query problem has been solved, as discussed below).
Our results are particularly interesting when h is relatively small. For example if h = O(n 1/2−ǫ ) for any ǫ > 0, then for finding a single optimal path of any type, our algorithm runs in O(n) time, and our data structures for the minimum-link shortest path and minimum-link path queries are also optimal.
It is easy to see that the minimum-link shortest paths and the shortest minimum-link paths are special cases of minimum-cost paths, and we discuss them separately mainly because our results for the two special cases are generally better that those for the general minimum-cost paths. In fact, as the cost function f is quite general, our algorithm for computing minimum-cost paths may find many applications. We give two examples below.
Polishchuk and Mitchell [24] gave an O(kn log 2 n) time algorithm for computing a shortest s-t path with at most k links for a given integer k, which improves the O(kn 2 ) time algorithm in [28]. As indicated in [24], the problem can be solved using any algorithm that can find a minimum-cost path with the cost function defined as f (a, b) = a if b ≤ k and f (a, b) = ∞ otherwise, where a and b are the length and the link distance of the path, respectively. Partially due to this reason, Polishchuk and Mitchell [24] already suspected that there is a misunderstanding on the algorithms of [6,29] for computing minimum-cost paths. We thus confirm their suspicion. On the other hand, applying our new (and correct) algorithm for minimum-cost paths can solve the problem in O(n + h 2 log 3/2 h) time, which is faster than the algorithm in [24] when h is sufficiently small or when k is relatively large.
As a dual problem, finding a minimum-link s-t path with length at most a given value l was also studied in [28], where a worst-case O(n 2 (r + log n)) time algorithm was given with r as the number of extreme edges of P. Note that r ≥ h. The problem can also be solved using any minimum-cost path algorithm by defining the cost function as f (a, b) = b if a ≤ l and f (a, b) = ∞ otherwise. Hence, applying our algorithm for minimum-cost paths can solve the problem in O(n + h 2 log 3/2 h), which clearly improves the algorithm of [28].

Other Related Work
If P is a simple rectilinear polygon (i.e., h = 0), then there always exists a rectilinear s-t path that has both the minimum length and the minimum link distance for any two points s and t in P [3,16]. de Berg [3] built a data structure of O(n log n) size in O(n log n) time that can find such a path in O(log n) time for any two-point query. The preprocessing time and space were both reduced to O(n) by Schuierer [26] (with O(log n) query time).
If P is a general rectilinear domain with h = 0, then there may not exist a rectilinear path that is both a minimum-link path and a shortest path [28]. The problems of finding only minimumlink paths or only shortest paths have been studied extensively. Imai and Asano [17] presented an O(n log n) time and space algorithm for finding a minimum-link s-t path in P, and the space was reduced to O(n) [14,21,25]. Recently, Mitchell et al. [22] proposed an O(n + h log h) time and O(n) space algorithm for the problem, after P is triangulated (which can be done in O(n log n) time or O(n + h log 1+ǫ h) time for any ǫ > 0 [1]). The algorithms in [14,21,22] also construct an O(n) size data structure that can answer each one-point minimum-link path query in O(log n) time.
For computing shortest s-t paths in P, Clarkson et al. [11] gave an algorithm of O(n log 2 n) time and O(n log n) space, and as a tradeoff between time and space, they modified their algorithm so that it runs in O(n log 3/2 n) time and space [12]. Wu et al. [27] proposed an O(n log r + r 2 log t) time algorithm, where r is the number of extreme edges of P, and the algorithm was later improved to O(n log r + r log 3/2 r) time [29]. Mitchell [19,20] solved the problem in O(n log n) time and O(n) space, and Chen and Wang [9,10] reduced the time to O(n + h log h) after P is triangulated.
If P is an arbitrary polygonal domain (i.e., not rectilinear), then the results from [9,10,11,12,19,20] are also applicable to finding arbitrary shortest paths under L 1 metric. In addition, the algorithms in [9,10,19,20] can be used to compute an O(n) size data structure so that each one-point L 1 shortest path query can be answered in O(log n) time. For two-point L 1 shortest path queries, Chen et al. [8] constructed a data structure of size O(n 2 log n) in O(n 2 log 2 n) time that can answer each query in O(log 2 n) time. Recently, Chen et al. [7] reduced the query time to O(log n) by building a data structure of size O(n + h 2 · log h · 4 To find a minimum-link s-t path between two points s and t in an arbitrary polygonal domain P, Mitchell [23] gave an O(Eα(n) log 2 n) time algorithm, where α(n) is the inverse of Ackermann's function and E is the size of the visibility graph of P and E = Θ(n 2 ) in the worst case. The one-point query problem was also studied in [23].
In the following, unless otherwise stated, a path always refers to a rectilinear path.

Our Techniques
Given two points s and t in the rectilinear domain P, to find an optimal s-t path, the algorithm of Yang et al. [29] first built a "path-preserving" graph G of size O(n log n) by using the idea of Clarkson et al. [11]. Then, it is shown that G contains an s-t path π G (s, t) that is homotopic to an optimal s-t path π(s, t) in P with the same length, and further, π(s, t) can be obtained from π G (s, t) by performing certain "dragging" operations. Motivated by this observation, Yang et al. [29] computed an optimal s-t path by applying Dijkstra's algorithm on G and simultaneously performing the dragging operations. We find a critical error in their way of applying Dijkstra's algorithm. We fix the error by using a "path-based" Dijkstra's algorithm and maintaining some additional information, and we prove that our algorithm is correct. Due to that we need to maintain more information on computing shortest minimum-link paths and minimum-cost paths, our algorithm for them runs slower than that for computing minimum-link shortest paths. To further reduce the running time (for small h), our main idea is to use a reduced graph G r of size O(h log h) instead of G. We show that G r contains an s-t path π Gr (s, t) that is homotopic to an optimal s-t path π(s, t) in P with the same length, and further, π(s, t) can be obtained from π Gr (s, t) by performing the dragging operations as in [29] and a new kind of operations, called through-corridor-path generating operations. The graph G r is built based on a corridor structure of P, which was used to find minimum-link paths in [22]. More specifically, we decompose P into O(h) junction rectangles and O(h) corridors. Each corridor is a simple rectilinear polygon. Although each corridor may have Θ(n) vertices, we show that we only need to consider at most four points of each corridor to build the graph G r . To this end, we make use of the histogram partitions of rectilinear simple polygons [26].
To solve the one-point queries, the approach of Chen et al. [6] is to "insert" the query point t to the graph G to obtain a set V g (t) of O(log n) vertices (called "gateways") of G such that an optimal path can be obtained by performing the dragging operations from the gateways. We follow the similar scheme but on our reduced graph G r , where only O(log h) gateways are necessary. Further, we also need to utilize the techniques of Schuierer [26] for simple rectilinear polygons.
For the two-point queries, the approach of Chen et al. [6] inserts both query points s and t to the graph G to obtain a set V g (s) of O(log n) gateways for s and a set V g (t) of O(log n) gateways of G for t, so that an optimal s-t path can be obtained by performing the dragging operations from these gateways. The query time becomes O(log 2 n) because every pair of points (p, q) with p ∈ V g (s) and q ∈ V g (t) needs to be considered. We again use the same scheme but on the graph G r with only O(log h) gateways for both s and t, which reduces the query time to O(log n + log 2 h). To further reduce the query time to O(log n), we follow the scheme in [7] for solving two-point L 1 shortest path queries in arbitrary polygonal domains. The main idea is to build a larger graph by adding more vertices to G r such that O( √ log h) gateways are sufficient for each query point.
The rest of the paper is organized as follows. We introduce some notation and concepts in Section 2. In Section 3, we review the algorithm given by Yang, Lee, and Wong [29] (we refer to it as the YLW algorithm), point out the error, and correct it. In Section 4, we further improve the algorithm for finding a single optimal s-t path. The one-point and two-point path query problems are discussed in Sections 5 and 6, respectively.

Preliminaries
In this section, we define some notation and review some concepts. Some terminologies are borrowed from the previous work, e.g., [7,8,11,29] For any two points p and q of P, if the line segment pq is in P, then we say that p is visible to q. Consider a vertical line l and a point p ∈ P. Let p ′ be the point on l whose y-coordinate is the same as that of p. We call p ′ the horizontal projection of p on l. If p is visible to p ′ , then we say that p is horizontally visible to l.
For any two points p and q, we use R pq to denote the rectangle with pq as a diagonal. A path in P is L-shaped if it consists of a horizontal segment and a vertical segment (each of them may be empty). A path is U-shaped if it consists of three segments s 1 , s 2 , and s 3 such that s 1 and s 3 are on the same side of the line containing s 2 (e.g., see Fig. 1). A path is called a staircase path if it does not contain a U-shaped subpath. Note that a staircase path is a shortest path.
Let V denote the set of all vertices of P. We let V also include the two points s and t. We review a path-preserving graph G(V) on V, which was originally from [11] and has been used elsewhere, e.g., [7,8,18,29]. The vertex set of G(V) consists of the points of V and Steiner points on some vertical lines, called cut-lines. The cut-lines and the Steiner points are defined as follows.
Let v m be the point of V with the median x-coordinate. The vertical line l m through v m is a cut-line. For each point v ∈ V, if v is horizontally visible to l m , then the horizontal projection of v on l m is a Steiner point. Let V l (resp., V r ) be the points of V on the left (resp., right) side of l m . The cut-lines and Steiner points on the left and right sides of l m are defined on V l and V r , recursively. We use a binary tree T (V) to represent the above recursive procedure, called cut-line tree. Each node u ∈ T (V) corresponds to a cut-line l(u) and a subset V (u) ⊆ V. If u is the root, then l(u) is l m and V (u) = V. The left and right subtrees of the root are defined recursively on V l and V r . Hence, T (V) has O(n) nodes and each point of V can define a Steiner point on at most O(log n) cut-lines. Therefore, there are O(n log n) Steiner points in total.
The vertex set of G(V) consists of all points of V and all Steiner points defined above. The edges of the graph are defined as follows. First, if a point v ∈ V defines a Steiner point v ′ on a cut-line, then G(V) has an edge vv ′ . Second, for any two adjacent Steiner points p 1 and p 2 on each cut-line, if the two points are visible to each other, then G(V) has an edge p 1 p 2 .
Clearly, G(V) has O(n log n) nodes and O(n log n) edges. Each edge of the graph is either horizontal or vertical. Each edge of G(V) has a weight that is the length of the corresponding line segment. The graph G(V) can be built in O(n log 2 n) time [11,18,29] 1 . The following lemma will be useful later. Lemma 1. [11,18,29] For any two points p and q in V, if R pq is empty (i.e., R pq is in P), then G(V) contains a staircase path from p to q.
For any path π in P, let L 1 (π) denote its length and let L d (π) denote its link distance. For any two points a and b on π, if the context is clear, we often use π(a, b) to denote the subpath of π between a and b. For any two points p and q in the plane, we say that q is to the northeast of p if q is in the first quadrant (including its boundary) with respect to p. Similarly, we define northwest, southwest, and southeast.

The YLW Algorithm and Our Correction
In this section, we first review the YLW algorithm [29] and then point out the error. Finally, we will fix the error and prove the correctness our new algorithm.

The YLW Algorithm
The YLW algorithm is essentially based on the following observation.
Lemma 2. (Yang et al. [29]) For any optimal path π from s to t in P, there is path π G in G(V) such that L 1 (π G ) = L 1 (π) and π G is homotopic to π (i.e., π G can be continuously dragged to π without going outside of P).
We briefly review the proof of Lemma 2 because it will help to understand the algorithm and also help us to prove our new algorithm given later.
Let π be any optimal path from s to t. It is shown (Lemma 2.1 [29]) that π can be divided into a sequence of staircase subpaths, and the two endpoints of each such subpath are in V. Hence, it is sufficient to prove the lemma for any staircase subpath of π. In the following, we consider a staircase subpath π(p, q) of π with p and q as the two endpoints. We further obtain a pushed staircase path as follows. Without loss of generality, we assume q is to the northeast of p and the segment of π(p, q) incident to p is horizontal. We push the first vertical segment of π(p, q) rightwards until either it hits a vertex of V or it becomes collinear with the second vertical segment of π(p, q). If the latter case happens, then we merge the two vertical segments and keep pushing the merged vertical segment rightwards. If the first case happens, then we push the next horizontal segment upwards in a similar way. The procedure stops until we arrive at the segment incident to q. Let π ′ denote the resulting path. Observe that L 1 (π ′ ) = L 1 (π(p, q)), π ′ is homotopic to π(p, q), and π ′ is also a staircase path. π ′ is called a pushed staircase path [29]. Also note that each segment of π ′ contains at least one vertex of V.
Remark. There are eight types of pushed staircase paths from p to q depending on which quadrant of p the point q lies in and also depending on whether the first segment of the path incident to p is horizontal or vertical.
The vertices of V partition π ′ into subpaths. To prove the lemma, it is sufficient to show the following claim: for any subpath π ′ (p ′ , q ′ ) of π ′ between any two adjacent vertices p ′ and q ′ of V on π ′ , there is a path π G (p ′ , q ′ ) connecting p ′ and q ′ in G(V) with the same length and the two paths are homotopic. Because every segment of π ′ contains at least one vertex of V, π ′ (p ′ , q ′ ) must be an L-shaped path. Without loss of generality, we assume q ′ is to the northwest of p ′ . If the rectangle R p ′ q ′ is empty (this includes the case where π ′ (p ′ , q ′ ) is a single segment), then by Lemma 1, the above claim is true. Otherwise, as shown in [29] (Lemma 4.5), there are some points of V in R p ′ q ′ that can be ordered as p ′ = v 0 , v 1 , . . . , v t = q ′ with R v i−1 v i being empty and v i to the northwest of v i−1 for each 1 ≤ i ≤ t, and further, π ′ (p ′ , q ′ ) is homotopic to the concatenation of v i−1 v i for all Converting πG(p ′ , q ′ ) (the dashed red path) to π ′ (p ′ , q ′ ) (the solid blue path between p ′ and q ′ ).
1 ≤ i ≤ t. By Lemma 1, for each 1 ≤ i ≤ t, G(V) contains a staircase path connecting v i−1 and v i and the path is in R v i−1 v i (and thus is homotopic to v i−1 v i ). Therefore, by concatenating the staircase paths from v i−1 to v i for all i = 1, 2, . . . , t, we obtain a staircase path from p ′ to q ′ and the path is homotopic to π ′ (p ′ , q ′ ). Note that the staircase path has the same length as π ′ (p ′ , q ′ ) since π ′ (p ′ , q ′ ) is an L-shaped path (and thus is also a shortest path). The above claim thus follows.
This proves Lemma 2. The proof actually constructs the path π G in G(V) corresponding to the optimal path π, and π G is called a target path. Yang et al. [29] also showed that π can be obtained from π G by applying certain dragging operations during searching the graph G(V). Before describing the details of the operation, we first give some intuition on how π can be obtained from π G . Based on the above constructive proof for Lemma 2, we only need to show that for each Lshaped path π ′ (p ′ , q ′ ), it can be obtained from the corresponding staircase path π G (p ′ , q ′ ) in G(V). Without loss of generality, we assume that q ′ is to the northeast of p ′ and the segment incident to p ′ in π ′ (p ′ , q ′ ) is vertical. Because π G (p ′ , q ′ ) is homotopic to π ′ (p ′ , q ′ ), we can convert π G (p ′ , q ′ ) to π ′ (p ′ , q ′ ) as follows (e.g., see Fig. 2). Starting from p ′ , for each horizontal segment of π G (p ′ , q ′ ), drag it upwards until either it hits the horizontal segment of π ′ (p ′ , q ′ ) or it becomes collinear with the next horizontal segment of π G (p ′ , q ′ ). In the former case, we have obtained π ′ (p ′ , q ′ ). In the latter case, we continue to drag the new horizontal segment upwards in the same way as before.
In the sequel, we briefly review the dragging queries [29]. This will make our paper self-contained and also help us to explain our new algorithm as well as the optimal path queries given later.
The YLW algorithm intends to search a target path in G(V). The algorithm starts from s. When a vertex p of G(V) is processed, at most eight paths from s to p are stored at p such that their last pushed staircase subpaths containing p are different. Later the algorithm will advance these paths from p to each neighboring vertex q of p in G(V). Let π(s, p) be such a path stored at p and we want to advance it from p to q to obtain a path π(s, q) from s to q. Without loss of generality, we assume p is to the northeast of p ′ , where p ′ is the start point of the last staircase path of π(s, p) containing p, and we also assume that the last segment w of π(s, p) is horizontal (i.e., w is incident to p). Other cases are similar. Let π ′ (s, q) = π(s, p) ∪ pq. We obtain π(s, q) from π(s, q ′ ) by a dragging operation on w as follows. We say that w is fixed if it borders an obstacle that is above w, in which case w cannot be dragged upwards anymore, and is floating otherwise. Since pq is an edge of G(V), it is either vertical or horizontal.
1. If q is to the right of p, then π(s, q) = π ′ (s, q) and the last segment of π(s, q) is w ∪ pq. 2. If q is to the left of p, then we ignore the path π(s, q) (i.e., the path will not be considered). 3. If q is above p (i.e., pq is vertical), then depending on whether w is fixed there are two subcases.
(a) If w is fixed (e.g., see Fig. 3(a)), then π(s, q) = π ′ (s, q) and pq becomes the last segment of pq. Note that pq is fixed if and only if it borders an obstacle that is on its right side.  i. If w can be dragged upwards to q without hitting a point of V (e.g., see Fig. 3(b)), then we drag w to q and obtain π(s, q), which has the dragged w as its last segment. ii. Otherwise, we ignore the path π(s, q).
4. If q is below p, then there are further two subcases.
(a) If w borders an obstacle below it (e.g., see Fig. 3(c)), then a new U-shaped path is generated and a new pushed staircase subpath is also generated with w being the first segment. We have π(s, q) = π ′ (s, q) with pq as the last segment. (b) Otherwise, we ignore the path π(s, q).
If we apply the dragging operations on a target path from s to t, then an optimal path can be eventually produced. This can be seen from the intuition we discussed earlier (refer to Lemma 4.6 of [29] for details). This motivates the YLW algorithm, which we describe below on finding a minimum-link shortest s-t path (other two types of optimal paths are similar).
The YLW algorithm works by applying Dijkstra's algorithm according to the measure vector (L 1 (π), L d (π)) for a path π. Initially, all vertices of G(V) are in a priority queue Q with measure vectors (∞, ∞) except that the measure vector for s is (0, 0). As long as Q is not empty, the algorithm removes from Q the vertex p with the smallest measure vector (lexicographically, i.e., for two vectors (a 1 , b 1 ) and (a 2 , b 2 ), the first one is smaller than the second one if and only if a 1 < a 2 , or a 1 = a 2 and b 1 < b 2 ) and advance the paths stored at p to each of p's neighbor q by using the dragging operations. Let π(s, q) be a path obtained for q. There may be other paths that are already stored at q and the types of the last staircase subpaths of these paths are also stored (recall that there are eight types of pushed staircase subpaths). The YLW algorithm relies on the following two rules to determine whether the new obtained path π(s, q) should be stored at q, and if yes, whether some paths stored at q should be removed. Let π ′ (s, q) be any path that has already been stored at q.
Rule(a) If the measure vectors of π(s, q) and π ′ (s, q) are not the same, then discard the one whose measure vector is strictly larger. Rule(b) If π(s, q) and π ′ (s, q) have the same measure vector and of the same type, compare their last segments. If their last segments overlap, discard the path whose last segment is longer.
It is claimed in [29] that once the point t is processed, among all paths stored at t, the one with the smallest measure vector is an optimal s-t path.
We find that the algorithm is not correct, mainly due to Rule(a). Figure 4 illustrates a counterexample. Assume that both π 1 and π 2 are paths from s to p with L 1 (π 1 ) = L 1 (π 2 ) and L d (π 1 ) + 1 = L d (π 2 ). Thus, the measure vector of π 1 is strictly smaller than that of π 2 . According to Rule(a), we should discard π 2 . Observe that we can obtain an s-t path from s to t using π 2 without having any extra link. However, to obtain an s-t path using π 1 , we need at least two more links. Therefore, π 2 can lead to a better s-t path than π 1 , and thus, we should not discard π 2 . Notice that the reason this happens is that although the measure vector of π 1 is strictly smaller than that of π 2 , the last segment of π 2 is shorter than that of π 1 (and thus it may be "freely" dragged upwards higher than that of π 1 ).
In fact, the most essential reason for this error to happen might be the following. If π is a shortest s-t path, then for any two points p and q in π, the subpath of π between p and q is also a shortest path from p to q. However, this may not be the case for minimum-link paths. Namely, if π is a minimum-link s-t path, then it is possible that for two points p and q in π, the subpath of π between p and q is not a minimum-link path from p to q. Due to this reason, one can verify that the O(nt + n log n) time algorithm given by Yang et al. [28] for computing optimal paths is not correct either. Indeed, the approach in [28] also applies Dijkstra's algorithm on a graph to search the optimal paths using the measure vectors like (L 1 (π), L d (π)).
By Rule(a 1 ), we may need to store two paths π 1 and π 2 at q even if the measure vector of one path is strictly smaller than that of the other, in which case L 1 (π 1 ) = L 1 (π 2 ) and L d (π 1 ) = L d (π 2 ) ± 1. Hence, unlike the YLW algorithm, each vertex q of G(V) may store paths with different measure vectors. Therefore, we cannot apply the same "vertex-based" Dijkstra's algorithm as before. Instead, we propose a "path-based" Dijkstra's algorithm. Roughly speaking, we will process individual paths instead of vertices. Specifically, in the beginning there is only one path from s to s itself in the priority queue Q. In general, as long as Q is not empty, we remove from Q the path π with the smallest measure vector. Assume that the endpoint of π is p. Then, we advance π from p to each of p's neighbors q. If π(s, q) is stored at q by our rules (i.e., both Rule(a 1 ) and Rule(b)), then we (implicitly) insert π(s, q) to Q. The algorithm stops once Q is empty. Since we process paths following the increasing measure order, the algorithm will eventually stop. Finally, among all paths stored at t, we return the one with the smallest measure as the optimal solution.
We will prove the correctness of the algorithm in Section 3.3. In terms of the running time, the YLW algorithm maintains at most eight paths at each vertex p of G(V). To see this, due to the Rule(b), for each type of staircase paths, p maintains at most one path. In our new algorithm, the paths maintained at p always have the same length but their link distances differ by at most one. Hence, again due to Rule(b), there are at most sixteen paths maintained at p. Clearly, this does not affect both the time and the space complexities of the algorithm asymptotically. Thus, the algorithm still runs in O(n log 2 n) time and O(n log n) space, as the YLW algorithm.
In addition, using another path-preserving graph G * (V) of O(n log 1/2 n) vertices and O(n log 3/2 n) edges [12], Yang et al. [29] proposed another O(n log 3/2 n) time and space algorithm (see Section 4.2 of [29]). Further, Chen et al. [6] reduced the space of the algorithm to O(n log n) with the same O(n log 3/2 n) time (similar technique was also used in [8]). By applying the techniques of both [29] and [6] to our new method, we can also obtain an algorithm of O(n log 3/2 n) time and O(n log n) space. We omit the details.
We proceed on the problem of finding a minimum-cost s-t path. Recall that we have a cost function f . For any path π, we use f (π) to denote the cost of the path. Our algorithm is the same as above with the following changes. First, the paths π in the priority Q are prioritized by f (π). Second, we replace both Rule(a 1 ) and Rule(b) by the following rule.
We give some intuition on why we use the above rule. Refer to Fig. 5, where there are three paths π 1 , π 2 , and π 3 from s to q. Let s i be the last segment of π i for each 1 ≤ i ≤ 3, and we assume that they overlap with |s 1 | < |s 2 | < |s 3 |, where |s i | is the length of each s i . We also assume that L d (π 1 ) = L d (π 2 ) = L d (π 3 ) and L 1 (π 1 ) > L 1 (π 2 ) > L 1 (π 3 ). In this case, we have to keep all three paths because any of them may lead to the best path from s to t. For example, for each 1 ≤ i ≤ 3, the path π i may lead to the best path from s to t i . One can generalize the example so that a total of Ω(n) paths may need to be stored at p. However, O(n) is the upper bound since the last segment of each such path starts from a different vertex of G(V) in the horizontal line through q and there are O(n) such vertices. For this reason, their are O(n 2 log n) paths stored in all O(n log n) vertices of G(V). Hence, the running time of the algorithm becomes O(n 2 log 2 n) and the space becomes O(n 2 log n). One may want to use some other rules to reduce the number of paths that need to be stored at q, e.g., Rule(b); however, in the worst case, the number of paths stored at q is still Θ(n).
We point out a detail about the algorithm implementation. Suppose we have computed a new path π(s, q) at q and we want to apply Rule(a 2 ). Then, we need to know whether there is a path π ′ (s, q) already stored at q whose last segment is exactly the same as that of π(s, q). If we check every path stored at q, then this step would cost O(n) time, resulting in an overall O(n 3 log n) time. We can actually implement this step in O(1) time, as follows. Let pq be the last segment of π(s, q) and suppose pq is horizontal. Observe that p must be a vertical projection of a point in V on the horizontal line through q. We use an array A of size |V| such that A[i] corresponds to the i-th vertex of V in the order of increasing x-coordinate. Hence, if p is the projection of the i-th vertex of V, then we can simply check the path stored at A[i] in O(1) time, and if π(s, p) should be stored, then we simply store it at A[i]. Similarly, we also build another array for the horizontal projections of the vertices of V on the vertical line through q. In this way, the overall running time of the algorithm is O(n 2 log 2 n). The space complexity is still O(n 2 log n) because the total size of the arrays at each vertex of the graph is O(n).
Further, as for the minimum-link shortest paths, by using the graph G * (V) and the techniques in [6,29], we can reduce the running time by a factor of √ log n. We omit the details. For computing a shortest minimum-link s-t path, we use the same algorithm as above for the minimum-cost paths but with the following changes. First, we use the measure vector (L d (π), L 1 (π)) instead. Second, we use the following rule, which is similar to Rule(a 2 ).
Rule(a 3 ) Let π 1 be one of π ′ (s, q) and π(s, q), and π 2 the other. If the last segments of π 1 and π 2 are exactly the same and the measure vector of π 1 is no larger than that of π 2 , then we discard π 2 .
The time and space complexities are the same as the above for the minimum-cost paths. If we are looking for a minimum-link s-t path (without considering the length), then we can use the following rule.
We also discard π 2 if the following is true: , the last segments of π 1 and π 2 overlap, and the last segment of π 1 is no longer than that of π 2 .
The rule makes sure that we only need to keep at most eight paths at any vertex q of G(V): for each of the following four directions of q: left, right, above, below, there are two paths whose last segments are from that direction and their link distances differ by at most one. Hence, similar to the minimum-link shortest paths, we can find a minimum-link path in O(n log 3/2 n) time and O(n log n) space. As discussed in Section 1, the problem of finding a single minimum-link path and its one-point query problem have been solved optimally [22] (after P is triangulated). We discussed the above result mainly because we will use it to answer the two-point queries in Section 6.
The correctness of all above algorithms is proved in Section 3.3.

The Correctness of Our Algorithm
We first show the correctness of the algorithm for computing a minimum-link shortest path. The analysis for other paths is very similar. Let π(s, t) be a minimum-link shortest s-t path in P. Let π G(V) (s, t) be the corresponding target path from s to t in the graph G(V). For any vertex p in the target path, let π(s, p) be the path in P from s to p obtained by applying the dragging operations on the subpath of π G(V) (s, t) from s to p. To prove the correctness of our algorithm, it is sufficient to show that the paths of π(s, p) for the vertices p of π G(V) (s, t) from s to t will be computed and advanced following the vertex order of π G(V) (s, t) during our algorithm. According to our analysis before, we only need to prove it for any L-shaped subpath π(p, q) between two adjacent vertices p and q of π(s, t).
We assume the path π(s, p) has been computed and stored at p, and is about to advance. Initially this is trivially true when p = s. Let π G(V) (p, q) be the subpath of π G(V) (s, t) between p and q, and let p = v 0 , v 1 , . . . , v k = q be the vertices of π G(V) (p, q) in order from p to q. Recall that The blue solid path is π(s, t), the red dashed path is π G(V) (p, q), and the green dotted path is π(s, v ′ 1 ).
π G(V) (p, q) is a staircase path. Without loss of generality, we assume q is to the northeast of p. If the path π(s, v 1 ) is stored at v 1 , then our algorithm is correct. Otherwise, there must be a path π ′ (s, v 1 ) stored at v 1 that causes π(s, v 1 ) not to be stored. According to Rules (a 1 ) and (b), at least one of the following cases must happen: (3) the measure vectors of the two paths are exactly the same, the last staircase subpaths of both paths are of the same type, and the last segment of π ′ (s, v 1 ) is shorter than or equal to that of π(s, v 1 ). If Case (1) happens, then consider the following path π ′ (s, t) from s to t (e.g., see Fig. 6): the concatenation of π ′ (s, v 1 ), a vertical segment from v 1 to a point v ′ 1 on the horizontal segment of the L-shaped subpath π(p, q), and the subpath π(v ′ 1 , t) of π(s, t) between v ′ 1 and t. Note that If Case (2) happens, then we still consider the path π ′ (s, t) obtained above. Observe that where the minus 1 is due to that we may be able to drag the last segment of π(s, v 1 ) so that it overlaps with the first segment π(v ′ 1 , t) (and thus save one link). (2)), we obtain that L d (π ′ (s, t)) ≤ L d (π(s, t)). Further, because L 1 (π ′ (s, v 1 )) = L 1 (π(s, v 1 )), we obtain L 1 (π ′ (s, t)) = L 1 (π(s, t)). This implies that using π ′ (s, v 1 ) we can also obtain a minimum-link shortest s-t path, and thus, π(s, v 1 ) can be safely ignored.
If Case (3) happens, then similar to the proof of Lemma 4.7 in [29], using π ′ (s, v 1 ) we can also obtain a minimum-link shortest s-t path, and thus, π(s, v 1 ) can be safely ignored.
The above proves that in any case our algorithm stores necessary paths at v 1 that can be used to eventually obtain a minimum-link shortest s-t path. By the similar argument, we can show that this is true for v i for all i = 2, 3, . . . , k. This establishes the correctness of our algorithm.
We proceed to show the correctness of our algorithm for computing a minimum-cost s-t path. We follow the above analysis scheme and focus on proving that the path π(s, v 1 ) will be stored at v 1 if necessary. If π(s, v 1 ) is not stored at v 1 , then according to Rules (a 2 ), this only happens because there is another path π ′ (s, v 1 ) stored at v 1 such that the last segments of π(s, v 1 ) and π ′ (s, v 1 ) are exactly the same and f (π ′ (s, v 1 )) ≤ f (π(s, v 1 )).
First of all, we know that the last segment of π(s, v 1 ) (i.e., pv 1 ) is horizontal and we can drag it upwards freely until the horizontal segment e of the L-shaped path π(p, q) to obtain the path π(s, t) (i.e., by concatenating with π(v ′ 1 , t)). Since the last segments of π(s, t) and π ′ (s, t) are exactly the same, regardless of whether π(s, t) and π ′ (s, t) are of the same type, we can also drag the last segment of π ′ (s, v 1 ) upwards freely until e, so that we can obtain another s-t path π ′ (s, t). Further, the above dragging on the last segment of π ′ (s, t) does not introduce any extra link and the amount of length it introduces is the same as that introduced by dragging the last segment of π(s, v 1 ). As f (π ′ (s, v 1 )) ≤ f (π(s, v 1 )) and the cost function f is non-decreasing in both the length and the link distance of the path, we can obtain that f (π ′ (s, t)) ≤ f (π(s, t)). Hence, we can also obtain a minimum-cost s-t path by using π ′ (s, v 1 ), and thus π(s, v 1 ) can be safely ignored without being stored at v 1 . This establishes the correctness of the algorithm.
The correctness of our algorithm for computing shortest minimum-link paths follows the similar analysis as the above case for minimum-cost paths. We omit the details.
Finally, we show the correctness for computing a minimum-link s-t path. We again follow the above scheme. If the path π(s, v 1 ) is not stored at v 1 , then according to Rule (a 4 ), there must be another path π ′ (s, v 1 ) stored at v 1 such that one of the following two cases happens: , the last segments of both paths overlap, and the last segment of π ′ (s, v 1 ) is no longer than that of the last segment of π(s, v 1 ).
If Case (1) happens, then as in the analysis for minimum-link shortest paths, we consider the path π ′ (s, t) obtained from π ′ (s, v 1 ) by adding a vertex segment v 1 v ′ 1 . We have shown above that L d (π ′ (s, t)) ≤ L d (π(s, t)) and thus it is safe to ignore π(s, v 1 ). If Case (2) happens, we can follow the proof of Lemma 4.7 of [29] (or the similar analysis as the above for the minimum-cost paths) to show that π ′ (s, v 1 ) can also lead to a minimum-link s-t path.

The Improved Algorithm
In this section, we improve our algorithm proposed in Section 3, so that in addition to O(n), the complexities of our improved algorithm only depend on h, i.e., the number of holes of P. We first review the corridor structure of P [22] and the histogram partitions of rectilinear simple polygons [26].

The Corridor Structure of P
For ease of exposition, we make a general position assumption that no two edges of P are collinear. The vertical visibility decomposition of P, denoted by VD(P), is obtained by extending each vertical edge of P until it hits the boundary of P (e.g., see Fig. 7). Each cell of VD(P) is a rectangle. Each extension segment is called a diagonal of VD(P).
The corridor structure of P has been introduced before, e.g., see [22]. Let G vd be the dual graph of VD(P) (e.g., see Fig. 7), i.e., each node of G vd corresponds to a cell of VD(P) and two nodes have an edge if the corresponding cells share an edge. Based on G vd , we obtain a corridor graph G cor as follows. First, we keep removing every degree-one node from G vd along with its incident edge until no such nodes remain. Second, we keep contracting every degree-two node from G vd (i.e., remove the node and replace its two incident edges by a single edge) until no such nodes remain. The graph thus obtained is G cor , which has O(h) nodes and O(h) edges [22]. Refer to Fig. 8 for an example. The cells of VD(P) corresponding to the nodes of G cor are called junction rectangles. If we remove all junction rectangles from P, each connected region is a simple rectilinear polygon, which is called a corridor. Each corridor has two diagonals each of which is on a vertical side of a junction rectangle, and we call them the doors of the corridor. For convenience, if a diagonal d bounds two junction rectangles (e.g., see Fig. 8), then we consider d itself as a "degenerate" corridor whose two doors are both d. With the degenerated corridors, each vertex of P lies in a unique corridor.   The decomposition VD(P) can be computed in O(n + h log 1+ǫ h) time for any ǫ > 0 [1]. After VD(P) is known, the corridor structure of P (i.e., computing all corridors and junction rectangles) can be obtained in O(n) time.

The Histogram Partitions
The histogram partition is a decomposition of a simple rectilinear polygon [26]. We will need to build the histogram partitions on the corridors of P. Below we review the partition and we follow the terminologies of [26].
A simple rectilinear polygon H is called a histogram if its boundary can be divided into an xor y-monotone chain and a single line segment, which is called the base of H (e.g., see Fig. 9).
Consider a simple rectilinear polygon Q (e.g., a corridor C of the corridor structure of P) and let e be an edge of Q (e.g., a door of C). A histogram partition of Q with respect to e, denoted by H(Q, e), is defined as follows. Let H be the maximal histogram with base e in Q, i.e., there is no other histogram in Q with base e that can properly contain it (e.g., see Fig. 10). A window of H is a maximal segment on the boundary of H that is contained in the interior of Q except its two endpoints (e.g., see Fig. 10). For each window w of H, it divides H into two subpolygons, and we let Q(w) denote the one that does not contain e. If H does not have a window, then we are done with the histogram partition of Q. Otherwise, for each window w, we perform the above partition on Q(w) recursively with respect to w.  For any points p and q in Q, it is known that there exists a path from p to q in Q that is both a shortest path and a minimum-link path [3,16,26], and we call it a smallest path.

A Reduced Path Preserving Graph
Recall that our algorithm in Section 3 use a graph G(V), which is built on the vertices of V and has O(n log n) nodes and edges. In this section, as a major tool for reducing the complexities of our algorithm, we propose a reduced graph of only O(h log h) nodes and edges.
The rest of this section is organized as follows. In Section 4.3.1, we introduce a set B of backbone points, based on which we will define the reduced graph G(B) in Section 4.3.2. In Section 4.3.3, we compute G(B). In Section 4.4, we give an algorithm to compute optimal paths by using G(B), and Section 4.5 proves its correctness. The algorithm in Section 4.4 is for the special case where both s and t are in junction rectangles. Section 4.6 generalizes the approach to other cases.

The Backbone Points
We introduce a set B of O(h) backbone points on the doors of the corridors of P, which will be used to define our reduced graph later.
Consider a corridor C of the corridor structure of P. Let d 1 and d 2 be the two doors of C. Note that both doors are vertical. The region of C excluding the two doors is called the interior of C. If there exist a point p 1 ∈ d 1 and a point p 2 ∈ d 2 such that p 1 p 2 is horizontal and p 1 p 2 in C then we say that C is an open corridor; otherwise, it is closed (e.g., see Fig. 11 and Fig. 12).
Consider an open corridor C (e.g., see Fig. 11). Let p 1 and p 2 be the points defined above. Imagine that we drag p 1 p 2 vertically upwards (resp., downwards) until we hit a vertex of C, then the current locations of p 1 and p 2 are two backbone points. In this way, each door of C has two backbone points. Clearly, the rectangle R with the four backbone points as the vertices is in C and we call R the canal of C. The two horizontal edges of R are called bridges of C. Further, the top edge of R is the upper bridge and the bottom edge is called the lower bridge.
If C is a degenerate corridor, which is a single diagonal d, then C is also an open corridor and the upper (resp., lower) bridge is degenerated to the upper (resp., lower) endpoint of d.
We have the following self-evident observation on open corridors. 1. If both p 1 and p 2 are on the boundary of the canal R, then p 1 p ∪ pp 2 is a shortest path in C from p 1 to p 2 , where p is the horizontal projection of p 2 on d 1 . 2. Otherwise, p 1 q 1 ∪ q 1 q 2 ∪ q 2 p 2 is a shortest path in C from p 1 to p 2 for some bridge q 1 q 2 of C.
In either case, we use π(C, p 1 , p 2 ) to denote the above shortest path between p 1 and p 2 , and we call it a canonical path.
Next, we consider the case where C is closed (e.g., see Fig. 12). Let H 1 be the maximal histogram in C with base d 1 . As C is closed, H 1 has a window w 1 that separates d 1 from d 2 , that is, w 1 divides C into two sub-polygons that contain d 1 and d 2 , respectively. By the definition of windows, if we extend w 1 to d 1 , the extension will hit d 1 at a point, denoted by q 1 , before it goes out of C. Similarly, we define H 2 , w 2 , and q 2 , with respect to the other door d 2 . The two points q 1 and q 2 are backbone points of C. The following is proved in [26].
Observation 2 (Lemma 3.1 of [26]) Suppose d 1 and d 2 are the two doors of a closed corridor C. For any two points p 1 ∈ d 1 and p 2 ∈ d 2 , the concatenation of p 1 q 1 , a shortest path from q 1 to q 2 in C, and q 2 p 2 is a shortest path from p 1 to p 2 in C. We use π(C, p 1 , p 2 ) to denote the path, and we call it a canonical path.

The Reduced Graph G(B)
In the following, we introduce the reduced graph, denoted by G(B), and we will use it to compute optimal paths. We first consider the case where both s and t are in junction rectangles. With a little abuse of notation, we let B also contain both s and t.
We build the graph G(B) with respect to the points of B in the same way as G(V) with respect to V in Section 3. Hence, G(B) has O(h log h) vertices and O(h log h) edges. In addition, we add the following O(h) edges to G(B). Consider a closed corridor C with the two backbone points q 1 and q 2 on its two doors. Note that q 1 and q 2 are also two vertices in G(B). We add to G(B) an edge e(q 1 , q 2 ) to connect q 1 and q 2 with length equal to L 1 (π(C, q 1 , q 2 )), i.e., the length of the canonical path π(C, q 1 , q 2 ). We call e(q 1 , q 2 ) a corridor edge of G(B), and call π(C, q 1 , q 2 ) a corridor path of C. We do this for all closed corridors. This completes the construction of G(B). Note that every path π G(B) in G(B) corresponds to a path π in P with the same length in the sense that if the path π G(B) contains a corridor edge, then π contains the corresponding corridor path. Similar to Lemma 1, we have the following observation.
Observation 3 For any two points p and q in B, if the rectangle R pq is empty, then G(B) contains a staircase path connecting p and q.
The following lemma is analogous to Lemma 2, but on the reduced graph G(B). It explains why the graph G(B) can help to find optimal paths. Lemma 3. There exists a path π G(B) in G(B) from s to t that is homotopic to an optimal s-t path and the two paths have the same length; we call π G(B) a target path.
Proof: Let π be an optimal s-t path in P. Since both s and t are in junction rectangles, an easy observation is that if π contains an interior point of a corridor C, then π must travel through C, i.e., π enters C through one door and leaves C through the other.
We assume that π travels through some closed corridors since otherwise the analysis would be similar (but easier). Consider each such closed corridor C with two doors d 1 and d 2 . Let q 1 and q 2 be the two backbone points on d 1 and d 2 , respectively. If we traverse π from s to t, define p 1 to be the last point on d 1 we encounter and define p 2 to be the first point on d 2 we encounter. Hence, the subpath of π between p 1 and p 2 , denoted by π(p 1 , p 2 ), is in C. We obtain another s-t path π ′ by replacing π(p 1 , p 2 ) with the canonical path π(C, p 1 , p 2 ) in C. By Observation 2, π(C, p 1 , p 2 ) is a shortest path in C, and thus, L 1 (π ′ ) = L 1 (π). Since both π(p 1 , p 2 ) and π(C, p 1 , p 2 ) are paths in C, which is simply connected, they are homotopic to each other. Therefore, π ′ is homotopic to π. Note that π ′ contains the two backbone points q 1 and q 2 and the subpath of π ′ between q 1 and q 2 is the corridor path of C, which corresponds to a corridor edge e(q 1 , q 2 ) in G(B).
We do the above for all such closed corridors that are traveled through by π. With a little abuse of notation, let π ′ be the new s-t path. By the above analysis, L 1 (π ′ ) = L 1 (π) and π ′ is homotopic to π. Let π 1 be a maximal subpath of π ′ that does not contain any corridor path. Note that π 1 does not contain an interior point of any closed corridor. Let a and b be the two endpoints of π 1 . Clearly, a and b are in B. Because all corridor paths are in G(B), to prove the lemma, it is sufficient to show that there is a path in G(B) connecting a and b with the same length as π 1 and the path is homotopic to π 1 . We assume that π 1 travels through at least one open corridor since otherwise the analysis would be similar (but easier).
Suppose π 1 travels through an open corridor C. If we traverse on π 1 from a to b, let p 1 be the first point and last point of π 1 ∩ C, respectively. Hence, p 1 is on a door of C and p 2 is on the other door. Let π 1 (p 1 , p 2 ) be the subpath of π 1 between p 1 and p 2 . We obtain another path π ′ 1 from a to b by replacing π 1 (p 1 , p 2 ) with the canonical path π(C, p 1 , p 2 ). Since π(C, p 1 , p 2 ) is a shortest path between p 1 and p 2 in C, L 1 (π 1 ) = L 1 (π ′ 1 ) and π ′ 1 is homotopic to π 1 . By Observation 1, π(C, p 1 , p 2 ) consists of at most one horizontal segment and at most two vertical segments, and further, the two endpoints of the horizontal segment are on the two doors of C, respectively, and the two vertical segments are on the doors of C.
We do this for all such open corridors that are traveled through by π 1 . Let π 2 denote the new path, which still connects a and b. Based on the above discussion, L 1 (π 1 ) = L 1 (π 2 ) and π 2 is homotopic to π 1 . Further, for each horizontal segment of π 2 , if it intersects the interior of a corridor C (which is necessarily an open corridor), then it must intersect both doors of C.
Suppose we traverse π 2 from a to b. If π 2 intersects a junction rectangle R, then let p 1 and p 2 be the first and last points π 2 intersecting R, respectively. Let π 2 (p 1 , p 2 ) be the subpath of π 2 between p 1 and p 2 . We obtain another path π ′ 2 from a to b by replacing π 2 (p 1 , p 2 ) with an L-shaped path connecting p 1 and p 2 , which has the same length as π 2 (p 1 , p 2 ) and is homotopic to π 2 (p 1 , p 2 ). Hence, π ′ 2 has the same length as π 2 and is homotopic to π 2 . We do the above for all such junction rectangles intersected by π 2 , and let π 3 be the resulting path, which still connects a to b. The length of π 3 is the same as that of π 2 and π 3 is homotopic to π 2 . Further, for each vertical segment of π 3 that is not incident to either s or t, it must be on a vertical side of a junction rectangle. 13. Illustrating the case where s2 is vertical.
We assume that π 3 contains a U-shaped subpath since otherwise the analysis would be similar (but easier). Consider a U-shape subpath of π 3 with three segments s 1 , s 2 , and s 3 . As shown in [29], s 2 must contain an obstacle edge e of P since otherwise we could shorten the path by dragging s 2 towards the direction of s 1 and s 3 . Depending on whether s 2 is horizontal or vertical, there are two cases.
1. If s 2 is horizontal, then e must intersect the interior of an open corridor C. To see this, on the one hand, e cannot be in a closed corridor because π 1 (and thus π 2 and π 3 ) does not contain an interior point of any closed corridor. On the other hand, the top or bottom side of each junction rectangle only contains a proper subset of an obstacle edge. Since s 2 is a horizontal segment of π 3 and e (and thus s 2 ) intersects the interior of C, s 2 intersects both doors of C, say, at two points p 1 and p 2 . Without loss of generality, we assume the obstacle bounded by e is locally above e. Because e intersects the interior of C and e is an obstacle edge, we cannot freely move p 1 p 2 in C vertically upwards. This implies that p 1 p 2 is the upper bridge of C and thus p 1 and p 2 are two backbone points of C. We pick either one of p 1 and p 2 , and call it a breakpoint of π 3 . 2. If s 2 is vertical, since s 2 is between s 1 and s 3 , s 2 cannot be incident to either s or t. Hence, s 2 (and thus e) must be on a vertical side of a junction rectangle R. Further, since s 1 and s 3 are toward the same direction, each of s 1 and s 3 must go inside an open corridor from s 2 since otherwise they would have to both go inside R and we could drag s 2 to shorten the path. Let p be the common endpoint of s 1 and s 2 (e.g., see Fig. 13). Hence, p must be on a door d 1 of an open corridor C. Since s 1 goes inside C, s 1 must also intersect the other door d 2 of C. Without loss of generality, we assume s 1 is above s 2 . Since s 2 contains an obstacle edge e, d 1 and e are on the same side of R and d 1 is higher than e. As s 2 intersects both doors of C, it must be higher than the lower bridge of C. This implies that s 2 must contain the endpoint p 1 of the lower bridge of C on d 1 , and we call p 1 a breakpoint of s 2 .
In either case above, we show that s 2 must contain a backbone point as a breakpoint of π 3 . If π 3 has other U-subpaths, then for each of them, the middle segment also contains a backbone point as a breakpoint of π 3 . Hence, if π 4 is a subpath of π 3 partitioned by the breakpoints, then π 4 must be a staircase path and both endpoints of π 4 must be in B. Let a and b be the two endpoints of π 4 , respectively. To prove the lemma, it is sufficient to show that G(B) has a path connecting a and b with the same length as π 4 and the path is homotopic to π 4 .
Without loss of generality, we assume that b is to the northeast of a. Based on π 4 , in the following, we obtain another shortest path π 5 from a to b such that π 5 has the same length as π 4 and is homotopic to π 4 . In fact, π 5 is similar in spirit to the pushed staircase path defined in [29] α p q C α ′ π 5 α ′ Fig. 14. The blue dashed dotted path is π5, where the two segments α and α ′ are labeled. The red dotted segment is the lower bridge of C. Fig. 15. The upper and lower endpoints of α are pu and p l , respectively. The obstacle vertex v is also labeled.
(also discussed in Section 3) but with respect to the open corridors and the junction rectangles. If the segment of π 4 incident to s is horizontal, then let α be the second horizontal segment of π 4 ; otherwise let α be the first horizontal segment of π 4 . Unless α is incident to t, we push α upwards until either it hits a vertex of P or it becomes collinear with the next horizontal segment of π 4 . In the latter case, we merge the two horizontal segments and let α refer to the merged segment and we push α upwards again. This procedure stops either when α hits an edge of P or becomes incident to t. We do the same for the rest of horizontal segments following their order along the path from a to b. Let π ′ 4 denote the resulting path. Clearly, π ′ 4 has the same length as π 4 and is homotopic to π 4 .
Next, we push the vertical segments of π ′ 4 . If the segment of π ′ 4 incident to s is vertical, then let β be the second vertical segment of π ′ 4 ; otherwise let β be the first vertical segment of π ′ 4 . Unless β is incident to t, we push β rightwards until either it hits a vertex of P or it becomes collinear with the next vertical segment of π ′ 4 . In the latter case, we merge the two vertical segments and let β refer to the merged segment and we continue to push β rightwards. This procedure stops either when β hits a vertex of P or becomes incident to t. Suppose β hits a vertex v of P. If v is on the boundary of a junction rectangle R, in which case β is on the right side of R, then we do nothing. Otherwise, v must be a vertex in the interior of an open corridor C, in which case we push β leftwards until it overlaps with the left door of C (note that β is now on the right side of a junction rectangle). This finishes the push operation for the vertical segment β. We proceed to do the same for the rest of the vertical segments following their order along the path from a to b. Let π 5 be the resulting path. Clearly, π 5 has the same length as π ′ 4 and is homotopic to π ′ 4 . Consider any segment α of π 5 . In the following, we show that α must contain a backbone point of B. This is obviously true if α is incident to either a or b. Below we assume that α is incident to neither a nor b. Depending on whether α is horizontal or vertical, there are two cases.
1. If α is horizontal, then α contains an obstacle edge e that bounds an obstacle from below. Recall that due to definition of degenerated open corridors, each vertex of P must be in a corridor. Let C be the corridor that contains the right endpoint of e. Note that C may be a degenerated open corridor. Since both the vertical segments of π 5 right before and after α are on vertical sides of junction rectangles, α must travel through C. Further, α contains the upper bridge of C since the portion of α between the two doors of C cannot be dragged upwards in C due to e ∩ C. Hence, α contains two backbone points that are the two endpoints of the upper bridge of C. 2. If α is vertical, then according to our construction of π 5 , α is on the right side of a junction rectangle. Depending on whether α contains an obstacle vertex, there are two cases. C, and this segment travels through C. Let d be the door of C that contains p. Let q be the lower endpoint of d. Since α contains an obstacle vertex and the upper endpoint of α is on d, q must be on α. Further, since α ′ travels through C, pq must contain the left endpoint of the lower bridge of C, which is a backbone point. As pq ⊆ α, α contains the above backbone point. (b) Otherwise, according to our construction of π 5 , if we push α rightwards, then we will hit an obstacle vertex v in the interior of C (e.g., see Fig. 15). Let α ′ be the next horizontal segment of α. As the above case, α ′ is going rightwards and travels through C. This means that v is below α ′ . Note that the lower bridge b l of C must be below α ′ and above v. Also note that α overlaps with the left door d of C. Let p u and p l be the upper and lower endpoints of α, respectively. Since v will be hit if we push α rightwards, v is above p l and below p u . Since b l is above v and below α ′ (and thus p u ), we obtain that b l is above p l and below p u (e.g., see Fig. 15). Therefore, the left endpoint of b l , which is a backbone point, is on α. This proves that α contains a backbone point.
The above shows that each segment of π 5 contains a backbone point. Hence, each subpath of π 5 partitioned by all breakpoints on π 5 must be an L-shaped path. Let π 6 be any such subpath, and let x and y be its endpoints, which are both in B. To prove the lemma, it is sufficient to show that G(B) contains a path from x to y that has the same length as π 6 and is homotopic to π 6 , as follows.
Without loss of generality, we assume y is to the northeast of x. We also assume that the segment incident to x is horizontal and the one incident to y is vertical. Other cases can be analyzed similarly. Hence, π 6 consists of a horizontal segment xz and a vertical segment zy for some point z.
If the rectangle R xy is empty (i.e., R xy in P), then by Observation 3, G(B) contains a staircase path π G(B) (x, y) from x to y in R xy . Since R xy is in P, π G(B) (x, y) is homotopic to π 6 with the same length. Otherwise, there exist backbone points contained in R xy and they can be ordered as y) be the concatenation of all these staircase paths π G(B) (h i , h i+1 ) for i = 1, 2, . . . , k − 1. Clearly, π G(B) (x, y) is a staircase path and thus has the same length as π 6 . In the following, we show how we find the above sequence of backbone points, and the way we find them will also imply that π G(B) (x, y) is homotopic to π 6 .
Since yz is vertical and y is in a junction rectangle, z is also in the same junction rectangle. Refer to Fig. 16. As R xy is not empty and both x and z are in junction rectangles, xz must travel through some open corridors (maybe degenerated). We push xz upwards until it hits a vertex of P, at which moment, the new segment, denoted by α, must contain the upper bridge b u of an open corridor, and we let h 2 refer to the right endpoint of b u (recall that h 1 = x). Note that h 2 is to northeast of of h 1 = x and R h 1 ,h 2 is empty. Next, we consider the L-shaped path h 2 z ∪ zy. Note that h 2 is also in a junction rectangle. Hence, we can use the same way as above to find h 3 , h 4 , . . ., until at some moment the pushed horizontal segment contains y.
As a summary, G(B) contains a path π G(B) from s to t such that π G(B) has the same length as the optimal path π and is homotopic to π. ✷ The following corollary confirms that G(B) is indeed a "path-preserving" graph.
Proof: Let π be a minimum-link shortest s-t path in P. By Lemma 3, there is a path π G(B) from s to t in G(B) with the same length of π. On the other hand, any path in G(B) corresponds to a path in P with the same length. Hence, π G(B) is a shortest s-t path in both G(B) and P. The corollary thus follows. ✷

Computing the Graph G(B) and the Reduced Domain
We show that the graph G(B) can be computed in O(n + h log 2 h) time. To this end, we will introduce a reduced domain P r , which is a polygonal domain that is a subset of P and has O(h) vertices, such that every ordinary edge of G(B) is in P r . Recall that in Section 3 the graph G(V) with respect to V of n points can be constructed in O(n log 2 n) time [11,18,29]. To construct G(B), one possible solution is to modify the previous algorithms [11,18,29] on the set B of O(h) points. However, since we still need to determine whether two points of B is visible in P in order to determine whether G(B) has an edge connecting the two points, even if we can reduce the factor O(n log 2 n) to O(h log 2 h), the algorithm may still suffer an O(n log n) factor in the time complexity. In the following, we propose a different approach.
We assume that the corridor structure of P has already been computed. First of all, all backbone points can be easily computed in O(n) time. Hence, all vertices of G(B) are known. By using the algorithm in [26], all corridor paths and thus the corridor edges of G(B) can be computed in O(n) time since the total size of all corridors is O(n). It remains to compute the ordinary edges of G(B), as follows.
Consider any ordinary edge e of G(V) that connects two vertices v 1 and v 2 of G(V). Hence, e is the segment v 1 v 2 that is either horizontal or vertical. Note that all vertices of G(B) are in junction rectangles. If e is vertical, an easy observation is that e must be in a junction rectangle.   has O(h) vertices and edges. We call P r the reduced domain. Constructing P r can be easily done in O(n) time from the corridor structure of P. By Lemma 4, we can compute the ordinary edges of G(B) with respect to the reduced domain P r of O(h) complexity instead of P of O(n) complexity. Consequently, by applying the previous algorithms [11,18,29], we can compute all ordinary edges of G(B) in O(h log 2 n) time.
As a summary, we can compute the graph G(B) in O(n + h log 2 h) time and O(n + h log h) space.

Computing an Optimal Path Using G(B)
In this section, we compute an optimal s-t path using G(B). Specifically, we show that an optimal s-t path can be computed by applying the dragging operations as in [29] on the ordinary edges of π G(B) and applying a new kind of operations, called through-corridor-path generating operations, on corridor edges of π G(B) , where π G(B) is a target path of G(B) defined in Lemma 3.
The algorithmic scheme is similar to that in Section 3.2. Recall that each ordinary edge of G(B) is either horizontal or vertical. When we advance the searching process through an ordinary edge, we perform a dragging operation in exactly the same way as described in Section 3.2 (which is also the way in the YLW algorithm [29]). If we are advancing along a corridor edge, then we apply a through-corridor-path generating operation, which is introduced in the following. To this end, we first review some results from Schuierer [26].
Consider a closed corridor C. Let d be a door of C and let q be the backbone point on d. Recall that q is an extension of a window w of the maximal histogram H in C with base d.
Let p be a point in C. Following the terminology in [26], a rectilinear path from p to a point on d is called an admissible path if the last link is orthogonal to d. A minimum-link admissible path from p to d is an admissible path from p to any point of d with the smallest number of links, and we use L d (p, d) to denote the number of links in the path. Let I 1 (p, d) (resp., I 2 (p, d)) denote the set of points on d that can be reached from p with an admissible path of at most L d (p, d) (resp., L d (p, d) + 1) links (e.g., see Fig. 17). It is known that each of I 1 (p, d) and I 2 (p, d) is an interval of d, and I 1 (p, d) ⊆ I 2 (p, d) [26]. Further, if p is not horizontally visible to d, then both intervals have q as one of their endpoints. By using the histogram partition H(C, d), Schuierer [26] built a data structure in O(|C|) time such that given any point p ∈ C, the two intervals I 1 (p, d) and I 2 (p, d) can be determined in O(log |C|) time. With a little abuse of notation, we also use H(C, d) to refer to the above data structure.
Suppose p is a point on the other door of C than d (so p is not horizontally visible to d). Then, I 1 (p, d) is uniquely determined by a point, denoted by λ 1 (p, d), on the window w in the following way [26] (e.g., see Fig. 18). Recall that d is vertical and thus w is horizontal. Without loss of generality, assume that the histogram H is locally above w and locally on the left of d. We shoot a ray from λ 1 (p, d) upwards until a point p 1 on the boundary of C and then we project p 1 perpendicular to d and let p 2 be the projection point. The point p 2 is the other endpoint of the interval I 1 (p, d), i.e., I 1 (p, d) = qp 2 . Note that p 2 is above q. Let I ′ 1 (p, d) denote the segment λ 1 (p, d)q, which is on the extension of the window w. We can also understand the two intervals I 1 (p, d) and I ′ 1 (p, d) in the following way. There exists an admissible path of L d (p, d) links from p to q, denoted by π 1 (C, p, q), which is actually a smallest path from p to q, and its last link is I ′ 1 (p, d); for any point q ′ ∈ I 1 (p, d), by dragging the last segment of π 1 (C, p, q) upwards until q ′ , we can obtain an admissible path of L d (p, d) links from p to q ′ . The data structure H(C, d) can also report λ 1 (p, d) in O(log n) time and the path π 1 (C, p, q) can be output in additional time linear in the link distance of the path. The interval I 2 (p, d) is uniquely determined by a point λ 2 (p, d) on the window w in the similar way as above. Similarly, we define I ′ 2 (p, d) and the corresponding admissible path of L d (p, d) + 1 links from p to q whose last link is I ′ 2 (p, d), denoted by π 2 (C, p, q), which is a shortest path (but not necessarily a smallest path) from p to q in C [26]. Similarly, the data structure H(C, d) can also report λ 2 (p, d) in O(log n) time and the path π 2 (C, p, q) can be output in additional time linear in the link distance of the path.
In the following, we introduce our through-corridor-path generating operations for advancing paths along corridor edges in our algorithm for searching the graph G(B).
Consider a corridor edge e(q 1 , q 2 ) connecting two vertices q 1 and q 2 of G(B). Note that q 1 and q 2 are two backbone points that are on the two doors d 1 and d 2 of a closed corridor C, respectively. Consider a path π(s, q 1 ) from s to q 1 maintained by our algorithm. Suppose we want to advance π(s, q 1 ) from q 1 to q 2 along the corridor edge e(q 1 , q 2 ). We perform the following through-corridorpath generating operation that will extend π(s, q 1 ) from q 1 to q 2 to obtain a path π(s, q 2 ) from s to q 2 .
Recall that q 1 is an extension of a window w 1 of the maximal histogram H 1 in C with base d 1 . Hence, w 1 divides C into two sub-polygons that contain d 1 and d 2 , respectively. Without loss of generality, we assume that the sub-polygon containing d 2 is locally above w 1 . We also assume that C is locally on the right of d 1 (e.g., see Fig. 19).
Let α be the last segment of π(s, q 1 ) (i.e., the one incident to q 1 ) and let p be the other endpoint of α than q 1 . Suppose we have already built the data structure H(C, d 2 ) for C with respect to the door d 2 . Depending on whether α is horizontal or vertical, there are two cases.
1. If α is horizontal (e.g., see Fig. 20), then p must be to the left of q 1 since C is locally on the right side of d 1 . In this case, we use H(C, d 2 ) to determine the path π 1 (C, q 1 , q 2 ) (whose last link is I ′ 1 (q 1 , d 2 )) and concatenate it with π(s, q 1 ) to obtain π(s, q 2 ). We also compute the number of links of π(s, q 2 ) and its length, and store them at q 2 . Note that L 1 (π(s, q 1 )) and L d (π(s, q 1 )) are already stored at q 1 . 2. If α is vertical, then depending on whether p is above q 1 , there are two subcases.
(a) If p is above q 1 , then we use the same approach as above to obtain π(s, q 2 ). Note that in this case the path makes a turn at q 1 while there is no turn at q 1 in the above case. Fig. 19. Illustrating a closed corridor C with two doors d1 and d2. q1 and q2 are the two backbone points, defined by the windows w1 and w2, respectively.   Fig. 21. Illustrating the through-corridor-path generating operation for the case where α is vertical and p is on d1 below q1. The smallest path πopt(C, q1, q2) are shown with red dashed segments. Note that I ′ 1 (p, d2) = λ1(p, d2)q2.
(b) If p is below q 1 , then depending on whether p is on d 1 , there are further two subcases. i. If p is not on d 1 , then we use the same approach as above to obtain π(s, q 2 ).
ii. If p is on d 1 , this is the trickiest case. Let π opt (C, p, q 2 ) denote the smallest path from p to q 2 in C whose last link is I ′ 1 (p, d 2 ) (e.g., see Fig. 21). π opt (C, p, q 2 ) can also be determined in O(log n) time by the data structure H(C, d 2 ). We obtain π(s, q 2 ) by concatenating π opt (C, p, q 2 ) with the subpath of π(s, q 1 ) between s and p.
As a summary, to obtain π(s, q 2 ), if Case 2(b)ii happens, then we connect the subpath of π(s, q 1 ) between s and p with π opt (C, p, q 2 ); otherwise, we connect π(s, q 1 ) with π 1 (C, q 1 , q 2 ). Note that in either case the last link of π(s, q 2 ) is I ′ 1 (q 1 , d 2 ). In either case, let π ′ be the subpath of π(s, q 2 ) contained in C. With the histogram partition H(C, d 2 ), we can obtain L 1 (π ′ ) and L d (π ′ ) as well as the first and last links of π ′ in O(log n) time (the actual path π ′ can be output in additional O(L d (π ′ )) time). Hence, we can compute L 1 (π(s, p 2 )) and L d (π(s, p 2 )) as well as its last link in O(log n) time, without explicitly computing the actual path π ′ . Therefore, the through-corridorpath generating operation can be performed in O(log n) time.
As discussed before, our algorithm works in the same way as the one in Section 3 except that we apply through-corridor-path generating operations on corridor edges of G(B) instead of the dragging operations. We can compute the histogram partitions for all closed corridors as the preprocessing for performing the through-corridor-path generating operations, and the total preprocessing time is O(n) since the size of all corridors is O(n). After the algorithm finishes, the path π stored at t with the smallest measure is an optimal s-t path. Note that if π has some subpaths in closed corridors, then π is implicitly maintained, we can output those subpaths in linear time by using the histogram partitions on the closed corridors. The following theorem gives some implementation details and analyzes the time complexities. The algorithm correctness is proved in the next subsection. Theorem 1. We can compute a minimum-link shortest s-t path in O(n + h log 3/2 h) time and O(n + h log h) space, and compute a shortest minimum-link s-t path or a minimum-cost s-t path in O(n + h 2 log 3/2 h) time and O(n + h 2 log h) space.
Proof: We will first show that computing a minimum-link shortest path can be done in O(n + h log 2 h) time and O(n + h log h) space and computing other two types of optimal paths can be done in O(n + h 2 log 2 h) time and O(n + h 2 log h) space, and then we will improve the algorithms by utilizing the techniques in [6,29]  For computing other two types of optimal paths, because each node of G(B) may store O(h) paths, the total number of paths stored in the algorithm is O(h 2 log h). Hence, in the entire algorithm, the total number of the dragging operations is O(h 2 log h) and the total number of throughcorridor-path generating operations is O(h 2 ). Thus, these operations together take O(h 2 log h log n) time, and the algorithm runs in O(n + h 2 log h log n) time in total. Note that n + h 2 log h log n = O(n + h 2 log 2 h). The space complexity is O(n + h 2 log h).
In the sequel, we improve the above algorithms by using the reduced domain P r proposed in Section 4.3.3 and the techniques in [6,29].
We first discuss the problem of finding a minimum-link shortest path. To reduce the running time, one key issue is to reduce the time on the dragging operations as there are O(h log h) such operations in the algorithm. The bottleneck of each such operation is to answer the following segment dragging queries: Given an ordinary edge e of G(B) and a direction ρ perpendicular to e, the query asks for the first vertex of V hit by e (called the hit vertex in [29]) if we drag e along the direction ρ (such a hit vertex is undefined if e hits an interior of an edge of P). Note that e is either horizontal or vertical. Each such query can be answered in O(log n) time with O(n) time preprocessing [4]. To reduce the time, the idea in [29] is to compute the results of the segment dragging queries on all edges of the graph in the preprocessing, so that the hit vertex of each such query can be obtained in O(1) time during the course of the algorithm. To adapt their techniques, we show below that in our algorithm on G(B) we only need to solve those segment dragging queries with respect to the reduced domain P r instead of P.
Let P ′ be the union of P r and all closed corridors. An observation is that the optimal path obtained by our algorithm, i.e., by applying the dragging operations on the ordinary edges of a target path π G(B) (s, t) and applying the through-corridor-path generating operations on the corridor edges of π G(B) (s, t), must be in P ′ . Indeed, this can be verified by checking that the optimal path π 5 obtained in the proof of Lemma 3 is in P ′ . Further, the closed corridors only affect the results of the through-corridor-path generating operations. Hence, to perform segment dragging queries (which are only used in the dragging operations), it is sufficient to only consider the domain P r , i.e., finding the hit vertices in P r .
With the above discussions, we adapt the techniques of [29] in the following way. First, as discussed in Section 3, we construct another path-preserving graph G * (B) with respect to B in the same way as G * (V) with respect to V, and G * (B) has of O(h log 1/2 h) vertices and O(h log 3/2 h) edges. Next, we insert the O(h) corridor edges to G * (B). As G(B), we can compute all ordinary edges of G * (B) with respect to the reduced domain P r in O(h log 3/2 h) time and space by using exactly the same algorithm of [29] but on B and P r . Further, we compute the hit vertices of all ordinary edges of G * (B) in the preprocessing by using the same algorithm in [29], but again on B and the reduced domain P r , in O(h log 3/2 h) time.  [6], we can further reduce number of edges of G * (B) to O(h log h) by representing some edges of the graph implicitly. Some details on maintaining the edges implicitly were provided in [6]. In the following, we add more details on computing the hit vertices of all edges of G * (B). The algorithm FindGG' in [29] computes the hit vertices of all ordinary edges of G * (B) in O(h log 3/2 h) time and O(h log 3/2 h) space. We modify it in the following way so that the space can be reduced to O(h log h) while keeping the same running time asymptotically (the idea should also be used in our O(n log 3/2 n) time and O(n log n) space algorithm for computing the minimum-link shortest paths using the graph G * (V) in Section 3.2).
Consider a cut-line L and a horizontal strip (i.e., a plane region bounded by two horizontal lines) as in the description of FindGG' [29]. There is a set S of k = O(log h) vertices of P r that are horizontally visible to L in the strip. Each vertex of S defines a Steiner point on L, so there are k Steiner points on L in the strip. We sort these Steiner points on L. For each segment of L divided by these Steiner points in the strip, the algorithm FindGG' computes its hit vertices on its both left and right sides. In the following, we only discuss the right hit vertices. All these hit vertices in all cut-lines and all strips can be computed in O(h log 3/2 h) time and O(h log h) space. One issue is that for every pair of Steiner points (not necessarily adjacent) a and b defined by S on L, we need to compute the (right) hit vertex of ab. To this end, FindGG' uses a table of size O(k 2 ) to maintain these hit vertices, so that given a and b, the hit vertex of ab can be obtained in O(1) time. But this table makes the total space of the algorithm become O(h log 3/2 h). To reduce the space while still keeping the O(1) query time, we replace the table by an array of size k + 1 and construct a range-minima data structure on the array [2,15]. Specifically, let l i be the i-th lowest segment of L divided by the Steiner points of S. Thus, L has k + 1 such segments in the strip. Let A[1 · · · k + 1] be an array of k + 1 elements such that each A[i] represents the x-coordinate of the hit vertex of l i (we also associate the hit vertex with A[i]). We build a range-minima data structure on A in O(k) time such that given any i and j with 1 ≤ i ≤ j ≤ n, the minimum value (and its index in A) in Fig. 22. Illustrating the definitions of a, a1, a ′ 1 , a2, and a ′ 2 . The (green) dashed dotted path is π. For computing the other two types of optimal paths, we can use the similar idea as above. The running time is O(n + h 2 log 1/2 h) and the space is O(n + h 2 log h). We omit the details. ✷

The Algorithm Correctness
In this section, we prove the correctness of our algorithm. As will be seen later, the main effort is to show that our through-corridor-path generating operations are correct. Let π be an optimal s-t path and let π G(B) be the corresponding target path obtained in the constructive proof of Lemma 3. If we can prove the following main claim: an optimal s-t path can be obtained by applying the segment dragging operations and through-corridor-path generating operations on the edges of π G(B) in the order from s to t, then by the proof techniques of Section 3.3, we can also show that our algorithms can correctly compute an optimal s-t path. Hence, in the following, we focus on proving the above main claim.
We assume that π travels through at least one closed corridor since otherwise the analysis would be similar (and simpler because we would not need to consider through-corridor-path generating operations). Along the path π from s to t, let C be the first closed corridor traveled through by π. Let d 1 be the first door of C intersected by π and let d 2 be the other door. Let π(a 1 , a 2 ) denote the subpath of π in C with a 1 ∈ d 1 and a 2 ∈ d 2 such that the edge of π(a 1 , a 2 ) incident to a 1 is perpendicular to d 1 and the edge of π(a 1 , a 2 ) incident to a 2 is perpendicular to d 2 . Refer to Fig. 22 for an example. Note that such a subpath must exist as π travels through C. Let a 1 a ′ 1 and a 2 a ′ 2 be the first and last edges of π(a 1 , a 2 ), respectively. Let aa 1 be the last edge of π(s, a 1 ).
Let q 1 and q 2 be the backbone points on d 1 and d 2 , respectively (e.g., see Fig. 22). Recall that q 1 is an extension of a window w 1 of the maximal histogram H 1 in C with base d 1 . Hence, w 1 divides C into two sub-polygons that contain d 1 and d 2 , respectively. Without loss of generality, we assume that the sub-polygon containing d 2 is locally above w 1 . We also assume that C is locally on the right of d 1 .

Obtaining a Special Optimal s-t Path π ′
In the following, we obtain another optimal s-t path π ′ that is homotopic to π, and π ′ has some special properties that will facilitate our analysis later. First of all, if π contains q 1 , then we let π ′ = π. Below we assume that π does not contain q 1 . Depending on whether a 1 is above or below q 1 , there are two cases.
1. If a 1 is above q 1 (e.g., see Fig. 23), then π(a 1 , a 2 ) must intersect w ′ 1 and w 1 , where w ′ 1 is the window that contains q 1 and is on the extension of w 1 . This further implies that π(a 1 , a 2 ) must contain the edge e of C that is between w ′ 1 and w 1 (if not, we can shorten the path by making it contain e). Let p be any point in the interior of e. We replace the subpath π(a 1 , p) by an L-shaped path a 1 q 1 ∪ q 1 p to obtain a new s-t path π ′ . Clearly, π ′ is homotopic to π. Below we argue that π ′ is also an optimal s-t path by showing that L 1 (π ′ ) ≤ L 1 (π) and L d (π ′ ) ≤ L d (π). Indeed, since a 1 q 1 ∪q 1 p is L-shaped, we have L 1 (π ′ ) ≤ L 1 (π). Next, we show that L d (π ′ ) ≤ L d (π). By the definition of a 1 , the segment a 1 a ′ 1 goes rightwards into the interior of C from a 1 . Thus, the subpath π(a 1 , p) contains at least two turns. The L-shaped path a 1 q 1 ∪q 1 p contains one turn. However, adding it to π ′ may introduce another turn at a 1 . Note that there is no additional turn at p. To see this, the last segments of both a 1 q 1 ∪ q 1 p and π(a 1 , p) are horizontal since p is an interior point of e and e is an edge of both π and π ′ . This implies that L d (π ′ ) ≤ L d (π). This proves that π ′ is an optimal s-t path. 2. If a 1 is below q 1 , then depending on whether aa 1 is vertical, there are two subcases.
(a) Suppose aa 1 is vertical (e.g., see Fig. 22). By the definition of w 1 , π must intersect a point p on the window w 1 . We replace π(a 1 , p) by an L-shaped path a 1 q 1 ∪ q 1 p to obtain a new s-t path π ′ . Clearly, π ′ is homotopic to π. We argue that π ′ is also an optimal s-t path by showing that L 1 (π ′ ) ≤ L 1 (π) and L d (π ′ ) ≤ L d (π). Similar to the above case, L 1 (π ′ ) ≤ L 1 (π) holds. Below, we show that L d (π ′ ) ≤ L d (π). Because a 1 is strictly below q 1 and a 1 a ′ 1 goes rightwards into the interior of C, the subpath π(a 1 , p) contains at least two turns (including the one at a 1 ) in π. On the other hand, the L-shaped path a 1 q 1 ∪q 1 p introduces at most two turns to π ′ : one at q 1 and the other possibly at p (note that there is no turn at a 1 ). This implies that L d (π ′ ) ≤ L d (π). (b) Suppose aa 1 is horizontal (e.g., see Fig. 24). In this case a must be to the left of a 1 since a is outside the corridor C. Hence, aa ′ 1 is the segment of π consisting of both aa 1 and a 1 a ′ 1 . Let a ′ 1 a ′′ 1 be the vertical segment incident to a ′ 1 . One can verify that a ′′ 1 must be above a ′ 1 since otherwise π would not be an optimal s-t path. Again, π must intersect the window w 1 at a point p.
As a summary, the above obtains an optimal s-t path π ′ , and there are two cases for π ′ : either π ′ contains q 1 , or a 1 is below q 1 and a ′ 1 a ′′ 1 intersects the window w 1 . Fig. 24. Illustrating the case where aa1 is horizontal and a ′ 1 a ′′ 1 does not intersect w1. Fig. 25. Illustrating the case where aa1 is horizontal and a ′ 1 a ′′ 1 intersects w1 (at p).
Let b refer to the point q 1 if π ′ contains q 1 and refer to a 1 otherwise. Let bb ′ denote the last segment of the subpath π ′ (s, b).

Obtaining another Optimal s-t Path π 5
In the sequel, we obtain another optimal s-t path π 5 by modifying the subpath π ′ (s, b), so that π 5 has certain special properties that will facilitate our analysis later.
Let π 1 = π ′ (s, b). The following analysis follows the similar scheme as in the proof of Lemma 3. We assume π 1 travels through at least one open corridor since otherwise the analysis would be similar (but easier). Suppose π 1 travels through an open corridor C. Hence, π 1 crosses both doors of C. Let p 1 and p 2 be the points on the two doors of C, respectively, such that the segment incident to p 1 and the segment incident to p 2 in the subpath π 1 (p 1 , p 2 ) are both horizontal (and thus perpendicular to the doors). Since π 1 travels through C, such two points p 1 and p 2 must exist. We replace π 1 (p 1 , p 2 ) by the canonical path π(C, p 1 , p 2 ) to obtain another path π ′ 1 , and one can verify that L 1 (π ′ 1 ) ≤ L 1 (π ′ ) and L d (π ′ 1 ) ≤ L d (π ′ ), and thus π ′ 1 is still an optimal s-t path. Note that π ′ 1 still contains the point b because b is not in any open corridors. We do the above for all open corridors traveled through by π 1 . Let π 2 denote the new optimal s-t path. Note that for each horizontal segment of π 2 (s, b), if it intersects the interior of an open corridor, then it must intersect both doors of the corridor.
Suppose we traverse π 2 (s, b) from s to b. If π 2 (s, b) intersects a junction rectangle R, then let p 1 and p 2 be the first and last points π 2 (s, b) intersecting R, respectively. We obtain another s-t path π ′ 2 by replacing π 2 (p 1 , p 2 ) with an L-shaped path connecting p 1 and p 2 such that L d (π ′ 2 ) = L d (π 2 ). Note that such an L-shaped path must exist. Clearly, L 1 (π ′ 2 ) = L 1 (π 2 ). Hence, π ′ 2 is also an optimal s-t path.
We do the above for all junction rectangles intersected by π 2 (s, b), and let π 3 be the resulting path. Note that each vertical segment of π 3 must be on a vertical side of a junction rectangle unless it is incident to s. Also note that π 3 still contains b.
As shown in the proof of Lemma 3, any subpath of π 3 (s, b) partitioned by the points of B on π 3 (s, b) must be a staircase path. Consider any such a staircase subpath π 3 (b 1 , b 2 ), where b 1 and b 2 are the two endpoints. We obtain a pushed path in the same way as in the proof of Lemma 3. We do this for all subpaths of π 3 (s, b) and let π 5 be the resulting path (we use π 5 instead of π 4 to be consistent with the proof of Lemma 3), which is still an optimal s-t path. Again, as shown in the d 2 Fig. 26. Illustrating the case where b ′ 2 b2 is vertical. Note that b2 = b = a1. The green dashed dotted path is π5.
proof of Lemma 3, for any segment of π 5 (s, b), it must contain a point of B or it is incident to b. Hence, each subpath of π 5 (s, b) partitioned by the points of B must be an L-shaped path. Consider any such subpath π 5 (b 1 , b 2 ) of π 5 (s, b). In the following, we argue the correctness of our algorithm on the subpath π 5 (b 1 , b 2 ).

Analyzing the Subpath
We first discuss the case where b 2 = b, i.e., it is not the last subpath of π 5 (s, b).
Without loss of generality, we assume that b 2 is to the northeast of b 1 and the segment of π 5 (b 1 , b 2 ) incident to b 1 is vertical. As shown in the proof of Lemma 3, G(B) has a staircase path π G(B) (b 1 , b 2 ) connecting b 1 to b 2 and the region between the two paths π 5 (b 1 , b 2 ) and π G(B) (b 1 , b 2 ) is empty (because the two paths are homotopic). Hence, when the algorithm processes the horizontal edges of π G(B) (b 1 , b 2 ), they can be dragged upwards to form π 5 (b 1 , b 2 ) without hitting any vertices of P (similar to the example in Fig. 2).
Next, we discuss the case where b 2 = b. Recall that b may be either q 1 or a 1 , and if b = a 1 , then b is on d 1 below q 1 and a ′ 1 a ′′ 1 intersects the window w 1 . In the sequel, we first show that by the dragging operations, our algorithm will obtain a particular path, denoted by π(s, q 1 ), and later we will use π(s, q 1 ) to argue the correctness of our through-corridor-path generating operations.
If b = q 1 , then π 5 contains q 1 . By the same argument as above and using the dragging operations, we can obtain π 5 (b 1 , b 2 ), and thus obtain π 5 (s, q 1 ) as well. In this case, we use π(s, q 1 ) to refer to π 5 (s, q 1 ).
If b = a 1 , then let b ′ 2 b 2 be the segment of π 5 (b 1 , b 2 ) incident to b 2 (e.g., see Fig. 26). Depending on whether b ′ 2 b 2 is horizontal or vertical, there are two cases. If b ′ 2 b 2 is vertical (e.g., see Fig. 26), then π * (b 1 , q 1 ) is also L-shaped, where π * (b 1 , q 1 ) is defined to be the concatenation of π 5 (b 1 , b 2 ) and b 2 q 1 . Hence, G(B) also has a staircase path π G(B) (b 1 , q 1 ) connecting b 1 to q 1 . As argued above, by performing the dragging operations on the edges of π G(B) (b 1 , q 1 ), we can obtain π * (b 1 , q 1 ) and thus obtain a path π(s, q 1 ) from s to q 1 that is a concatenation of π 5 (s, b 2 ) and b 2 q 1 . In this case, we use π(s, q 1 ) to refer to the concatenation of π 5 (s, b 2 ) and b 2 q 1 .
If b ′ 2 b 2 is horizontal (e.g., see Fig. 27), then b ′ 2 a ′ 1 = b ′ 2 a 1 ∪ a 1 a ′ 1 is a single segment of π 5 . We push b ′ 2 a ′ 1 upwards until we hit an obstacle vertex v. With a little abuse of notation, we still use π 5 to denote the new path (which is still an optimal s-t path) after the push operation, and use a 1 , a ′ 1 , b ′ 2 , and b 2 to refer to the corresponding new points in the new path. Recall that C is the closed corridor that has d 1 as a door. Depending on whether v is in the corridor C or not, there are two cases.
1. If v is in C, then since a ′ 1 a ′′ 1 intersects w 1 , v must be on the extension of the window w 1 and b 2 (= a 1 ) is at q 1 now. By using the same argument as before, we can obtain π 5 (s, q 1 ) by applying the dragging operations. In this case, π(s, q 1 ) refers to π 5 (s, q 1 ). 2. If v is not in C, then we claim that v must be on the upper bridge of some open corridor. Indeed, recall that the vertical segment b 1 b ′ 2 must be on the right side of a junction rectangle. Note that b 2 is on the right side of a different junction rectangle. Hence, b ′ 2 b 2 must travel through some open corridors and v must be at the lowest upper bridge of one of such open corridors. Let C ′ denote the open corridor whose upper bridge contains v. Since b ′ 2 b 2 travels through C ′ , b ′ 2 b 2 contains a backbone point p that is on a door of C ′ (in fact it contains two such backbone points, but one is enough for our argument). The point p breaks the path π 5 (b 1 , b 2 ) into two subpaths π 5 (b 1 , p) and π 5 (p, b 2 ) = pb 2 . Note that π 5 (b 1 , p) is an L-shaped path and π 5 (p, b 2 ) is a horizontal segment. Let π * (p, q 1 ) = pb 2 ∪ b 2 q 1 , which is an L-shaped path. Hence, by using the dragging operations, our algorithm will obtain the path π 5 (b 1 , p) and the path π * (p, q 1 ), and thus obtain the path π 5 (s, b 2 ) ∪ b 2 q 1 . In this case, we use π(s, q 1 ) to refer to the path π 5 (s, b 2 ) ∪ b 2 q 1 .
As a summary, the above shows that after our algorithm processes the edges of the target path from s to q 1 by applying the dragging operations, a path π(s, q 1 ) will be computed at q 1 with the following property: if π 5 contains q 1 , then π(s, q 1 ) = π 5 (s, q 1 ); otherwise, π(s, q 1 ) is π 5 (s, a 1 ) ∪ a 1 q 1 , a 1 is below q 1 on d 1 , and a ′ 1 a ′′ 1 intersects the window w 1 . In the following, we argue the correctness of our algorithm on processing the corridor edge e(q 1 , q 2 ) by applying the through-corridor-path generating operation. Depending on whether q 1 is in π 5 , there two main cases as discussed above. We will show that in either case, after the operation, we will obtain a path π(s, q 2 ) with the following property: if we apply the dragging operation on the last edge of π(s, q 2 ) and q 2 a 2 (which is a path of G(B)), then we can obtain a path π(s, a 2 ) from s to a 2 such that the concatenation of π(s, a 2 ) and π 5 (a 2 , t) is an optimal s-t path, which implies that storing π(s, q 2 ) at q 2 is sufficient for obtaining an optimal s-t path (this further implies the correctness of our through-corridor-path generating operation).

The First Main Case
We begin with the first case where π 5 contains q 1 . In this case, π(s, q 1 ) = π 5 (s, q 1 ). Let α = pq 1 be the last segment of π 5 (s, q 1 ). Depending on whether α is horizontal or vertical, there are two cases.
The horizontal case. If α is horizontal (e.g., see Fig. 20), then p is to the left of q 1 . In this case, according to our through-corridor-path generating operation, π(s, q 2 ) = π(s, q 1 ) ∪ π 1 (C, q 1 , q 2 ). By applying a dragging operation on the last segment of π(s, q 2 ), we obtain a path π(s, a 2 ) from s to a 2 , as follows.
Recall the intervals I 1 (q 1 , d 2 ) and I 2 (q 1 , d 2 ) defined in Section 4.4 (e.g., see Fig. 28). By the definition of q 1 , I 1 (q 1 , d 2 ) = I 2 (q 1 , d 2 ) [26]. Also recall that the last segment of π 1 (C, q 1 , q 2 ) is the interval I ′ 1 (q 1 , d 2 ) on the window w 2 . If a 2 is in the interval I 1 (q 1 , d 2 ), then we simply push the last segment of π(s, q 2 ) upwards until a 2 . Otherwise, we let π(s, a 2 ) = π(s, q 1 ) ∪ q 2 a 2 (i.e., add a vertical segment q 2 a 2 to connect d 2 28. Illustrating the intervals I1(q1, d2) and I2(q1, d2), which are equal. The segment λ1(q1, d2)q2 on the extension of w2 is the interval I ′ 1 (q1, d2) π(s, q 2 ) with a 2 ). Note that the above way of constructing π(s, a 2 ) in either case is consistent with applying the dragging operation on the last segment of π(s, q 2 ) and q 2 a 2 . In the latter case, for the purpose of the argument, we conceptually add a horizontal segment of zero length to the end of π(s, a 2 ) to connect a 2 such that the last segment of π(s, a 2 ) is also horizontal, and this makes it consistent with the path π 5 (s, a 2 ), whose last segment is also horizontal. Our goal is to show that π(s, a 2 )∪π 5 (a 2 , t) is also an optimal s-t path. To this end, in either case, due to that the last segments of both π(s, a 2 ) and π 5 (s, a 2 ) are horizontal, it is sufficient to prove L 1 (π(s, a 2 )) ≤ L 1 (π 5 (s, a 2 )) and L d (π(s, a 2 )) ≤ L d (π 5 (s, a 2 )). First of all, by the definition of π 1 (C, q 1 , q 2 ), the subpath of π(s, a 2 ) between q 1 and a 2 is a shortest path from q 1 to a 2 in C [26]. Thus, L 1 (π(s, a 2 )) ≤ L 1 (π 5 (s, a 2 )). In the following, we prove L d (π(s, a 2 )) ≤ L d (π 5 (s, a 2 )). Let π(q 1 , a 2 ) be the subpath of π(s, a 2 ) between q 1 and a 2 . Depending on whether a 2 is in I 1 (q 1 , d 2 ), there are two subcases.
The vertical case. Next we consider the case where α = pq 1 is vertical. We obtain our path π(s, a 2 ) in the same way as before. As in the above horizontal case, one can verify that L 1 (π(s, a 2 )) = L 1 (π 5 (s, a 2 )) holds in all cases below, and thus we will focus on proving L d (π(s, a 2 )) ≤ L d (π 5 (s, a 2 )). Depending on whether p is above q 1 , there are two subcases.
If p is below q 1 , then depending on whether p is on d 1 , there are further two subcases. If p is not on d 1 , then again both π(s, a 2 ) and π 5 (s, a 2 ) make a turn at q 1 . We also have L d (π(s, a 2 )) = L d (π(s, q 1 )) + L d (π(q 1 , a 2 )) and L d (π 5 (s, a 2 )) = L d (π 5 (s, q 1 )) + L d (π 5 (q 1 , a 2 )). The rest of the analysis is similar as before and we omit the details.
In the following, we assume that p is on d 1 . In this case, according to our through-corridor-path dragging operation (e.g., see Fig. 21), π(s, q 2 ) = π(s, p) ∪ π opt (C, p, q 2 ), which may not contain q 1 . By the definition of q 2 , the last segment of π opt (C, p, q 2 ) is orthogonal to d 2 and L d (π opt (C, p, q 2 )) = L d (p, d 2 ) [26].
Next we consider the case where a 2 ∈ I 1 (a 1 , d 2 ). In this case, we have L d (π(s, a 2 )) = L d (π(s, a 1 ))+ L d (a 1 , d 2 ) + 2. Depending on whether a 2 is in I 2 (a 1 , d 2 ), there are further two subcases.

Wrapping Things Up
The above shows the correctness of our through-corridor-path generating operations: if π(s, q 1 ) is stored at q 1 , then we can extend π(s, q 1 ) through the corridor C to obtain π(s, q 2 ), which can further be used to obtain an optimal s-t path by applying the dragging operation on the last segment.
Next we argue that if the path π(s, q 1 ) is not stored at q 1 , then there must exist another path π ′ (s, q 1 ) stored at q 1 that can also be used to obtain an optimal s-t path by applying the through-corridor-path generating operation on π ′ (s, q 1 ).
We first discuss the minimum-link shortest paths. We again consider the two main cases depending on whether π 5 contains q 1 .
(a) If the first case happens, then as the above analysis, the concatenation of π ′ (s, q 1 ), π 1 (C, q 1 , a 2 ), and π 5 (a 2 , t) is an s-t path whose length is strictly smaller than that of π 5 , contradicting with that π 5 is a (minimum-link) shortest path. (b) Suppose the second case happens. Regardless of whether the last segment of π ′ (s, q 1 ) is horizontal or vertical, due to the extra "budget" 2 on the link distance, one can verify that by applying the through-corridor-path generating operation on π ′ (s, q 1 ) we can obtain a path π ′ (s, a 2 ) from s to a 2 such that if π ′ 5 = π ′ (s, a 2 ) ∪ π 5 (a 2 , t), then L 1 (π ′ 5 ) = L 1 (π 5 ) and L d (π ′ 5 ) ≤ L d (π 5 ). Thus, using π ′ (s, q 1 ), we can also obtain a minimum-link shortest s-t path.
Other types of optimal paths can be analyzed in a similar way. We omit the details. The corridor edges partition the target path π G(B) into subpaths. The above proves that by applying the dragging operations on the edges of the first such subpath and applying a throughcorridor-path generating operation on the first corridor edge e(q 1 , q 2 ), we can obtain a path π(s, q 2 ) such that by applying a dragging operation on its last segment, we can obtain an optimal s-t path. For the second subpath of the target path, we use the similar argument. The only difference is the following. The first subpath starts from s, so we do not need to argue anything. However, in the second subpath, we have to show that there exists a path stored at q 2 so that by applying a dragging operation on its last segment we can obtain an optimal path. But this has been proved above. Hence, by applying the above analysis on each of the subpaths of π G(B) , we can prove that our algorithm will find an optimal s-t path.
This completes the proof of the correctness of our algorithm.

The General Cases
The above discussed the case where both s and t are in junction rectangles. In this section, we generalize the approach to other cases. We begin with the most general case where both s and t are in corridors. Let C s and C t be the two corridors that contain s and t, respectively. We first assume C s = C t . Consider a door d of C s . We define a point s d on d as follows. If s is horizontally visible to d, then s d is the horizontal projection of s to d. Otherwise, let w be the window of the maximal histogram of C with base d such that w separates s and d. We define s d to be the intersection of d and the extension of w (e.g., see Fig. 30). With s d thus defined, for any point p ∈ d, there is a shortest path from s to p in C s that is the union of ps d and π opt (C, s d , s), where π opt (C, s d , s) is the smallest path between s and s d in C [26]. We also call s d a corridor-connection point of s on d.
Similarly, for each door d of C t , we define a corridor-connection point t d with respect to t and C t . In this way, there are four corridor-connection points on the doors of C s and C t .
We let B now consist of all backbone points and the four corridor-connection points. We define the graph G(B) with respect to B in the same way as before. In addition, we add s and t as two new vertices to G(B) and also add the following four corridor-connection edges. For each corridorconnection point q defined by s, we add an edge in G(B) connecting q to s. The weight of the edge is L 1 (π opt (C s , s, q)), and the link distance L d (π opt (C s , s, q)) as well as the segment of π opt (C s , s, q) incident to q is also stored at the edge. Similarly, we add two corridor-connection edges connecting to t. This completes the definition of G(B).

Lemma 5.
There exists an s-t path π G(B) (s, t) in G(B) that is homotopic to an optimal s-t path π(s, t) and the two paths π G(B) (s, t) and π(s, t) have the same length; we call π G(B) (s, t) a target path. This implies that a shortest s-t path in G(B) is also a shortest s-t path in P.
Proof: Consider any optimal s-t path π in P. If we traverse on π from s to t, let d s be the first door of C s we encounter and let q s be first point on d s we encounter. Similarly, if we traverse on π from t to s, let d t be the first door of C t we encounter and let q t be first point on d t we encounter. Let p s be the corridor-connection point of s on d s . Let p t be the corridor-connection point of t on d t .
Based on π, we obtain another s-t path π ′ by replacing the subpath π(s, q s ) by q s p s ∪π opt (C s , p s , s) and replacing the subpath π(t, q t ) by q t p t ∪π opt (C t , p t , t). Clearly, L 1 (π ′ ) = L 1 (π) and π ′ is homotopic to π. Observe that π ′ consists of the following three subpaths: π ′ (s, p s ), which a path from s to p s in C s , π ′ (p s , p t ), and π ′ (p t , t), which a path from p t to t in C t . Since both p s and p t are in junction rectangles, according to the analysis of Lemma 3, the graph G(B) has a path π G(B) (p s , p t ) from p s to p t with the same length as π ′ (q s , q t ) and π G(B) (p s , p t ) is homotopic to π ′ (q s , q t ). As the two subpaths π ′ (s, p s ) and π ′ (p t , t) correspond to two corridor-connection edges in G(B), let π G(B) (s, t) be the concatenation of the above two corridor-connection edges and π G(B) (p s , p t ). According to the above analysis, the length of π G(B) (s, t) is equal to L 1 (π) and π G(B) (s, t) is homotopic to π. Hence, the first part of the lemma follows.
By using the similar argument as Corollary 1, the second part of the lemma can be proved. ✷ In light of the preceding lemma, we can compute an optimal s-t path by searching the graph G(B). Comparing with the algorithm for the previous case where both s and t are in junction rectangles, one big difference is in the beginning of the algorithm. Here, our algorithm starts to explore the two corridor-connection edges connecting to s. For each such edge, say, from s to s d on Fig. 31. Illustrating the interval I2(s, d), which is the segment ab on d.
a door d of C s , we move to the vertex s d of G(B) to obtain two paths and store them at s d , and the two paths are defined as follows. Without loss of generality, we assume C s is locally on the right of d. Depending on whether s is horizontally visible to d, there are two cases.
If s is not horizontally visible to d, recall that in Section 4.4 we defined intervals I 1 (s, d), I ′ 1 (s, d), I 2 (s, d), I ′ 2 (s, d), and two admissible paths π 1 (C, s, s d ) and π 2 (C, s, s d ) from s to s d in C. Also, L d (π 1 (C, s, s d )) = L d (s, d) and L d (π 2 (C, s, s d )) = L d (s, d) + 1. The last link of π 1 (C, s, s d ) is I ′ 1 (s, d) and the last link of π 2 (C, s, s d ) is I ′ 2 (s, d). We store the two paths π 1 (C, s, s d ) and π 2 (C, s, s d ) at s d .
If s is horizontally visible to d, then we can also define I 1 (s, d), I 2 (s, d), π 1 (C, s, s d ) and π 2 (C, s, s d ) in a way consistent with the above case, as follows. We define both π 1 (C, s, s d ) and π 2 (C, s, s d ) to be the horizontal segment ss d . However, we consider π 1 (C, s, s d ) as having a single segment while π 2 (C, s, s d ) as having another vertical segment incident to s with zero length. Hence, we still have L d (π 1 (C, s, s d )) = L d (s, d) and L d (π 2 (C, s, s d )) = L d (s, d) + 1. Note that L d (s, d) = 1. We define I 1 (s, d) as the single point s d and define I 2 (s, d) as the interval on d swept by s d if we push ss d vertically in C s (e.g., see Fig. 31). Note that the last segments of both π 1 (C, s, s d ) and π 2 (C, s, s d ) are ss d . However, if a dragging operation is applied, ss d is fixed for π 1 (C, s, s d ) and floating for π 2 (C, s, s d ), i.e., we cannot drag ss d vertically in π 1 (C, s, s d ) but we can do so in π 2 (C, s, s d ) due to the zero-length vertical segment at s. We store the two paths π 1 (C, s, s d ) and π 2 (C, s, s d ) at s d .
Next, the algorithm proceeds in the same way as before until when a corridor-connection edge from t d to t is processed, at which moment, we apply the following concatenation procedure to concatenate the current paths stored at t d with the two paths π 1 (C, t, d) and π 2 (C, t, d) (defined similarly as π 1 (C, s, d) and π 2 (C, s, d)) to obtain an s-t path. This is done with the help of the two intervals I 1 (t, d) and I 2 (t, d). The details are given below, which are somewhat similar to the through-corridor-path generating procedure.
Let π(s, t d ) be a path stored at t d and we wish to extend it to t. Let α = pt d be the last edge of the path and let π(s, p) be the subpath of π(s, t d ) between s and p. Without loss of generality, we assume that C t is locally on the right of d.
If α is horizontal, then we simply concatenate π(s, t d ) with π 1 (C, t, d) through t d . If α is vertical and p is on I 1 (t, d), then we concatenate π(s, p) with π 1 (C, t, d) through p after dragging the last edge (i.e., the segment incident to t d ) of π 1 (C, t, d) until p. If α is vertical and p is on I 2 (t, d), then we concatenate π(s, p) with π 2 (C, t, d) through p after dragging the last edge of π 2 (C, t, d) until p. If p is not on I 2 (t, d), then we again simply concatenate π(s, t d ) with π 1 (C, t, d) through t d . By the definitions of the two intervals I 1 (t, d) and I 2 (t, d), one can verify that the above gives the best solution for extending the path π(s, t d ) to t.
Once the searching algorithm on the graph G(B) is finished, we pick from all the paths stored at t the one with the smallest measure as the optimal solution. The algorithm is applicable to all types of optimal paths and the running times are asymptotically the same as before because computing all corridor-connection edges can be done in additional O(n) time [26].
The above discusses the case where C s = C t . If C s = C t , then we first compute a smallest path π opt (C, s, t) in C s in O(|C s |) time [26]. Clearly, if there exists an optimal path s-t in C s , then π opt (C, s, t) is a solution. Otherwise, any optimal s-t path first goes outside C s through one door and then gets back to C s through the other door. We apply the same algorithm as above by conceptually treating C s and C t differently.
If s is in a corridor and t is in a junction rectangle, we can use the similar approach as the above general case. The difference is that the concatenation procedure is not needed any more.

The One-Point Optimal Path Queries
In this section, we present our results on one-point queries, where s is the source point and t is the query point. The high-level scheme of our approach is similar to that in [6], which is based on the incorrect algorithm of [29] and the graph G(V) discussed in Section 3. Our new approach is based on our new algorithm and the reduced graph G(B) proposed in Section 4.
Let B now consist of the source s and all backbone points. Let G(B) be the graph we build in Section 4 on B. Note that if s is in a corridor, then the graph has two corridor-connection edges incident to s. We first consider the minimum-link shortest path queries.

The Minimum-Link Shortest Paths
Consider a query point t. We first assume that t is in a junction rectangle.
As in [6,7,8], we define a new graph G t (B) by "inserting" t into G(B), as follows. Roughly speaking, G t (B) is the graph defined with respect to B ∪ {t} in the same way as G(B) with respect to B with the following constraint: the vertical cut-line l(t) through t is at a leaf node of the cut-line tree (and thus l(t) does not have any Steiner points). Specifically, let T (B) be the cut-line tree of G(B). Since |B| = O(h), T (B) has O(h) nodes and its height is O(log h). We first define a set of projection cut-lines of t. Starting from the root v of T (B), if the cut-line l(v) of v is horizontally visible to t, then l(v) is a projection cut-line of t. If t is on the left side of l(v), then we proceed on the left child of v and the projection cut-lines in the left subtree of v are defined recursively; otherwise, we proceed on the right child of v. In this way, we can define O(log h) projection cut-lines for t because there is at most one projection cut-line at each level of T (B).
For each projection cut-line l(v) of t, we add a vertex v t to G(B), where v t is a Steiner point that is the horizontal projection of t onto l(v). Let a v and b v be the vertices of G(B) on l(v) right above and below v t , respectively, and they are called the gateways of t. We also add the following three edges to the graph: tv t , v t a t , and v t b t . Since t has O(log h) projection cut-lines, we add at most O(log h) vertices and edges to G(B), and the resulting graph is G t (B). Let V g (t) be the set of all gateways of t. Clearly, |V g (t)| = O(log h). Intuitively, the gateways "control" the paths from t to all other vertices of G t (B). Since G t (B) is essentially the graph defined with respect to B ∪ {t} in the same way as G(B) with respect to B, our algorithm in Section 4 can find a minimum-link shortest s-t path by searching G t (B). Based on this observation, we use the following approach to answer the query.

The Minimum-Cost Paths
For the minimum-cost paths, we use the same approach as above. The difference is that now each vertex of the graph G(B) maintains O(h) paths. Therefore, we need to consider O(h log h) candidate paths stored in the O(log h) gateways of t. Hence, the query time becomes O(log n + h log h). The preprocessing is the same as those in the algorithm given in Section 4, i.e., O(n + h 2 log 3/2 h) time and O(n + h 2 log h) space.

The Shortest Minimum-Link Path Queries
For the shortest minimum-link paths, following the above approach, we can obtain a result whose complexities are the same as the minimum-cost paths. However, we are able to do better. The main idea is that we can add more pruning rules to Rule(a 2 ) in Section 4, so that for each gateway q of t, we can do binary search to find a best path among all O(h) paths stored at q to connect to t, and consequently we only need to spend O(log h) time on q, and the total query time becomes O(log n + log 2 h). Specifically, we replace Rule(a 2 ) by the following Rule(a ′ 2 ) (a ′ 2 ) Let π 1 be one of π ′ (s, q) and π(s, q), and π 2 the other. We discard π 2 if one of the following two cases happen: (1) L 1 (π 1 ) ≤ L 1 (π 2 ) and L d (π 1 ) ≤ L d (π 2 ) − 2; (2) L 1 (π 1 ) ≤ L 1 (π 2 ), L d (π 1 ) = L d (π 2 ), the last segments of both paths overlap, and the last segment of π 1 is no longer than that of π 2 .
Using the similar analysis as in Section 4.5, one can verify that with the new rule the previous algorithm still works. Note that with the new rule each vertex q still needs to store Θ(h) paths in the worst case (e.g., extending the example in Fig. 5 by assuming L d (π 1 ) = L d (π 2 ) = L d (π 3 ) and L 1 (π 1 ) > L 1 (π 2 ) > L 1 (π 3 )). Based on the new rule, depending on whether the last segment is from upwards, leftwards, rightwards, downwards, there are four types of paths stored at q. More importantly to our approach for answering queries, the new rule guarantees the following property: each type of paths stored at q can be partitioned into two sets Π 1 (q) and Π 1 (q) such that (1) all paths of Π 1 (q) (resp., Π 2 (q)) have the same link distance; (2) the link distance of the paths of Π 1 (q) is one larger than that of the paths of Π 2 (q); (3) the paths of Π 1 (q) (resp., Π 2 (q)) can be organized into a sequence π 1 , π 2 , . . . , π k with k = O(h) such that their lengths are strictly decreasing and the lengths of their last segments are strictly increasing (e.g., see Fig. 5 with L 1 (π 1 ) > L 1 (π 2 ) > L 1 (π 3 )).
Consider a query point t. We first assume that t is in a junction rectangle. Let q be a gateway of V g (t). Without loss of generality, we assume that q is in the first quadrant of t. To extend the paths π(s, q) stored at q to t, we use the following approach. Note that we only need to consider the paths π(s, q) whose last segments are from upwards and rightwards of q (since other paths cannot lead to an optimal s-t path). We consider the type of paths whose last segments are from rightwards of q (the other type of paths can be processed similarly). Let Π 1 (q) and Π 2 (q) be the two sets of sorted paths. We consider the set Π 1 (q) (the other set can be processed similarly). Let the sequence of the paths of Π 1 (q) be π 1 , π 2 , . . . , π k as defined above. Suppose we want to find the best path among above paths to extend it to t with the smallest measure. Since the lengths of those paths are strictly decreasing, if we can find the largest index i ∈ [1, k] such that we can freely drag the last segment of π i downwards until t without making any extra turn, then π i is the best path. To find such an index i, we can use binary search as follows. Since the lengths of the last segments of these paths are strictly increasing, the downward hit vertices of these segments are actually sorted in increasing order by their y-coordinates. As these hit vertices have already been computed and Theorem 2. For the one-point path queries, we have the following results.
p. Since |V g (s)| = O(log h), there are O(log 2 h) such paths we need to consider. Because we can perform each dragging operation in O(1) time [6], the total time is O(log 2 h). Among all obtained s-t paths, we return the one with the smallest measure as the optimal solution. Hence, the total query time is O(log n + log 2 h).
If at least one of s and t is in corridors, then similar to the one-point query problem, we first find the corresponding corridor-connection points and then apply the concatenation procedure in addition to the dragging operations. We still need to consider O(log 2 h) paths, and the query time is still O(log n + log 2 h).
In summary, with O(n + h 2 log 2 h) time and space preprocessing, each two-point minimum-link shortest path query can be answered in O(log n + log 2 h) time.
For the minimum-cost path queries, we use the similar approach. In the preprocessing, for each vertex p of the graph G(B), we run our algorithm in Section 4 (for computing the minimumcost paths) on G(B) with p as the source point. Using the techniques in [6], this can be done in O(n + h 3 log 2 h) time and space. The query algorithm follows the same scheme as above. Since in this problem each vertex stores O(h) paths, we have to consider O(h log 2 h) paths. Therefore, the query time becomes O(log n + h log 2 h).
For the shortest minimum-link path queries, we also use the similar approach. We do the same preprocessing as before by using the algorithm for computing shortest minimum-link paths in Section 4. As the minimum-cost path problem, the preprocessing takes O(n + h 3 log 2 h) time and space. The query algorithm follows the same scheme as above. In this problem, although each vertex stores O(h) paths, we can use binary search in the same way as in the one-point query problem, and thus the total query time is O(log n + log 3 h).
In addition, we also consider the two-point minimum-link path queries since the problem was not studied before. As discussed in Section 3.2, Rule(a 3 ) makes sure that each vertex of G(B) only needs to store O(1) paths. Hence, the algorithm is similar to the one for the minimum-link shortest paths. The preprocessing time and space is O(n + h 2 log 2 h) and the query time is O(log n + log 2 h).

Reducing the Query Times
With slightly more preprocessing, we reduce the query time for each problem by a factor of log h. Similar approach was already used in [7]. The main idea is to build an enhanced graph G E (B) of larger size on the backbone points of B, so that we only need a set of O(  [7] for more details. We first discuss the minimum-link shortest paths. We do the following in the preprocessing. For each vertex p of G E (B), we apply our algorithm in Section 4 on G E (B) with p as the source point, after which for each vertex q of the graph, it stores O(1) paths π(p, q) from p to q. This can be done in O(n + h log 3/2 h2 √ log h ) time and O(n + h log 1/2 h2 √ log h ) space. Running the algorithm for all vertices p of G E (B) takes O(n + h 2 log 2 h4 √ log h ) time and O(n + h 2 log h4 √ log h ) space. We assume that both s and t are in junction rectangles. We first compute their gateways sets V g (s) and V g (t), which can be done again in O(log h) time (with O(n + h log 3/2 h2 √ log h ) time and O(n + h log 1/2 h2 √ log h ) space preprocessing) [7]. Since the sizes of both gateway sets are bounded by O( √ log h), we only need to consider O(log h) paths to extend to connect s and t. Therefore, the query time becomes O(log h). If s or t is in a corridor, then we again need to first compute their corridor-connection points in O(log n) time, and then follow the approach we discussed before but with only O(log h) paths to consider. Hence, the total query time is O(log n).
In summary, with O(n + h 2 log 2 h4 √ log h ) time and O(n + h 2 log h4 √ log h ) space preprocessing, each two-point query of the minimum-link shortest paths can be answered in O(log n) time. Note that h 2 log 2 h4 √ log h = O(h 2+ǫ ) for any ǫ > 0. The same approach is also applicable for other two types of optimal paths. For the minimum-cost paths, the preprocessing has one more h factor on both the time and space. Specifically, with O(n + h 3 log 2 h4 √ log h ) time and O(n + h 3 log h4 √ log h ) space preprocessing, each query can be answered in O(log n + h log h) time. For the shortest minimum-link paths, the preprocessing complexities are the same as the above for the minimum-cost paths, but the query time is O(log n + log 2 h). For minimum-link path queries, the complexities of the preprocessing and the query algorithm are all the same as those for the minimum-link shortest paths.
We summarize the two-point query results for all problems in the following theorem.