For any undefined graph terminology, see [5, 19]. We study the fundamental problems of computing, for a given undirected unweighted graph, its diameter and its radius. There is a textbook algorithm for solving both problems in time on -vertex -edge graphs. However, it is a direct reduction to All-Pairs Shortest-Paths (APSP), that is a seemingly more complex problem with a much larger (quadratic-size) output than for the diameter and radius problems. On one hand, there is a long line of work presenting more efficient – often linear-time – algorithms for computing the diameter and/or the radius on some special graph classes [1, 9, 10, 11, 12, 14, 15, 17, 18, 21, 23, 25, 26, 27, 28, 29, 30, 37]. On the other hand, under the Strong Exponential-Time Hypothesis (SETH) and the Hitting Set Conjecture (HS), respectively, we cannot solve either of these two problems in truly subquadratic-time [1, 38]111 By truly subquadratic we mean a running-time in , for some positive such that ..
We aim at characterizing the graph classes for which these above (SETH- or HS-) “hardness” results do not hold. Ideally we would like to derive a dichotomy theorem, not unlike those proved in  but covering many more subquadratic-time solvable special cases from the literature. Our work is part of a recent series of papers, with co-authors, where we try to reach this objective based on tools and concepts from Computational Geometry [25, 26, 27]. – See also [1, 11] for some pioneering works in this line of research. – Specifically, a class of hypergraphs has fractional Helly number at most if for any positive there is some positive such that, in any subfamily of hyperedges in a hypergraph of , if there is at least a fraction of all the -tuples of hyperedges with a non-empty common intersection, then there exists an element that is contained in a fraction at least of all hyperedges in this subfamily. Then, the fractional Helly number of a graph class is the fractional Helly number of the family of the ball hypergraphs of all graphs in . For instance Matousek proved that every hypergraph of VC-dimension has its fractional Helly number that is upper bounded by a function of . It implies that the graphs of bounded distance VC-dimension, studied in [8, 27], have a bounded fractional Helly number. Note that the latter graphs comprise planar graphs, bounded clique-width graphs and interval graphs amongst other subclasses of interest. Motivated by the results from  on diameter and radius computation in these graphs, we ask whether we can compute the diameter and the radius in truly subquadratic time within graph classes of constant fractional Helly number. As a first step toward resolving this question, our current research focuses on the simpler class of Helly graphs. Recall that a graph is Helly if any family of pairwise intersecting balls has a non-empty common intersection. So, in particular, Helly graphs have fractional Helly number two. Furthermore, we stress that the Helly graphs are one of the most studied classes in Metric Graph Theory (e.g., see the survey  and the papers cited therein).
There is a positive such that, for every -vertex -edge Helly graph, we can compute its diameter and its radius in time .
We note that proving Conjecture 1 already looks like a challenging task. To the best of our knowledge, until this work the only known result in this direction was a positive answer to this conjecture for the class of dually chordal graphs . Hence, the relative hardness of proving Conjecture 1 motivated us to also study the complexity of diameter and radius computations on more restricted subclasses, such as chordal Helly graphs or more generally -free Helly graphs. – This latter choice was also partly motivated by a nice characterization of hereditary Helly graphs: indeed, they are exactly the -sun-free chordal graphs . – We stress that it is already SETH-hard to compute the diameter on chordal graphs in truly subquadratic time . On the positive side, there exist linear-time algorithms for computing the radius on general chordal graphs , and the diameter on various subclasses of chordal graphs, e.g. interval graphs, directed path graphs and strongly chordal graphs [9, 15, 22]. Most of these special cases, including the three aforementioned examples, are strict subclasses of chordal Helly graphs. As a result, our work pushes forward the tractability border for diameter computation on chordal graphs and beyond.
Our first main result in the paper is a truly subquadratic-time algorithm for computing the radius of Helly graphs (Theorem 1). We can also directly derive from this algorithm an additive -approximation of the diameter. Our algorithm runs in time w.h.p., and it uses as its main ingredient some weak consequence of the unimodality of the eccentricity function of Helly graphs : every local minimum of the eccentricity function in a Helly graph is a global minimum. From a positive point of view this might look like a major step toward proving Conjecture 1. However, the complexity of computing the diameter on Helly graphs remains open. From a negative point of view this current situation could be compared with the case of chordal graphs: for which we can compute the radius  and an additive -approximation of the diameter [15, 22] in linear time, but for which it is SETH-hard to compute the diameter exactly in truly subquadratic time .
Next we focus on the class of -free Helly graphs, which have been studied on their own and have more interesting convexity properties than general Helly graphs [23, 20]. In particular, the center of a -free Helly graph is convex and it has diameter at most 3 and radius at most 2 [23, 20]. In contrast, the center of a general Helly graph is isometric but it can have arbitrarily large diameter; in fact, any Helly graph is the center of some other Helly graph .
We stress that -free Helly graphs encompass the bridged Helly graphs and all Helly graphs of hyperbolicity , amongst other examples.
By restricting ourselves to this subclass we can use the well-known multi-sweep heuristic of Corneil et al.
, amongst other examples. By restricting ourselves to this subclass we can use the well-known multi-sweep heuristic of Corneil et al., in order to compute vertices of provably large eccentricity, as a brick-basis for exact linear-time algorithms for computing both a central vertex and the diameter. Our general approach for these graphs is also partly inspired by the algorithms of Chepoi and Dragan  and Dragan and Nicolai , in order to compute a central vertex in chordal graphs and a diametral pair in distance-hereditary graphs, respectively. We stress that in contrast to this positive result on -free Helly graphs, and as notified to us by Chepoi (private communication), a similar method cannot apply to general Helly graphs. Indeed, the values obtained for Helly graphs with the multi-sweep heuristic can be arbitrarily far from the diameter, which comes from the property that any graph can be isometrically embedded into a Helly graph [24, 34].
Furthermore, our results for -free Helly graphs go beyond the mere calculation of the diameter and the radius. Indeed, we are able to compute the eccentricity of all vertices, which for Helly graphs can be reduced to computing the graph center. For that, we first need to solve the related problem of computing a diametral pair (i.e., a pair of vertices of which the distance in the graph equals the diameter), which surprisingly requires a more intricate approach than for just computing the diameter. This intermediate result has interesting consequences on its own. For instance, if we apply our algorithms on an arbitrary chordal graph, then we can use a (supposedly) diametral pair in order to decide, in linear time, if either we computed the diameter correctly or the input graph is not Helly. See Remark 2 for more details. Note that in comparison, the best-known recognition algorithms for chordal Helly graphs run in time . Our two main ingredients in order to solve these above problems are (i) a “pseudo-gatedness” property of the subsets of weak diameter at most two in -free Helly graphs, and (ii) a reduction from finding a diametral pair under some technical assumptions to the same problem on a related split Helly graph. We find the latter result all the more interesting that split graphs are amongst the hardest instances for diameter computation . As one of our main technical contributions in this part, we solve a variant of Hitting Set  on Helly graphs. This general result can be used, e.g. in order to compute all vertices of eccentricity three in a split Helly graph.
Finally, our above investigations on -free Helly graphs lead us to the following natural research question: what are the other graph classes where the diameter can be efficiently computed from a subfamily of split graphs? In particular, can we reduce diameter computation on general chordal graphs to the same problem on split graphs?
This would imply that the subclass of split graphs is, in some sense, the sole hard case for diameter computation on chordal graphs.
Furthermore, this could help in finding new subclasses of chordal graphs for which we can compute the diameter faster than in .
We answer positively to this open question, but in a more restricted setting (Theorem 5).
Specifically, our reduction is indeed from diameter computation on chordal graphs to the same problem on split graphs, but the computational results which we obtain are better if then we reduce to the well-known Disjoint Set problem – a.k.a. the monochromatic Orthogonal Vector
Orthogonal Vectorproblem. We stress that there is a trivial linear-time reduction from diameter computation on split graphs to Disjoint Set, but the converse reduction from this problem to computing the diameter of a related split graph runs in time quadratic in the number of elements in the ground set of the input family. This is evidence that Disjoint Set might be a harder problem than diameter computation on split graphs – at least in some density regimes.
As a byproduct of our reduction, we prove that the diameter can be computed in truly subquadratic time on any subclass of chordal graphs with constant VC-dimension (Theorem 6). This nicely complements the results from , which mostly apply to sparse graph classes of constant distance VC-dimension or assuming a bounded (sublinear) diameter.
Throughout the remainder of the paper, we denote by the distance between vertices and . The metric interval between and is defined as . For any , we can also define the slice . The ball of radius and center is defined as , and denoted . In particular, and denote the closed and open neighbourhoods of a vertex , respectively. More generally, for any vertex-subset we define . The metric projection of a vertex on , denoted , is defined as . The eccentricity of a vertex is defined as and denoted by . We also define the set of all the farthest vertices from vertex . – Note that we will omit the subscript if the graph is clear from the context. – The radius and the diameter of a graph are denoted and , respectively. Finally, is the center of , a.k.a. the set of all the central vertices of .
2 Fast Radius computation within Helly graphs
We start this section with a simple randomized test, which is inspired from previous works on adaptive greedy set cover algorithms .
Let be a graph, let be a positive integer and let . There is an algorithm that w.h.p. computes a set in time with the following two properties:
if then ;
conversely, if then .
Let for some arbitrary large constant . If then , and so we can compute the set of all the vertices of eccentricity at most in time by running a BFS from every vertex.
From now on we assume that .
By we mean a subset in which every vertex was added independently at random with probability
we mean a subset in which every vertex was added independently at random with probability. Observe that we have . By Chernoff bounds we get with probability . Then, for every , we compute , which takes total time . We divide our analysis in two cases. First let us assume that . Then, with probability we have . Second, let us assume that . We get . Overall, let contain all the vertices such that . By a union bound over vertices, the set satisfies our two above-stated properties with probability . ∎
We derive from this simple test above an approximation algorithm for computing the radius and the diameter, namely:
Let be a graph and be a positive integer. There is an algorithm that w.h.p. runs in time and such that:
If the algorithm accepts then ;
If the algorithm rejects then .
Note that since , this algorithm rejects any graph with . However, it might also reject some graphs such that but .
For some to be defined later, we construct a set as in Lemma 1. W.h.p. it takes time . There are two cases. If then we know that and we stop. Otherwise, we pick any vertex and we compute . Here it is important to observe that all the vertices of are pairwise at a distance . Furthermore, w.h.p. we have . We end up computing a BFS from every vertex of , accepting in the end if and only if all these vertices have eccentricity . By setting , the total running time is w.h.p. in . ∎
An important consequence of Lemma 2 is that the hard instances for diameter and radius approximations are those for which the difference is large, namely:
If then, w.h.p., we can compute an additive -approximation of and an additive -approximation of in total time.
We compute by dichotomic search the smallest such that the algorithm of Lemma 2 accepts. Note that w.h.p. , and so . Furthermore, we have w.h.p. , and so . We output and as approximations of and , respectively. ∎
Application to Helly graphs.
For Helly graphs, the diameter and the radius are closely related. This is a consequence of the unimodality property of the eccentricity function of Helly graphs , a property that will be further discussed in the next section. In particular, the following relations hold between the two:
Lemma 3 ().
If is a Helly graph then . In particular, .
If is a Helly graph then, w.h.p., we can compute and an additive -approximation of in time .
3 Journey to the Center of -free Helly graphs
We now improve our results for the class of -free Helly graphs. Our results in this section are divided into three parts. In Section 3.1 we first explain how to compute a central vertex, and so the radius, in a -free Helly graph. We use this result and other properties in Section 3.2, in order to compute the diameter and a corresponding diametral pair. Finally, all the results in Section 3.1 and Section 3.2 are combined and enhanced in Section 3.3 so as to compute the eccentricity of all vertices.
3.1 Computing a central vertex
We start with general properties of Helly graphs and -free Helly graphs which we will then use in our analysis. The first such property is a consequence of the unimodality of the eccentricity function in Helly graphs (see ). Recall that a function is called unimodal if every its local minimum is global.
Lemma 4 ().
Let be a Helly graph. Then, for any vertex of and any farthest vertex we have .
Pseudo-modular graphs are exactly the graphs where each family of three pairwise intersecting balls has a common intersection . Clearly, Helly graphs is a subclass of pseudo-modular graphs.
Lemma 5 ().
For every three vertices , , of a pseudo-modular graph there exist three shortest paths , , connecting them such that either (1) there is a common vertex in or (2) there is a triangle in with edge on , edge on and edge on (see Fig. 5). Furthermore, (1) is true if and only if , and , for some , and (2) is true if and only if , and , for some .
figureVertices and three shortest paths connecting them in pseudo-modular graphs.
The next properties are specific to -free Helly graphs. A set of a graph is called convex if for every , holds.
Lemma 6 ().
Every ball of a -free Helly graph is convex.
For every vertices and of a -free Helly graph and any integer , the set is a clique.
Consider any two vertices and assume that they are not adjacent. Let . Consider balls and in . These balls pairwise intersect. By the Helly property, there must exist a vertex on a shortest path from to which is at distance at most from . As by Lemma 6 the ball is convex, must belong to . Thus, , and a contradiction arises. ∎
We now introduce an important brick-basis of our approach.
The multi-sweep heuristic of Corneil et al. consists in performing a BFS , or a variant of it , from an arbitrary vertex , then from a farthest vertex (usually the last one visited), and finally to output as an estimate of
as an estimate of. On general graphs, there may be an arbitrary gap between and the output of this heuristic . However, on many graph classes it gives us a constant additive approximation of the diameter [13, 15, 16, 23]. We now prove that in particular, it is the case for -free Helly graphs.
Let be a -free Helly graph with diameter and radius . Let be an arbitrary vertex, be a vertex most distant from , and be a diametral pair of . Then, .
Furthermore, if , then and . So, in particular, if is even, then .
By Lemma 3, is either or . Let . For vertices of , we have , , . Furthermore, the three of , and are at most .
First we show that, if for some integer , then . By the triangular inequality, we have . Consider balls , , in . As and , those balls pairwise intersect. By the Helly property, there is a vertex in belonging to all three balls. Necessarily, , and . Similarly, we can get a vertex in such that , and . As both and are in , by Lemma 7, . Thus, .
Now, if for some integer , then and, therefore, . If for some integer , then either and hence or . As in the latter case , we also get .
In what follows, we consider this case, when , in more details. If is even (i.e., ), then and therefore . Assume now that is odd (i.e.,
is odd (i.e.,) and that . That is, . We will show that, under these conditions, must hold. For that assume w.l.o.g. that . Since , we have that . Furthermore, by the triangular inequality, we have , and so . We shall use the following intermediate results:
If then, by Lemma 5, there is a triangle in such that , . Necessarily, and .
If , consider balls , , in . As these balls pairwise intersect, by the Helly property, there is a vertex in with , and . That is, .
If then, as before, we can get a vertex in with , and . Necessarily, .
Hence, must hold. ∎
We left open whether the lower-bound of Lemma 8 can be refined to . Note that this would be best possible. Indeed although in some cases of interest, e.g. interval graphs, the output of the multi-sweep heuristic always equals the diameter , this nice property does not hold for strongly chordal graphs and so neither for -free Helly graphs . Therefore, in Section 3.2 we shall need additional tests in order to decide whether the output of this heuristic equals the diameter (and to compute a diametral pair when it is not the case).
Before finally proving the main result of this subsection, we need the following gated property of Helly graphs. The (weak) diameter of a set is equal to .
Let be a Helly graph and be a subset of weak diameter at most two. Then, for any there exists a vertex .
As it is standard  we call such a vertex a gate of , and we denote it by – we will omit the subscript if the set is clear from the context.
Since has weak diameter at most two the balls and pairwise intersect. Therefore, the result follows from the Helly property. ∎
For any fixed as above, we can compute a gate for every vertex in linear time. Indeed, it suffices to run a breadth-first search from and then, using a straightforward dynamic programming, to choose for every vertex a father, one step closer to , with maximum metric projection on . Then, the gate of a node is itself if it is in , otherwise it is the gate of its father.
We are now ready to improve the result of Theorem 1 for -free Helly graphs, as follows:
If is a -free Helly graph then we can compute a central vertex and so in linear time.
Let be an arbitrary vertex, let and let . By Lemma 8, . Therefore, by Lemma 3, (two of these numbers being equal, it gives us two possibilities). In order to decide in which case we are, we use Lemma 4. Indeed, if then . Furthermore, by Lemma 7, this set is a clique. We compute, for every , its distance and a corresponding gate – which exists by Lemma 9. As observed in Remark 1, it takes linear time. Then, implies . If so then note that a vertex of has eccentricity if and only if it is adjacent to the gate of every vertex at a distance exactly from . Overall, in order to compute we pick the smallest such that a vertex of eccentricity can be extracted from . ∎
3.2 Computing a diametral pair
We base on the results from Section 3.1 so as to prove the following theorem:
If is a -free Helly graph then we can compute a diametral pair and so in linear time.
Digression: an application to chordal Helly graphs
Our results in the paper are proved valid assuming the input graph to be Helly. However, the best-known recognition algorithms for this class of graphs run in quadratic time . In what follows, we first explain an interesting application of Theorem 3 to general chordal graphs. We recall that it can be decided in linear time whether a given graph is chordal .
We use the following results on LexBFS in our analysis:
Lemma 10 ().
Let be the vertex visited last by an arbitrary LexBFS. If the graph is chordal, then the eccentricity of is within of the diameter.
Lemma 11 ().
If the vertex of a chordal graph last visited by a LexBFS has odd eccentricity, then .
Altogether combined with Theorem 3 we obtain that:
Consider an arbitrary chordal graph . If we assume to be Helly then, by Theorem 3, there exists a linear-time algorithm for computing a diametral pair of . Note that, we can apply this algorithm to without the knowledge that it is Helly, and either the algorithm will detect that is not Helly (e.g., because some property of Helly graphs does not hold for ) or it will output some pair of vertices . Furthermore, if is chordal Helly, then is a diametral pair. Let .We can check for a chordal graph whether , or is not Helly, as follows:
If , is even and , then this certifies that . Else, either is not Helly or we have , is odd and . Since , we get by Lemma 10.
Proof of Theorem 3
The remainder of this subsection is now devoted to the proof of Theorem 3. For that, we first compute , which by Theorem 2 can be done in linear time. We also apply the multi-sweep heuristic, i.e., we pick an arbitrary vertex and we perform a BFS from a vertex . There are two main cases depending on the parity of .
Case is even.
By Lemma 8, . Since by Lemma 3 we have , it follows that . Note that, in particular, if then and belongs to a diametral path. Otherwise, . We now explain how to compute a diametral pair in this latter subcase.
Let . We may assume (otherwise, and so, is an end of a diametral pair). In this situation, and are mutually far apart. The next result is a cornerstone of our algorithm:
Let be mutually far apart vertices in a -free Helly graph such that is even, and let . Then, is a diametral pair of if and only if and .
Since , for any , the balls of radius and with centers , respectively, pairwise intersect. The Helly property implies the existence of a vertex such that . Since we also have , we conclude that and . Now on one direction, let be a diametral pair. By Lemma 7, is a clique, implying . Therefore, . For similar reasons, we must have (otherwise, , a contradiction). Conversely, let be such that and . Suppose by contradiction . In particular, the balls of radius and respective centers pairwise intersect. By the Helly property, there exists a such that . But then, , a contradiction. Hence, we proved that is a diametral pair. ∎
Our strategy now consists in computing a pair that satisfies the condition of this above Lemma 12. We do so by using the “gated property” of Lemma 9. Indeed, let be as above defined, and let . Since by Lemma 7 is a clique, this set is well-defined and, according to Remark 1, it can be computed in linear time. In order to compute a diametral pair of , by Lemma 12 it is sufficient to compute a pair such that . At first glance this approach does not look that promising since it is a particular case of the Disjoint Set problem (sometimes called the monochromatic Orthogonal Vector), that cannot be solved in truly subquadratic time under SETH . Before presenting our solution to this special Disjoint Set problem (i.e., Lemma 15) we introduce an – optional – pre-processing so as to simplify a little bit the structure of our problem. For that we need the following lemma:
In a -free Helly graph , for any clique and adjacent vertices , the metric projections and are comparable, i.e., either or .
Let be adjacent and suppose for the sake of contradiction that there exist and . Then, induces a . ∎
Let us compute for every . It takes linear time. We initialize and then we consider the vertices in sequentially. At the time we consider a vertex , we check whether there exists a such that . If it is the case then we remove from . Indeed, by Lemma 13 it implies . In particular, , and so we can safely discard vertex . Overall, the resulting subset is a stable set by construction.
A graph is split if its vertex-set can be bipartitioned in a clique and a stable set. Note that by construction, the induced subgraph is a split graph. Computing the diameter of split graphs is already SETH-hard . Fortunately, our split graph has some additional properties, namely we prove next that it is Helly.
Let be two vertices in a -free Helly graph such that , let and let be a stable set. Then, is a split Helly graph.
By Lemma 7, the subset is a clique, hence is a split graph. Furthermore, let us consider a family of pairwise intersecting balls in . We may assume that no such a ball is equal to , or , for all of these fully contain . In particular, there exists a subset such that the subsets pairwise intersect. Then, we have that the balls of radius and with centers in and the balls of radius and with centers in the vertices of pairwise intersect in . By the Helly property (applied to ), there exists a vertex at a distance from both and , and at a distance from all of . Since , we get and so, . Consequently, is Helly. ∎
We are now left with computing a diametral pair for split Helly graphs.
A diametral pair in a split Helly graph can be computed in linear time.
Let be a split Helly graph with clique and stable set (note that if and are not given then they can be computed in linear time ). Assume to be connected and (otherwise, we are done). By the Helly property, if and only if contains a universal vertex. Furthermore, if it is the case then any pair of non-adjacent vertices is diametral. Hence, from now on we assume that . Let and let be an arbitrary total order of . For every , we define . Our algorithm proceeds the vertices sequentially, for , and does the following: If has eccentricity in , then we compute a diametral pair in this subgraph which contains and we stop.
We claim that our algorithm above is correct. For that we prove by finite induction that for any , if the algorithm did not stop in less than steps then: (i) is connected; and (ii) is a diametral pair of if and only if it is a diametral pair of . Since , this is true for . From now on we assume . If the algorithm did not stop at step then (since in addition is connected by the induction hypothesis), has eccentricity two in . In particular, every vertex has a common neighbour with , implying that there can be no isolated vertex in . We so obtain that is connected. Furthermore, if is a diametral pair of then, necessarily, it is also a diametral pair of the connected subgraph (i.e., because and have no common neighbour in this subgraph, and so they are at distance to each other). Conversely, let be a diametral pair of . Suppose, by contradiction, that is not a diametral pair of , or equivalently . Since the neighbour sets pairwise intersect, by the Helly property, there exists a vertex . But then, is not a diametral pair of (as , a contradiction. As a result, our above algorithm for computing a diametral pair of