Computing optimal shortcuts for networks

We study augmenting a plane Euclidean network with a segment, called a shortcut, to minimize the largest distance between any two points along the edges of the resulting network. Problems of this type have received considerable attention recently, mostly for discrete variants of the problem. We consider a fully continuous setting, where the problem of computing distances and placing a shortcut is much harder as all points on the network, instead of only the vertices, must be taken into account. We present the first results on the computation of optimal shortcuts for general networks in this model: a polynomial time algorithm and a discretization of the problem that leads to an approximation algorithm. We also improve the general method for networks that are paths, restricted to two types of shortcuts: those with a fixed orientation and simple shortcuts.


Introduction
A fundamental task in network analysis, especially in the context of geographic data (for instance, for networks that model roads, rivers, or train tracks), is analyzing how an existing network can be improved. This can arise in many different contexts: in relation to facility location analysis, for example, to guarantee a certain maximum travel time from any point on the network to the nearest hospital, or in road network design problems, to decide where to add road segments to reduce network congestion [23].
In fact, due to the many and varied applications of this type of network optimization problem, there is a vast amount of work in areas like operational research and transportation science, which deals with different aspects of the so-called Network Design Problem: deciding how to add or modify network connections (e.g., roadway segments) in order to improve aspects such as travel time, capacity or connectivity (see, for instance [11,13,23]).
One of the simplest approaches to model networks like the ones above is as a geometric network : an undirected graph whose vertices are points in R 2 and whose edges are straightline segments connecting pairs of points. Moreover, in many applications, it is reasonable to assign lengths to the edges equal to the Euclidean distance between their endpoints. These are called Euclidean networks. When, in addition, there are no crossings between edges, the Euclidean network is said to be plane. Many problems in geographic analysis, for instance, those involving certain transportation networks, can be reasonably modeled with a plane Euclidean network. In the following, we shall simply write network, it being understood as plane and Euclidean.
One of the most fundamental ways to improve a network is by adding edges. This increases the connectivity of the network and potentially can decrease travel times and congestion. The most studied criteria to measure network improvement, in the geometric setting, are related to distances. Particularly important is the maximum distance, or diameter of the network, which provides an upper bound on the distance between any two network points. Another important distance-related criterion in this context is the dilation, which captures the maximum detour between two points on the network.
In this paper, we focus on the problem of adding segments to a network in order to improve its diameter. This can be seen as a variant of the Diameter-Optimal-k-Augmentation problem for edge-weighted geometric graphs, which consists in inserting k additional edges into an edge-weighted geometric graph, while minimizing the largest distance in the resulting graph. While in most augmentation problems the additional edges are inserted between two existing vertices of the graph, we consider a continuous version, for k = 1: the endpoints of our inserted segment, called shortcut, can be any two points (not necessarily vertices) on the network. In addition, our goal is to find an optimal shortcut: one minimizing the diameter of the resulting network, over all possible shortcuts. We point out here that a segment will be considered a shortcut only if its insertion improves the diameter of the resulting network. The fact that all points on the network must be taken into account turn the computation of distances and the placement of a shortcut into a much harder problem. For instance, since the resulting network also includes the points on the shortcut inserted, we can run into the somewhat counterintuitive situation that the insertion of a segment worsens the diameter of the resulting network.
In the continuous setting, two major variants of the problem arise, depending on how the shortcut is inserted into the network. In the first variant, which we call highway model, the crossings between the shortcut and the network edges do not form new network vertices: a path can only enter and leave the shortcut through its endpoints. In contrast, in the planar model, every crossing creates a new vertex, which can be used by paths in the network. Figure 1 illustrates the difference between the two models.
We deal in this paper with optimal shortcuts in the planar model. This model is more general, and is applicable to a wider range of situations, like the addition of segments to road or pedestrian networks. From a theoretical point of view, the difference between the highway and planar model is important. The latter results in more complex problems, since the fact that a shortcut can be used only in part, implies that the structural information on how the distances in the network change after adding a segment is more difficult to maintain. Moreover, as we show in this work, many intuitive properties of shortcuts do not hold in the planar model anymore.

