Multi-Terminal Shortest Paths in Unit-Weight Planar Graphs in Linear Time
aa r X i v : . [ c s . D S ] F e b Multi-Terminal Shortest Paths in Unit-Weight Planar Graphsin Linear Time
Lorenzo Balzotti ∗ Paolo G. Franciosa † Abstract
Given a set of terminal pairs on the external face of a planar graph with unit edge weights,we give a linear-time algorithm to compute a set of non-crossing shortest paths joining eachterminal pair, if it exists.
Keywords: planar graphs, multi-terminal shortest paths, unit-weight graphs
The problem of computing shortest paths in planar graphs arises in application fields such as intel-ligent transportation system (ITS), geographic information system (GIS), route planning, logistic,traffic simulations and robotics. In particular “non-crossing” paths in a planar graph are studiedto optimize VLSI layout, where two paths non-crossing can share edges and vertices but they donot cross each other in the plane.We are given a planar graph G = ( V, E ), where V is a set of n vertices and E is a set ofedges, with | E | = O ( n ). The graph has a fixed embedding, and we are also given a set of k terminal pairs ( s , t ) , ( s , t ) , . . . , ( s k , t k ) lying on the external face of G . The multi-terminal non-crossing shortest paths problem consists in finding k non-crossing shortest paths in G , each joininga terminal pair ( s i , t i ), provided that such non-crossing paths exist.In this paper, we solve the multi-terminal non-crossing shortest paths problem on unit-weightplanar graphs in O ( n ) worst-case time. We improve, in the unit-weight case, the result of Takahashi et al. [23], that solves the same problem in a non-negative edge-weighted planar graph in O ( n log k )(actually, in their paper the worst-case time is O ( n log n ), that can easily reduced to O ( n log k )by applying the planar single source shortest path tree algorithm by Henzinger et al. [14]). Theirresult is improved by Steiger in O ( n log log k ) [22], exploiting the algorithm by Italiano et al. [15].These two algorithms maintain the same time complexity also in the unit-weight case.Our algorithm relies on two main results: • an algorithm due to Eisenstat and Klein [7], that gives in O ( n ) worst-case time an implicitrepresentation of a sequence of shortest-path trees in a unit-weight undirected planar graph G ,where each tree is rooted in a vertex of the external face of G , • the concept of incremental shortest paths (ISP) subgraph of a graph G , introduced in Section 3,that is a subgraph incrementally built by adding a sequence of shortest paths in G starting fromthe infinite face of G . We show that an ISP subgraph of G partitions the embedding of G in regionssuch that for any two vertices a, b in G lying in the same region R there is always a shortest pathin G joining a and b contained in R . ∗ Dipartimento di Scienze di Base e Applicate per l’Ingegneria, Sapienza Universit`a di Roma, Via Antonio Scarpa,16, 00161 Roma, Italy. [email protected] . † Dipartimento di Scienze Statistiche, Sapienza Universit`a di Roma, p.le Aldo Moro 5, 00185 Roma, Italy. [email protected] kn ) worst-case time; this happens when all k shortestpaths share a subpath of Θ( n ) edges. Related work
Our article fits into a wider context of computing many distances in planargraphs. In the positive weighted case, the all pairs shortest paths (APSP) problem is solved byFrederickson in O ( n ) [10], while the single source shortest paths (SSSP) problem is solved inlinear time by Henzinger et al. [14]. The best known algorithm for computing many distances inplanar graphs is due to Gawrychowski et al. [11] and it allows us to compute the distance betweentwo vertices in O (log n ) time after a preprocessing requiring O ( n / ) time. Other results on manydistances problem can be found in [4, 5, 6, 9, 19, 20].If we are interested in distances from any vertex in the external face to any other vertex, thenwe can use Klein’s algorithm [16] that, with a preprocessing of O ( n log n ), answers to each distancequery in O (log n ) time.Kowalik and Kurowski [17] deal with the problem of deciding whether any two query verticesof a unit-weight planar graph are closer than a fixed constant k . After a preprocessing of O ( n )time, their algorithm answers in O (1), and, if so, a shortest path between them is returned.Multiple pairs shortest paths are also used to compute max-flow in planar undirected graphs[12, 13, 21]. In particular, they are used to compute the vitality of edges and vertices with respectto the max-flow [1, 2].Balzotti and Franciosa [3] show that, given the union of a set of shortest non-crossing paths ina planar graph, the lengths of each shortest path can be computed in linear time. This improvesthe result of [23], that can only be applied when the union of the shortest paths is a forest. Improved results
As we have said, we specialize the problem of finding k shortest non-crossingpath in [23] to the unit-weight case, decreasing the worst-case time complexity from O ( n log k ) to O ( n ) (for every k ). Therefore, we improve the results in [8, 18, 24] under the hypothesis that theinput graph is unit-weight.Erickson and Nayyeri [8] generalized the work in [23] to the case in which the k terminal pairslie on h face boundaries. They prove that k non-crossing paths, if they exists, can be found in2 O ( h ) n log k time. Applying our results, if the graph is unit-weight, then the time complexitydecreases to 2 O ( h ) n .The same authors of [23] used their algorithm to compute k non-crossing rectilinear pathswith minimum total length in a plane with r obstacles [24]. They found such paths in O ( n log n )worst-case time, where n = r + k , that reduces to O ( n ) if the graph is unit-weight by using ourresults.Kusakari et al. [18] showed that a set of non-crossing forests in a planar graph can be foundin O ( n log n ), where two forest F and F are non-crossing if for any pair of paths p ⊆ F and p ⊆ F , p and p are non-crossing. With our results, if the graph is unit-weight, then the timecomplexity becomes linear. Structure of the paper
After giving some definitions in Section 2, in Section 3 we explain themain theoretical novelty and in Section 4 we resume Eisenstat and Klein’s algorithm. In Section5 we show our algorithm and in Section 6 we prove its computational complexity. Conclusions aregiven in Section 7.
Let G be a plane graph, i.e., a planar graph with a fixed planar embedding. We denote by f ∞ G (orsimply f ∞ ) its external face. 2e use standard union and intersection operators on graphs, but for convenience we define theempty graph as a graph without edges. Definition 1
Given two undirected (or directed) graphs G = ( V ( G ) , E ( G )) and H = ( V ( H ) , E ( H )) ,we define the following operations and relations: • G ∪ H = ( V ( G ) ∪ V ( H ) , E ( G ) ∪ E ( H )) , • G ∩ H = ( V ( G ) ∩ V ( H ) , E ( G ) ∩ E ( H )) , • G ⊆ H ⇐⇒ V ( G ) ⊆ V ( H ) and E ( G ) ⊆ E ( H ) , • G \ H = ( V ( G ) , E ( G ) \ E ( H )) , • G = ∅ ⇐⇒ E ( G ) = ∅ ( V ( G ) can be nonempty). Given an undirected (directed) graph G = ( V ( G ) , E ( G )), given an edge (dart) e and a vertex v wewrite, for shortly, e ∈ G in place of e ∈ E ( G ) and v ∈ G in place of v ∈ V ( G ).We denote by uv the edge whose endpoints are u and v and we denote by −→ uv the dart from u to v . For every dart −→ uv we define rev[ −→ uv ] = −→ vu and head[ −→ uv ] = v . For every vertex v ∈ V ( G ) wedefine the degree of v as deg ( v ) = |{ e ∈ E ( G ) | v is an endpoint of e }| .For each ℓ ∈ N we denote by [ ℓ ] the set { , . . . , ℓ } .Let R be a subgraph of G , we denote by ∂R the external face of R . Given a (possibly notsimple) cycle C , we define the region bounded by C , denoted by R C , as the maximal subgraph of G whose external face has C as boundary. Given a directed path p we denote by p its undirected version, in which each dart −→ ab is replacedby edge ab ; moreover, we denote by rev[ p ] its reverse version, in which each dart −→ ab is replaced bydart −→ ba .We say that a path p is an a - b path if its extremal vertices are a and b ; clearly, if p is a directedpath, then p starts in a and it ends in b . Moreover, given i ∈ [ k ], we denote by i -path an s i - t i path.Given an a - b path p and a b - c path q , we define p ◦ q as the (possibly not simple) a - c pathobtained by the union of p and q .Let p be a simple path and let a, b ∈ V ( p ). We denote by p [ a, b ] the subpath of p with extremalvertices a and b .We denote by | p | the length, i.e., the number of edges, of a path p .We say that two paths in a plane graph G are non-crossing if the curves they describe in thegraph embedding do not cross each other; a formal definition can be found in [7]. This propertyobviously depends on the embedding of the graph. Non-crossing paths may share vertices and/oredges or darts. W.l.o.g., we assume that the terminal pairs are distinct, i.e., there is no pair i, j ∈ [ k ] such that { s i , t i } = { s j , t j } . Let γ i be the path in f ∞ G that goes clockwise from s i to t i , for i ∈ [ k ]. Byhypothesis, we assume that pairs { ( s i , t i ) } i ∈ [ k ] are well-formed , i.e., for all j, ℓ ∈ [ k ] either γ j ⊂ γ ℓ or γ j ⊃ γ ℓ or γ j ∩ γ ℓ = ∅ . This property can be easily verified in linear time.We define here a partial ordering as in [3, 23] that represents the inclusion relation between γ i ’s. This relation intuitively corresponds to an adjacency relation between non-crossing shortestpaths joining each pair.Choose an arbitrary i ∗ such that there are neither s j nor t j , with j = i ∗ , walking on f ∞ from s i ∗ to t i ∗ (either clockwise or counterclockwise), and let e ∗ be an arbitrary edge on that walk. Foreach j ∈ [ k ], we can assume that e ∗ γ j , indeed if it is not true, then it suffices to switch s j with3 j . We say that i ≺ j if γ i ⊂ γ j . We define the genealogy tree T G of a set of well formed terminalpairs as the transitive reduction of poset ([ k ] , ≺ ). W.l.o.g., we assume that i ∗ = 1, hence the rootof T G is 1.If i ≺ j , then we say that i is a descendant of j and j is an ancestor of i . Moreover, we saythat j is the parent of i , and we write p ( i ) = j , if i ≺ j and there is no r such that i ≺ r and r ≺ j .Figure 1 shows an example of well-formed terminal pairs, and the corresponding genealogy treefor i ∗ = 1. From now on, in all figures we draw f ∞ G by a solid light grey line. s t s t s t s t s t s t s t e ∗ i ∗ = 1, then we obtainthe genealogy tree on the right. In this section we introduce the concept of incremental shortest paths (ISP) subgraph of a graph G , that is a subgraph incrementally built by adding a sequence of shortest paths in G startingfrom f ∞ G (see Definition 2). The interest towards ISP subgraphs is due to the fact that for any twovertices a, b in G lying in a same face R of the ISP subgraph there is always a shortest path in G joining a and b contained in R (boundary included).This is the main novel result of this paper, that allows us to prove that, in order to build theunion of shortest paths joining terminal pairs, we can start from the union of some of the shortestpaths computed by algorithm in [7].All the results of this section hold for positive edge weighted graphs, where the length of a pathis the sum of edge weights instead of the number of edges. Definition 2
A subgraph X of G is an incremental shortest paths (ISP) of G if X = X r , where { X i } i ∈ [ r ] is a succession of subgraphs of G built in the following way: X = f ∞ G and X i = X i − ∪ p i ,where p i is a shortest x i - y i path in G with x i , y i ∈ X i − . Remark 1
All degree one vertices of an ISP subgraph of G are in f ∞ G . We define now operator ↓ , that given a path π and a cycle C , in case π intersects C , replacesa subpath of π by a portion of C , as depicted in Figure 2.(b). Definition 3
Let C be a cycle in G . Let a, b be two vertices in R C and let π be a simple a - b path.In case π and C have no common vertices we define π ↓ C = π . Otherwise, let x and y be the firstand last vertex in V ( π ∩ C ) walking from a to b in π , respectively. Let γ be the x - y path on C suchthat the region bounded by γ ◦ π [ x, y ] does not contain R C . We define π ↓ C = π [ a, x ] ◦ γ ◦ π [ y, b ] . Figure 2 shows examples of Definition 2 and Definition 3.In the following proposition we show that if X is an ISP subgraph of G and given any face f of X , then every path π in G whose extremal vertices are in R ∂f is not shorter than π ↓ ∂f . Theorem 1
Let X be an ISP subgraph of G . Let f be a face of X , and let a, b be two distinctvertices in R ∂f . For any a - b path π we have | π ↓ ∂f | ≤ | π | . y x y x y x y x y (a) fπ π ↓ f (b) Figure 2: (a) shows an ISP subgraph X of G ; extremal vertices of p , p , p , p , p are drawn.Different faces of X have different color. In (b) there is an example of Definition 3. Proof.
Let { X i } i ∈ [ r ] be the succession of ISP subgraphs such that X = X r , and let p i be thepath that builds X i from X i − . W.l.o.g, we assume that p i has no vertices in X i − other than itsendpoints x i and y i , otherwise we can split p i on intersections with X i − and repeatedly apply thesame proof to each portion of p i . We prove the thesis by induction on j for every choice of a face f of X j , a, b ∈ R ∂f and a - b path π .In the base case, where j = 1, there are exactly two faces A and B in X . Let a, b ∈ V ( R ∂A )(the same argument holds for B ) and let π be any a - b path. In case π ⊆ R ∂A we have π ↓ ∂A = π ,hence the thesis trivially holds. In case π R ∂A , then π ↓ ∂A is not longer than π because asubpath of π has been replaced by a portion of p , that is a shortest path.We assume that the thesis holds for all i < j and we prove it for j . Let f be a face of X j andlet f ′ be the unique face of X j − such that f ⊂ f ′ . Let a, b ∈ V ( R ∂f ) and let π be an a - b path.Three cases may occur: • case π ⊆ R ∂f : the thesis trivial holds, since π ↓ ∂f = π ; • case π ⊆ R ∂f ′ and π R ∂f : since π ⊆ R ∂f ′ and π R ∂f , then π crosses p j an even numberof times, thus π ↓ ∂f is not longer than π , since a subpath of π has been replaced by a portion of p j , that is a shortest path; • case π R ∂f ′ : since f ⊂ f ′ , it is easy to see that π ↓ ∂f = ( π ↓ ∂f ′ ) ↓ ∂f . Let us consider π ′ = π ↓ ∂f ′ . By induction, it holds that | π ′ | ≤ | π | . We observe now that π ′ ⊆ R ∂f ′ and π ′ R ∂f ,hence the previous case applies, showing that | π ′ ↓ ∂f | ≤ | π ′ | . Finally, the two previous inequalitiesimply | π ↓ ∂f | ≤ | π ↓ ∂f ′ | ≤ | π | . (cid:3) We can state now the main property of ISP subgraphs.
Corollary 2
Let X be an ISP subgraph of G and let f be a face of X . For every a, b ∈ R ∂f thereexists a shortest a - b path of G contained in R ∂f . In this section we summarize the result of Eisenstat and Klein’s paper [7], that deals with themultiple source shortest paths (MSSP) problem. Their algorithm takes as input an undirectedunit-weight planar graph G and returns an implicit representation of a sequence of shortest pathtrees whose roots are the vertices of the external face.Let us assume that v , v , . . . , v r is the sequence of vertices in the external face in clockwiseorder, and T i is the shortest-path tree rooted in v i computed by the algorithm in [7], for i ∈ [ r ].The sequence of trees T i , for i ∈ [ r ], is represented by explicitly listing the darts in T , and listingthe darts that are added to transform T i into T i +1 , for 1 < i ≤ r (for each added dart from x to y , the unique dart that goes to y in T i is deleted; with the only two exceptions of the added dartleading to v i , and the deleted dart leading to v i +1 ). Hence, the output of their algorithm is T and5 succession of sets of darts. A key result in [7] shows that if a dart d appears in T i +1 \ T i , then d cannot appear in any T j +1 \ T j , for j > i . Thus the implicit representation of the sequence ofshortest path trees has size O ( n ). This representation can be computed in O ( n ) worst-case time. In this section we introduce algorithm
MPSPsupergraph , that builds a succession { X i } i ∈ [ k ] ofsubgraphs of G such that X k contains a shortest path for each terminal pair, and it possiblycontains some extra edges. We anticipate that X i ∪ f ∞ G is an ISP subgraph of G , for all i ∈ [ k ].In the next section, we present algorithm MPSPunion that, by using algorithm
MPSPsupergraph ,builds a directed graph that is exactly the union of the shortest directed paths joining each terminalpair given by algorithm
MPSPsupergraph .Algorithm
MPSPsupergraph builds a succession { X i } i ∈ [ k ] of subgraphs of G by using the suc-cession of shortest path trees given by Eisenstat and Klein’s algorithm. We point out that we arenot interested in the shortest path trees rooted at every vertex of f ∞ G computed by the algorithmin [7], but we only need the shortest path trees rooted in s i ’s. So, we define T i as the shortest pathtree rooted in s i , for i ∈ [ k ]. We denote by T i [ v ] the path in T i from s i to v .The algorithm starts by computing the first subgraph X , that is just the undirected 1-path in T , i.e., T [ t ]. Then the sequence of subgraphs X i , for i = 2 , . . . , k is computed by adding someundirected paths extracted from the shortest path trees T i ’s defined by of Eisenstat and Klein’salgorithm.We define the set H i ⊆ X i of vertices h such that at least one dart d is added while passingfrom T i − to T i such that head[ d ] = h . Hence, H i is the set of vertices whose parent in T i differsfrom the parent in T i − . At iteration i , we add path T i [ h ] to X i , for each h in H i . Algorithm
MPSPsupergraph :Input: an undirected unit-weight planar embedded graph G and k well-formed terminalpairs of vertices ( s i , t i ), for i ∈ [ k ], on the external face of G Output: an undirected graph X k that contains a set of non-crossing paths P = { π , . . . , π k } , where π i is a shortest s i - t i path, for i ∈ [ k ] X = T [ t ]; for i = 2 , . . . , k do X i = X i − ; For all h ∈ H i , X i = X i ∪ T i [ h ]; Let η i be the undirected path on T i that starts in t i and walks backwards until avertex in X i is reached; X i = X i ∪ η i ;Figure 3 shows an example of how algorithm MPSPsupergraph builds X starting from X . InFigure 3.(a) X is drawn and Figure 3.(b) shows the darts whose head is in H . We give attentionto the unique dart d whose head is the vertex x . We observe that d is already in X , this happensbecause rev[ d ] ∈ T [ t ]. Indeed, it is possible that at iteration i some portions of some undirectedpaths that we add in Line 4 are already in X i − . Figure 3.(c) highlights S h ∈ H T [ h ] and η , whilein Figure 3.(d) X is drawn.The subgraphs we build, i.e., { X i } i ∈ [ k ] , united with f ∞ G satisfy all the hypothesis of Theorem 1.Indeed, paths added in Line 4 and Line 6 are shortest paths in G joining vertices in X i − , thusfulfilling Definition 2. So, we exploit Theorem 1 to prove that X i contains an i -path, for i ∈ [ k ],and, in particular, X k contains a set of non-crossing paths P = { π , . . . , π k } , where π i is a shortest i -path, for i ∈ [ k ]. The main idea is to show that X i contains an undirected path that has the6 t s t s t (a) X in black s t s t s t x (b) X in grey and the dartswhose head is in H in red s t s t s t s t (c) S h ∈ H T [ h ] in red and η in green s t s t s t s t (d) X in black Figure 3: an example of how algorithm
MPSPsupergraph builds X starting from X .same length of the shortest i -path found by the algorithm by Eisenstat and Klein. This is provedin Theorem 3.Given a subgraph X of G , we say that an i -path p is the leftmost i -path in X if for every i -path q ⊆ X it holds R p ◦ γ i ⊆ R q ◦ γ i . Theorem 3
Let π i be the leftmost i -path in X i , for i ∈ [ k ] . The following hold:3.(1) π i is the path in X i that starts in s i and (going from s i to t i ) always turns left until it reaches t i , for i ∈ [ k ] ,3.(2) π i is a shortest i -path, for i ∈ [ k ] ,3.(3) for all i, j ∈ [ k ] , π i and π j are non-crossing. Proof. • Let i ∈ [ k ]. For convenience let λ i be the undirected path on X i that starts in s i and always turns left until either it reaches t i or it reaches a vertex of degree one in X i , for i ∈ [ k ];we observe that λ i is well defined and, by Remark 1, x ∈ f ∞ G . We have to prove that λ i = π i , for i ∈ [ k ].First, we observe that s i ∈ X i because s i − ∈ H i , thus, by Line 4, T i [ s i − ] ⊆ X i . This implies s i ∈ X i as we have claimed.Let x be the extremal vertex of λ i other than s i . Suppose by contradiction that x = t i . Twocases are possible: either x ∈ V ( f ∞ G ) \ V ( γ i ) or x ∈ V ( γ i ) \ { t i } .The first case cannot occur because Line 4 and Line 6 imply T i [ t i ] ⊆ X i , thus λ i would cross η i , absurdum. In the second case, let us assume by contradiction that x ∈ V ( γ i ) \ { t i } . Let d ∈ λ i be the dart such that head[ d ] = x . By definition of λ i , vertex x has degree one in X i . By Line 2,Line 4 and Line 6, all vertices with degree one are equal to either s ℓ or t ℓ , for some ℓ ∈ [ k ], andthis implies that there exists j < i such that x ∈ { s j , t j } . This is absurdum because there is not s j or t j in V ( γ i ) \ { s i , t i } such that j < i . Hence λ i is an i -path, and, by its definition, λ i is theleftmost i -path in X i . Therefore λ i = π i . 7 We prove that π i is a shortest i -path by using Theorem 1, indeed, X i ∪ f ∞ G is an ISPsubgraph of G by construction. Let G ′ be the graph obtained from G by adding a dummy path q from s i to t i in f ∞ G with high length (for example, | q | = | E ( G ) | ). Let R be the region of G ′ bounded by the cycle π i ◦ q . We observe that T i [ t i ] ↓ ∂R = π i and π i ◦ q is the boundary of a faceof G ′ . Thus, by Theorem 1, | π i | ≤ | T i [ t i ] | . Since T i [ t i ] is a shortest path, then π i is a shortest pathin G ′ , hence it also is a shortest path in G . • Let us assume by contradiction that there exist i, j ∈ [ k ] such that π i and π j are crossing,with i < j . Thus π j has not turned always left in X j , absurdum. (cid:3) As we have anticipated in the previous section, the graph X k given by the algorithm MPSPsupergraph contains a shortest path for each terminal pair, but X k may also contain edges that do not belongto any shortest path. To overcome this problem we apply algorithm MPSPunion , that builds adirected graph Y k = S i ∈ [ k ] ρ i , where ρ i is a directed shortest i -path, for i ∈ [ k ]. Moreover, weprove that Y k can be built in linear time. This implies that, by using the results in [3], we cancompute the length of all shortest i -paths, for i ∈ [ k ], in O ( n ) worst-case time (see Theorem 7).We use the succession of subgraphs { X i } i ∈ [ k ] . By Theorem 3, we know that X i contains ashortest undirected i -path π i and we can list its edges in O ( | π i | ). But if an edge e is shared bymany π i ’s, then e is visited many times. Thus obtaining S i ∈ [ k ] π i by this easy procedure requires O ( kn ) worst-case time. To overcome this problem, we should visit every edge in S i ∈ [ k ] π i only aconstant number of times.We use two results proved in [3]. The first lemma shows that two uncomparable paths π i and π j in the genealogy tree T g cannot share a dart, although it is possible that −→ ab ∈ π i and −→ ba ∈ π j . Lemma 4 ([3]) Let π i be a shortest directed i -path and let π j be a shortest directed j -path, forsome i, j ∈ [ k ] . If j is not an ancestor neither a descendant of i in T G , then π i and π j have nocommon darts. The second lemma deals with the intersection of non-crossing and paths joining comparablepairs.
Lemma 5 ([3]) Let { π i } i ∈ [ k ] be a set of non-crossing directed paths. Let i, j ∈ [ k ] , if i is adescendant of j , then π i ∩ π j ⊆ π ℓ , for all ℓ ∈ [ k ] such that i ≺ ℓ ≺ j . Let ρ i be a shortest directed i -path and let ρ j be a shortest directed j -path, for some i, j ∈ [ k ], i = j . By Lemma 4, if i and j are not comparable in T G , then ρ i and ρ j have no common darts.Moreover, by Lemma 5, if i is an ancestor of j in T G , then ρ i ∩ ρ j ⊆ ρ p ( j ) . By using these two facts,in order to list darts in ρ i , then it suffices to find darts in ρ i \ ρ p ( i ) , for all i ∈ [ k ] \ { } (we remindthat 1 is the root of T G ). To this goal we use algorithm MPSPunion , that builds a succession ofdirected graphs { Y i } i ∈ [ k ] such that Y k is equal to S i ∈ [ k ] ρ i , where ρ i is a shortest directed i -path,for i ∈ [ k ].We prove the correctness of algorithm MPSPunion in Theorem 6. At iteration i we compute ρ i \ ρ p ( i ) , showing that ρ i \ ρ p ( i ) = σ i ∪ rev[ τ i ], where σ i and τ i are computed in Line 5 and Line 6,respectively. We observe that if ρ i ∩ ρ p ( i ) = ∅ , then σ i = rev[ τ i ] = ρ i . Theorem 6
Graph Y k computed by algorithm MPSPunion is the union of k shortest non-crossing i -paths, for i ∈ [ k ] . Proof.
Let { π i } i ∈ [ k ] be the set of paths defined in Theorem 3. For all i ∈ [ k ], we denote by −→ π i thedirected version of π i , oriented from s i to t i . 8 lgorithm MPSPunion :Input: an undirected unit-weight planar embedded graph G and k well-formed terminalpairs of vertices ( s i , t i ), for i ∈ [ k ], on the external face of G Output: a directed graph Y k formed by the union of directed shortest non-crossing pathsfrom s i to t i , for i ∈ [ k ] Compute X as in algorithm MPSPsupergraph ; Y is the directed version of X oriented from s to t ; for i = 2 , . . . , k do Compute X i as in algorithm MPSPsupergraph ; σ i is the directed path that starts in s i and always turns left in X i until either σ i reaches t i or the next dart d i of σ i satisfies d i ∈ Y i − ; τ i is the directed path that starts in t i and always turns right in X i until either τ i reaches s i or the next dart d ′ i of τ i satisfies rev[ d ′ i ] ∈ Y i − ; Y i = Y i − ∪ σ i ∪ rev[ τ i ];First we define ρ = −→ π and for all i ∈ [ k ] \ { } we define ρ i = ( −→ π i [ s i , u i ] ◦ ρ p ( i ) [ u i , v i ] ◦ −→ π i [ v i , t i ] , if −→ π i ∩ ρ p ( i ) = ∅ , −→ π i , otherwise , (1)where we assume that if V ( −→ π i ∩ ρ p ( i ) ) = ∅ , then u i and v i are the vertices in V ( −→ π i ∩ ρ p ( i ) ) thatappear first and last in −→ π i , respectively. Now we split the proof into three parts: first we prove that { ρ i } i ∈ [ k ] is a set of shortest paths (we need it to apply Lemma 4); second we prove that { ρ i } i ∈ [ k ] is a set of non-crossing paths (we need it to apply Lemma 5); third we prove that Y = S i ∈ [ k ] ρ i (we prove it by Lemma 4 and Lemma 5). • { ρ i } i ∈ [ k ] is a set of shortest paths: we proceed by induction on i . The base case is trivialbecause π is a shortest path by definition. Let us assume that ρ j is a shortest j -path, for j < i ,we have to prove that ρ i is a shortest i -path. If −→ π i ∩ ρ p ( i ) = ∅ , then ρ i = −→ π i by (1), thus the thesisholds because { π i } i ∈ [ k ] a set of shortest paths. Hence let us assume that −→ π i ∩ ρ p ( i ) = ∅ , then itsuffices, by definition of ρ i , that | π i [ u i , v i ] | = | ρ p ( i ) [ u i , v i ] | . It is true by induction. • { ρ i } i ∈ [ k ] is a set of non-crossing paths: we proceed by induction on i . The base case is trivialbecause there is only one path. Let us assume that { ρ j } j ∈ [ i − is a set of non-crossing paths, wehave to prove that ρ i does not cross ρ j , for any j < i .If ρ i and ρ j are crossing and j is not an ancestor of i , then, by construction of ρ i , either ρ p ( i ) and ρ j are crossing or π i and π j are crossing; that is absurdum in both cases by induction andTheorem 3. Moreover, by definition, ρ i does not cross ρ p ( i ) , and by induction, if ℓ is an ancestor of i such that ℓ = p ( i ), then ρ i does not cross ρ ℓ , indeed, if not, then ρ ℓ would cross ρ p ( i ) , absurdum.Hence { ρ i } i ∈ [ k ] is a set of non-crossing paths. • Y is the union of ρ i ’s: now we prove that Y = S i ∈ [ k ] ρ i . In particular we show that ρ = −→ π and for all i ∈ [ k ] \ { } ρ i = ( σ i ◦ ρ p ( i ) [ u i , v i ] ◦ rev[ τ i ] , if −→ π i ∩ ρ p ( i ) = ∅ , −→ π i , otherwise . (2)As always, we proceed by induction on i . The base case is trivial, thus we assume that (1) isequivalent to (2) for all i < ℓ . We have to prove that (1) is equivalent to (2) for i = ℓ .If −→ π ℓ does not intersect any dart of ρ p ( ℓ ) , then (1) is equivalent to (2). Thus we assume that −→ π ℓ ∩ ρ p ( ℓ ) = ∅ . By (1) and (2) and by definition of σ i and τ i in Line 5 and Line 6, respectively, itsuffices to prove that d i ∈ ρ p ( i ) and rev[ d ′ i ] ∈ ρ p ( i ) .9ow, by induction we know that d i ∈ ρ ℓ for some ℓ < i , we have to show that d i ∈ ρ p ( i ) . ByLemma 4 and being { ρ j } j ∈ [ k ] a set of shortest paths, it holds that ℓ is an ancestor or a descendantof i . Being the s j ’s visited clockwise by starting from s , then ℓ is an ancestor of i . Finally, byLemma 5 and being { ρ j } j ∈ [ k ] a set of non-crossing path, it holds that ρ i ∩ ρ ℓ ⊆ ρ p ( i ) . Being p ( i ) < i ,then d i ∈ ρ p ( i ) as we claimed. By a similar argument, it holds that rev[ d ′ i ] ∈ ρ p ( i ) . (cid:3) It is proved in [3] that, starting from the union of a set of shortest paths between well-formedterminal pairs, distances between terminal pairs can be computed in linear time. Thus we can givethe following main theorem.
Theorem 7
Given a plane undirected unit-weight graph G and a set of well-formed terminal pairs { ( s i , t i ) } on the external face f ∞ of G we can compute U = S i ∈ [ k ] p i and the lengths of all p i , for i ∈ [ k ] , where p i is a shortest i -path and { p i } i ∈ [ k ] is a set of non-crossing paths, in O ( n ) worst-casetime. Proof.
By Theorem 6 the required graph U is the undirected version Y k of the graph computed byalgorithm MPSPunion . Algorithm
MPSPunion uses algorithm
MPSPsupergraph , that requires O ( n )worst-case time, because it visits each edge of G at most O (1) times (in Line 4, T i [ h ] can be foundby starting in h and by walking backwards on T i ) and because Eisenstat and Klein’s algorithmrequires O ( n ) worst-case time, implying that S i ∈ [ k ] H i can be found in O ( n ). Moreover, algorithm MPSPunion visits each dart of the “directed version” of X k at most O (1) times, where the directedversion of X k is the directed graph built from X k by replacing each edge ab by the pair of darts −→ ab and −→ ba . Thus, algorithm MPSPunion requires O ( n ) worst-case time, since X k is a subgraph of G . Finally, we compute the length of p i , for all i ∈ [ k ], in O ( n ) by using the results in [3]. (cid:3) Remark 2
If the input graph G in not unit-weight but all edges have small integer weights, thenwe obtain all the previous results in O ( n + L ) worst-case time by splitting every edge of weight r in r unit-weight edges, where L is the sum of all edge weights. In this paper we have shown a linear time algorithm to compute multi-terminal shortest pathswhose extremal vertices are in the external face of a planar unit-weight graph.The algorithm relies on the algorithm by Eisenstat and Klein for computing SSSP trees rootedon the vertices of the external face and on the novel concept of ISP subgraph of a planar graph,that can be of interest itself.We wish to investigate the multi-terminal shortest path problem when each terminal pairscontains only one vertex on the external face.
References [1]
G. Ausiello, P. G. Franciosa, I. Lari, and A. Ribichini , Max flow vitality in generaland st-planar graphs , Networks, 74 (2019), pp. 70–78.[2] ,
Max-flow vitality in undirected unweighted planar graphs , CoRR, abs/2011.02375(2020).[3]
L. Balzotti and P. G. Franciosa , Computing Lengths of Shortest Non-Crossing Paths inPlanar Graphs , arXiv e-prints, (2020), p. arXiv:2011.04047.104]
S. Cabello , Many Distances in Planar Graphs , Algorithmica, 62 (2012), pp. 361–381.[5]
D. Z. Chen and J. Xu , Shortest Path Queries in Planar Graphs , in Proceedings of theThirty-Second Annual ACM Symposium on Theory of Computing, May 21-23, 2000, Portland,OR, USA, F. F. Yao and E. M. Luks, eds., ACM, 2000, pp. 469–478.[6]
H. N. Djidjev , Efficient Algorithms for Shortest Path Queries in Planar Digraphs , in In-ternational Workshop on Graph-Theoretic Concepts in Computer Science, Springer, 1996,pp. 151–165.[7]
D. Eisenstat and P. N. Klein , Linear-Time Algorithms for Max Flow and Multiple-SourceShortest Paths in Unit-Weight Planar Graphs , in Symposium on Theory of Computing Con-ference, STOC’13, Palo Alto, CA, USA, June 1-4, 2013, D. Boneh, T. Roughgarden, andJ. Feigenbaum, eds., ACM, 2013, pp. 735–744.[8]
J. Erickson and A. Nayyeri , Shortest Non-Crossing Walks in the Plane , in Proceedings ofthe Twenty-Second Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2011, SanFrancisco, California, USA, January 23-25, 2011, D. Randall, ed., SIAM, 2011, pp. 297–208.[9]
J. Fakcharoenphol and S. Rao , Planar graphs, negative weight edges, shortest paths, andnear linear time , J. Comput. Syst. Sci., 72 (2006), pp. 868–889.[10]
G. N. Frederickson , Fast Algorithms for Shortest Paths in Planar Graphs, with Applica-tions , SIAM J. Comput., 16 (1987), pp. 1004–1022.[11]
P. Gawrychowski, S. Mozes, O. Weimann, and C. Wulff-Nilsen , Better Tradeoffs forExact Distance Oracles in Planar Graphs , in Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2018, New Orleans, LA, USA, January7-10, 2018, A. Czumaj, ed., SIAM, 2018, pp. 515–529.[12]
R. Hassin , Maximum Flow in (s,t) Planar Networks , Inf. Process. Lett., 13 (1981), p. 107.[13]
R. Hassin and D. B. Johnson , An O(n log n) Algorithm for Maximum Flow in UndirectedPlanar Networks , SIAM J. Comput., 14 (1985), pp. 612–624.[14] M. R. Henzinger, P. N. Klein, S. Rao, and S. Subramanian , Faster Shortest-PathAlgorithms for Planar Graphs , J. Comput. Syst. Sci., 55 (1997), pp. 3–23.[15]
G. F. Italiano, Y. Nussbaum, P. Sankowski, and C. Wulff-Nilsen , Improved Algo-rithms for Min Cut and Max Flow in Undirected Planar Graphs , in Proceedings of the 43rdACM Symposium on Theory of Computing, STOC 2011, San Jose, CA, USA, 6-8 June 2011,L. Fortnow and S. P. Vadhan, eds., ACM, 2011, pp. 313–322.[16]
P. N. Klein , Multiple-source shortest paths in planar graphs , in Proceedings of the SixteenthAnnual ACM-SIAM Symposium on Discrete Algorithms, SODA 2005, Vancouver, BritishColumbia, Canada, January 23-25, 2005, SIAM, 2005, pp. 146–155.[17]
L. Kowalik and M. Kurowski , Short Path Queries in Planar Graphs in Constant Time , inProceedings of the 35th Annual ACM Symposium on Theory of Computing, June 9-11, 2003,San Diego, CA, USA, L. L. Larmore and M. X. Goemans, eds., ACM, 2003, pp. 143–148.[18]
Y. Kusakari, D. Masubuchi, and T. Nishizeki , Finding a Noncrossing Steiner Forest inPlane Graphs Under a 2-Face Condition , J. Comb. Optim., 5 (2001), pp. 249–266.[19]
S. Mozes and C. Sommer , Exact Distance Oracles for Planar Graphs , in Proceedings of theTwenty-Third Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2012, Kyoto,Japan, January 17-19, 2012, Y. Rabani, ed., SIAM, 2012, pp. 209–222.1120]
Y. Nussbaum , Improved Distance Queries in Planar Graphs , in Algorithms and Data Struc-tures - 12th International Symposium, WADS 2011, New York, NY, USA, August 15-17, 2011.Proceedings, F. Dehne, J. Iacono, and J. Sack, eds., vol. 6844 of Lecture Notes in ComputerScience, Springer, 2011, pp. 642–653.[21]
J. H. Reif , Minimum s-t Cut of a Planar Undirected Network in O ( n log ( n )) time , SIAMJ. Comput., 12 (1983), pp. 71–81.[22] A. J. Steiger , Single-Face Non-Crossing Shortest Paths in Planar Graphs , M.S.thesis, University of Illinois at Urbana-Champaign, 2017. [Online], Available:http://hdl.handle.net/2142/98345.[23]
J. Takahashi, H. Suzuki, and T. Nishizeki , Shortest Noncrossing Paths in Plane Graphs ,Algorithmica, 16 (1996), pp. 339–357.[24] ,