Fast approximation and exact computation of negative curvature parameters of graphs

In this paper, we study Gromov hyperbolicity and related parameters, that represent how close (locally) a metric space is to a tree from a metric point of view. The study of Gromov hyperbolicity for geodesic metric spaces can be reduced to the study of graph hyperbolicity. The main contribution of this paper is a new characterization of the hyperbolicity of graphs. This characterization has algorithmic implications in the field of large-scale network analysis. A sharp estimate of graph hyperbolicity is useful, e.g., in embedding an undirected graph into hyperbolic space with minimum distortion [Verbeek and Suri, SoCG'14]. The hyperbolicity of a graph can be computed in polynomial-time, however it is unlikely that it can be done in subcubic time. This makes this parameter difficult to compute or to approximate on large graphs. Using our new characterization of graph hyperbolicity, we provide a simple factor 8 approximation algorithm for computing the hyperbolicity of an $n$-vertex graph $G=(V,E)$ in optimal time $O(n^2)$ (assuming that the input is the distance matrix of the graph). This algorithm leads to constant factor approximations of other graph-parameters related to hyperbolicity (thinness, slimness, and insize). We also present the first efficient algorithms for exact computation of these parameters. All of our algorithms can be used to approximate the hyperbolicity of a geodesic metric space. We also show that a similar characterization of hyperbolicity holds for all geodesic metric spaces endowed with a geodesic spanning tree. Along the way, we prove that any complete geodesic metric space $(X,d)$ has such a geodesic spanning tree. We hope that this fundamental result can be useful in other contexts.


Introduction
Understanding the geometric properties of complex networks is a key issue in network analysis and geometry of graphs. One important such property is the negative curvature [27], causing the traffic between the vertices to pass through a relatively small core of the network -as if the shortest paths between them were curved inwards. It has been empirically observed, then formally proved [12], that such a phenomenon is related to the value of the Gromov hyperbolicity of the graph. In this paper, we propose exact and approximation algorithms to compute hyperbolicity of a graph and its relatives (the approximation algorithms can be applied to geodesic metric spaces as well).
A metric space (X, d) is δ-hyperbolic [3,7,24] if for any four points w, v, x, y of X, the two largest of the distance sums d(w, v) + d(x, y), d(w, x) + d(v, y), d(w, y) + d(v, x) differ by at most 2δ ≥ 0. A graph G = (V, E) endowed with its standard graph-distance d G is δ-hyperbolic if the metric space (X, d G ) is δ-hyperbolic. In case of geodesic metric spaces and graphs, δhyperbolicity can be defined in other equivalent ways, e.g., via thin or slim geodesic triangles. The hyperbolicity δ(X) of a metric space X is the smallest δ ≥ 0 such that X is δ-hyperbolic. It can be viewed as a local measure of how close X is to a tree: the smaller the hyperbolicity is, the closer the metrics of its 4-point subspaces are close to tree-metrics.
The study of hyperbolicity of graphs is motivated by the fact that many real-world graphs are tree-like from a metric point of view [1,2,4] or have small hyperbolicity [26,27,30]. This is due to the fact that many of these graphs (including Internet application networks, web networks, collaboration networks, social networks, biological networks, and others) possess certain geometric and topological characteristics. Hence, for many applications, including the design of efficient algorithms (cf., e.g., [4,[9][10][11][12][13]17,20,32]), it is useful to know an accurate approximation of the hyperbolicity δ(G) of a graph G.
Related work. For an n-vertex graph G, the definition of hyperbolicity directly implies a simple brute-force O(n 4 ) algorithm to compute δ(G). This running time is too slow for computing the hyperbolicity of large graphs that occur in applications [1,4,5,22]. On the theoretical side, it was shown that relying on matrix multiplication results, one can improve the upper bound on time-complexity to O(n 3.69 ) [22]. Moreover, roughly quadratic lower bounds are known [5,15,22]. In practice, however, the best known algorithm still has an O(n 4 )-time worstcase bound but uses several clever tricks when compared to the brute-force algorithm [4]. Based on empirical studies, an O(mn) running time is claimed, where m is the number of edges in the graph. Furthermore, there are heuristics for computing the hyperbolicity of a given graph [14], and there are investigations whether one can compute hyperbolicity in linear time when some graph parameters take small values [16,21].
Perhaps, it is interesting to notice that the first algorithms for testing graph hyperbolicity were designed for Cayley graphs of finitely generated groups (these are infinite vertex-transitive graphs of uniformly bounded degrees). Gromov gave an algorithm to recognize Cayley graphs of hyperbolic groups and estimate the hyperbolicity constant δ. His algorithm is based on the theorem that in Cayley graphs, the hyperbolicity "propagates", i.e., if balls of an appropriate fixed radius induce a δ-hyperbolic space, then the whole space is δ -hyperbolic for some δ > δ (see [24], 6.6.F and [18]). Therefore, in order to check the hyperbolicity of a Cayley graph, it is enough to verify the hyperbolicity of a sufficiently big ball (all balls of a given radius in a Cayley graph are isomorphic to each other). For other algorithms deciding if the Cayley graph of a finitely generated group is hyperbolic, see [6,28]. However, similar methods do not help when dealing with arbitrary graphs.
By a result of Gromov [24], if the four-point condition in the definition of hyperbolicity holds for a fixed basepoint w and any triplet x, y, v of X, then the metric space (X, d) is 2δ-hyperbolic. This provides a factor 2 approximation of hyperbolicity of a metric space on n points running in cubic O(n 3 ) time. Using fast algorithms for computing (max,min)-matrix products, it was noticed in [22] that this 2-approximation of hyperbolicity can be implemented in O(n 2.69 ) time. In the same paper, it was shown that any algorithm computing the hyperbolicity for a fixed basepoint in time O(n 2.05 ) would provide an algorithm for (max, min)-matrix multiplication faster than the existing ones. In [19], approximation algorithms are given to compute a (1 + )approximation in O( −1 n 3.38 ) time and a (2 + )-approximation in O( −1 n 2.38 ) time. As a direct application of the characterization of hyperbolicity of graphs via a cop and robber game and dismantlability, [9] presents a simple constant factor approximation algorithm for hyperbolicity of G running in optimal O(n 2 ) time. Its approximation ratio is huge (1569), however it is believed that its theoretical performance is much better and the factor of 1569 is mainly due to the use in the proof of the definition of hyperbolicity via linear isoperimetric inequality. This shows that the question of designing fast and (theoretically certified) accurate algorithms for approximating graph hyperbolicity is still an important and open question.
Our contribution. In this paper, we tackle this open question and propose a very simple (and thus practical) factor 8 algorithm for approximating the hyperbolicity δ(G) of an n-vertex graph G running in optimal O(n 2 ) time. As in several previous algorithms, we assume that the input is the distance matrix D of the graph G. Our algorithm picks a basepoint w, a Breadth-First-Search tree T rooted at w, and considers only geodesic triangles of G with one vertex at w and two sides on T . For all such sides in T , it computes the maximum over all distances between the two preimages of the centers of the respective tripods. This maximum ρ w,T can be easily computed in O(n 2 ) time and provides an 8-approximation for δ(G). If the graph G is given by its adjacency list, then we show that ρ w,T can be computed in O(nm) time and linear O(n + m) space. For geodesic spaces (X, d) endowed with a geodesic spanning tree we show that the same relationships between ρ w,T and the hyperbolicity of (X, d) hold, thus providing a new characterization of hyperbolicity. En passant, we show that any complete geodesic space (X, d) always has such a geodesic spanning tree. Perhaps, it is surprising that hyperbolicity that is originally defined via quadruplets and can be 2-approximated via triplets (i.e., via pointed hyperbolicity), can be finally defined and approximated only via pairs (and an arbitrary fixed BFS-tree). We hope that this new characterization can be useful in establishing that graphs and simplicial complexes occurring in geometry and in network analysis are hyperbolic.
The way ρ w,T is computed is closely related to how hyperbolicity is defined via slimness, thinness, and insize of its geodesic triangles. Similarly to the hyperbolicity δ(G), one can define slimness ς(G), thinness τ (G), and insize ι(G) of a graph G. As a direct consequence of our algorithm for approximating δ(G) and the relationships between δ(G) and ς(G), τ (G), ι(G), we obtain constant factor O(n 2 ) time algorithms for approximating these parameters. On the other hand, an exact computation, in polynomial time, of these geometric parameters has long stayed elusive. This is due to the fact that ς(G), τ (G), ι(G) are defined as minima of some functions over all the geodesic triangles of G, and that there may be exponentially many such triangles. In this paper we provide the first polynomial time algorithms for computing ς(G), τ (G), and ι(G). Namely, we show that the thinness τ (G) and the insize ι(G) of G can be computed in O(n 2 m) time and the slimness ς(G) of G can be computed in O(n 2 m + n 4 / log 3 n) time 1 . However, we show that the minimum value of ρ w,T over all basepoints w and all BFS-trees T cannot be approximated in polynomial time with a factor strictly better than 2 unless P = NP.

Gromov hyperbolicity and its relatives
2.1. Gromov hyperbolicity. Let (X, d) be a metric space and w ∈ X. The Gromov product 2 of y, z ∈ X with respect to w is (y|z Proposition 2.1. [3,7,23,24] If (X, d) is δ-hyperbolic with respect to some basepoint, then (X, d) is 2δ-hyperbolic.
Let (X, d) be a metric space. An (x, y)-geodesic is a (continuous) map γ : [0, d(x, y)] → X from the segment [0, d(x, y)] of R 1 to X such that γ(0) = x, γ(d(x, y)) = y, and d(γ(s), γ(t)) = |s − t| for all s, t ∈ [0, d(x, y)]. A geodesic segment with endpoints x and y is the image of the map γ (when it is clear from the context, by a geodesic we mean a geodesic segment and we denote it by [x, y]). A metric space (X, d) is geodesic if every pair of points in X can be joined by a geodesic. A real tree (or an R-tree) [7, p.186] is a geodesic metric space (T, d) such that (1) there is a unique geodesic [x, y] joining each pair of points x, y ∈ T ; Let (X, d) be a geodesic metric space. A geodesic triangle ∆(x, y, z) with x, y, z ∈ X is the union [x, y]∪[x, z]∪[y, z] of three geodesics connecting these points. A geodesic triangle ∆(x, y, z) is called δ-slim if for any point u on the side [x, y] the distance from u to [x, z] ∪ [z, y] is at most δ. Let m x be the point of [y, z] located at distance α y := (x|z) y from y. Then, m x is located at distance α z := (y|x) z from z because α y +α z = d(y, z). Analogously, define the points m y ∈ [x, z] and m z ∈ [x, y] both located at distance α x := (y|z) x from x; see Fig. 1 for an illustration. We define a tripod T (x, y, z) consisting of three solid segments [x, m], [y, m], and [z, m] of lengths α x , α y , and α z , respectively. The function mapping the vertices x, y, z of ∆(x, y, z) to the respective leaves of T (x, y, z) extends uniquely to a function ϕ : ∆(x, y, z) → T (x, y, z) such that the restriction of ϕ on each side of ∆(x, y, z) is an isometry. This function maps the points m x , m y , and m z to the center m of T (x, y, z). Any other point of T (x, y, z) is the image of exactly two points of ∆(x, y, z). A geodesic triangle ∆(x, y, z) is called δ-thin if for all points u, v ∈ ∆(x, y, z), ϕ(u) = ϕ(v) implies d(u, v) ≤ δ. The insize of ∆(x, y, z) is the diameter of the preimage {m x , m y , m z } of the center m of the tripod T (x, y, z). Below, we remind that the hyperbolicity of a geodesic space can be approximated by the maximum thinness and slimness of its geodesic triangles. For a geodesic metric space (X, d), one can define the following parameters: • hyperbolicity δ(X) = min{δ : X is δ-hyperbolic}, • pointed hyperbolicity δ w (X) = min{δ : X is δ-hyperbolic with respect to a basepoint w}, • slimness ς(X) = min{δ : any geodesic triangle of X is δ-slim}, • thinness τ (X) = min{δ : any geodesic triangle of X is δ-thin}, • insize ι(X) = min{δ : the insize of any geodesic triangle of X is at most δ}.

2.2.
Hyperbolicity of graphs. All graphs G = (V, E) occurring in this paper are undirected and connected, but not necessarily finite (in algorithmic results they will be supposed to be finite). For any two vertices x, y ∈ V, the distance d(x, y) is the minimum number of edges in a path between x and y. Let [x, y] denote a shortest path connecting vertices x and y in G; we call [x, y] a geodesic between x and y. The interval I(u, v) = {x ∈ V : d(u, x) + d(x, v) = d(u, v)} consists of all vertices on (u, v)-geodesics. There is a strong analogy between the metric properties of graphs and geodesic metric spaces, due to their uniform local structure. Any graph G = (V, E) gives rise to a geodesic space (X G , d) (into which G isometrically embeds) obtained by replacing each edge xy of G by a segment isometric to [0, 1] with ends at x and y. X G is called a metric graph. Conversely, by [7,Proposition 8.45], any geodesic metric space (X, d) is (3,1)-quasi-isometric to a graph G = (V, E). This graph G is constructed in the following way: let V be an open maximal 1 3 -packing of X, i.e., d(x, y) > 1 3 for any x, y ∈ V (that exists by Zorn's lemma). Then two points x, y ∈ V are adjacent in G if and only if d(x, y) ≤ 1. Since hyperbolicity is preserved (up to a constant factor) by quasi-isometries, this reduces the computation of hyperbolicity for geodesic spaces to the case of graphs.
The notions of geodesic triangles, insize, δ-slim and δ-thin triangles can also be defined in case of graphs with the single difference that for graphs, the center of the tripod is not necessarily the image of any vertex on the sides of ∆(x, y, z). For graphs, we "discretize" the notion of δ-thin triangles in the following way. We say that a geodesic triangle ∆(x, y, z) of a graph G is δ-thin if for any v ∈ {x, y, z} and vertices a ∈ [v, u] and b ∈ [v, w] (u, w ∈ {x, y, z}, and u, v, w intervals of G are κ-thin is called the interval thinness of G and denoted by κ(G). Denote also by δ(G), δ w (G), ς(G), τ (G), and ι(G) respectively the hyperbolicity, the pointed hyperbolicity with respect to a basepoint w, the slimness, the thinness, and the insize of a graph G.

Auxiliary results
We will need the following inequalities between ς(G), τ (G), ι(G), and δ(G). They are known to be true for all geodesic spaces (see [3,7,23,24,31]). We present graph-theoretic proofs in case of graphs for completeness (and due to slight modifications in their definitions for graphs).
The fact that δ(G) ≤ 2ς(G)+ 1 2 is a result of Soto [31,Proposition II.20]. For our convenience, we reformulate and prove the other results in four lemmas, plus one auxiliary lemma.
Let ς(G) = ς. Pick any geodesic triangle ∆(x, y, z) of G formed by shortest paths [x, y], [x, z], and [y, z]. Consider the vertices x y , y x , y z , z y , x z , z x as defined in Subsection 2.2. It suffices to show that d(y z , z y ) ≤ 4ς. Since ς(G) ≤ ς, there is a vertex a ∈ [x, z] ∪ [y, z] such that d(a, y z ) ≤ ς. If a ∈ [x, z], then necessarily d(z y , a) ≤ ς (as [x, z] and [y, z] are shortest paths) and hence d(y z , z y ) ≤ 2ς. So, we may assume that a belongs to [y, z]. If a ∈ [y x , z] ⊆ [y, z], then d(x, y z )+d(z, z x ) = d(x, z y )+d(z, z y ) = d(x, z) ≤ d(x, y z )+d(y z , a)+d(a, z) = d(x, y z )+d(y z , a) By symmetry, also for vertex z y , we can get d(z y , y z ) ≤ 2ς or d(z y , y x ) ≤ 2ς. Therefore, if d(z y , y z ) > 2ς, then d(z y , y z ) ≤ d(z y , y x ) + d(y z , y x ) ≤ 4ς must hold. Thus, ι(G) ≤ 4ς(G). Lemma 3.3. Let G be a graph with δ(G) = δ and x, y, w be arbitrary vertices of G. Then, for To prove ς(G) ≤ 3δ + 1 2 , where δ := δ(G), consider a geodesic triangle ∆(x, y, z) formed by shortest paths [x, y], [x, z], and [y, z] and let w be an arbitrary vertex from [x, y]. Without loss of generality, suppose that (x|z) w ≤ (y|z) w . Since w is on a shortest path between x and y, Consider four vertices w, x, y, z and assume without loss of generality that Without loss of generality, assume that (x|y) w ≤ (y|z) w . Let x y and y x be respectively the vertices of [w, x] and [w, y] at distance (x|y) w from w. Let z be the vertex of [w, z] at distance (x|y) w ≤ (y|z) w from w. Since d(x y , y x ) ≤ τ and d(y x , z ) ≤ τ , by the triangle inequality, we have: This establishes the four-point condition for w, x, y, z, and consequently δ( Proof. Let u, v be two arbitrary vertices of G and let x, y ∈ I(u, v) such that d(u, x) = d(u, y).

Geodesic spanning trees
In this section, we prove that any complete geodesic metric space (X, d) has a geodesic spanning tree rooted at any basepoint w. We hope that this general result will be useful in other contexts. For graphs this is well-known and simple, and such trees can be constructed in various ways, for example via Breadth-First-Search. The existence of BFS-trees in infinite graphs has been established by Polat [29,Lemma 3.6]. However for geodesic spaces this result seems to be new (and not completely trivial) and we consider it as one of the main results of the paper. A geodesic spanning tree rooted at a point w (a GS-tree for short) of a geodesic space (X, d) is a union of geodesics Γ w := x∈X γ w,x with one end at w such that y ∈ γ w,x implies that γ w,y ⊆ γ w,x . Then X is the union of the images [w, x] of the geodesics of γ w,x ∈ Γ w and one can show that there exists a real tree T = (X, d T ) such that any γ w,x ∈ Γ w is the (w, x)-geodesic of T . Finally recall that a metric space (X, d) is called complete if every Cauchy sequence of X has a limit in X.
Theorem 4.1. For any complete geodesic metric space (X, d) and for any basepoint w one can define a geodesic spanning tree Γ w = x∈X γ w,x rooted at w and a real tree T = (X, d T ) such that any γ w,x ∈ Γ w is the unique (w, x)-geodesic of T .
The first assertion of the theorem immediately follows from the following proposition: For any complete geodesic metric space (X, d), for any pair of points x, y ∈ X one can define an (x, y)-geodesic γ x,y such that for all x, y ∈ X and for all u, v ∈ γ x,y , we have γ u,v ⊆ γ x,y .
Proof. Let be a well-order on X. For any x, y ∈ X we define inductively two sets P ≺v x,y and P v x,y for any v ∈ X: We set P x,y = u∈X P u x,y .
For all x, y ∈ X and for any v ∈ X, there exists an (x, y)-geodesic γ x,y such that P x,y ⊆ γ x,y .
Proof. We prove the claim by transfinite induction on the well-order .
To (1): Assume that for any u ≺ v, there exists an (x, y)-geodesic γ u x,y such that P u x,y ⊆ γ u x,y . If P ≺v x,y = {x, y} (this happens in particular if v is the least element of X for ), then let γ ≺v x,y such that |d(x, u) − t| ≤ }. Note that D is a closed subset of [0, d(x, y)] and that for any u ∈ P ≺v x,y , d(x, u) ∈ D. We define γ = γ ≺v x,y in two steps: we first define γ on D and then we extend it to the whole segment [0, d(x, y)].
For any t ∈ D, there exists a sequence (u i ) i∈N such that for every i, is a Cauchy sequence in (X, d) and thus (u i ) i∈N converges to a point u ∈ X since (X, d) is complete. Note that u is independent of the choice of the sequence (u i ) i∈N , and let γ(t) = u. For any u ∈ P ≺v x,y , d(x, u) ∈ D and it is easy to see that γ(d(x, u)) = u (i.e., γ contains P ≺v x,y ). Moreover, note that by triangle inequality |d( Consequently, x,y = P ≺v x,y , the property holds by the previous statement of the claim. Otherwise, P v x,y = P ≺v x,y ∪ {v}, and the property holds by the definition of P v x,y . To (3): If there exists v ∈ X such that X coincides with {u ∈ X : u v}, then we are done by the previous statement of the claim. Otherwise, the proof is identical to the proof of statement (1) of the claim.
Proof. By Claim 1, there exists an (x, y)-geodesic γ x,y such that P x,y ⊆ γ x,y . Conversely, for any v ∈ γ x,y , since P ≺v x,y ⊆ P x,y , γ x,y is an (x, y)-geodesic containing P ≺v x,y ∪ {v}. Therefore, by the definition of P v x,y , v ∈ P v x,y ⊆ P x,y . Let B(x, r) denotes the closed ball of radius r centered at a point x of (X, d).

Claim 3.
For all x, y ∈ X and for any u ∈ P x,y , P x,u = P x,y ∩ B(x, d(x, u)).
We prove the claim by induction on . Note that if for any x,y ∩ B(x, d(u, x))) ⊆ P x,u and P ≺v x,y ∩ B(y, d(u, y)) ⊆ γ 2 , γ 3 is an (x, y)-geodesic containing P ≺v x,y ∪ {v}. By the definition of P v x,y , we have v ∈ P v x,y ⊆ P x,y By Claim 2, we can consider the set of geodesics {P x,y : x, y ∈ X}. For all x, y ∈ X and for any u, v ∈ P x,y such that d(v, x) < d(u, x), by Claim 3, P u,v ⊆ P x,u ⊆ P x,y . This finishes the proof of Proposition 4.2.
Consequently, Γ w = x∈X γ w,x is a geodesic spanning tree of (X, d) rooted at w. For any x ∈ X, denote by [w, x] the geodesic segment between x and w which is the image of the geodesic γ x,w . From the definition of Γ w , if x ∈ [x, w], then [x , w] ⊆ [x, w]. From the continuity of geodesic maps and the definition of Γ w it follows that for any two geodesics γ w,x , γ w,y ∈ Γ w the intersection [w, x] ∩ [w, y] is the image [z, w] of some geodesic γ w,z ∈ Γ w . Call z the lowest common ancestor of x and y (with respect to the root w) and denote it by lca(x, y).
for any two points x, y ∈ X. The second assertion of the theorem immediately follows from the following proposition:  , y)] to X such that γ T,x,y (t) = γ T,x,z (t) if 0 ≤ t ≤ d(x, z) and γ T,x,y (t) = γ T,z,y (t − d(x, z)) if d(x, z) ≤ t ≤ d(x, z) + d(z, y). Clearly, [x, y] is the image of γ T,x,y and z = γ T,x,y (d(x, z)). Let 0 ≤ t < t ≤ d(x, z) + d(z, y) and let u := γ T,x,y (t) and v := γ T,x,y (t ). If t, t ≤ d(x, z), then u, v ∈ [x, z] and one can easily see d(x, z)) = t − t and therefore [x, y] is a geodesic segment of T and γ T,x,y is a geodesic map.
Let x, y, u be any triplet of points of X and set z := lca(x, y), z := lca(x, u), and z := lca(u, y). Suppose without loss of generality that d(u, z ) ≤ d(u, z ). Since z , z belong to Since we also have z ∈ [y, w], from the definition of z we deduce that z ∈ [z, w]. If z = z , from the definition of z we conclude that z / ∈ [z , z ], i.e., z ∈ [x, z ]. In this case, z ∈ [z, w] ⊆ [y, w], yielding z = z . This show that either (1) z = z ∈ [z , w] or (2) z = z ∈ [z, w]. We will use this conclusion to prove that T is a real tree.
First we show that T is uniquely geodesic. Suppose by way of contradiction that there exists a point u / This finishes the proofs of Proposition 4.3 and Theorem 4.1.

Fast approximation
In this section, we introduce a new parameter of a graph G (or of a geodesic space X). This parameter depends on an arbitrary fixed BFS-tree of G (or a GS-tree of X). It can be computed efficiently and it provides constant-factor approximations for δ(G), ς(G), and τ (G). In particular, we obtain a very simple factor 8 approximation algorithm for the hyperbolicity δ(G) of an n-vertex graph G running in optimal O(n 2 ) time (assuming that the input is the distance matrix of G).

5.1.
Fast approximation of hyperbolicity. Consider a graph G = (V, E) or a geodesic space (X, d) and an arbitrary BFS-tree T or GS-tree T , respectively, rooted at some vertex or point w (see Section 4). Denote by x y the point of [w, x] T at distance (x|y) w (respectively, (x|y) w ) from w and by y x the point of [w, y] T at distance (x|y) w (respectively, (x|y) w ) from w. In case of graphs, x y and y x are vertices of G. Let ρ w,T := sup{d(x y , y x ) : x, y ∈ X}. In some sense, ρ w,T can be seen as the insize of G with respect to w and T : the differences between ρ w,T and ι(G) are that we consider only geodesic triangles ∆(w, x, y) containing w where the geodesics [w, x] and [w, y] belong to T , and we consider only d(x y , y x ), instead of max{d(x y , y x ), d(x w , w x ), d(y w , w y )}. Using T , we can also define the thinness of G with respect to w and T : let µ w,T = sup d(x , y ) : ∃x, y such that x ∈ [w, x] T , y ∈ [w, y] T and d(w, x ) = d(w, y ) ≤ (x|y) w . Using the same ideas as in the proofs of Propositions 2.2 and 3.1 establishing that ι(X) = τ (X) and ι(G) = τ (G), we can show that these two definitions give rise to the same value.
Proposition 5.1. For any geodesic space X and any GS-tree T rooted at a point w, ρ w,T = µ w,T . Analogously, for any graph G and any BFS-tree T rooted at w, ρ w,T = µ w,T .
In the following, when w and T are clear from the context, we denote ρ w,T by ρ. The next theorem is the main result of this paper. It establishes that 2ρ provides an 8-approximation of the hyperbolicity of δ(G) or δ(X), and that in the case of a finite graph G, ρ can be computed in O(n 2 ) time when the distance matrix D of G is given.
(2) If G has n vertices, given the distance matrix D of G, ρ w,T can be computed in O(n 2 ) time.
Consequently, an 8-approximation (with an additive constant 1) of the hyperbolicity δ(G) of G can be found in O(n 2 ) time.
Proof. We prove the first assertion of the theorem for graphs (for geodesic spaces, the proof is similar). Let ρ := ρ w,T , δ := δ(G), and δ w := δ w (G). By Gromov's Proposition 2.1, δ ≤ 2δ w . We proceed in two steps. In the first step, we show that ρ ≤ 4δ. In the second step, we prove that δ w ≤ ρ + 1 2 . Hence, combining both steps we obtain δ ≤ 2δ w ≤ 2ρ + 1 ≤ 8δ + 1. The first step follows from Proposition 3.1 and from the inequality ρ ≤ ι(G) = τ (G). To prove that δ w ≤ ρ + 1/2, for any quadruplet x, y, z, w containing w, we show the four-point condition d(x, z) + d(y, w) ≤ max{d(x, y) + d(z, w), d(y, z) + d(x, w)} + (2ρ + 1). Assume without loss of generality that d(x, z) + d(y, w) ≥ max{d(x, y) + d(z, w), d(y, z) + d(x, w)} and that d(w, x y ) = d(w, y x ) ≤ d(w, y z ) = d(w, z y ). From the definition of ρ, d(x y , y x ) ≤ ρ and d(y z , z y ) ≤ ρ. Consequently, by the definition of x y , y x , y z , z y and by the triangle inequality, we get the last inequality following from the definition of x y and y x in graphs (in the case of geodesic metric spaces, we have d(x, x y ) + d(y, y x ) = d(x, y)). This establishes the four-point condition for w, x, y, z and proves that δ w ≤ ρ + 1/2. We present now a simple self-contained algorithm for computing ρ in O(n 2 ) time when G = (V, E) is a graph with n vertices. For any non-negative integer r, let x(r) be the unique vertex of [w, x] T at distance r from w if r < d(w, x) and the vertex x if r ≥ d(w, x). First, we compute in O(n 2 ) time a table M with lines indexed by V , columns indexed by {1, . . . , n}, and such that M (x, r) is the identifier of the vertex x(r) of [w, x] T located at distance r from w. To compute this table, we explore the tree T starting from w. Let x be the current vertex and r its distance to the root w.  When the graph G is given by its adjacency list, one can compute its distance-matrix in O(min(mn, n 2.38 )) time and then use the algorithm described in the proof of Theorem 5.2. However, we explain in the next proposition how to obtain an 8-approximation of δ(G) in O(mn) time using only linear space. Proof. Fix a vertex w and compute a BFS-tree T of G rooted at w. Note that at the same time, we can compute the value d(w, x) for each x ∈ V .
For each vertex x, consider the map P x : {0, . . . , d(w, x)} → V such that for each 0 ≤ i ≤ d(w, x), P x (i) is the unique vertex on the path from w to x in T at distance i from w. For every vertex x, consider the map Q x : V → N ∪ {∞} such that for each y ∈ V , Q x (y) = d(y, P x (i)) if i = d(w, y) ≤ d(w, x) and Q x (y) = ∞ otherwise.
We perform a depth first traversal of T starting at w and consider every vertex x in this order. Initially, P x = P w can be trivially computed in constant time and Q x = Q w can be initialized in O(n) time. During the depth first traversal of T , each time we go up or down, P x can be updated in constant time. Assume now that a vertex x is fixed. In O(n + m) time and space, we compute d(x, y) for every y ∈ V by performing a BFS of G from x. Moreover, each time we modify x, for each y, we can update Q x (y) in constant time by setting Q x (y) : We perform a depth first traversal of T from w and consider every vertex y in this order. As for P x , we can update P y in constant time at each step. Since d(w, x), d(w, y), and d(x, y) are available, one can compute (x|y) w in constant time. Therefore, in constant time, we can find y x = P y ( (x|y) w ) using P y and compute d(x y , y x ) = Q x (y x ) using Q x .
Consequently, for each x, we compute max{d(x y , y x ) : y ∈ V } in O(m) time and therefore, we compute ρ w,T in O(mn) time. At each step, we only need to store the distances from all vertices to w and to the current vertex x, as well as arrays representing the maps P x , Q x , and P y . This can be done in linear space.
Remark 5.5. If we are given the distance-matrix D of G, we can use the algorithm described in the proof of Proposition 5.4 to avoid using the O(n 2 ) space occupied by table M in the proof of Theorem 5.2. In this case, since the distance-matrix D of G is available, we do not need to perform a BFS for each vertex x and the algorithm computes ρ w,T in O(n 2 ) time.
The following result shows that the bounds in Theorem 5.2 are optimal.
Proposition 5.6. For any positive integer k, there exists a graph H k , a vertex w, and a BFStree T rooted at w such that δ(H k ) = k and ρ w,T = 4k.
For any positive integer k, there exists a graph G k , a vertex w, and a BFS-tree T rooted at w such that ρ w,T ≤ 2k and δ(G k ) = 4k.
Proof. The graph H k is the 2k × 2k square grid from which we removed the vertices of the rightmost and downmost (k − 1) × (k − 1) square (see Fig. 2, left). The graph H k is a median graph and therefore its hyperbolicity is the size of a largest isometrically embedded square subgrid [10,25]. The largest square subgrid of H k has size k, thus δ(H k ) = k.
Let w be the leftmost upmost vertex of H k . Let x be the downmost rightmost vertex of H k and y be the rightmost downmost vertex of H k . Then d(x, y) = 2k and d(x, w) = d(y, w) = 3k. Let P and P be the shortest paths between w and x and w and y, respectively, running on the boundary of H k . Let T be any BFS-tree rooted at w and containing the shortest paths P and P . The vertices x y ∈ P and y x ∈ P are located at distance (x|y) w = 1 2 (d(w, x) + d(w, y)−d(x, y)) = 2k from w. Thus x y is the leftmost downmost vertex and y x is the rightmost upmost vertex. Hence ρ w,T ≥ d(x y , y x ) = 4k. Since the diameter of H k is 4k, we conclude that ρ w,T = 4k = 4δ(H k ).
Let G k be the 4k × 4k square grid and note that δ(G k ) = 4k. Let w be the center of G k . We suppose that G k is isometrically embedded in the 1 -plane in such a way that w is mapped to the origin of coordinates (0, 0) and the four corners of G k are mapped to the points with coordinates (2k, 2k), (−2k, 2k), (−2k, −2k), (2k, −2k), We build the BFS-tree T of G k as follows. First we connect w to each of the corners of G k by a shortest zigzagging path (see Fig. 3). For each i ≤ i ≤ k, we add a vertical path from (i, i) to (i, 2k), from (i,  Figure 2.
the following structure: it consists of a subpath of one of the zigzagging paths until this path arrives to the vertical or horizontal line containing v and then it continues along this line until v.
We divide the grid in four quadrants Pick any two vertices x = (i, j) and y = (i , j ). If x and y belong to opposite quadrants of G k , then w ∈ I(x, y) and x y = y x = w. So, we can suppose that either x and y belong to the same quadrant or to two incident quadrants of G k . Denote by m = m(x, y, w) the median of the triplet x, y, w, i.e., the unique vertex in the intersection I(x, y) ∩ I(x, w) ∩ I(y, w) (m is the vertex having the median element of the list {i, 0, i } as the first coordinate and the median element of the list {j, 0, j } as the second coordinate). Notice that m has the same distance r := (x|y) w to w as x y and y x ((x|y) w is integer because G k is bipartite). Case 1. x = (i, j) and y = (i , j ) belong to the same quadrant of G k .
Suppose that x and y belong to the first quadrant (alias 2k × 2k square) Since the vertices x y , y x , and m have the same distance r to w and belong to Q 1 , they all belong to the same side L of the sphere S r (w) of the 1 -plane of radius r and centered at w. Let L 0 := [x y , y x ] be the subsegment of L between x y and y x . Notice first that if L 0 is completely contained in one or two incident k × k squares (say in Q 12 and Q 13 ), then d(x y , y x ) ≤ 2k. Indeed, in this case L 0 can be extended to a segment L 0 having its ends on two vertical sides of the rectangle Q 12 ∪ Q 13 . Therefore, L 0 is the diagonal of a k × k square included in Q 12 ∪ Q 13 , thus the 1 -length of L 0 (and thus of L 0 ) is at most 2k. Thus we can suppose that the vertices x y and y x are located in two non incident k × k squares. This is possible only if one of these vertices belongs to Q 12 and another belongs to Q 14 , say x y ∈ Q 12 and y x ∈ Q 14 . This implies that x ∈ Q 11 ∪ Q 12 and y ∈ Q 11 ∪ Q 14 . Notice that neither x nor y may belong to Q 11 . Indeed, 2k 2k 2k 2k w Figure 3. In G k , ρ w,T ≤ 2k = 1 2 δ(G k ), showing that (up to an additive factor of 1) the inequality δ ≤ 2ρ + 1 is tight in the proof of Theorem 5.2. 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 00 00 00 11 11 11 x w Q 2 if x ∈ Q 11 , then the center (k, k) of Q 1 belongs to the path of T from w to x. Consequently, this path is completely contained in Q 11 ∪ Q 13 , contrary to the assumption that x y ∈ Q 12 . Thus x ∈ Q 12 and y ∈ Q 14 , i.e., 0 ≤ i ≤ k, k ≤ j ≤ 2k, k ≤ i ≤ 2k, and 0 ≤ j ≤ k. This means that the median m of the triplet x, y, w has coordinates (i, j ) and belongs to Q 13 . The path of T from w to x = (i, j) is zigzagging until (i, i) and then is going vertically. Analogously, the path of T from w to y = (i , j ) is zigzagging until (j , j ) and then is going horizontally. If we suppose, without loss of generality, that i ≤ j , then m = (i, j ) belongs to the (w, x)-path of T and therefore x y = m. This contradicts our assumption that x y and y x do not belong to a common or incident k × k squares. This concludes the proof of Case 1.
Case 2. x = (i, j) and y = (i , j ) belong to incident quadrants of G k .
Suppose that x ∈ Q 1 and y ∈ Q 2 , i.e., i, j, j ≥ 0 and i ≤ 0. The points x y and y x belong to different but incident sides L, L of the sphere S r (w) of the 1 -plane, x y ∈ L and y x ∈ L . The median point m also belongs to these sides. Since i ≤ 0 ≤ i, we conclude that m has 0 as the first coordinate. Thus m belongs to both segments L and L . Suppose without loss of generality that j ≤ j , i.e., the second coordinate of m is j. Consequently, r = j. If i ≥ j 2 , then the vertex ( j 2 , j 2 ) belongs simultaneously to L and to the path of T connecting w and x; thus in this case x y is either ( j 2 , j 2 ) or ( j 2 , j 2 ). If i < j 2 , then one can easily see that the intersection of L with the path of T from w to x is the vertex x y = (i, j − i). In both cases, d(x y , c) ≤ j 2 where c = (0, j 2 ). Analogously, we can show that d(y x , c) ≤ j 2 . Consequently, d(x y , y x ) ≤ d(x y , c) + d(c, y x ) = 2 j 2 ≤ 2k as j ≤ 2k. This finishes the analysis of Case 2. Consequently, ρ = ρ w,T ≤ 2k, concluding the proof of the proposition.
The definition of ρ w,T depends on the choice of the basepoint w and of the BFS-tree T rooted at w. We show below that the best choices of w and T do not improve the bounds in Theorem 5.2. For a graph G, let ρ − (G) = min{ρ w,T : w ∈ V and T is a BFS-tree rooted at w} and call ρ − (G) the minsize of G. On the other hand, the maxsize ρ + (G) = max{ρ w,T : w ∈ V and T is a BFS-tree rooted at w} of G coincides with its insize ι(G). Indeed, from the definition, ρ + (G) ≤ ι(G). Conversely, consider a geodesic triangle ∆(x, y, w) maximizing the insize and suppose, without loss of generality, that d(x y , y x ) = ι(G), where x y and y x are chosen on the sides of ∆(x, y, w). Then, if we choose a BFS-tree rooted at w, and such that x y is an ancestor of x and y x is an ancestor of y, then one obtains that ρ + (G) ≥ ι(G). We show in Section 6 that ρ + (G) (= ι(G) = τ (G)) can be computed in polynomial time, and by Proposition 3.1, it gives a 4-approximation of δ(G).
On the other hand, the next proposition shows that one cannot get better than a factor 8 approximation of hyperbolicity if instead of computing ρ w,T for an arbitrary BFS-tree T rooted at some arbitrary vertex w, we compute the minsize ρ − (G). Furthermore, we show in Section 6 that we cannot approximate ρ − (G) with a factor strictly better than 2 unless P = NP.
The graph G * k is just the graph G k from Proposition 5.6. By this proposition and the definition of ρ − (G * k ), we have δ(G * k ) = 4k and ρ − (G * k ) ≤ ρ w,T ≤ 2k. Let H k be the graph H k from Proposition 5.6 in which we cut-off the vertices x y and y x : namely, we removed these two vertices and made adjacent their neighbors in H k . This way, in H k the vertices x, y are pairwise connected to w by unique shortest paths, that are the boundary paths P and P of H k shortcut by removing x y and y x and making their neighbors adjacent. Since δ(H k ) = k, from the definition of H k it follows that δ(H k ) may differ from k by a small constant. Let H * k be the graph obtained by gluing two copies of H k along the leftmost upmost vertex w (see Fig. 2, right). Consequently, the vertex w becomes the unique articulation point of H * k which has two blocks, each of them isomorphic to H k . Pick any basepoint w * and any BFS-tree T * of H * k rooted at w * . We assert that ρ w * ,T * ≥ 4k − 2. Indeed, pick the vertices x and y in the same copy of H k that do not contain w * (if w * = w). Then both paths of T * connecting w * to x and y pass via the vertex w. Since w is connected to x and y by unique shortest paths P and P , the paths P and P belong to T * . The vertices x * y and y * x in the tree T * are the vertices of P and P , respectively, which are the neighbors of x y and y x located at distance (x|y) w from w. One can easily see that d(x * y , y * x ) = 4k − 2, i.e., ρ w * ,T * ≥ 4k − 2. If instead of knowing the distance-matrix D, we only know the distances between the vertices of G up to an additive error k, then we can define a parameter ρ w,T in a similar way as ρ w,T is defined and show that 2 ρ w,T + k + 1 is an 8-approximation of δ(G) with an additive error of 3k + 1.
Proposition 5.8. Given a graph G, a BFS-tree T rooted at a vertex w, and a matrix D such that d(x, y) ≤ D(x, y) ≤ d(x, y) + k, we can compute in time O(n 2 ) a value ρ w,T such that δ(G) ≤ 2 ρ w,T + k + 1 ≤ 8δ(G) + 3k + 1.
The first assertion follows from the fact that for any x, y ∈ V , ( x|y) w ≤ ( x|y) w ≤ (x|y) w (as d(x, y) ≤ D(x, y)). Consequently, we have d(x y , y x ) ≤ τ and therefore D( To prove that δ w ≤ ρ+ k+1 2 , for any quadruplet x, y, z, w containing w, we show the four-point condition d(x, z) + d(y, w) ≤ max{d(x, y) + d(z, w), d(y, z) + d(x, w)} + (2 ρ + k + 1). Assume without loss of generality that d(x, z) + d(y, w) ≥ max{d(x, y) + d(z, w), d(y, z) + d(x, w)} and that d(w, x y ) = d(w, y x ) ≤ d(w, y z ) = d(w, z y ). The remaining part of the proof closely follows the proof of Theorem 5.2.
From the definition of ρ, d(x y , y x ) ≤ ρ and d(y z , z y ) ≤ ρ. Consequently, by the definition of x y , y x , y z , z y and by the triangle inequality, we get The last line inequality follows from This establishes the four point condition for w, x, y, z and proves that δ w ≤ ρ + k+1 2 .
Interestingly, ρ w,T can also be defined in terms of a distance approximation parameter. Consider a geodesic space X and a GS-tree T rooted at some point w, and let ρ = ρ w,T . For a point x ∈ X and r ∈ R + , denote by x(r) the unique point of [w, x] T at distance r from w if r < d(w, x) and the point x if r ≥ d(w, x). For any x, y and ∈ R + , let r xy ( ) := sup{r : d(x(r ), y(r )) ≤ for any 0 ≤ r ≤ r}. This supremum is a maximum because the function r → d(x(r ), y(r )) is continuous. Observe that by Proposition 5.1, ρ = inf{ : r xy ( ) ≥ (x|y) w for all x, y}.
When we consider a graph G with a BFS-tree T rooted at some vertex w, we have similar results. For a vertex x, we define x(r) as before when r is an integer and for vertices x, y, we define r xy ( ) := max{r ∈ N : d(x(r ), y(r )) ≤ for any 0 ≤ r ≤ r}. Since ρ = inf{ : r xy ( ) ≥ (x|y) w for all x, y}, we get that d(x, y) ≤ d ρ (x, y) + 1 ≤ d(x, y) + ρ + 1.
Proposition 5.9. If the distance matrix D of a graph G is unknown but the kth power graph G k of G is given for k ≥ ρ w,T , then one can approximate the distance matrix D of G in optimal O(n 2 ) time with an additive term depending only on k.
Proof. With G k at hand, for a fixed vertex x ∈ V the values of r xy (k) and d k (x, y), for every y ∈ V , can be computed in linear time using a simple traversal of the BFS-tree T .
In fact, with ρ w,T at hand we can compute a 7-approximation of the thinness τ (G) of G.
Theorem 5.11. Given a graph G (respectively a geodesic metric space X) and a BFS-tree T (respectively, a GS-tree T ) rooted at w, τ (G) ≤ 7ρ w,T + 4 ≤ 7τ (G) + 4 (respectively, τ (X) ≤ 7ρ w,T ≤ 7τ (X)). Consequently, a 7-approximation (with an additive constant 4) of the thinness τ (G) of G can be computed in O(n 2 ) time (respectively, in O(mn) time) for any graph G given by its distance matrix (respectively, by its adjacency list).
The second statement of the theorem is a corollary of the first statement, of Theorem 5.2, and of Proposition 5.4. To prove the first statement, we first need the following simple lemma.
Proof. Let [w, x], [w, y], [w, z] be the three shortest paths from w to respectively x, y, and z in T . Let [x, y] be any geodesic going through z, and let [z, x] and [z, y] be the geodesics from z to respectively x and y that are contained in [x, y]. Since d(x, y) = d(x, z) + d(z, y), we have (w|x) z − (w|x) y + d(y, z) = (w|y) z .
By definition, ρ w,T ≤ τ (G), thus the first statement of Theorem 5.11 follows from the fact that ι(G) = τ (G) and the following proposition.
Proposition 5.13. In a graph G (respectively, a geodesic metric space X), for any BFS-tree T (respectively, any GS-tree T ) rooted at some vertex w, ι(G) = τ (G) ≤ 7ρ w,T + 4 (respectively, ι(X) = τ (X) ≤ 7ρ w,T ). y Notice that d(z, u ) = d(z, t ) ≤ (x|y) z = f − b ≤ f = (w|x) z ≤ f + c = (w|y) z . By Lemma 5.12, (w|z) u , (w|z) t ≤ ρ + 1 2 , and consequently, d(u , t ) ≤ 4ρ + 2. We now show that d(u, v) ≤ 6ρ + 3. Note that if b = 0, then we are in the same case as for the pair u , t , and thus we can assume that b > 0. Let Observe also that d(x, Observe that Observe also that d(x, . Recall that f + c = (y|w) z . Consequently, by Lemma 5.12, (w|x) v , (w|z) t ≤ ρ + 1 2 . Since b ≤ ρ + 1 2 , we get that d(t , v ) ≤ 7ρ + 4. Consider a collection T = (T w ) w∈V of trees where for each w, T w is an arbitrary BFS-tree rooted at w, and let ρ T = max w∈V ρ w,Tw . Since for each w, ρ w,Tw can be computed in O(n 2 ) time, ρ T can be computed in O(n 3 ) time. We stress that for any fixed w ∈ V , δ w (G) can be also computed in O(n 3 ) time. Furthermore, by Proposition 2.1, δ w (G) gives a 2-approximation of the hyperbolicity δ(G) of G. In what follows, we present similar complexity approximations for ς(G) and τ (G).
To get a better bound for ς(G), we need to involve one more parameter. Let u and v be arbitrary vertices of G and T u ∈ T be the BFS-tree rooted at u. Let also (u = u 0 , u 1 , . . . , u = v) be the path of T u joining u with v. Define κ Tu (u, v) := max{d(a, u i ) : a ∈ I(u, v), d(a, u) = i} and κ T := max{κ Tu (u, v) : u, v ∈ V }. Note that κ T ≤ κ(G) and that κ T can be computed in O(n 3 ) time and O(n 2 ) space. Observe also that for any u, v, κ Tu (u, v) ≤ ρ u,Tu and thus κ T ≤ ρ T .
Proposition 5.14. For a graph G and a collection of BFS-trees T = (T w ) w∈V , ι(G) = τ (G) ≤ ρ T + 2κ T ≤ 3ρ T ≤ 3τ (G) and ς(G) ≤ ρ T + 2κ T ≤ 8ς(G). Consequently, a 3-approximation of The algorithm for computing τ x (G) works as follows. First, we compute the distance matrix of G in O(mn) time. Next, we compute g w (x, y) and h x,y (w) for all y, w in time O(mn). Finally, we enumerate all y, w in O(n 2 ) to compute max g w (x, y) : d(x, w) ≤ h x,y (w) . By Lemma 6.3, the obtained value is exactly τ x (G) = max τ x,y (G). Therefore, we are just left with proving that we can compute g w (x, y) and h x,y (w) for all y, w in time O(mn), which is a direct consequence of the two next lemmas. Lemma 6.4. For any fixed x, w ∈ V , one can compute the values of g w (x, y) for all y ∈ V in O(m) time.
Proof. In order to compute g w (x, y), we use the following recursive formula: g w (x, y) = 0 if d(x, y) < d(x, w), g w (x, y) = d(w, y) if d(x, y) = d(x, w), and g w (x, y) = max g w (x, y ) : y ∈ N (y) and d(x, y ) = d(x, y) − 1 otherwise. Given the distance matrix D, for any y ∈ V , we can compute {y ∈ N (y) : d(x, y ) = d(x, y) − 1} in O(deg(y)) time. Therefore, using a standard dynamic programming approach, we can compute the values g w (x, y) for all y ∈ V in O( y deg(y)) = O(m) time. Proof. In order to compute h x,y (w), we use the following recursive formula: h x,y (w) = max (y|w) x , h x,y (w) where h x,y (w) = max h x,y (w ) : w ∈ N (w) and d(x, w ) = d(x, w) + 1 . Given the distance matrix D, for any fixed w ∈ V , we can compute w ∈ N (w) : d(x, w ) = d(x, w) + 1 in O(deg(w)) time. If we order the vertices of V by non-increasing distance to x, using dynamic programming, we can compute the values of h x,y (w) for all w in O( w deg(w)) = O(m) time.
6.2. Exact computation of slimness. The goal of this subsection is to prove the following result (Theorem 6.1(2)): Proposition 6.6. ς(G) can be computed in O(n 2 m + n 4 / log 3 n) time.
To prove Proposition 6.6, we introduce the "pointed slimness" ς w (G) of a given vertex w. Formally, ς w (G) is the least integer k such that, in any geodesic triangle ∆(x, y, z) such that w ∈ [x, y], we have d(w, [x, z] ∪ [y, z]) ≤ k. Note that ς w (G) cannot be used to approximate ς(G) (that is in sharp contrast with δ w (G) and τ w (G)). In particular, ς w (G) = 0 whenever w is a pending vertex of G (or, more generally, a simplicial vertex of G). On the other hand, we have ς(G) = max w∈V ς w (G). Therefore, given an algorithm for computing ς w (G) in O(T (n, m)) time, we can compute ς(G) in O(nT (n, m)) time, by calling n times this algorithm. Next we describe such an algorithm that runs in O(nm + n 3 / log 3 n) time for every w (Lemma 6.10). By the remark above, the latter will prove Theorem 6.1 (2). For every y, z ∈ V we set p w (y, z) to be the least integer k such that, for every geodesic [y, z], we have d(w, [y, z]) ≤ k. The following lemma is the cornerstone of our algorithm. Lemma 6.7. ς w (G) ≤ k iff for all x, y ∈ V such that w ∈ I(x, y), and any z ∈ V , min{p w (x, z), p w (y, z)} ≤ k.
The algorithm for computing ς w (G) proceeds in two phases. We first compute p w (y, z) for every y, z ∈ V . Second, we seek for a triple (x, y, z) such that w ∈ I(x, y) and min{p w (x, z), p w (y, z)} is maximized. By Lemma 6.7, the obtained value is exactly ς w (G). Therefore, we are just left with proving the running time of our algorithm.
In particular, s t , t s ∈ N [w], and so, d(s t , t s ) ≤ 1 since w is simplicial. Lemma 6.17. If s, t ∈ X, then d(s t , t s ) ≤ 1.
Proof. We have (s|t) w = 2 − d(s, t)/2. In particular, (s|t) w ≤ 1. As a result, s t , t s ∈ N [w], and since w is simplicial, we obtain d(s t , t s ) ≤ 1.
Lemma 6.18. If s ∈ X and t ∈ C, then d(s t , t s ) ≤ 1.
Proof. We have (s|t) w = 5/2−d(s, t)/2 ∈ {3/2, 2}. In particular, if d(s, t) = 2 then (s|t) w = 1, and so, we are done because s t , t s ∈ N [w] and w is simplicial. Otherwise, d(s, t) = 1, and so, (s|t) w = 2. In particular, s t = s and s t , t s are two literals contained in t. The latter implies d(s t , t s ) ≤ 1 since a clause cannot contain a literal and its negation.
Finally, we prove that in order to get ρ w,T ≤ 1, a necessary and sufficient condition is that the parent nodes of the clause vertices are pairwise adjacent in G Φ . By construction, the latter corresponds to a satisfying assignment for Φ. Lemma 6.19. If s, t ∈ C, then s t , t s ∈ X.