Related work.
The motivation of this work lies on the well-studied Road Network Design Problem, which has been subject of much attention in many areas, including operational research, transport geography, and engineering, and has been recognized as one of the most difficult and challenging problems in transport [23]. We refer to [11,13,23] for relevant surveys on this general problem, for their urban and road variants. The network design problem is extremely  Figure 1: Example of network with diameter 4 (each edge has unit length): (a) in the highway model, no single segment insertion can improve the diameter, (b) in the planar model, segment pq is a shortcut, since its insertion reduces the diameter to d(r,r) = 3.5. complex, involving plenty of different aspects such as travel demand, road capacity, traffic flow, and congestion. In this work we focus on a much simplified geometric scenario, with the goal of exploring some of the algorithmic aspects of this complex problem. For that reason, our problem is mostly related graph augmentation problems, and in particular to those where the graph is geometric.
There has been a considerable amount of work devoted to the non-geometric version of the Optimal-k-Augmentation problem, see for instance [14,17]. However, there are very few results on augmentation problems over plane geometric graphs. Farshi et al. [12] considered plane Euclidean networks in R d and designed approximation algorithms to minimize the dilation when inserting one edge. The analogous problem for networks embedded in a metric space is studied in [20,21]. See the survey [19] for more on augmentation problems over plane geometric graphs.
In the geometric and continuous setting, most known results on the problem studied in this paper consider the highway model and certain classes of graphs. For paths, De Carufel et al. [6] gave an algorithm to find an optimal shortcut in linear time, and also optimal pairs of shortcuts (i.e., k = 2) for convex cycles. Trees have been studied in a recent follow-up work [7], which presents an algorithm to find an optimal shortcut for a tree of size n in O(n log n) time. For circles, very recently Bae et al. [1] have analyzed how to add up to seven shortcuts in an optimal way. For the planar model much lees is known. Yang [22] designed three different approximation algorithms to compute an optimal shortcut for certain types of paths. Cáceres et al. [5] were the first to deal with general networks, for which they show that one can find a shortcut in polynomial time if one exists, but they do not compute an optimal one. Note that there are networks whose diameter cannot be improved by adding only one segment (e.g., a cycle).
Our results. We present the first study of optimal shortcuts in the planar model for general networks, and several improved results for paths. An important contribution of our work is to highlight many important differences between the highway and planar models, the latter resulting in considerably harder problems. In Section 2, we give a polynomial time algorithm to compute an optimal shortcut, if one exists, for a general network. Moreover, we present a discretization of the problem that immediately leads to an approximation algorithm, generalizing an existing result for paths [22]. Section 3 focuses on paths: we first show that the diameter of a path network after adding a shortcut can be computed in Θ(n) time. Then we improve the general method of Section 2 for shortcuts of any fixed direction. Finally, we study simple shortcuts, a variant that has been considered before [5,22], which has applications in settings where the added edge cannot intersect the existing network. We show that an optimal simple shortcut can be found, if one exists, in O(n 2 ) time.

Preliminaries
We will use N = (V (N ), E(N )) to denote a network with n vertices, and N for its locus, the set of all points of the Euclidean plane that are on N . Thus, N is treated indistinctly as a network or as a closed point set. When N is a path, we use P instead of N . Further, we write a ∈ N for a point a on N , and V (N ) ⊂ N .
A path P between two points a, b on N is a sequence au 1 . . . u k b where u 1 u 2 , . . . , u k−1 u k ∈ E(N ), a is a point on an edge ( = u 1 u 2 ) incident to u 1 , and b is a point on an edge ( = u k−1 u k ) incident to u k . We use |P | to denote the length of P , i.e., the sum of the lengths of all edges u i u i+1 plus the lengths of the segments au 1 and bu k . The length of a shortest path from a to b is the distance between a and b on N . This distance is written as d N (a, b) or d(a, b) when the network is clear, and whenever ab / ∈ E(N ), it is larger than |ab|, the Euclidean distance between the points.
The eccentricity of a point a ∈ N is ecc(a) = max b∈N d(a, b), and the diameter of N , also called generalized or continuous diameter of N [6,7,9], is diam(N ) = max a∈N ecc(a). Two points a, b ∈ N are diametral whenever d(a, b) = diam(N ), and a shortest path connecting a and b is then called diametral path.
The diameter of N , diam(N ), can be computed in quadratic time [5,9]. Furthermore, the diametral pairs of N are either (i) two vertices, (ii) two points on distinct non-pendant edges 4 , or (iii) a pendant vertex and a point on a non-pendant edge [5, Lemma 6]. Thus, with some abuse of notation, in Section 2, we will say that a diametral pair α, β ∈ V (N ) ∪ E(N ) may be (i) vertex-vertex, (ii) edge-edge, or (iii) vertex-edge.
A shortcut for N is a segment s with endpoints on N such that its insertion improves the diameter of the resulting network, that is, diam(N ∪ s) < diam(N ). We say that shortcut s is simple if its two endpoints are the only intersection points with N , and s is maximal if it is the intersection of a line and (N ∪ s), i.e., s = (N ∪ s) ∩ , for some line ; see Figure 1(b) for an example of a non-simple and maximal shortcut. A shortcut is optimal if it minimizes diam(N ∪ s) among all shortcuts s for N .

