WorksComputer Science
Faster Planar Diameter using Pseudoline Envelopes
Abstract
We give an improved algorithm for weighted directed planar diameter that runs in time. This improves upon the time algorithm for weighted directed planar diameter of Gawrychowski, Kaplan, Mozes, Sharir, and Weimann [SIAM J. Comput. 2021] and the recent time algorithm for unweighted undirected planar diameter of Fredslund-Hansen, Mozes, and Weimann [SOSA 2027]. The main new result is an improved data structure for computing the farthest vertex when given feasible planar distances to the vertices on the outer face. The critical insight is the fact that normalized distances to the vertices of a face behave like pseudolines, for which we can leverage range searching and upper envelope data structures. Using the farthest vertex data structure, we are able to compute all vertex eccentricities and diameter in .
Introduction
Let be a directed graph with vertices, real edge weights , and no negative weight cycles. Write and for the vertex and edge sets of , and for the length of a shortest directed -to- path. We set when is unreachable from , and . In particular, need not equal in a directed graph. The outgoing eccentricity of and the diameter of are
Throughout the paper, eccentricity means outgoing eccentricity.
Computing the diameter of the graph is a fundamental problem in graph algorithms. For sparse graphs with vertices, edges, and no negative weight edges, the simple algorithm of performing single source shortest path (SSSP) computation from every vertex runs in total time1 using Dijkstra’s algorithm. Roditty and Vassilevska Williams [34] showed that assuming the strong exponential time hypothesis (SETH) and the orthogonal vectors (OV) hypothesis, there is no time algorithm for any . Since obtaining a truly subquadratic time is unlikely for general graphs, significant attention has turned to computing exact diameter in more structured families of graphs, such as bounded treewidth graphs [13, 3, 20, 4], planar graphs [6 GKM^{+}21, 17], minor-free graphs [15, 29, 25 CCG^{+}25, 35], and geometric intersection graphs [BKK^{+}22, DKP24, CGL24, CCG^{+}25, CCG^{+}26a, CCG^{+}26b].
In a celebrated 2017 breakthrough, Cabello [6] showed that diameter in weighted directed planar graphs can be computed in running time. Gawrychowski, Kaplan, Mozes, Sharir and Weimann [GKM+21] subsequently improved the running time to . Central to both results is the understanding of additively weighted Voronoi diagrams for planar distances.
Voronoi diagram techniques crucially exploited planarity and thus did not readily extend to other graph classes. Progress in broader graph classes instead came from exploiting the combinatorial structure of distances through bounded VC-dimension. Ducoffe, Habib, and Viennot [15] first showed that subquadratic time diameter computation was possible in unweighted undirected minor-free graphs with a different structural technique involving distance VC-dimension. In a different approach, using the distance profile set systems that were shown to have bounded VC-dimension in planar graphs by Li and Parter [26], Le and Wulff-Nilsen [29] developed normalized distance profiles to obtain subquadratic diameter algorithms in unweighted minor-free digraphs. Zheng [35] recently extended the VC-dimension approach to handle minor-free digraphs with real edge weights.
Distance profile techniques have led to renewed progress on planar graphs. Recently, Fredslund-Hansen, Mozes, and Weimann [17] improved the running time for unweighted undirected planar graphs to time by strengthening the Li and Parter [26] bound for planar distance profiles. This leaves a gap between time for weighted directed planar graphs and time in unweighted undirected planar graphs. Neither exponent seems to be optimal, raising the question of how far either bound can be improved.
Abboud, Mozes, and Weimann explicitly asked whether planar diameter admits an -time algorithm or whether a superlinear lower bound can be proved [1]. At the 2016 Dagstuhl seminar Structure and Hardness in P, Søren Dahlgaard suggested as an open problem that conditional hardness was a possible target for planar diameter [27 Section 4.9]. The exponent also has a natural algorithmic motivation: the planar separator theorem of Lipton and Tarjan [28] guarantees a balanced separator with vertices, and it is natural to need to consider all vertex–separator pairs in an algorithm to compute diameter. This makes time a natural milestone for planar diameter upper and lower bounds.
Results
We reach this natural milestone for weighted planar diameter.
Theorem 1. There is an time algorithm for computing the diameter and all vertex eccentricities of a real-weighted directed -vertex planar graph with no negative weight cycles.
The algorithm rests on a new structural theorem about planar shortest-path distances: normalized distance profiles form a family of pseudolines. Fix a face of a plane graph with vertices ordered around the face. For every vertex , the normalized distance profile is the sequence . We prove that any two such profiles change relative order at most once as increases, meaning that this is a collection of pseudolines. See Figure 1 for an illustration. The most notable and surprising aspect of the new structural result is that is allowed to be anywhere in the graph. The standard Monge property of planar graphs applies only to pairs of vertices on a single face. This new structural result enables the usage of upper envelope and range searching techniques for planar distances.

