Going Beyond Surfaces in Diameter Approximation
Abstract
Calculating the diameter of an undirected graph requires quadratic running time under the Strong Exponential Time Hypothesis and this barrier works even against any approximation better than . For planar graphs with positive edge weights, there are known -approximation algorithms with running time . However, these algorithms rely on shortest path separators and this technique falls short to yield efficient algorithms beyond graphs of bounded genus.
In this work we depart from embedding-based arguments and obtain diameter approximations relying on VC set systems and the local treewidth property. We present two orthogonal extensions of the planar case by giving -approximation algorithms with the following running times:
-
-time algorithm for graphs excluding an apex graph of size as a minor,
-
-time algorithm for the class of -apex graphs.
As a stepping stone, we obtain efficient -approximate distance oracles for graphs excluding an apex graph of size as a minor. Our oracle has preprocessing time and query time , where is the metric stretch. Such oracles have been so far only known for bounded genus graphs. All our algorithms are deterministic.
Keywords and phrases:
diameter, approximation, distance oracles, graph minors, treewidth2012 ACM Subject Classification:
Theory of computation Graph algorithms analysisFunding:
Supported by Polish National Science Centre SONATA-19 grant 2023/51/D/ST6/00155.Editors:
Anne Benoit, Haim Kaplan, Sebastian Wild, and Grzegorz HermanSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
The diameter of a graph , denoted , is the largest distance between a pair of its vertices in the shortest path metric. We assume that each edge is assigned some real positive weight, and the length of a path is the sum of its weights. The obvious way to calculate is to check the distances for all vertex pairs, but this inevitably requires quadratic time. This trivial approach is essentially optimal because already unweighted graphs of diameter 2 or 3 cannot be distinguished in time under the Strong Exponential Time Hypothesis [49] (see [2] for hardness in sparse graphs). On the other hand, truly subquadratic algorithms to compute diameter are available in planar graphs [10, 34] and graph classes excluding a minor [26, 42, 46]. Still, the best algorithm for planar graphs runs in time111The variable refers to the number of vertices in a graph but all the considered graph classes are sparse so the number of edges is . The -notation hides factors polylogarithmic in . We refer to the dependence as almost-linear. [34], which is far from linear.
The absence of fast algorithms calculating the diameter exactly led the researchers to seek fast approximation algorithms. Weimann and Yuster [55] gave the first almost-linear -approximation for planar diameter, running in time . This was improved to randomized time by Chan and Skrepetos [12] (see also [18]). Li and Parter [47] gave a deterministic algorithm of this type, as well as a distributed algorithm with a small number of rounds. Observe that each of these can be used to recognize unweighted planar graphs of diameter , simply by setting . There are also specialized algorithms for this task by Eppstein [28], with running time , and by Abboud, Mozes, and Weimann [1], with running time .
Shortest path separators.
An area that is technique-wise related is the design of approximate distance oracles. After a preprocessing step, we would like to quickly estimate any -distance within factor . Thorup [53] exploited the fact that planar graphs admit balanced separators consisting of two shortest paths to give an oracle with preprocessing time , space , and query time . The shortest path separators constitute a crucial ingredient of all the three aforementioned algorithms for estimating planar diameter as well.
Abraham and Gavoille [3] presented a generalization of shortest path separators to graph classes excluding a minor and extended Thorup’s oracle to such classes. However, their separators no longer enjoy such a nice structure. The main caveat is that already in a single balanced separator one might need to use paths such that is a shortest path only in . Hence may be much longer than , which is easily seen to be unavoidable already in the class of apex graphs222 is called an apex graph if can be made planar by removal of a single vertex., and it is unclear how to exploit such a separator for diameter computation. The second issue is that finding the separator requires highly superlinear time, which burdens the preprocessing time of the oracle. Almost-linear preprocessing time is currently available only for graphs of bounded genus [40] and for unit disk graphs [13]. The lack of well-structured balanced separators beyond surface-embeddable graphs seems to have limited the development of efficient metric-related algorithms so far.
Beyond surface embedding.
There are two directions of generalizing the topological graph classes. First, one can pick faces in the surface embedding of a graph and replace them with certain graphs of pathwidth , which are called the vortices. Second, one can insert a set of vertices, called the apices, and connect them possibly to anyone. The structural theorem of Robertson and Seymour [48] states that for any graph , all the graphs excluding as a minor can be constructed from graphs embeddable in some fixed surface using these two operations and by taking a clique-sum of them.
When the excluded minor is an apex graph, this description can be slightly restricted [25]. What is important to us, apex-minor-free graphs enjoy the local treewidth property: their treewidth is bounded in terms of the (unweighted) diameter and this relation is known to be linear [24]. Note that the diameter of an edge-weighted graph cannot be related to treewidth by any means because the diameter can be reduced by scaling the weights, while the topological structure of the graph remains the same. Nevertheless, we will see that the local treewidth property is still useful in the considered setting.
The main message of this work is that the local treewidth property can be used instead of shortest path separators for the sake of approximating diameter and radius, as well as for efficient construction of distance oracles. We first employ it to tackle apex-minor-free graphs but we also show that its usefulness is not limited to such graph classes.
Additive core-sets.
Suppose we have a list of vertices in and we want to (approximately) learn all the distance patterns, between a vertex and all of . Chan and Skrepetos [12] employed Cabellos’s technique of abstract Voronoi diagrams [10] to build a data structure to browse such distance patterns in the case when is planar and lie on a single face. However, this technique relies heavily on the embedding of the graph.
A more versatile argument was given by Li and Parter [47] in order to approximate planar diameter in a distributed regime. Following their convention, a subset is called a -additive core-set of if for every there exists such that for each we have . When , a trivial rounding argument yields a -additive core-set of size . Remarkably, the dependence on can be in fact removed from the exponent [47]. This theorem relies on a bound on the VC dimension of a certain set system and this argument carries over to any minor-free graph class [46]. A direct consequence of these theorems reads as follows. (Here stands for the -vertex clique.)
Lemma 1 (Corollary of [46, Theorem 1.3]).
Let be an edge-weighted -minor-free graph , , , and . Then admits an -additive core-set (with respect to ) of size .
For the sake of completeness, we provide a proof in Section 2. The local treewidth property will allow us to apply this lemma for to efficiently compress information about distances in large subgraphs.
1.1 Our contribution
A crucial property of a separator consisting of shortest paths is that can be covered by subgraphs of strong333A subgraph of has strong diameter if every pair of vertices can be connected by a path in of length at most . For comparison, weak diameter refers to distances measured in . diameter . Then the interaction between the two sides of can be channeled through portals on when small distance distortion is allowed. We show that balanced separators of this kind exist and can be efficiently found in any class excluding an apex minor. Specifically, we construct a clustering of an apex-minor-free graph into pieces of small strong diameter such that the graph obtained by contracting each cluster has bounded treewidth. We use this construction to estimate the eccentricity of every vertex , that is, .
Theorem 2.
Let be an apex graph of size . There is an algorithm that, given an edge-weighted -minor-free graph and , runs in time and estimates eccentricity of each vertex vertex within additive error . Moreover, for each the algorithm outputs vertex for which .
As a corollary, we get -approximation for both diameter and radius, which are respectively the largest and the smallest eccentricity.
To employ the additive core-sets in the proof of Theorem 2, we first need to precompute approximate distances for pairs of vertices. To this end, we design a distance oracle with preprocessing and query times tailored to our needs. Similar oracles are available for minor-free graphs [3, 16, 40] but their preprocessing times are far from linear. An oracle with additive error suffices for the proof of Theorem 2 but we can improve it to multiplicative error by taking into account the metric stretch, i.e., the ratio between the largest and smallest positive distances.
Theorem 3.
Let be an apex graph. Given an edge-weighted -minor-free graph of metric stretch and , one can build an -approximate distance oracle with preprocessing time and query time .
The simplest case not covered by Theorem 2 is of course given by the class of apex graphs. This class no longer enjoys the local treewidth property. Moreover, some problems which are easy on planar graphs become much harder after insertion of a single apex [5, 11]. Note that removing just a single vertex can increase the diameter significantly and so our clustering technique cannot be directly applied to decompose such a graph.
We give a stronger theorem that in particular covers the apex graphs. As a consequence of Robertson and Seymour’s structural theorem, for every graph there exists an apex graph and a constant , such that every -minor-free graph can be constructed via a clique-sum from graphs with the following property: each becomes -minor-free after deletion of vertices [23, Theorem VI.1]. We extend Theorem 2 to such graphs, assuming that the deletion set is known.
Theorem 4.
Let and be a graph class excluding an apex graph of size . There is an algorithm that, given an edge-weighted graph , , and a set of size , for which , runs in time , where , and estimates within factor .
Unlike the apex-minor-free case, this time we do not estimate eccentricities because Theorem 4 involves a certain “irrelevant vertex rule” that only preserves the diameter (approximately). The assumption that the set is given in the input can be dropped for the class of planar graphs, i.e., when the input is a -apex graph. In this case, one can find the set in time [37], which leads to the following unconditional statement.
Corollary 5.
There is an -time algorithm that estimates the diameter of an edge-weighted -apex graph within factor .
This result can be regarded as a generalization of the planar case in a direction that is orthogonal to Theorem 2. Unfortunately, when the class excludes an arbitrary apex graph , we do not know whether one can drop the assumption about the set being provided. Indeed, the fastest parameterized algorithm to find set for which is -minor-free (where is some apex graph) requires quadratic time [50]. We discuss the perspective of handling more general graph classes in Section 6.
1.2 Related Work
Apart from the ones used in this work, there are more VC set systems considered in the context of minor-free graph metrics [7, 8, 21, 22, 26, 39]. Some other approaches to such metrics are based on a decomposition into low-diameter subgraphs, including the classic KPR theorem [41]. Our low-diameter clustering scheme bears resemblance to the shortcut partitions [14, 15, 16] which provide even stronger guarantees but it is not known how to construct them in almost-linear time. The related buffered cop decompositions [16] yield cluster graphs of bounded weak coloring numbers [6]. These in turn are connected to sparse covers [4, 9, 29], however there the low-diameter subgraphs need not to be disjoint.
An alternative way to represent a metric by a bounded treewidth graph is a metric embedding. For example, an edge-weighted planar graph can be embedded into a metric given by a graph of treewidth so that the additive distortion is [32]. The function can be estimated as [14]. For apex-minor-free graphs, the current best treewidth bound is [16]. In the latter case, we again do not know if such an embedding can be computed in almost-linear time. See also [23, 30] for metric embeddings of minor-free graphs and a variant with multiplicative distortion.
1.3 Organization of the Paper
We begin with Section 2 including preliminaries on VC set systems and additive core-sets. The following three sections contain the main technical lemmas. Sections 3 and 4 culminate with the proof of Theorem 2 while Section 5 contains the crucial lemma for Theorem 4. The formal proofs of Theorems 3 and 4 can be found in the full version of the article. The full version also contains the proofs of the statements marked with .
2 Preliminaries
All our statements concern undirected graphs with real positive edge weights. In an unweighted graph, each weight is set to one.
Definition 6 (Treewidth).
A tree decomposition of a graph is a pair where is a tree, and is a function, such that:
-
1.
for each the nodes form a non-empty connected subtree of ,
-
2.
for each edge there is a node with .
The width of is defined as . The treewidth of a graph (denoted is the minimal width a tree decomposition of .
VC dimension.
A set system is a collection of subsets of some set . We say that a subset is shattered by if , that is, every subset of is an intersection of with some . The VC dimension of a set system is the size of the largest shattered subset. The notion of VC dimension was introduced by Vapnik and Chervonenkis [54]. What is important to us, a set system of bounded VC dimension cannot be too large.
Lemma 7 (Sauer–Shelah Lemma [51]).
Let be a set system of VC dimension over a set of size . Then .
2.1 Additive core-sets
For a vector its -norm is defined as .
Definition 8 ([47]).
For a sequence of vertices from we define the distance tuple of with respect to as .
For a vertex set , a subset is called a -additive core-set with respect to if for every there exists such that .
We will take advantage of the bound on VC dimension of certain set systems related to a graph metric. Le and Wulff-Nilsen [46] considered a slight modification of the set systems introduced by Li and Parter [47], and so they denoted them by .
Definition 9 ([46]).
Let be an edge-weighted graph, be a -tuple of vertices from , and . For we define:
Let be a collection of subsets of the ground set .
Theorem 10 ([46, Theorem 1.3]).
Let be an edge-weighted -minor free graph and be as in Definition 9. Then has VC dimension at most .
We adapt the construction of additive core-sets from [47] to rely on the set system .
Lemma 1 (Corollary of [46, Theorem 1.3]). [Restated, see original statement.]
Let be an edge-weighted -minor-free graph , , , and . Then admits an -additive core-set (with respect to ) of size .
Proof.
Let , , and . Next, we choose . We will extend Definition 9 slightly. For vertices we define as the largest integer for which . Note that is always bounded by . For a vertex let be the pair . By Theorem 10 and Lemma 7, the family has size . It follows that the family has elements.
We construct by picking for each an arbitrary vertex with . Then . To show that is an -additive core-set, pick . We need to prove that there exists such that . By construction, there is for which . Now we need to argue that for each it holds that .
The simplest case is for . As , there is an integer such that both belong to the interval . Hence .
Now consider . Let be the largest integer (possibly negative) for which . We define analogously with respect to . Note that . Because it must be . By the same argument as before, the numbers , differ by at most . Finally, since we obtain that .
In our setting we will only know approximations of the distances from . We show that this suffices to construct an additive core-set.
Lemma 11.
Let be an edge-weighted -minor-free graph , , and . Let be given and denote . Next, suppose that for each we are given that satisfies . Then in time we can compute a -additive core-set of of size .
Proof.
We first describe the algorithm, which is a simple greedy construction of a -cover in a metric space. Initialize and iterate over in any fixed order. When processing , check if contains for which . If there is no such element, add to .
First we show that every vector in is within distance in the metric from the set . Suppose otherwise and let be a vertex whose vector is further than from this set. In particular, this means that for each considered before . So must have been added to at this point; a contradiction.
Now we argue that is a -additive core-set. For each we know that there exists such that . Next, by assumption and likewise for . Then by the triangle inequality we get , as intended.
Next, we bound the size . By construction, for each we have . We apply the triangle inequality again to get . By applying Lemma 1 for we obtain so that the -radius balls (in the metric) centered at cover the set . Each such ball has diameter so it can contain at most one element from the set . This implies and so the size bound follows from Lemma 1.
Finally, we analyze the running time. When inspecting a vertex we need to compute distances in between and the vectors of all the vertices already placed in the core-set. This requires at most operations and so the running time bound follows from the bound on .
3 Low Radius Clustering
We begin with summoning the local treewidth property of apex-minor-free graphs.
Lemma 12 ([24]).
For every apex graph , there exists a constant such that for every unweighted -minor-free graph it holds that .
Our first tool is a clustering of a graph into induced subgraphs of small strong diameter.
Definition 13.
For an edge-weighted graph , we define a -radius clustering of as a collection of pairs with the following properties.
-
1.
forms a partition of .
-
2.
For each it holds that is connected, , and each is within distance from in .
For we denote by the cluster graph obtained from by contracting each into a single vertex. The vertex is called the center of the -th cluster.
Note that each cluster in a -radius clustering has strong diameter at most . As our first goal, we aim to construct a -radius clustering, for , whose cluster graph has treewidth . Secondly, even when is chosen to be much smaller we would like to put vertices , satisfying , into “nearby” clusters.
For a graph , a layering is simply a function . When such a function is clear from the context, for we denote by the subgraph of induced by the vertices with . Given a clustering of and a layering of , we naturally extend it to a layering of .
Lemma 14 ().
Let be an apex graph. Given a connected edge-weighted -vertex -minor-free graph and , we can in time find a -radius clustering of and a layering function such that the following hold.
-
1.
For an interval of size , the graph has treewidth .
-
2.
The treewidth of is bounded by .
-
3.
For each and satisfying , it holds that . In this case, there is an interval depending only on , such that and the -distance is the same in and .
The proof constructs the layering by analyzing a shortest-path tree rooted at an arbitrary vertex . Then the -th layer corresponds to vertices whose distance from belongs to . The clustering is obtained by contracting all the edges in connecting vertices sharing the same layer.
Clearly, each root-to-leaf path in traverses at most layers, which bounds the (unweighted) diameter of . Since is a contraction of , it is -minor-free as well and we can take advantage of the local treewidth property. A similar argument yields Item 1 while Item 3 follows from the triangle inequality.
Lemma 12 only guarantees that can be bounded in terms of , without providing an efficient way to construct a tree decomposition. Moreover, the known algorithms for computing optimal (or -approximate) tree decomposition require time exponential in treewidth, whereas we aim at polynomial dependence on . Luckily, there is one algorithm available that suits our needs, with a bit worse width guarantee.
While several algorithms rely on dynamic programming over a tree decomposition to compute the diameter exactly [2, 28, 36], we cannot afford such an strategy due to prohibitive error accumulation. Instead, we will turn the decomposition into a balanced one, again by increasing its width slightly, and use it to build our data structures.
Lemma 15.
There is an algorithm that, given a graph of treewidth at most , runs in time and outputs a binary rooted tree decomposition of of width , depth , and size .
Proof.
4 Processing a Tree Decomposition
We will need an argument to reroute paths to go through a center of some cluster .
Lemma 16.
Let be an edge-weighted graph, , and let be a vertex set contained in the -radius ball around . Suppose there is a shortest -path in that intersects . Then .
Proof.
Orient the path from to and define as the first and the last vertices from appearing on . Since lie on a shortest -path, we have . Next, it holds that each of , is at most . Hence and , which yields the desired inequality.
We will now show how, using a tree decomposition of the cluster graph of width , to construct a distance oracle and estimate eccentricities. We give a unified proof for both statements because the constructed oracle is directly applied to obtain the second result. The presented algorithm is arguably simpler than the recursive schemes based on shortest path separators since in the analysis we only need to manage rounding errors, rather than . We no longer need to assume that the excluded minor is an apex graph and this will allow us later to apply Theorem 17 in a more general setting.
Theorem 17.
Suppose we are given an edge-weighted -vertex -minor-free graph , , a -radius clustering of , and a binary rooted tree decomposition of of width , depth , and size .
-
1.
In time we can build a data structure that, when queried for , outputs in time .
-
2.
Assume additionally that is connected and let . In time we can compute eccentricity of each vertex within additive error . Moreover, within the same time we can also output a vertex for which .
Let us clarify that the parameter does not have to be given and it only appears in the analysis. However, we can always assume that the diameter is known within factor 2 after computing any eccentricity.
Proof.
We begin with some notation that will be used throughout the proof. We will use variables to denote vertices of and variables to index the set of clusters. For a cluster , let denote the node that is closest to the root among those satisfying . We naturally extend this notation to vertices of : all vertices receive . This mapping can be computed for all clusters and vertices in linear time by scanning top-down.
For let denote the set of clusters for which lies in the subtree of rooted at , inclusively. Next, let .
Claim 18.
It holds that , and all the sets can be computed in total time .
Proof.
For each the nodes satisfying must be lie on the -to-root path in and so there are of them. Hence each contributes to the sum , which yields the upper bound as is a partition of . This argument leads directly to an algorithm computing the sets .
Distance oracle.
Consider , , and . We call a valid triple when and . For fixed , the number of valid triples in which appears is at most , and so by Claim 18 the number of valid triples is .
Recall that for the vertex is the center of cluster . We will populate table indexed by valid triples, so that will store the exact -distance within the graph . If there is no such path, we set .
Claim 19.
We can compute for all valid triples in total time .
Proof.
Consider . For each with , we compute all distances from in using the linear single-source shortest path algorithm for -minor-free graphs [52]. The total running time, over all , is proportional to the number of valid triples.
We now argue that information gathered in table is sufficient to retrieve all distances in , up to small additive error. This is the only place where we rely on the fact that each cluster has small strong diameter.
Claim 20.
For each there exist and such that:
-
1.
and are valid triples,
-
2.
.
Proof.
Let be a shortest -path in . Next, let denote the set of clusters intersected by and let be the set of nodes in which appear, i.e., . Since is a contraction of , the subgraph is connected. Consequently, induces a connected subtree of . Let be the node that is closest to the root among . Note that for some .
We claim that the pair satisfies the requested conditions. Note that for each the node lies in the subtree of rooted at . Hence and so . In particular, we obtain that so , are valid triples (Item 1).
Since is a shortest -path and , we infer that the -distance in equals their distance in . Now we apply Lemma 16 to the graph and . Because , we know that intersects . It is crucial that all -vertices are within distance from when considering distances within (Definition 13(2)), not just in . As , this property carries over to the graph . Lemma 16 implies that . We have , , and , which yields Item 2.
Claim 21 (Oracle).
Let be given. Using the table we can output in time .
Proof.
We iterate over all pairs for which and are valid triples. There are only candidates for just because is a valid triple and so must lie on the -to-root path. For each such there are clearly at most candidates for .
We return equal to the minimum value of taken over all such pairs . For each the considered sum is either or it equals the length of some -walk in . This implies that . The inequality follows from Claim 20.
Claims 19 and 21 yield the additive distance oracle (Item 1). Now we move on to a proof sketch of Item 2, whose complete proof can be found in the full version of the paper.
Eccentricities.
For a non-root we refer to its parent in as . For let denote the value returned by the oracle from Claim 21 when queried for the pair . This is a well-defined function because the oracle is deterministic. Recall the concept of an additive core-set from Lemma 1 and that .
Claim 22 ().
In total time we can compute for each non-root a subset of size that is a -additive core-set of with respect to .
The total number of distances we care about is . Each of them can be estimated using the oracle in time . We would like to use those numbers to compute the additive core-sets, however a priori the bound from Lemma 1 might not hold for approximate distances. Nevertheless, we prove that a greedy procedure still constructs a small core-set, even after perturbation of distances. A similar issue is handled in [47] via randomization but we can afford a simpler argument because our strategy allows us to first query the oracle for all the distances between and .
In the next claim, we argue that the core-sets suffice to estimate the maximal distance between and , where is fixed and is quantified over all vertices from some subtree. There are three sources of accuracy loss: relying on the additive core-set, on the approximate distance oracle, and stretching the paths along a center from (Lemma 16).
Claim 23 ().
Consider with children . Let and be a -additive core-set with respect to . Let over all , and be defined as follows:
Then . Furthermore, the vertex realizing satisfies .
We now use the additive core-sets to estimate the eccentricity of a vertex. Essentially, we apply Claim 23 for each choice of the lowest common ancestor of ; hence times.
Claim 24 ().
For a given vertex we can compute its eccentricity within additive error in time . Within the same time, we can output a vertex for which .
Theorem 17(2) follows by applying Claim 24 to each vertex.
Theorem 2. [Restated, see original statement.]
Let be an apex graph of size . There is an algorithm that, given an edge-weighted -minor-free graph and , runs in time and estimates eccentricity of each vertex vertex within additive error . Moreover, for each the algorithm outputs vertex for which .
Proof.
One can assume that is connected as otherwise the diameter is . We compute the eccentricity of an arbitrary vertex : this can be done in linear time [52]. The diameter of must be contained in . We apply Lemma 14 for in time ; let denote the obtained -radius clustering. Next, let ; note that . By Lemma 14(2) we know that . We use Lemma 15 to build a binary tree decomposition of of width , depth and size ; this takes time . Now we can take advantage of Theorem 17(2) to compute the eccentricities of all vertices within additive error , together with vertices that realize these distance approximately. This takes time . Finally, observe that is greater than 1 in any non-trivial instance so and so the time needed to compute the tree decomposition is negligible.
In the full version of the article we show how to replace additive error in the distance oracle with multiplicative one, which yields Theorem 3.
5 Handling Apices
We move on to the proof of Theorem 4, extending the diameter approximation to graphs with an apex set , for which is apex-minor-free. We do not formulate an analogous theorem generalizing the distance oracle because it is trivial. To see this, first precompute all the distances from each and then, given , return the minimum of their distance in and . The first scenario can be readily handled with the same data structure as in Theorem 3.
The reason why we cannot apply the same reduction for diameter computation is that might be huge compared to . Hence we lose the relation between the diameter and radii of clusters (governing the additive error), crucial to bound the treewidth of the cluster graph. As a remedy, we will first preprocess the graph to chop it into connected components of bounded diameter.
Lemma 25.
Let be a fixed graph and . Let be a connected edge-weighted -vertex connected graph, be such that is -minor-free and , and satisfy . There is an algorithm that, given the above and , runs in time and either correctly reports that or outputs a connected edge-weighted -vertex graph and of size , with the following guarantees.
-
1.
is -minor-free.
-
2.
.
-
3.
If then .
-
4.
Each connected component of has strong diameter at most .
Proof.
First of all, we remove all edges with weight larger then as they cannot contribute to any shortest path. Observe that is -minor-free for . We compute shortest paths from each vertex using the linear SSSP algorithm for minor-free graphs [52]. If any computed distance is greater than , we can terminate the algorithm. Otherwise for each , , we insert the -edge with weight or update the weight if the edge is already present. This preserves all the pairwise distances in and does not affect the graph . We will keep the variable to refer to the modified graph. The performed modification ensures the following property.
Claim 26.
Let and suppose that there is a shortest -path in that intersects . Then there is a shortest -path with one internal vertex that belongs to .
For let denote the largest integer for which . For we define its signature as where is some fixed ordering of . Let . Since we have not terminated the algorithm in the first step, each is most and so .
We say that a pair is relevant if for each we have . We also call relevant if it appears in at least one relevant pair.
Claim 27.
Let be such that is a relevant pair. Then there is no -path of length that goes through .
Proof.
If there was such a path then for some . But for each we have .
Claim 28.
Let be such that and is relevant. If then .
Proof.
Suppose that . Since is relevant, there exists such that is a relevant pair. Due to Claim 27, the shortest -path avoids so . By the same argument and the claim follows from the triangle inequality.
For each relevant let us choose an arbitrary with ; we denote the set of chosen vertices as . Clearly . For each we compute all the distances from in in linear time and check whether there is any with and . If so, then by Claim 28 we can again terminate the algorithm.
Claim 29.
Suppose that the algorithm has not been terminated and let be the set of vertices satisfying for all . Next, let be the set of edges from with at least one endpoint in . Suppose that . Then .
Proof.
Consider and let be a shortest -path in . By assumption, is not longer than . We need to show that there is a -path of length that avoids . If intersects then by Claim 26 we can assume that consists only of edges incident to (at most two). Then clearly avoids .
Suppose now that and that uses some edge from . Then there is whose distance in to each of is at most . We claim that are irrelevant. Assume w.l.o.g. that is relevant and let be the chosen vertex with . We have as otherwise we would have terminated the algorithm due to Claim 28. But so . This contradicts the property used to define .
We established that are irrelevant, so the pair is also irrelevant. By definition, this means that there is such that . We have and likewise for the pair . We estimate
Hence the path is sufficiently short and it avoids . The claim follows.
We showed that removing all edges from is safe for approximating the diameter of . It remains to prove that this operation splits into pieces of bounded strong diameter.
Claim 30.
Let be a set of vertices inducing a connected component of . Then .
Proof.
For let be the set of vertices within distance from in . Observe that is either a single vertex from or a union of for for some . In the first case the diameter is 0 so let us focus on the second case.
Let and be a shortest -path in . Then for some . Let be the farthest vertex on (counting from ) that belongs to . The -distance in is at most their distance in so as is a shortest path. Next, take to be the next vertex on after and pick satisfying . Analogously as before, we find the vertex that is farthest on and continue this process. By construction, every vertex appears at most once as so this splits into at most subpaths of length . Also for each the edge between and has weight at most because we have removed all the heavier edges at the very beginning. The claim follows from .
We check that and satisfy all the points of the lemma. First, is a subgraph of so it remains -minor-free. Next, removing edges can only increase the diameter so while the second inequality follows from Claim 29. The diameter bound for components of has been given in Claim 30. Finally, the sets and can be identified in time .
We briefly explain how Lemma 25 leads to Theorem 4. Given we want to learn that or that . Let be the output given by Lemma 25 and . Each connected component of satisfies . We apply Lemma 14 to get a -radius clustering of so that the treewidth of the cluster graph is . We combine those to get a -radius clustering of by assigning each a singleton cluster.
Using Lemma 15 we can compute a balanced tree decomposition of of width . It can be now processed with Theorem 17(2): in time we can estimate within additive error . If this value is too large, we learn that , implying . Otherwise we infer that . Repeating this procedure for different allows us to estimate within multiplicative error . The details can be found in the full version of the article.
6 Conclusion and Open Problems
We have presented almost-linear algorithms approximating diameter that bypass topological arguments and work way beyond surface-embeddable graphs. A natural next step would be to generalize these results further, to all graph classes excluding a minor. The reason why we could not extend Corollary 5 to all cases covered in Theorem 4 is that we need to know the deletion set to the apex-minor-free class. The best known algorithm finding such a set requires quadratic time [50]. To apply the same strategy for the general case of -minor-free graphs, one would need to compute some form of the Robertson and Seymour’s decomposition, which seems an even harder task. However, recent advances in minor testing [43] suggest that this may be possible in time (see the section “Outlook” there). We have not attempted to generalize Theorem 4 to work on such decompositions because (1) this would require a tedious analysis of a balanced tree decomposition of the clique-sum decomposition, and (2) this strategy currently seems hopeless to achieve running time . Is there an alternative approach that would work without the decomposition at hand?
Another question is whether one can improve the dependence on to or even ? The current running time bound follows from the fact that we need to precompute distances and each oracle call requires time . Can this be improved? For example, for planar metrics there exist distance oracles with constant query time (for constant albeit with preprocessing time [12, 45].
When it comes to the dependence on , our running time is burdened by the fact that for -treewidth graphs we compute a tree decomposition of width . Unfortunately, all the known almost-linear -approximation algorithms for treewidth require time exponential in . Since we rely on a construction from [31] that works for general graphs, it is tempting to improve the width guarantee therein when the input graph is -minor-free. Again, this is doable in planar graphs [38].
References
- [1] Amir Abboud, Shay Mozes, and Oren Weimann. What Else Can Voronoi Diagrams Do for Diameter in Planar Graphs? In Inge Li Gørtz, Martin Farach-Colton, Simon J. Puglisi, and Grzegorz Herman, editors, 31st Annual European Symposium on Algorithms (ESA 2023), volume 274 of Leibniz International Proceedings in Informatics (LIPIcs), pages 4:1–4:20, Dagstuhl, Germany, 2023. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ESA.2023.4.
- [2] Amir Abboud, Virginia Vassilevska Williams, and Joshua R. Wang. Approximation and fixed parameter subquadratic algorithms for radius and diameter in sparse graphs. In Robert Krauthgamer, editor, Proceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2016, Arlington, VA, USA, January 10-12, 2016, pages 377–391. SIAM, 2016. doi:10.1137/1.9781611974331.CH28.
- [3] Ittai Abraham and Cyril Gavoille. Object location using path separators. In Proceedings of the twenty-fifth annual ACM symposium on Principles of distributed computing, pages 188–197, 2006. doi:10.1145/1146381.1146411.
- [4] Ittai Abraham, Cyril Gavoille, Dahlia Malkhi, and Udi Wieder. Strong-diameter decompositions of minor free graphs. In Proceedings of the nineteenth annual ACM symposium on Parallel algorithms and architectures, pages 16–24, 2007. doi:10.1145/1248377.1248381.
- [5] Francisco Barahona. The max-cut problem on graphs not contractible to . Operations Research Letters, 2(3):107–111, 1983. doi:10.1016/0167-6377(83)90016-0.
- [6] Romain Bourneuf and Marcin Pilipczuk. Bounding -scatter dimension via metric sparsity. In Yossi Azar and Debmalya Panigrahi, editors, Proceedings of the 2025 Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2025, New Orleans, LA, USA, January 12-15, 2025, pages 3155–3171. SIAM, 2025. doi:10.1137/1.9781611978322.101.
- [7] Nicolas Bousquet and Stéphan Thomassé. VC-dimension and Erdős–Pósa property. Discrete Mathematics, 338(12):2302–2317, 2015. doi:10.1016/j.disc.2015.05.026.
- [8] Vladimir Braverman, Shaofeng H-C Jiang, Robert Krauthgamer, and Xuan Wu. Coresets for clustering in excluded-minor graphs and beyond. In Proceedings of the 2021 ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 2679–2696. SIAM, 2021. doi:10.1137/1.9781611976465.159.
- [9] Costas Busch, Ryan LaFortune, and Srikanta Tirthapura. Sparse covers for planar graphs and graphs that exclude a fixed minor. Algorithmica, 69:658–684, 2014. doi:10.1007/s00453-013-9757-4.
- [10] 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. doi:10.1145/3218821.
- [11] Dibyayan Chakraborty and Kshitij Gajjar. Finding geometric representations of apex graphs is NP-hard. Theor. Comput. Sci., 971:114064, 2023. doi:10.1016/J.TCS.2023.114064.
- [12] Timothy M. Chan and Dimitrios Skrepetos. Faster Approximate Diameter and Distance Oracles in Planar Graphs. In Kirk Pruhs and Christian Sohler, editors, 25th Annual European Symposium on Algorithms (ESA 2017), volume 87 of Leibniz International Proceedings in Informatics (LIPIcs), pages 25:1–25:13, Dagstuhl, Germany, 2017. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ESA.2017.25.
- [13] Timothy M. Chan and Dimitrios Skrepetos. Approximate shortest paths and distance oracles in weighted unit-disk graphs. Journal of Computational Geometry, 10(2):3–20, February 2019. doi:10.20382/jocg.v10i2a2.
- [14] Hsien-Chih Chang, Jonathan Conroy, Hung Le, Lazar Milenkovic, Shay Solomon, and Cuong Than. Covering planar metrics (and beyond): trees suffice. In 2023 IEEE 64th Annual Symposium on Foundations of Computer Science (FOCS), pages 2231–2261. IEEE, 2023. doi:10.1109/FOCS57990.2023.00139.
- [15] Hsien-Chih Chang, Jonathan Conroy, Hung Le, Lazar Milenkovic, Shay Solomon, and Cuong Than. Resolving the steiner point removal problem in planar graphs via shortcut partitions. arXiv preprint arXiv:2306.06235, 2023. doi:10.48550/arXiv.2306.06235.
- [16] Hsien-Chih Chang, Jonathan Conroy, Hung Le, Lazar Milenković, Shay Solomon, and Cuong Than. Shortcut partitions in minor-free graphs: Steiner point removal, distance oracles, tree covers, and more. In Proceedings of the 2024 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 5300–5331. SIAM, 2024. doi:10.1137/1.9781611977912.191.
- [17] Hsien-Chih Chang, Jie Gao, and Hung Le. Computing Diameter+2 in Truly-Subquadratic Time for Unit-Disk Graphs. In Wolfgang Mulzer and Jeff M. Phillips, editors, 40th International Symposium on Computational Geometry (SoCG 2024), volume 293 of Leibniz International Proceedings in Informatics (LIPIcs), pages 38:1–38:14, Dagstuhl, Germany, 2024. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.SoCG.2024.38.
- [18] Hsien-Chih Chang, Robert Krauthgamer, and Zihan Tan. Almost-linear -emulators for planar graphs. In Stefano Leonardi and Anupam Gupta, editors, STOC ’22: 54th Annual ACM SIGACT Symposium on Theory of Computing, Rome, Italy, June 20 - 24, 2022, pages 1311–1324. ACM, 2022. doi:10.1145/3519935.3519998.
- [19] Panagiotis Charalampopoulos, Paweł Gawrychowski, Yaowei Long, Shay Mozes, Seth Pettie, Oren Weimann, and Christian Wulff-Nilsen. Almost optimal exact distance oracles for planar graphs. Journal of the ACM, 70(2):1–50, 2023. doi:10.1145/3580474.
- [20] Krishnendu Chatterjee, Rasmus Ibsen-Jensen, and Andreas Pavlogiannis. Optimal tree-decomposition balancing and reachability on low treewidth graphs. IST Austria, 2014. doi:10.15479/AT:IST-2014-314-v1-1.
- [21] Victor Chepoi, Bertrand Estellon, and Yann Vaxès. Covering planar graphs with a fixed number of balls. Discret. Comput. Geom., 37(2):237–244, 2007. doi:10.1007/S00454-006-1260-0.
- [22] Vincent Cohen-Addad, Andrew Draganov, Matteo Russo, David Saulpic, and Chris Schwiegelshohn. A tight VC-dimension analysis of clustering coresets with applications. In Yossi Azar and Debmalya Panigrahi, editors, Proceedings of the 2025 Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2025, New Orleans, LA, USA, January 12-15, 2025, pages 4783–4808. SIAM, 2025. doi:10.1137/1.9781611978322.162.
- [23] Vincent Cohen-Addad, Hung Le, Marcin Pilipczuk, and Michal Pilipczuk. Planar and minor-free metrics embed into metrics of polylogarithmic treewidth with expected multiplicative distortion arbitrarily close to 1. In 64th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2023, Santa Cruz, CA, USA, November 6-9, 2023, pages 2262–2277. IEEE, 2023. doi:10.1109/FOCS57990.2023.00140.
- [24] Erik D. Demaine and Mohammad Taghi Hajiaghayi. Equivalence of local treewidth and linear local treewidth and its algorithmic applications. In J. Ian Munro, editor, Proceedings of the Fifteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2004, New Orleans, Louisiana, USA, January 11-14, 2004, pages 840–849. SIAM, 2004. URL: https://dl.acm.org/doi/10.5555/982792.982919.
- [25] Erik D. Demaine, MohammadTaghi Hajiaghayi, and Ken-ichi Kawarabayashi. Approximation algorithms via structural results for apex-minor-free graphs. In Susanne Albers, Alberto Marchetti-Spaccamela, Yossi Matias, Sotiris E. Nikoletseas, and Wolfgang Thomas, editors, Automata, Languages and Programming, 36th International Colloquium, ICALP 2009, Rhodes, Greece, July 5-12, 2009, Proceedings, Part I, volume 5555 of Lecture Notes in Computer Science, pages 316–327. Springer, 2009. doi:10.1007/978-3-642-02927-1_27.
- [26] 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 Journal on Computing, 51(5):1506–1534, 2022. doi:10.1137/20M136551X.
- [27] Lech Duraj, Filip Konieczny, and Krzysztof Potepa. Better diameter algorithms for bounded vc-dimension graphs and geometric intersection graphs. In Timothy M. Chan, Johannes Fischer, John Iacono, and Grzegorz Herman, editors, 32nd Annual European Symposium on Algorithms, ESA 2024, September 2-4, 2024, Royal Holloway, London, United Kingdom, volume 308 of LIPIcs, pages 51:1–51:18. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2024. doi:10.4230/LIPICS.ESA.2024.51.
- [28] David Eppstein. Diameter and treewidth in minor-closed graph families. Algorithmica, 27(3):275–291, 2000. doi:10.1007/S004530010020.
- [29] Arnold Filtser. On sparse covers of minor free graphs, low dimensional metric embeddings, and other applications. CoRR, abs/2401.14060, 2024. doi:10.48550/arXiv.2401.14060.
- [30] Arnold Filtser and Hung Le. Low treewidth embeddings of planar and minor-free metrics. In 2022 IEEE 63rd Annual Symposium on Foundations of Computer Science (FOCS), pages 1081–1092, 2022. doi:10.1109/FOCS54457.2022.00105.
- [31] Fedor V. Fomin, Daniel Lokshtanov, Saket Saurabh, Michal Pilipczuk, and Marcin Wrochna. Fully polynomial-time parameterized computations for graphs and matrices of low treewidth. ACM Trans. Algorithms, 14(3):34:1–34:45, 2018. doi:10.1145/3186898.
- [32] Eli Fox-Epstein, Philip N. Klein, and Aaron Schild. Embedding planar graphs into low-treewidth graphs with applications to efficient approximation schemes for metric problems. In Timothy M. Chan, editor, Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2019, San Diego, California, USA, January 6-9, 2019, pages 1069–1088. SIAM, 2019. doi:10.1137/1.9781611975482.66.
- [33] Viktor Fredslund-Hansen, Shay Mozes, and Christian Wulff-Nilsen. Truly Subquadratic Exact Distance Oracles with Constant Query Time for Planar Graphs. In Hee-Kap Ahn and Kunihiko Sadakane, editors, 32nd International Symposium on Algorithms and Computation (ISAAC 2021), volume 212 of Leibniz International Proceedings in Informatics (LIPIcs), pages 25:1–25:12, Dagstuhl, Germany, 2021. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ISAAC.2021.25.
- [34] Pawel Gawrychowski, Haim Kaplan, Shay Mozes, Micha Sharir, and Oren Weimann. Voronoi diagrams on planar graphs, and computing the diameter in deterministic õ(n) time. SIAM J. Comput., 50(2):509–554, 2021. doi:10.1137/18M1193402.
- [35] Pawel Gawrychowski, Shay Mozes, Oren Weimann, and Christian Wulff-Nilsen. Better tradeoffs for exact distance oracles in planar graphs. In Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 515–529. SIAM, 2018. doi:10.1137/1.9781611975031.34.
- [36] Thore Husfeldt. Computing Graph Distances Parameterized by Treewidth and Diameter. In Jiong Guo and Danny Hermelin, editors, 11th International Symposium on Parameterized and Exact Computation (IPEC 2016), volume 63 of Leibniz International Proceedings in Informatics (LIPIcs), pages 16:1–16:11, Dagstuhl, Germany, 2017. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.IPEC.2016.16.
- [37] Bart M. P. Jansen, Daniel Lokshtanov, and Saket Saurabh. A near-optimal planarization algorithm. In Chandra Chekuri, editor, Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2014, Portland, Oregon, USA, January 5-7, 2014, pages 1802–1811. SIAM, 2014. doi:10.1137/1.9781611973402.130.
- [38] Frank Kammer and Torsten Tholey. Approximate tree decompositions of planar graphs in linear time. Theor. Comput. Sci., 645:60–90, 2016. doi:10.1016/J.TCS.2016.06.040.
- [39] Adam Karczmarz and Da Wei Zheng. Subquadratic algorithms in minor-free digraphs: (weighted) distance oracles, decrementai reachability, and more. In Yossi Azar and Debmalya Panigrahi, editors, Proceedings of the 2025 Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2025, New Orleans, LA, USA, January 12-15, 2025, pages 4338–4351. SIAM, 2025. doi:10.1137/1.9781611978322.147.
- [40] Ken-ichi Kawarabayashi, Philip N Klein, and Christian Sommer. Linear-space approximate distance oracles for planar, bounded-genus and minor-free graphs. In International Colloquium on Automata, Languages, and Programming, pages 135–146. Springer, 2011. doi:10.1007/978-3-642-22006-7_12.
- [41] Philip Klein, Serge A. Plotkin, and Satish Rao. Excluded minors, network decomposition, and multicommodity flow. In Proceedings of the Twenty-Fifth Annual ACM Symposium on Theory of Computing, STOC ’93, pages 682–690, New York, NY, USA, 1993. Association for Computing Machinery. doi:10.1145/167088.167261.
- [42] Kacper Kluk, Marcin Pilipczuk, Michal Pilipczuk, and Giannos Stamoulis. Faster diameter computation in graphs of bounded Euler genus. In Keren Censor-Hillel, Fabrizio Grandoni, Joël Ouaknine, and Gabriele Puppis, editors, 52nd International Colloquium on Automata, Languages, and Programming, ICALP 2025, July 8-11, 2025, Aarhus, Denmark, volume 334 of LIPIcs, pages 109:1–109:19. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2025. doi:10.4230/LIPICS.ICALP.2025.109.
- [43] Tuukka Korhonen, Michal Pilipczuk, and Giannos Stamoulis. Minor containment and disjoint paths in almost-linear time. In 65th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2024, Chicago, IL, USA, October 27-30, 2024, pages 53–61. IEEE, 2024. doi:10.1109/FOCS61266.2024.00014.
- [44] Hung Le. Approximate distance oracles for planar graphs with subpolynomial error dependency. In Nikhil Bansal and Viswanath Nagarajan, editors, Proceedings of the 2023 ACM-SIAM Symposium on Discrete Algorithms, SODA 2023, Florence, Italy, January 22-25, 2023, pages 1877–1904. SIAM, 2023. doi:10.1137/1.9781611977554.CH72.
- [45] Hung Le and Christian Wulff-Nilsen. Optimal approximate distance oracle for planar graphs. In 62nd IEEE Annual Symposium on Foundations of Computer Science, FOCS 2021, Denver, CO, USA, February 7-10, 2022, pages 363–374. IEEE, 2021. doi:10.1109/FOCS52979.2021.00044.
- [46] Hung Le and Christian Wulff-Nilsen. VC set systems in minor-free (di)graphs and applications. In David P. Woodruff, editor, Proceedings of the 2024 ACM-SIAM Symposium on Discrete Algorithms, SODA 2024, Alexandria, VA, USA, January 7-10, 2024, pages 5332–5360. SIAM, 2024. doi:10.1137/1.9781611977912.192.
- [47] Jason Li and Merav Parter. Planar diameter via metric compression. In Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing, pages 152–163, 2019. doi:10.1145/3313276.3316358.
- [48] Neil Robertson and Paul D Seymour. Graph minors. XVI. Excluding a non-planar graph. Journal of Combinatorial Theory, Series B, 89(1):43–76, 2003. doi:10.1016/S0095-8956(03)00042-X.
- [49] Liam Roditty and Virginia Vassilevska Williams. Fast approximation algorithms for the diameter and radius of sparse graphs. In Proceedings of the Forty-Fifth Annual ACM Symposium on Theory of Computing, STOC ’13, pages 515–524, New York, NY, USA, 2013. Association for Computing Machinery. doi:10.1145/2488608.2488673.
- [50] Ignasi Sau, Giannos Stamoulis, and Dimitrios M. Thilikos. k-apices of Minor-closed Graph Classes. II. Parameterized Algorithms. ACM Trans. Algorithms, 18(3):21:1–21:30, 2022. doi:10.1145/3519028.
- [51] Norbert Sauer. On the density of families of sets. Journal of Combinatorial Theory, Series A, 13(1):145–147, 1972. doi:10.1016/0097-3165(72)90019-2.
- [52] Siamak Tazari and Matthias Müller-Hannemann. Shortest paths in linear time on minor-closed graph classes, with an application to steiner tree approximation. Discret. Appl. Math., 157(4):673–684, 2009. doi:10.1016/J.DAM.2008.08.002.
- [53] Mikkel Thorup. Compact oracles for reachability and approximate distances in planar digraphs. J. ACM, 51(6):993–1024, November 2004. doi:10.1145/1039488.1039493.
- [54] Vladimir N Vapnik and A Ya Chervonenkis. On the uniform convergence of relative frequencies of events to their probabilities. In Measures of complexity: festschrift for alexey chervonenkis, pages 11–30. Springer, 2015. doi:10.1007/978-3-319-21852-6_3.
- [55] Oren Weimann and Raphael Yuster. Approximating the diameter of planar graphs in near linear time. ACM Transactions on Algorithms (TALG), 12(1):1–13, 2015. doi:10.1145/2764910.