General networks
The main result in [5] states that one can always determine in polynomial time whether a network N has a shortcut (and compute one, in case of existence). In this section, we first prove the analogous result for optimal shortcuts. Our proof uses some ideas in [5] but captures the property of being optimal with a much shorter argument based on some functions defined in Lemma 1 below.
Let α, β ∈ V (N ) ∪ E(N ), and let e = uv and e = u v be two edges of N . When α is an edge, we use ecc(u, α) to indicate the maximum distance from u to the points on α (analogous for β and the remaining endpoints of e and e ); if α is a vertex, ecc(u, α) = d(u, α). In general, ecc(α, β) = max t∈α,z∈β d(t, z). Lemma 1. Let y = ax + b be a line intersecting edges e = uv and e = u v on points p and q, respectively, and let α, β ∈ V (N ) ∪ E(N ). For each pair (w, z) with w ∈ {u, v} and z ∈ {u , v }, function f w,z α,β (a, b) = ecc(w, α) + |wp| + |pq| + |qz| + ecc(z, β) is linear in b.
Proof. The only term in the expression of f w,z α,β (a, b) that is not linear is |pq| (the values ecc(w, α) and ecc(z, β) are fixed, and |wp| and |qz| are linear). Thus, it suffices to prove that there is a linear change when line y = ax + b is moved parallel to itself (changing slightly b), which is a straightforward consequence of the Side Splitter Theorem.
The following theorem is the optimality version of Theorem 8 in [5]. Theorem 1. It is possible to determine in polynomial time whether a network N admits an optimal shortcut, and compute one in case of existence.
Proof. As explained in [5,Proposition 7], the search space can be split into a polynomial number of regions; we include a description here for the sake of completeness.
Two lines are equivalent if the half-planes to the right (resp., to the left) that they define contain the same vertices of N . There are O(n 2 ) classes of equivalent lines as one can associate four lines to every pair of vertices u, v, say, lines m u + v + and m u − v − parallel to segment uv and leaving u and v in the same half-plane, and lines m u + v − , m u − v + leaving u, v in different half-planes. These lines must be placed sufficiently close to u and v as Figure 2(a) shows. Thus, every class of equivalent lines has a representative in the set Given a line m that crosses two fixed edges e, e ∈ E(N ), let P e,e (m) be the set of lines equivalent to m. This set can be seen as the set of segments determined by the corresponding intersections of the lines in P e,e (m) with edges e and e ; thus, the region of the plane that P e,e (m) defines has the shape of an hourglass [8, Section 3.1], see Figure 2(b). By the argument above, there are O(n 2 ) regions P e,e (m) per each pair of edges e, e ∈ E(N ), which gives a total of O(n 4 ) regions.
Consider a line r ≡ y = ax+b in a region P e,e (m) and the set I = {e = e 0 , e 1 , . . . , e k , e k+1 = e } of edges that it intersects in between e and e ; let when using a path that passes through vertices w, z and contains segment p i p j .
Geometrically, functions f w,z α,β (a, b) can be viewed as lines in the (b, f w,z α,β (a, b))-plane. By Lemma 1, they are linear in b and so, in order to compute them in an hourglass-shaped region P e,e (m), it suffices to obtain their evaluation only in those values of (a, b) corresponding to the lines that form the boundary of the region, which is defined by O(n) vertices. Note that for fixed α, β, w, z, all functions f w,z α,β (a, b) have an important part in common, as illustrated in Figure 3. Thus, the common values of the distances from α to z and from w to β only need to be computed once, which can be done in quadratic time. Each function will be different only in the portion of the path from w to z that depends on the segment defined by (a, b), and this distance can be computed in constant time. This results in O(n 6 ) running time for computing the O(n 4 ) functions f w,z α,β (a, b) in a region P e,e (m). An optimal shortcut for N in P e,e (m) is given by the minimum of the upper envelope of the set of lines f w,z α,β (a, b). Note that shortcuts must satisfy that ecc(t) < diam(N ) for every t ∈ s, since, by definition, any shortcut improves the diameter of N , and so all segments Applying the same argument to the O(n 4 ) regions P e,e (m), the result follows.
The importance of the preceding approach relies in the fact that the problem is polynomial. However, its running time is very high as it involves O(n 4 ) functions f w,z α,β (a, b) that must be computed, and this has to be done for each of the O(n 4 ) regions P e,e (m). Moreover, each evaluation of f w,z α,β (a, b) takes O(n 2 ) time. All in all, its running time amounts to O(n 10 ).