Figure 1. Left: an unweighted planar graph. Top right: distance profiles from four selected vertices, normalized by distance to . Bottom right: Every pseudoline defined by distance profiles crosses every other pseudoline at most once.
A basic obstacle to applying range searching to graph distances is the size of the separator. The framework of Cabello and Knauer [13] organizes distances across a separator using orthogonal range searching, with dimension depending on the number of separator vertices. This dependence is effective for bounded-treewidth graphs that have constant sized balanced separators, but planar graphs can require balanced separators of size . We show how to exploit planarity to avoid this. Instead we use Voronoi cells and the CCW-first ordering of [GKM+21] to organize the vertices into intervals, within each of which cell membership is determined by a single profile comparison. The pseudoline property allows us to build efficient data structures for performing this operation.
The resulting data structure removes a costly preprocessing step in the planar Voronoi approach to diameter. The construction of Gawrychowski et al. [GKM+21] uses preprocessing to compute the Voronoi diagram of an -vertex graph with sites. This data structure supports farthest-vertex queries in a Voronoi cell. We present a new data structure that allows these farthest-vertex queries to be restricted to a prescribed subset , fixed during preprocessing: for each site , we seek the farthest vertex from among the vertices of in its Voronoi cell. We call the target set. Writing , our preprocessing takes only time. This saves a factor of when all vertices are targets, while its dependence on allows us to preserve distances in a large graph and optimize over a much smaller region. Combining this structure with the fast Voronoi construction of Mozes and Prigan [31] and a recursive planar decomposition gives the running time.
Geometry of distances between boundaries and interiors Monge inequalities have long been useful in computing distances in planar graphs, as in FR-Dijkstra [18]. The connection between Monge matrices and pseudolines have been exploited previously [21, 23, 12] for matrix searching. However, the standard Monge argument only applies to distance matrices of vertices that lie on a single face. Our new theorem can be viewed as a proof that the normalized distance matrix between vertices on a single face and vertices anywhere else (after sorting rows and columns appropriately) is a totally monotone, a condition that is weaker than Monge.
Technical Overview
We give an overview of our techniques to compute all vertex eccentricities, and hence diameter of a directed plane graph . A key step is to do local computation on a strongly connected subgraph of with vertices and a set of vertices on a face that separates from some subset of vertices . To compute the farthest vertex in from a vertex , we define a function where for , and find a vertex that maximizes . In notation this is:
To do so, we utilize Voronoi diagrams.
Voronoi Diagrams For additive weights , we say that the weights are admissible, if for every , it holds that so the triangle inequality is respected. Note that shortest path distances in any graph satisfy triangle inequality and are thus admissible. Define the Voronoi cell of a boundary vertex as
For simplicity we assume that no ties occur so these cells partition and form the additively weighted Voronoi diagram . A Voronoi cell is represented in the dual graph, and for any , the boundary of the Voronoi cell is a collection of dual edges and faces and is denoted by . The diagram has a compact reduced dual representation of total complexity , and a represented edge may stand for a long path of underlying dual edges. The complexity of the Voronoi cell is measured by the number of faces that contain a vertex of and vertices of at least two other Voronoi cells. A standard fact (see [6] or [GKM+21, Corollary 2.3]) is that a Voronoi diagram of sites has total complexity .
Farthest vertex in Voronoi cells The Voronoi diagram gives us a way to compute the distances:
Gawrychowski, Kaplan, Mozes, Sharir, and Weimann [GKM+21, Theorem 1.1] provide such a data structure for -vertex planar graphs with no negative weight cycles and vertices lying on faces. After preprocessing time, their data structure constructs the diagram for any admissible additive weight in time. It then computes the maximum distance from each active site to a vertex in in time. Thus, both constructing the diagram and computing all cell maxima take total time.
The most expensive part is preprocessing, not query time. For each pair of boundary vertices, their construction preprocesses all possible bisectors as the difference between the two additive weights varies. A fixed pair of boundary vertices requires time and space to handle. Processing all pairs therefore incurs preprocessing time [GKM+21]. We avoid this pairwise preprocessing by using distance profiles that we will define shortly. When the sites lie on a single face, our data structure supports searching for the maximum among a fixed target subset of vertices with preprocessing time sensitive to its size. The following is our main data structure contribution.
Theorem 2 (Farthest Vertex Data Structure). Let be an -vertex directed plane graph with real edge lengths and no negative-length cycles. Fix a set of vertices on a single face of and a subset with vertices. After -time preprocessing, a query of admissible weights admits the computation of an implicit representation of in time. This representation supports querying for for any and a vertex (if any exist) witnessing the max in time.
The target vertex set is fixed during preprocessing, while the additive weights are supplied with each query. In the diameter algorithm, the graph we are building the data structure on may be much larger than , making this refined preprocessing time essential.
Distance profiles and pseudolines Fix an arbitrary vertex, say , where the vertices are ordered counterclockwise around a single face. Define the normalized distance profile of a target as
These were examined by Le and Wulff-Nilsen [29] which were inspired by the patterns of Li and Parter [26]. The crucial observation is that viewing the distance profile as a (discrete) curve going through the points , these curves satisfy a pseudoline property: two curves change relative order at most once along the boundary. See Figure 1 for an illustration of this. The proof of this follows from a variation of the result of Li and Parter [26], who show that unweighted graphs avoid alternating patterns. The pseudoline property indicates that these profiles behave similarly to abstract lines in the plane. In particular, this implies upper envelopes of pseudolines have complexity .
Handling a query For each query, we construct the additively weighted Voronoi diagram with the recent fast construction algorithm of Mozes and Prigan [31] in time. We then use the fact that the Voronoi edges of partition the -first ordering of the shortest-path tree rooted at into one circular interval per Voronoi edge, as observed in [GKM+21]. The cell induces a connected subtree of , and each excursion of the tree traversal outside the cell visits an entire attached subtree before returning. The outward edges of the cell occur in the order of its dual boundary, so all excursions through the same reduced Voronoi edge lie in its corresponding interval. See § 5.1 for details and Figure 3 for an illustration. On the interval corresponding to an edge separating the Voronoi cells of and , membership in the Voronoi cell of is determined by the single comparison . For an outside in the interval, the shortest path from to first leaves at a vertex . Replacing the -to- prefix by a shortest path from to yields , so the comparison with alone excludes every vertex outside in the interval.