Discretizing the set of possible shortcuts: approximation
In light of the high running time of the previous approach, it becomes interesting to look for faster approximation algorithms. Moreover, given the continuous nature of the problem, it is natural to wonder to what extent the problem can be discretized. In other words, how good can shortcuts be if we restrict them to some discrete collection of segments? The most natural choice for such a collection is probably the segments defined by pairs of vertices of N , but this choice can lead to poor results, as the example in Figure 4(a) shows. In some cases, one can do better by considering the maximal extensions of such segments: the maximal extension of a segment s is the longest segment containing s that has both endpoints on edges of N . Yang [22] showed that for paths, it is enough to consider only maximal extensions, a fact that allowed him to obtain an additive approximation for this class of graphs. Unfortunately, as Figure 4(b) illustrates, maximal extensions do not work anymore as soon as N is a tree: an extension of a segment can lead to a worse diameter than the segment itself. However, in  Figure 4: (a) The optimal shortcut is the dashed purple segment. The blue segment (and any other segment between two vertices) gives a larger diameter. (b) the original diameter is given by the orange path. The best shortcut connecting two vertices is bc. Contrary to intuition, extending bc to bd worsens the diameter, which becomes given by points a and e (pink path).
this section, we show that if one considers all extensions of segments defined by two vertices of N , then it is possible to guarantee an approximation factor for general networks. Let S be the infinite set of segments with endpoints in N , and let S 2 ⊂ S be the subset of segments of S that contain two vertices of N . The following proposition states that set S 2 is an approximation of S. Proposition 1. Let ρ be the largest edge length in N . Then, Proof. The first inequality is straightforward. For the second, it suffices to prove that given Segment s may cross several faces of N , refer to Figure 5(a). Consider the first and the last ones, say F 1 and F 2 , together with the vertices of N that are adjacent to p and q in those faces: u, v in F 1 and u , v in F 2 . Let V 1 be the vertices of N in the quadrilateral upqu (including u and u ), and let C 1 be its convex hull. Analogously, we have V 2 and C 2 for the quadrilateral vpqv . Note that both convex hulls may have one point in common. Extend one of the common internal tangents of C 1 and C 2 giving rise to a segment s with endpoints on two of the edges of F 1 and F 2 containing points p and q.
Observe that s intersects all the edges of N that are crossed by s. This construction allows us to show that, for any two points a, b ∈ N , the length of the shortest path between a and b that uses s is at most 4ρ plus the corresponding length but using s. To do this, we first use the triangle inequality to compare the lengths of the used portions of segments s and s , which gives a difference of 2ρ, and then we add the two distances indicated in Figure 5 A similar argument is used for a ∈ s and b ∈ N .
The collection S 2 is finite but quite large, it has size O(n 4 ), which gives a time complexity of O(n 6 ) to compute the optimal among the segments in S 2 . Indeed, there are O(n 2 ) possible extensions per each pair of vertices, and for each of them one needs to compute the diameter from scratch in O(n 2 ) time [18].
We would like to find a small subset of S 2 that preserves the property in Proposition 1. Ideally, we would like to consider not all the extensions of a segment with endpoints in V (N ) (that is exactly S 2 ), but only the best extension for each segment. Unfortunately, this appears rather difficult, as extensions of a segment do not seem to behave monotonically: already for a tree with a single vertex of degree larger than two, it may happen that an extension of a segment gives a worse diameter than the segment itself, see Figure 4(b). However, we show next that we can speed-up the computation of the diameter for each extension in S 2 , saving a nearly-linear factor in the total running time.
Given a segment s = p q , let r be the ray starting at p and containing s , and let P = p 0 , p 1 , . . . , p k be the sorted list of intersection points of r with edges of N . Segments s i = p p i are called extensions of s to the right; the extensions to the left are defined similarly. Next we show how to speed-up the re-computation of the diameter of N ∪ s i as we insert s 0 , s 1 , . . . s k , in that order. To that end, we split the re-computation of distances into two parts: distances from points on s i to points on N , and distances (in N ∪ s i ) between two points on N .   Figure 6: (a) Function Φ st uv . (b) If the distance from p 1 to st decreases when adding s 0 = uv, then, after adding s 1 = up 1 , it will become even smaller.
Proof. As a preprocessing step, we store the distances from each vertex to all the other edges and the point at each edge attaining that maximum distance. This allows us to construct the functions Φ st uv : [0, 1] → R + that encode the information of the maximum distance from each point on an edge uv to an edge st (see [18]). Their shape is as follows (see Figure 6(a)).
Let u and v be the farthest points to, respectively, u and v in edge st. Function Φ st uv increases uniformly from 0 and from 1 until the distance between both lines equals the distance between u and v , at that moment it stabilizes horizontally. Therefore, knowing the farthest points u and v to u and v in the segment st (and the distance between them), it is possible to build Φ st uv in constant time. The main idea of the proof is that it is also possible to update each map Φ st uv for each extension of a segment in constant time. Observe that Φ st uv encloses the information of the largest distance from any point of uv to the segment st.
In a first step, we consider the addition of the segment s 0 = uv. As u and v are on the network N , they belong to some edges g and g , and we use the information of Φ st g and Φ st g to find the largest distance from u and v to st (in the network N ). With that information, we compute Φ st uv in constant time. Thus, the maximum eccentricity of the edge s 0 = uv can be computed in linear time.
Note that, by building the map Φ st uv , it is possible to detect whether vertex v changes its eccentricity with respect to st. Thus, we update the values of the distances from vp 0 to all the other edges, and the point on each edge giving that maximum distance (again, in linear time).
The addition of s 0 may change the eccentricity of p 1 with respect to some other edge (and the same with any of the other p i 's), but we do not need to update that information at this moment. Indeed, if the distance from p 1 to st changes when adding s 0 , it can only decrease. Hence, the addition of s 1 will make that distance even smaller; see Figure 6(b). Thus, in step i, we only need to update the information of the new vertex p i , since by adding s i , the value of p i+1 will be updated. Since N (i) is a decreasing function as i grows, we do not need to compute N (i) for all values of i, but only for those i for which E(i) is maximal: such that there is no j > i with E(j) < E(i) (see Figure 7). Therefore, we can look for that minimum by binary search, computing N (i) only for O(log n) values of i. Using [15], we can update the distances between vertices in quadratic time and then compute N (i) also in quadratic time (the distance between pairs edge-edge and vertex-edge can be computed in constant time knowing the distance between vertices), giving a total time of O(n 3 log n).
We thus obtain the main result in this section. This result immediately gives a simple approximation algorithm: subdivide each edge in N by adding dummy vertices such that the largest resulting edge length is ε. Then the previous theorem implies the following result, which is a generalization to general networks of the result for paths presented in [22,Theorem 8.1].
Corollary 1. Let ρ be the largest edge length in a network N . Then, for any 0 < ε < ρ/2 it is possible to find a segment s such that diam(N ∪ s ) ≤ min s∈S diam(N ∪ s) + 4ε in O((nρ/ε) 5 log(nρ)) time.

Path networks
In the remaining, we focus on networks that are paths. To illustrate the complexity of this seemingly simple setting, we begin by observing that the insertion of a shortcut into a path can create a quadratic number of diametral pairs; as illustrated in the construction in roughly its height. The spikes are spaced by one unit each, while their heights are set such that the distance from o to the top of the spike is always the same, namely |pq|/2. In this way, for any two spike tops p i and q j on the left and right of o, respectively, the distance between p i and p j on P ∪ pq is always equal to |pq|, which is also the diameter of P ∪ pq.

Diameter after inserting a shortcut
The diameter of P can be immediately computed in linear time, however, the addition of a shortcut s can create a linear number of new faces, thus in principle it is not clear whether diam(P ∪ s) can be computed in linear time, i.e., without computing the diameter between each pair of faces. The main result in this section is that this is still possible. Path networks have the nice property that the maximal extension of an optimal shortcut is also optimal [22]. Thus, we can assume that s = pq is maximal and horizontal. The insertion of s splits P into polygonal chains, which bound the different faces created. Our goal is to compute the pair of chains that have maximum distance in P ∪ s.
We number the chains from 0 to m in the order of their left endpoints from left to right along s (using right endpoints do disambiguate). Except for possibly the first and last, all chains have both endpoints on s. For the ith chain C i , we denote its left and right endpoints by p l i and p r i , respectively. If the first vertex of P is not on s, we consider the path from its first vertex to the first intersection of P with s as a degenerate loop chain with equal left and right endpoints on s (analogous for the last vertex of P ).
Refer to Figure 9. Let |C i | be the length of C i , let L i = |pp l i | and R i = |p r i q|, and let s i denote the segment p l i p r i . Note that C i ∪ s i forms a cycle. We use D i for the distance on P ∪ s from p l i to its furthest pointp l i on C i ∪ s i (i.e., D i is the semiperimeter of C i ∪ s i ); see Figure 9(b). We make some basic observations about the diameter between two chains, depending on their relative position, as shown in Figure 10. They reveal the key property of the problem: the linear ordering between chains induced by s defines uniquely how the diameter between two chains is achieved.  Observation 1 (Disjoint chains). Let C i , C j be two chains of (P ∪ s) with s i ∩ s j = ∅ and s i to the left of s j . The diameter of Chain C i is completely to the left of C j (see Figure 10(a)), thus any path from a point in C i to one in C j must include segment p r i p l j . Since the furthest point in C i from p r i isp r i , and the same for p l j andp l j , the result follows by definition of D i and D j , and by observing that |p r i p l j | = R i − R j − |s j |.
Observation 2 (Nested chains). Let C i , C j be two chains of (P ∪ s) with s j ⊂ s i . The In this case the endpoints of the chain C j are nested inside those of C i (see Figure  10(b)), hence the two chains behave effectively like a cycle, because no diametral pair can have a point on segment s j , since |C j | > |s j |. The cycle is formed by chains C i , C j , and the two subsegments of s i \ s j . The diameter of any cycle is half of its perimeter, which in this case amounts to 1 2 (|C i | + |s i | − |s j | + |C j |). The second equality follows from the fact that Observation 3 (Overlapping chains). Let C i , C j be two chains of (P ∪ s) with s i ∩ s j = ∅, Proof. As in the previous case, the two chains behave effectively like a cycle (see Figure  10(c)), in this case formed by C i , C j and the segments p l i p l j and p r i p r j . The second equality follows from the fact that |p l i p l j | = L j − L i and |p r i p r j | = R i − R j .
Note that, while in the case of Figure 10(a) the diameter is achieved by a unique pair of points, that is not the case in situations (b) and (c), for which an infinite number of diametral pairs of points may exist (as in any cycle). Also, note that expressions for the diameter in Observations 2 and 3 are the same except for adding up either R j − R i or R i − R j . This difference only exists to differentiate between the two possible orders of the right endpoints of the two chains.
The algorithm for computing diam(P ∪ s) in linear time starts by going along P and computing all intersections with s in the order of P . Then we apply a linear-time algorithm for Jordan sorting [16] to obtain the intersections in the order along s, say, from left to right. Within the same running time we can compute the values C k and s k . Next, we sweep the endpoints of the chains along s to compute, for each chain C k , its furthest chain from the ones seen so far. To that end, certain information is computed and stored: 1. The furthest chain from C k to the left, given by arg max 0≤i<k α i , where Similarly, we store the furthest chain to the right.
2. The furthest chain nested inside C k . This is given by arg max j∈N k β j , where β j = |C j | + L j + R j and N k is the set of indices of all chains nested inside C k .
3. The furthest chain with one endpoint in C k , and one outside: given by arg max j∈O r k γ j , where γ j = |C j | + L j − R j and O r k is the set of indices of all overlapping chains with their left endpoint inside C k and their right endpoint outside. Similarly, we store those with their left endpoints outside and the right one inside of s k .
The computation of the information in (1) is straightforward when sweeping along s, say, from left to right. We just maintain the largest value of α i seen so far as we sweep. The case of nested or overlapping chains, which is explained next, is more complicated because one needs the maximum restricted to those chains that are contained or overlap with C k .
Suppose that C i starts to the left of C j (the other case is analogous). We use a data structure for range minimum queries [2,3]. This allows to preprocess an array A in linear time in order to find the maximum value in any subarray A[a, b] in O(1) time. In our context, we need two such data structures. We use arrays A n and A o to store the maximum β and γ values defined above for the chains that are nested and overlapping, respectively. Each array has one position for each endpoint of a chain, thus 2m in total. The positions are as they appear sorted along s, from left to right. Refer to Figure 11.
For a chain C j , the position corresponding to its left endpoint has a value equal to β j in the array A n , and value γ j in array A o . The values corresponding to the right endpoints of the chains are not used, i.e., they have value −∞, in both arrays. At each array position, we also store pointers to the corresponding chains.
To find the nested or overlapping chain furthest from C i we would like to perform one maximum range query in A n and one in A o , in both cases with a subarray corresponding to the interval between the endpoints of C i . The goal is to use these queries to obtain the furthest chain of each type: nested and overlapping. However, there is an issue. In the way A n and A o are defined, the result of a range query cannot distinguish between nested Figure 11: Example of arrays with distances to chains that are nested (A n ) and overlapping (A o ).
or overlapping chains, it necessarily searches in both sets (i.e., N i ∪ O r i ). Fortunately, the geometry of the problem guarantees that we can still use the result obtained, as we show next. The following lemma shows that if the furthest face is associated to a β i value, then it must be nested, and similarly, if it is associated to a γ i value, it must be overlapping.

Lemma 4.
Let C k be a chain with distance to C i equal to Then it holds that: Proof. We prove (i); an analogous argument proves (ii). Suppose that d * = |C i |−L i −R i +β k , but k ∈ O r i , i.e., C k is overlapping. Further, to the right of C i we have R i > R k and thus R k − R i < 0 < R i − R k . Hence, using this and the definitions of d * and β k , we have In other words, the value associated to γ k gives a larger distance than the one associated to β k , contradicting the optimality of d * .
Therefore, when processing a chain C k , we perform one maximum range query in A n and one in A o , and keep the maximum of those two values. Lemma 4 guarantees that the associated chain is the furthest one that is either nested or overlapping. Proceeding in an analogous way for the chains that are overlapping with one endpoint to the left of C k , the furthest face from C k of any of the three types (disjoint, nested, overlapping) can be found in O(1) time, and the maximum distance between two chains can thus be found in linear time.
Theorem 3. For every path P with n vertices and a shortcut s, it is possible to compute the diameter of (P ∪ s) in Θ(n) time.
It is worth noting that the ideas used in this section do not extend to networks that are trees. As soon as N is a tree, the insertion of s creates chains that can have several ways to connect in N ∪ s, making it impossible to know, a priori, the expression of their distance as we did for paths in Observations 1-3.

Optimal horizontal shortcuts
The observations in Section 3.1 also give us a way to compute an optimal horizontal shortcut for a path considerably faster than using the general method in Section 2. After a suitable rotation, this allows to find an optimal shortcut of any fixed orientation.
Assume as in Section 3.1 that shortcuts are horizontal and maximal, so they can be treated as horizontal lines. Now, consider the vertices in P sorted increasingly by y-coordinate, and let y a , y b , with y a < y b , be the y-coordinates of two consecutive vertices in that order. Observations 1-3 are stated in terms of chains, but they also apply to faces. Indeed, they imply that the distance between any two faces f i and f j is a linear function d ij (y) for y a ≤ y ≤ y b . Thus, each face is associated with k − 1 lines in 2D where k is the total number of faces, leading to a set L of Θ(k 2 ) lines (note that k = O(n)).
The optimal shortcut over all y ∈ [y a , y b ] is given by the minimum of the upper envelope of L, which can be computed in O(k 2 log k) time [10]. If this is done with each of the n − 1 horizontal strips formed by consecutive vertices of N , the optimal horizontal shortcut is obtained in total O(n 3 log n) time.
The preceding method can be improved if, instead of computing from scratch the upper envelope of L at each horizontal strip, we maintain the upper envelope between consecutive strips and only add or remove the lines that change when going from one strip to the next one. The changes between two consecutive strips are of three types: (i) one of the two line segments bounding a face within the strip changes; (ii) a face ends; (iii) a new face appears.
In the worst case, n − 1 lines are removed from L and another n − 1 lines are added to L.
Maintaining the upper envelope of N lines is equivalent to maintaining the convex hull of N points in 2D, which can be done in amortized O(log N ) time per insert/delete operation with a data structure of size O(N ) [4]. Since N = O(n 2 ), we obtain the following theorem.
Theorem 4. For every path P with n vertices, it is possible to find an optimal horizontal shortcut in O(n 2 log n) time, using O(n 2 ) space.

Optimal simple shortcuts
In this section we consider optimal simple shortcuts, i.e., we restrict the possible shortcuts to those whose interior does not intersect N . We show that an optimal simple shortcut can be computed much faster if it exists. Note that one must distinguish between an optimal simple shortcut and a simple optimal shortcut. The first is a shortcut that is optimal in the set of simple shortcuts; this is different of being optimal in the set of all shortcuts and, in addition, being simple.
Interestingly, it is known that optimal simple shortcuts may not exist, even for paths [23] (e.g., when the only optimal shortcut goes through a vertex, see Figure 12(a)). It is not clear, however, what the conditions for a network N to have an optimal shortcut are, even restricted to simple shortcuts. The following proposition is a first approach to this question.  Figure 12: (a) A network with no optimal simple shortcut: segment pq can be approached as much as desired with simple shortcuts. (b) N admits an optimal simple shortcut and N has non-convex faces.

Proposition 2.
Let N be a network whose locus N admits a simple shortcut, and let N be the network resulting from adding to N all edges of the convex hull of V (N ). If all faces of N are convex, then N has an optimal simple shortcut.
Proof. Suppose on the contrary that there is no optimal simple shortcut for N . Then, there is a sequence {s n } of simple shortcuts such that d n+1 < d n where d n = diam(N ∪ s n ). Let s n = p n q n . We may assume, without loss of generality, that {s n } is contained in a face F of N as there is a finite number of faces, at least one of which contains a subsequence of {s n }.
The same argument on the number of edges of a face lets us assume that for every n, points p n and q n are, respectively, on edge e and edge e of N . Since e is a compact set, sequence {p n } has a convergent subsequence {p n }. The corresponding sequence {q n } is not necessarily convergent, but edge e is also a compact set which implies that {q n } contains a convergent subsequence {q m }. Let {s m } = {p m q m }, lim p m = p, lim q m = q, and s = pq; we will write, with some abuse of notation, lim s m = s . Next, we prove that d s = diam(N ∪ s) < d n for every n.
Fixed n, consider two segments s m 0 , s m 1 ⊂ {s m } with n < m 0 < m 1 , and take ε > 0 such that d m 0 − d m 1 > ε; such segments do exist as lim s m = s. Let R be the set of points in face F whose distance to p or q is smaller than ε/8. Any segment s m with endpoints p ∈ e ∩ R and q ∈ e ∩ R verifies that |d s − d m | < ε/2. Indeed, Since lim s m = s, there exists m 2 such that s m ∈ R for all m ≥ m 2 . Let m 3 = max{m 1 , m 2 }.
Thus, for every sequence {s n } of simple shortcuts such that d n+1 < d n there is a shortcut s satisfying that d s < d n for all n. Further, s is simple (all faces of N are convex) and there is no optimal simple shortcut. This implies that s must be an edge of N which contradicts the fact that, by definition, edges are not shortcuts. Note that there can be sequences for which the corresponding segment s is an edge of CH(V (N ) \ E(N ) (here CH(V (N ) denotes the convex hull of V (N )), but there is a finite number of such edges and so one would obtain an optimal simple shortcut among all those segments s.  Figure 13: Inserting a simple shortcut pq. Figure 12(b) shows that the converse of Proposition 2 is not true. We now turn our attention to the computation of an optimal simple shortcut, if it exists. Let s = pq be a simple shortcut for a path P with endpoints u, v. Suppose that point p is closer to u than q along P ; let x = d(u, p) and y = d(v, q). There is only one bounded face in P ∪ s whose boundary is a cycle C(p, q). Let p and q be the farthest points from, respectively, p and q on C(p, q), and let z = (d P (p, q) − |pq|)/2. Note that d(p, q) = |pq| and z = d(p, q) = d(p, q). See Figure 13.
There are three candidates for diametral path in P ∪ s (see [6]): 1. The path from u to v via s is diametral if and only if z = min{x, y, z}, 2. the path from u to p via s is diametral if and only if y = min{x, y, z}, 3. the path from v to q via s is diametral if and only if x = min{x, y, z}.
Thus, diam(P ∪ s) ∈ {x + y + |pq|, x + z + |pq|, y + z + |pq|}. For the highway model, it was proved in [6] that P has an optimal shortcut satisfying x = y, which allows to compute it in linear time. In the planar model the situation is more complicated but, in a similar fashion, we can prove the following lemma, which will lead to Theorem 5.
Lemma 5. Let pq be an optimal simple shortcut for P . The following statements hold.
1. If neither p nor q are vertices of P then x = y = z.
2. If p or q are vertices of P then the two smallest values among x, y, z are equal.
Proof. First note that increasing (resp., decreasing) the value of either x or y leads to a decrease (increase) in the value of z.
Suppose that neither p nor q are vertices of P and assume on the contrary that x is smaller (respectively, greater) than y and z. Then point p can be slightly moved away from u (respectively, q away from v) in order to obtain a shortcut s such that diam(P ∪ s ) < diam(P ∪ pq). Thus, shortcut pq would not be optimal, which is a contradiction. The same argument applies for y. Finally, if the smallest value is z then we can slightly move p closer to u and q closer to v while decreasing the diameter of the augmented network, again a contradiction.
Suppose now that p is a vertex of P , i.e., q is the only possible point to be moved in order to argue as above and reach a contradiction. If x < y < z we can decrease y by moving point q closer to v obtaining a "better" shortcut, a contradiction. If x < z < y it suffices to increase y in order to decrease z to reach a contradiction. The remaining cases are analogous.
Theorem 5. It is possible to decide whether a path P with n vertices has an optimal simple shortcut and compute one (in case of existence) in O(n 2 ) time.
Proof. We first determine all candidate segments pq for an optimal simple shortcut and also other relevant segments to decide the existence of such a shortcut. Two cases are distinguished depending on whether p and q are vertices. Case 1. p, q / ∈ V (P ): we add O(n) extra vertices on each half of P , such that the i-th edges from each endpoint have the same length. Let P 1 and P 2 be the two resulting sub-paths where every edge e 1 ∈ P 1 has an associated edge e 2 ∈ P 2 of the same length, and vice-versa.
This partition of P allows us to compute the points p ∈ e 1 ∈ P 1 and q ∈ e 2 ∈ P 2 where x = y (and |e 1 | = |e 2 |). Among these points and according to Lemma 5, we want those satisfying that z = x (= y). Now, assume we have p ∈ e 1 and q ∈ e 2 such that x = y = z. Consider advancing a distance λ along e 1 and e 2 , from p and q to p and q . Since d P (p, q) = |P | − 2x and z = (d P (p, q) − |pq|)/2, we only need to compute the variation of |pq| with respect to the variation λ of x (and y). Figure 14(a) shows the construction where α denotes the angle formed by the prolongations of e 1 and e 2 , and a and b are, respectively, the distances from p and q to the intersection point of those prolongations. By the law of cosines we have Note that the variation of x might be in the direction of the intersection point o of the prolongations of e 1 and e 2 or in the opposite direction and, in general, it does not lead to a parallel segment to pq (see Figure 14(b)); in fact, segments pq and p q are parallel only if the triangle formed by p, q, and the intersection point o is isosceles.
Therefore, by solving O(n) quadratic equations, we obtain O(n) candidate segments pq with p, q / ∈ V (P ). Case 2. p or q are vertices of P : according to Lemma 5 our candidate segments must satisfy that the two smallest values among x, y, z are equal. Clearly, there are O(n 2 ) segments to consider with both endpoints being vertices; it remains to obtain those candidate segments with exactly one endpoint in V (P ).
For each vertex of P 1 (i.e., x is a fixed value), we have computed in case (1) the O(n) candidate segments verifying that x = y and so we must determine those for which x = z (analogous for each vertex in P 2 and y = z). This can be done as in case (1) where λ is now the variation of y since x is fixed; the formula is Note that p is a fixed vertex of P 1 and the corresponding q and q are points on an edge of P 2 . Thus, there is a total of O(n 2 ) candidate segments.
Besides the segments obtained in cases (1) and (2), we must consider other segments that are pivoting on a vertex w of P (see Figure 15) and such that the two smallest values among x, y, z are equal. Note that in the preceding cases we have not computed those whose endpoints are not vertices and z = x = y or z = y = x. This can be done applying twice the argument of case (2): to the left and to the right of the line shown in Figure 15 passing through vertex w. The desired value z is the sum of the two obtained values. w Figure 15: Shortcut that is pivoting on vertex w.
Finally, we classify all our segments, O(n 2 ) in total, into three sets: S of simple shortcuts, L of limit cases (the segment intersects P on three points), and shortcuts that intersect P on more than three points. There exists an optimal simple shortcut if and only if the minimum value of diam(P ∪ pq) over pq ∈ S ∪ L is attained by a segment in S.

Conclusions
In this paper we have presented the first results on the computation of optimal shortcuts for general networks in the planar model. This can be seen as a particular variant of the road network design problem, where the problem is abstracted to its most fundamental geometric version. Clearly, even in this restricted setting, the problem continues to be difficult and challenging. We have shown that an optimal shortcut can be computed in polynomial time, and given a discretization of the problem that results in an approximation of the original continuous version. Even though the discretization obtained is too large to be of practical use, it is interesting from a theoretical point of view, and hopefully will be useful to obtain smaller discretizations in the future.
We have also presented new results for paths, including how to quickly compute the diameter after inserting a shortcut, the computation of an optimal shortcut of fixed orientation, and of an optimal simple shortcut. These are important first steps on a relevant and difficult problem, which leave many intriguing questions open. The existence of a small discrete set of segments to approximate an optimal shortcut, or a fast algorithm to find an optimal shortcut for paths (any orientation), are some examples.
Finally, the questions studied in this paper but for optimal sets of k > 1 shortcuts pose challenging open problems.