Figure 3. Voronoi edges give CCW-first intervals. The pink cell has dual boundary , with the reduced Voronoi edge highlighted in orange. Paired arcs show the two traversal directions of each primal edge. The labels are the CCW-first preorder indices of the artificial leaves associated with the directed arcs . Numbering starts at with index 0, using the leftward ray in the outer face as reference. Every original vertex and every artificial leaf contributes one index, including leaves for reverse and non-tree arcs. The red tree edge enters the component of , where is the shortest path tree rooted at . On the bottom line, the orange bracket marks . The red segment marks the complete excursion into , from to the reverse arc at index 152; gray segments mark the other excursions through . The augmented subtree of contains seven original vertices and 39 artificial leaves, accounting for the difference . Thus . The dashed arc closes through the outer face.
We find the farthest vertex of within a -first interval by binary searching the sorted distances for . For a candidate distance , we consider targets whose -first positions lie in and whose distances from are at least . A data structure on -first positions and distances decomposes the candidate set into polylogarithmically many canonical subsets, whose upper envelopes are stored during preprocessing. If the largest envelope value at exceeds , the vertex corresponding to a maximizing profile belongs to and satisfies ; otherwise, no candidate belongs to . The pseudoline property of normalized distance profiles shows that these upper envelopes have linear complexity. Standard range searching then achieves preprocessing for the target vertices, in addition to shared global preprocessing. The reduced Voronoi diagram has Voronoi edges, each representing a bisector between two sites and defining one interval in the -first ordering rooted at each of the two sites. Thus, processing the resulting intervals in time per interval gives total query time.
From data structure queries to diameter. We apply the data structure within a recursive -division with few holes [24]. The important insight is that it suffices to handle distances between vertices on successive levels of the -division. This way, we can separately consider the holes of each piece of the division in every level of the hierarchy as a single face to apply Theorem 2. Pairs of vertices between these successive levels and the remaining pairs at the leaves account for every pair of vertices in the graph. Each vertex maintains the greatest distance found, yielding eccentricities and hence the diameter.
Organization
We begin with preliminaries in § 2, before presenting the full algorithm for diameter and eccentricities using our data structure of Theorem 2 in § 3. Next, we analyze the structural connection between distance profiles and pseudolines in § 4 before proving Theorem 2 in § 5.
Preliminaries
Unless stated otherwise, is a directed planar graph with vertices and edges with a weight function for each edge . We assume has no negative weight cycles. For a subgraph with vertices, we use to denote the vertices of , and to denote the edges of . We designate a face of as the outer face and let be the set of vertices on the boundary. A plane graph is a planar graph with a fixed embedding. Connectivity, faces, and planar duality refer to the underlying undirected embedded graph. We write and for the dual edge of a primal edge and the dual vertex of a face .
Simplifying assumptions. For the weighted algorithm for computing eccentricities, we will assume that the undirected version of the input planar graph is simple and maximal (thus triangulated), and we have weighted directed edges going in both directions (so the graph is strongly connected). We justify these assumptions as follows. We can remove self-loops and for each ordered pair of adjacent vertices, retain only a shortest directed edge. Define . Every reachable pair has a shortest simple path of absolute value at most . Add edges to any embedding of the graph to make it maximal, giving length to both directions of every added edge and to each missing reverse directed edge. Note that for any two vertices where can reach , the shortest path distance did not change by the transformation. On the other hand if cannot reach , the shortest path distance will be at least , as the sum of all original edges is at least . Thus if a shortest path from to is larger than in the augmented graph, then does not reach in the original graph. Furthermore, we can assume that the lengths of all shortest paths are unique. This can be done by standard symbolic perturbation of the edges.
Recursive subdivisions A region of a planar graph is an edge-induced embedded subgraph where we ignore edge orientations. A division covers the edges of the graph by regions, which may overlap on their boundaries. A vertex shared by multiple regions is a boundary vertex. The boundary vertices of a region are denoted by . A hole of is a face of that is not a face of the original embedded graph. An -division is a division with regions, each with at most vertices and boundary vertices. It has few holes if each region has holes and every edge shared by two regions lies on a hole boundary in each of them [citep][KMS13].
A decomposition tree is a rooted hierarchy of regions whose root is the entire graph and whose children cover their parent. For a geometrically decreasing sequence , a recursive -division with few holes is such a hierarchy where each level is a -division with few holes.
Theorem 3 (Recursive divisions [citep][KMS13], Theorems 2 and 3). For any geometrically decreasing sequence with larger than some absolute constant, a recursive -division with few holes can be computed in time.
We use the connected regions produced by this construction [citep][KMS13], Section 2.5). At scale , there are regions, each of size , with boundary vertices and holes.
Multiple-source shortest paths (MSSP). For a strongly connected planar graph , let denote the shortest-path tree rooted at , with tree edges directed away from .
We use the multiple-source shortest-path (MSSP) algorithm of Klein [citep][Kle05]. For a fixed face of an -vertex planar graph , the algorithm moves the root of the shortest-path tree around the boundary of . Over the entire execution, the shortest-path tree undergoes only changes, and a persistent representation gives access to the tree rooted at each boundary vertex.
Theorem 4 (MSSP [citep][Kle05], [citep][MWN10]). Let be an -vertex directed plane graph no negative weight cycles, and let be a distinguished face. In time and space, one can construct a data structure that, given and , returns in time.
Note that the original algorithm of [22] could only handle nonnegative edge weights. Mozes and Wulff-Nilsen [32] show that by vertex reweighting, this can be extended to any graph with no negative weight cycle with additional preprocessing time.
Distance oracle. We will need exact distances between arbitrary ordered pairs of vertices. We use the distance oracle of Charalampopoulos et al. [10], with the improved construction of Mozes and Prigan [31].
Theorem 5 (Distance oracle [31 Theorem 1.1]). Let be an -vertex directed planar graph with real edge weights and no negative weight cycles. In time and space, one can construct a data structure that, given any ordered pair , returns in time.
Weighted Eccentricities and Diameter Algorithm
We prove Theorem 1 by applying the Voronoi farthest vertex data structure of Theorem 2 separately within each hole of a recursive division. The high level strategy is to construct a recursive -division with few holes and consider each parent-child pair of regions . For each hole of , we query distances from vertices of to vertices of lying in or on its boundary.
Recall that the input is an -vertex planar graph that is strongly connected and triangulated. We present the entire algorithm here for computing the eccentricities of all vertices.
Construct a global distance oracle. Construct a single distance oracle on the entire graph using Theorem 5. This oracle is used in steps 4(b) and 4(c) of the algorithm.
Construct a recursive -division. Construct a recursive -division with few holes of Theorem 3, with geometrically decreasing scales and for a parameter we will specify later.
Initialize the answers. For every vertex , let denote its tentative eccentricity and denote a vertex witnessing this value. Initialize and .
Process distances. For every parent-child pair in the hierarchy, perform Steps 4(a) and 4(b) separately for each hole of , separating from , including the exterior hole when present. Let be the boundary walk around the hole . (If the hole is not simple, e.g. because of pendant vertices or bridges, perform the standard transformation of adding an additional copy of each vertex for each occurrence in a facial walk and add zero weight edges to make the boundary simple.) Note that Step 4(c) is performed only when is a leaf.
(a) Build the local data structures. Define by retaining the part of drawn in , together with its boundary . Thus . (Note that does not contain .) Using Theorem 2, choosing , construct the implicit data structure for querying for defined by vertices within .
(b) Handle child to parent distances. For every vertex , query the global distance oracle of Step 1 to obtain the additive boundary weights for . Using the implicit data structure for , query with the additive weights to compute the farthest vertex from in for all , updating and if a farther vertex is found. The distances used within the Voronoi data structure remain .
(c) Handle distances within leaves. If is a leaf, query the global distance oracle for for every ordered pair . Update and if a farther vertex is found. These distances are computed in the full graph using the distance oracles of Step 1.
At the end of the algorithm, we will have computed the eccentricity of every vertex as and a witness to the eccentricity . The diameter can be computed as the maximum eccentricity.
Correctness
Fix a vertex with for a leaf region . Suppose the eccentricity of is witnessed by a vertex . We divide into two cases depending on whether . In either case, we show that we have considered the distance from to as a candidate for eccentricity. We also show that every candidate considered in Steps 4(b) and 4(c) is an exact distance in , and hence cannot exceed the eccentricity of ; together with coverage, this proves correctness.
Coverage of leaf distances Suppose . Step 4(c) queries the global distance oracle for every ordered pair of vertices in . In particular, the oracle returns the exact distance , even if a shortest path leaves and reenters . This distance is considered as a candidate for the eccentricity of .
Coverage of non-leaf distances Suppose that . Then there must be some parent and child region and with , and where is the hole of containing , with boundary . The piece can be found by walking up the hierarchy from until we find that . Step 4(b) queries the global distance oracle to obtain for every , and constructs an implicit representation of .
The following argument applies to every processed parent-child pair , every hole of , and every source . For every , splitting a shortest -to- path at its last vertex of gives , since the remaining suffix lies in . Thus, for every , the value equals , so we have considered correct shortest paths for all candidates considered.
Suppose for . The data structure of Theorem 2 returns the farthest vertex in , suppose it returned some vertex . Thus satisfies the expression as follows.
Thus we have considered a distance as a candidate for the eccentricity of . Since witnesses the eccentricity of , equality follows, and is therefore globally farthest from .
Running time
The global distance oracle of Step 1 is constructed once in time using Theorem 5. Step 2 takes time using Theorem 3.
To analyze Step 4, consider a child region at scale of the recursive -division, its parent , and a hole of . In particular, this means that both and have size , and the boundary hole has size . Step 4(a) applies Theorem 2 to of size , with and . This takes preprocessing time.
Step 4(b) makes oracle queries to obtain the additive weights, taking time. For each of the vertices of , constructing takes time by Theorem 2. Querying all Voronoi cells takes time for each , taking time in total. Step 4(c) makes oracle queries per leaf, taking time per leaf and time over all leaves, since all leaves have size at most . Using the fact that there are many regions at scale , and that each child region has holes, so processing all its holes changes the bounds for Steps 4(a) and 4(b) by only a constant factor. Therefore, the total running time is:
The last equality uses that the scales are geometric, with minimum and maximum . Setting balances the terms and and gives time.
Pseudoline Families
Here we give a careful definition of weak pseudoline families that allow for stretches of equality between the pseudolines, before showing that normalized distance profiles form a pseudoline family. Subsequently, we describe efficient data structures for constructing upper envelopes of distance profile pseudolines.
Characterizing Pseudolines
In this section we define what it means for a family of discrete functions to be pseudolines. We say that the collection of functions is a weak pseudoline family, if the ordered list of differences switches signs at most once after omitting all zero entries. This induces a geometric belowness relationship: we can say is weakly below at , or in notation . These functions are called pseudolines because if is initially below , then there is at most one point where transitions to being weakly above , and will never be below afterwards. We formally characterize this relation as it will be useful in our later algorithms.
Definition 6. Let be a positive integer and consider discrete functions . For and , we can say that if the function lies weakly below at , meaning that one of the following holds:
Strictly below. .
Weakly below. and either:
(a) for all and for some .
(b) for all and for some .
(c) for all and .
This definition of a weak pseudoline family allows for stretches of equality and thus is slightly different from the standard definition of pseudolines in [2], but remark that they can be handled in essentially the same way (e.g. if you first make infinitesimal perturbations). We justify why we need this more cumbersome definition to handle these stretches of equality in an example in next section.
Normalized Distance Profiles form a Pseudoline Family
Recall that we consider a planar graph , with a specific identified face . Without loss of generality, we may assume that is the outer face. Recall also the definition of the normalized distance profiles:
Data Structures for Upper Envelope of Distance Profile Pseudolines
These distance profiles have stretches of equality for technical reasons: there can be stretches of equality between two distance profiles that arise naturally from the shortest path topology. As an example consider two vertices , where lies on the shortest path between and as well as on the shortest path between and . In this case
We prove here that normalized distance profiles form a weak pseudoline family by adapting the argument of Li and Parter [26]. Their argument was only for unweighted profiles, where they instead analyzed the discrete derivative of the distance profile . We generalize the argument to weighted profiles.
Lemma 7. The set of normalized distance profiles forms a (weak) pseudoline family.
Proof. Suppose for sake of contradiction that there were two vertices where their normalized distance profiles and crossed twice. Interchanging and if necessary, there are indices such that

Figure 2. Example of a planar graph with in counterclockwise order around the boundary. There is no way for the undirected path from to through to avoid crossing the undirected path from to through without meeting at some vertex . In notation of the proof of Lemma 7 we would have and .
Observe that the shortest path from to , with , must intersect some shortest path from to , with . This follows because appear in order on the boundary of , and thus in the undirected graph, there cannot be an undirected path from to to that does not intersect the undirected path from to to since both lie on the same side of the outer face (see Figure 2). Suppose that these two paths intersected at a vertex .
Subtracting from both sides yields
On the other hand, (1) combined with the definition of and gives and . Adding these comparisons gives
This is a contradiction, so we conclude that is a pseudoline family.
Data Structures for Upper Envelope of Distance Profile Pseudolines
In this section we discuss basic computation of upper envelopes, and describe a data structure to quickly compute upper envelopes of distance profiles around different boundary vertices.
Constructing upper envelopes We begin by considering two basic geometric primitives to manipulate pseudoline families.
Point comparison. Given two and a point , decide if .
Locating a crossing. Given two , find the smallest such that or report that none exist.
If these geometric primitives can be implemented in time, we can compute the upper envelope with any algorithm, e.g. Graham’s scan [33]. Graham’s scan sorts the vertices of such that , and then processes each pseudoline in this order from first to last, building the upper envelopes using a stack.
Theorem 8 (Graham’s Scan [33]). There is an algorithm that takes as input pseudolines and computes the upper envelope of the pseudolines with many calls to point comparisons and locating crossings.
Geometric primitives for distance profiles Here we show that point comparisons and locating a crossing can be performed in time for any collection of distance profiles for any of the choices of (when we choose a different we rotate the labels on all the sites so appears first on the boundary ordering) on the boundary after preprocessing. This is notable because to specify a single distance profile requires space, and there are many pseudolines of the form , so a naive implementation could require preprocessing. Conveniently, any fixed and any , the distance profiles can be obtained from by shifting all coordinates by an additive constant . Our following data structure is able to leverage this fact by exploiting the fact that this transformation preserves differences between adjacent points.
Lemma 9 (Geometric Primitive Data Structure). Let be a planar graph with a specified face and a set of target vertices, and let denote the number of boundary vertices of . Suppose all distances from boundary vertices of to vertices in are given. After preprocessing, point comparisons and crossing-location queries for the family for any fixed boundary vertex can be answered in time each.
Proof. The explicit distance matrix gives the values of for all and . It will be convenient for us to consider the discrete differences of adjacent values , where we define . Observe that this does not depend on the choice of basepoint , so there are at most such values. After sorting these values, we can translate the entries into rank space so all values are integers between 1 and , without changing the answer to any comparison between them.
Point Comparison To handle point comparisons between and , we can directly compute both values. If they are not equal, we are done. Otherwise , we will lexicographically compare the following discrete difference strings:
Suppose . Let be the largest value where . Interchanging and if necessary, assume that . As , we have that
and that . Thus we can safely conclude that .
Otherwise and all values of for all . Then we must look ahead for a crossing:
A similar argument allows us to decide if .
To handle these comparisons between strings, we consider the suffix array data structure [30] that allows for lexicographical comparisons of arbitrary substrings (contiguous subsets) in time. Furthermore, we remark that for different base vertices , all strings of the form (and ) are substrings of the (reversed) doubled discrete distance string:
Thus we can build two single suffix array in time over the strings and their reverse for all to handle these queries for all boundary vertices in time.
Locating a Crossing. There can be at most one crossing between any two pseudolines. If initially we have , and for some later we have , then for all . Thus we can binary search for the smallest with calls to point comparison.
Combining Lemma 9 with Theorem 8 yields the following theorem.
Lemma 10 (Upper envelope data structure). Consider an -vertex planar graph with a specified face and a set of target vertices. Suppose all distances from boundary vertices to target vertices of are given. After preprocessing, given any boundary vertex and a subset , the upper envelope of can be constructed in total time. The upper envelope can return and a witness to the maximum in time.
Farthest Vertex Data Structure
The main objective of this section is to prove the existence of the farthest vertex data structure of Theorem 2. To do so, we will first describe a way to order the edges in § 5.1. We then show in § 5.2 that it suffices to make a single data structure query with a contiguous interval in this ordering for each Voronoi edge of a Voronoi cell to find the farthest vertex. § 5.3 shows that we can compute such intervals efficiently. § 5.4 shows how the interval query can be handled by a reduction to computing pseudoline upper envelopes. Finally, we conclude by putting everything together to prove Theorem 2 in § 5.5.
Recall that is an -vertex planar graph with bidirected edges (possibly with different weights in each direction) and a collection of sites that lie in this order on the outer face of . Let denote the shortest path tree rooted at .
CCW-First Ordering
We use the CCW-first ordering of [GKM+21] to assign distinct indices to the vertices and directed edges of . For every directed edge , add an artificial leaf adjacent to , placing its edge immediately before in the counterclockwise order around . For a boundary root , let consist of the shortest path tree and all artificial leaf edges.
Perform a depth-first traversal of , visiting the children of each vertex in counterclockwise order, starting immediately after the edge to its parent. At , start from a fixed imaginary incoming edge embedded in the outer face. Let be the preorder index of a vertex in this traversal, starting with . Define the CCW-first index of a directed edge by . Every original vertex and every directed edge has a distinct index, including both directions of tree and non-tree edges.
We next show how to compute these indices for trees rooted at each boundary vertex with only total preprocessing.
Lemma 11 (CCW-first indices). After preprocessing time, the CCW-first index and the preorder index can be reported in time for any boundary , directed edge , and vertex .
Proof. We use MSSP to maintain the shortest path tree as the source moves around the outer face. Following [10 Appendix A.2], we use a fixed auxiliary root embedded in that face. Add to an additional edge , placed at the prescribed imaginary incoming edge of . MSSP performs parent changes of the form , where lies outside the subtree rooted at .
We maintain the Euler tour of the augmented tree, traversing each tree edge in both directions and following the counterclockwise edge order at each vertex. Store the Euler tour in a balanced binary tree supporting splits, concatenations, and prefix sums. Give value 1 to edges moving away from , and value 0 otherwise. These edges mark the first time a vertex or an artificial leaf is visited. To compute , we take the prefix sum of the Euler tour before the traversal from its parent. The same query for the artificial leaf gives .
An MSSP parent change detaches the subtree rooted at and inserts it at the position of in the counterclockwise edge order at . Since the incoming edge at also changes, we cyclically rotate the detached subtree tour to start immediately after the new parent edge. This requires only splits and concatenations, together with replacing the two occurrences of the old parent edge. We also update the pointer to the first arrival at . Thus each change takes time.
Finally, we make the binary tree storing the Euler tour persistent across the MSSP changes, and keep a version for every tree rooted at a boundary vertex . Since MSSP makes tree changes, maintaining the Euler tours takes time since each split and concatenation takes time. Persistence costs an extra factor in preprocessing time and query time. Thus the total preprocessing time and space are , and each query takes time.
Remark. The artificial leaves allow us to query directly even when does not belong to . For a fixed target vertex set of size , we can also compute for all and , and sort in each ordering, in additional time. Thus representing the orderings and extracting their restrictions to takes total preprocessing time and space.
Voronoi Cells and Shortest Path Trees
We will discuss the interaction between the Voronoi cell for some in the Voronoi diagram with respect to arbitrary admissible weights , the shortest path tree , and a CCW-first index of the edges. Let be the edges of the reduced dual Voronoi diagram of in counterclockwise order around the Voronoi cell. Each reduced Voronoi edge consists of a set of dual edges that separate from another Voronoi cell . Let be the directed primal edge whose dual is the first edge of encountered in a counterclockwise walk around the boundary of , oriented so that and . Let consist of the original vertices whose positions lie in the cyclic interval , where the interval for the last reduced edge ends at . If , this interval comprises one complete traversal. The following lemma relates these intervals to the structure of in and shows that, within each , membership in is determined by a single comparison with the neighboring site .
Lemma 12. Fix a site , and let be a shortest path tree rooted at . Then the following is true.
(a) Connected Voronoi subtree. [GKM+21, Lemma 2.1] The vertices of form a connected induced subtree of .
(b) Voronoi edges give CCW-first intervals. Let be a connected subtree of , with parent edge directed from into , whose dual belongs to . The entire CCW-first traversal into is a cyclic interval contained in the cyclic interval with vertices . In particular, .
(c) One comparison per interval. For every , if and only if .
Proof. We begin by showing that normalized distance profiles are monotone non-increasing as we walk down the shortest path tree. Consider a vertex with parent in . As the edge lies on the shortest path from to , we have that . For any other site , triangle inequality gives . Subtracting this yields:
Proof of (a) connected Voronoi subtrees. A vertex is in if is closer to than any other site. This means that for every other . Thus if has parent in , then for every we must have . By induction, the entire shortest path from to is in . Thus we conclude that is a connected subtree.
Proof of (b) Voronoi edges give CCW-first intervals. Let be the boundary walk of in the dual. By part (a), the paths in from to the tails of the edges leaving lie entirely in . These paths are non-crossing, and the CCW-first search explores their branches in counterclockwise order. Thus, contracting the subtree of induced by to preserves the cyclic order in which the search encounters the outward boundary edges. After contraction, these edges occur counterclockwise around in the order of their duals along , so the cyclic order of the reduced Voronoi edges agrees with the CCW-first order.
Each reduced Voronoi edge is a contiguous subpath of . Thus the outward directed primal edges whose duals belong to occur consecutively among the outward boundary edges encountered by the CCW-first search. Say is an edge dual to the primal edge of and is the connected component of . Once the tour enters through the edge , it visits the entire rooted subtree before returning to . Every interval endpoint is the index of an artificial leaf attached to a vertex of , so no endpoint is encountered during this excursion. Since lies in and is visited immediately before entering , the entire CCW-first traversal of lies in this cyclic interval. See Figure 3 for an illustration of this.
Proof of (c) one comparison per interval. Write , and consider a vertex . Suppose , then clearly . On the other hand if , then by (a) belongs to a rooted subtree of with parent edge . Let be the endpoint of that is the root of . By part (b), the dual of belongs to . Since separates from , we must have . This means that . By Equation (4), it follows that:
This means fails the comparison, proving (c). □
Computing Voronoi Edge Intervals
We use a theorem of Mozes and Prigan [31] that efficiently computes a Voronoi diagram of a set of sites lying on one face. We can assume all other faces have exactly three sides without changing the underlying graph metric by adding long edges (see simplifying assumptions of § 2). The key idea is to find trichromatic triangles which are faces with three vertices belonging to different Voronoi cells. These are the dual vertices of the Voronoi diagram of degree three. The theorem is as follows.
Theorem 13 (Lemma 3.1 of [31]). Let be an -vertex directed planar graph with real weights and no negative weight cycles, and be a collection of sites on one face. Assume that all other faces of have degree 3. After -time preprocessing, for any admissible weight function , an implicit representation of along with all trichromatic triangles can be computed in time.
To recover the intervals according to the CCW-first indices of the shortest path trees, we can use Lemma 11 to get the index for trichromatic edges.
Together with the compressed Voronoi diagram and Lemma 11, we can compute the indices of the interval corresponding to each Voronoi edge.
Corollary 14. After preprocessing, for every admissible weight function on a set of boundary sites , after computing the implicit Voronoi diagram in time and trichromatic triangles with Theorem 13, we can recover the induced CCW interval of a Voronoi edge in time.
Data Structures via Range Searching
In this section we describe standard range searching data structures to show that finding the farthest vertex can be performed using upper envelopes of distance profile pseudolines.
Lemma 12(c) says that we can decompose the Euler tour into intervals where we need to only compare distance profiles with a single competitor boundary site to determine if vertices are in . This means that for interval , it suffices to query many intervals for the vertex that maximizes while satisfying . This can be encapsulated in the following problem.
Problem 1 (Interval Threshold Maximization Problem). Consider a sequence of pseudolines that take on values on unique coordinates where each pseudoline has an associated distance . Construct a data structure to support queries of an interval , a pseudoline coordinate , and a threshold to output the index that maximizes subject to such that .
This problem can be solved using standard multilevel orthogonal range searching technique where we store the upper envelope data structures. We give here the full proof of this via reduction to a problem that can be solved using upper envelopes (in our case with Lemma 10). For this reduction, it helps to define the following intermediate problem.
Problem 2 (Interval Threshold Decision Problem). Consider a sequence of pseudolines that takes on values on unique coordinates. Construct a data structure to support queries of an interval , a pseudoline coordinate , and a threshold to an index where .
We also define the following problem that can be solved using upper envelopes.
Problem 3 (Global Threshold Decision Problem). Consider a sequence of pseudolines that takes on values on unique coordinates. Construct a data structure to support queries for a pseudoline coordinate and a threshold to output any index where .
The reductions are standard. We present a full proof here for completeness.
Lemma 15 (Data structure reductions). Suppose a data structure for Problem 3 can be constructed in time and could handle queries in time. Assuming that , a data structure for Problem 1 can be constructed in time with query time.
Proof. As an intermediate step, we first reduce Problem 1 to Problem 2.
Reducing from Problem 1 to Problem 2 We proceed by standard divide and conquer. Sort all values of , and split the pseudolines into two sets and for which all values in are greater than those in . Build the data structure for Problem 2 on , then recursively build a data structure for Problem 1 on both and . Queries can be handled by binary search, use the data structure for to determine if any pseudoline with value larger than satisfies the interval and threshold condition. If there is, then recurse on , otherwise recurse on . In the recursion, binary search for new endpoints of the query interval, since and only contain subsets of the original indices.
Suppose we had a data structure for Problem 2 with preprocessing time with query time. The construction time for the data structure for Problem 1 has the recurrence . This solves to as any data structure for takes at least time. The query time has the recurrence , which solves to .
:::
Reducing from Problem 2 to Problem 3 This follows by standard segment trees [14], that decompose an interval into dyadic intervals. Suppose we had a data structure for Problem 3 with preprocessing time with query time. Then the preprocessing time satisfies which solves to by building a solution to Problem 3, and ignoring the global preprocessing time. To perform a query, it takes time. Thus we have shown that and that . so we conclude the lemma.
Proving thm:mainds
Here we prove our main data structure result of Theorem 2 that we restate below for convenience.
Theorem 2 (Farthest Vertex Data Structure). Let be an -vertex directed plane graph with real edge lengths and no negative-length cycles. Fix a set of vertices on a single face of and a subset with vertices. After -time preprocessing, a query of admissible weights admits the computation of an implicit representation of in time. This representation supports querying for for any and a vertex (if any exist) witnessing the max in time.
Proof. We begin by describing the data structure.
Data structure We store the data structure of Corollary 14 for recovering Voronoi edge intervals and a single MSSP data structure from Theorem 4 shared by all boundary vertices. For each , we also store the data structure for Problem 1 on the pseudolines in increasing order of , associating each pseudoline with the distance .
Preprocessing time Constructing the data structures for computing Voronoi edge intervals and MSSP takes preprocessing time. Using distances obtained by the MSSP, Lemma 10 allows for constructing an upper envelope to solve the decision problem of Problem 3 on any pseudolines with the same boundary vertex in time after preprocessing. The reduction of Lemma 15 therefore gives construction time for the data structure for Problem 1 at each boundary vertex, or over all boundary vertices. The total preprocessing time is thus .
Handling a query Given an admissible weight function , we use Corollary 14 to construct an implicit representation of its Voronoi diagram in time. For each Voronoi edge on the boundary of a cell , we recover the corresponding interval in the CCW-first ordering rooted at in time. By Lemma 12(c), processing this interval requires one query (or two for circular intervals) to the data structure for Problem 1 associated with , also taking time. Thus, after constructing the diagram, we can process all boundary edges of in time.
Conclusion
We have reached a milestone for planar diameter and all vertex eccentricities by showing that these quantities can be computed in time. We conclude with some open problems.
Tighter bounds for exact planar diameter. We reiterate the question asked by Abboud, Mozes, and Weimann [1]. Does planar diameter admit an -time algorithm or can a superlinear lower bound be proved? Are other improvements beyond for planar diameter possible?
Wiener index. The Wiener index computes the sum of shortest path distances between all pairs of vertices. Upper envelopes are only good for maximum queries, so our farthest vertex
data structure of Theorem 2 does not naturally support computation of Wiener index. Typically, supporting the Wiener index requires computation of sums and counts of vertices in a Voronoi cell. Since queries can be processed offline, it may be possible to use point-pseudoline range searching data structures to handle queries on pseudolines in time. Unfortunately this does not directly lead to any improvement on the time algorithm in [GKM+21].
3. Dynamic exact diameter and distance oracles. Can the structural observations relating to pseudolines made in this paper help for dynamic exact distance problems?
AI Methodology
The results presented in this paper were developed through multiple interactions with GPT-6 Astra. The idea to use range searching and pseudolines was suggested by the first author. The manuscript itself was written by the authors with editing assistance by the LLM.
References
- [1]Amir Abboud, Shay Mozes, and Oren Weimann. What else can Voronoi diagrams do for diameter in planar graphs? In 31st Annual European Symposium on Algorithms, ESA 2023, volume 274 of LIPIcs, pages 4:1–4:20. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2023.arxiv.org/abs/2305.02946
- [2]Pankaj K. Agarwal and Micha Sharir. Pseudo-line arrangements: Duality, algorithms, and applications. SIAM J. Comput., 34(3):526–552, 2005.DOI
- [3]Amir Abboud, Virginia Vassilevska Williams, and Joshua R. Wang. Approximation and fixed parameter subquadratic algorithms for radius and diameter in sparse graphs. In SODA, pages 377–391, 2016.
- [4]Karl Bringmann, Thore Husfeldt, and Måns Magnusson. Multivariate analysis of orthogonal range searching and graph distances. Algorithmica, 82(8):2292–2315, 2020.
- [6]Sergio Cabello. Subquadratic algorithms for the diameter and the sum of pairwise distances in planar graphs. ACM Trans. Algorithms, 15(2):21:1–21:38, 2019.
- [10]Panagiotis Charalampopoulos, Pawel Gawrychowski, Yaowei Long, Shay Mozes, Seth Pettie, Oren Weimann, and Christian Wulff-Nilsen. Almost optimal exact distance oracles for planar graphs. J. ACM, 70(2):12:1–12:50, 2023.DOI
- [12]Timothy M. Chan. Near-optimal randomized algorithms for selection in totally monotone matrices. In Dániel Marx, editor, Proceedings of the 2021 ACM-SIAM Symposium on Discrete Algorithms, SODA 2021, Virtual Conference, January 10 - 13, 2021, pages 1483–1495. SIAM, 2021.DOI
- [13]Sergio Cabello and Christian Knauer. Algorithms for graphs of bounded treewidth via orthogonal range searching. Comput. Geom., 42(9):815–824, 2009.DOI
- [14]Mark de Berg, Otfried Cheong, Marc J. van Kreveld, and Mark H. Overmars. Computational Geometry: Algorithms and Applications. Springer, Berlin, Heidelberg, 3rd edition, 2008.
- [15]Guillaume Ducoffe, Michel Habib, and Laurent Viennot. Diameter, eccentricities and distance oracle computations on H-minor free graphs and graphs of bounded (distance) Vapnik-Chervonenkis dimension. SIAM J. Comput., 51(5):1506–1534, 2022.DOI
- [17]Viktor Fredslund-Hansen, Shay Mozes, and Oren Weimann. A tight bound for facial distance patterns in planar graphs. CoRR, abs/2608.07187, 2026.
- [18]Jittat Fakcharoenphol and Satish Rao. Planar graphs, negative weight edges, shortest paths, and near linear time. J. Comput. Syst. Sci., 72(5):868–889, 2006.
- [20]Thore Husfeldt. Computing graph distances parameterized by treewidth and diameter. In IPEC, volume 63 of LIPics, pages 16:1–16:11, 2016.DOI
- [21]Maria M. Klawe. Superlinear bounds for matrix searching problems. J. Algorithms, 13(1):55–78, 1992.DOI
- [22]Philip N. Klein. Multiple-source shortest paths in planar graphs. In Proceedings of the Sixteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2005, pages 146–155. SIAM, 2005.
- [23]Haim Kaplan, Shay Mozes, Yahav Nussbaum, and Micha Sharir. Submatrix maximum queries in Monge matrices and partial Monge matrices, and their applications. ACM Trans. Algorithms, 13(2):26:1–26:42, 2017.
- [24]Philip N. Klein, Shay Mozes, and Christian Sommer. Structured recursive separator decompositions for planar graphs in linear time. In Symposium on Theory of Computing Conference, STOC 2013, pages 505–514. ACM, 2013.arxiv.org/abs/1208.2223
- [25]Adam Karczmarz and Da Wei Zheng. Subquadratic algorithms in minor-free digraphs: (weighted) distance oracles, decremental reachability, and more. In SODA, pages 4338–4351. SIAM, 2025.arxiv.org/abs/2410.12003
- [26]Jason Li and Merav Parter. Planar diameter via metric compression. In Moses Charikar and Edith Cohen, editors, Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing, STOC 2019, Phoenix, AZ, USA, June 23-26, 2019, pages 152–163. ACM, 2019.arxiv.org/abs/1912.11491
- [27]Moshe Lewenstein, Seth Pettie, and Virginia Vassilevska Williams. Structure and hardness in P (Dagstuhl seminar 16451). Dagstuhl Reports, 6(11):1–34, 2017.DOI
- [28]Richard J. Lipton and Robert Endre Tarjan. A separator theorem for planar graphs. SIAM Journal on Applied Mathematics, 36(2):177–189, 1979.DOI
- [29]Hung Le and Christian Wulff-Nilsen. VC set systems in minor-free (di)graphs and applications. In SODA, pages 5332–5360. SIAM, 2024.arxiv.org/abs/2304.01790
- [30]Udi Manber and Gene Myers. Suffix arrays: A new method for on-line string searches. SIAM Journal on Computing, 22(5):935–948, 1993.
- [31]Shay Mozes and Daniel Prigan. Distances in planar graphs are almost for free! CoRR, abs/2603.26313, 2026.arxiv.org/abs/2603.26313
- [32]Shay Mozes and Christian Wulff-Nilsen. Shortest paths in planar graphs with real lengths in O(n log² n / log log n) time. In Algorithms – ESA 2010, Part II, volume 6347 of Lecture Notes in Computer Science, pages 206–217. Springer, 2010.arxiv.org/abs/0911.4963
- [33]Franco P. Preparata and Michael Ian Shamos. Computational Geometry - An Introduction. Texts and Monographs in Computer Science. Springer, 1985.
- [34]Liam Roditty and Virginia Vassilevska Williams. Fast approximation algorithms for the diameter and radius of sparse graphs. In Dan Boneh, Tim Roughgarden, and Joan Feigenbaum, editors, Symposium on Theory of Computing Conference, STOC’13, Palo Alto, CA, USA, June 1-4, 2013, pages 515–524. ACM, 2013.
- [35]Da Wei Zheng. Real-weighted diameter and eccentricities of minor-free and bounded VC-dimension graphs in truly subquadratic time. In ESA, volume 388 of LIPIcs, pages 61:1–61:12, 2026.arxiv.org/abs/2607.01926