Online Spanners in Metric Spaces

Given a metric space $\mathcal{M}=(X,\delta)$, a weighted graph $G$ over $X$ is a metric $t$-spanner of $\mathcal{M}$ if for every $u,v \in X$, $\delta(u,v)\le d_G(u,v)\le t\cdot \delta(u,v)$, where $d_G$ is the shortest path metric in $G$. In this paper, we construct spanners for finite sets in metric spaces in the online setting. Here, we are given a sequence of points $(s_1, \ldots, s_n)$, where the points are presented one at a time (i.e., after $i$ steps, we saw $S_i = \{s_1, \ldots , s_i\}$). The algorithm is allowed to add edges to the spanner when a new point arrives, however, it is not allowed to remove any edge from the spanner. The goal is to maintain a $t$-spanner $G_i$ for $S_i$ for all $i$, while minimizing the number of edges, and their total weight. We construct online $(1+\varepsilon)$-spanners in Euclidean $d$-space, $(2k-1)(1+\varepsilon)$-spanners for general metrics, and $(2+\varepsilon)$-spanners for ultrametrics. Most notably, in Euclidean plane, we construct a $(1+\varepsilon)$-spanner with competitive ratio $O(\varepsilon^{-3/2}\log\varepsilon^{-1}\log n)$, bypassing the classic lower bound $\Omega(\varepsilon^{-2})$ for lightness, which compares the weight of the spanner, to that of the MST.


Introduction
In the online minimum spanning tree problem, points of a finite metric space arrive one-by-one, and we need to connect each new point to a previous point to maintain a spanning tree. Imase and Waxman [44] proved Θ(log n)-competitiveness, which is the best possible bound. Later, Alon and Azar [2] studied this problem for points in the Euclidean plane, and proved a lower bound Ω(log n/ log log n) for the competitive ratio. Their result was the first to analyze the impact of auxiliary points (Steiner points) on a geometric network problem in the online setting. Several algorithms were proposed over the years for the online minimum Steiner tree and Steiner forest problems, on graphs in both weighted and unweighted settings; see [1,5,10,40,50]. However, these algorithms do not provide any guarantees on the stretch factor. This leads to the following open problem.
▶ Problem. Determine the best possible bounds for the competitive ratios for the weight and the number of edges of online t-spanners, for t ≥ 1.
Previously, Gupta et al. [39,Theorem 1.5] constructed online spanners for terminal pairs in the same model we consider here. The analysis of [39] implicitly implies that, given a sequence of n points in an online fashion in a general metric space, one can maintain a O(log n)-spanner with O(n) edges and O(log n) lightness, as pointed out by one of the authors [59]. Recent work on online directed spanners [36] is not comparable to our results.
In the geometric setting, (1 + ε)-spanners are possible in any constant dimension d ∈ N. Tight worst-case bounds Θ d (ε −d ) and Θ d (ε 1−d ) on the lightness and sparsity of offline (1 + ε)spanners have recently been established by Le and Solomon [47]. Online Euclidean spanners in R d have been introduced by Bhore and Tóth [14]. In the real line (1D), they have established a tight bound of O((ε −1 / log ε −1 ) log n) for the competitive ratio of any online (1 + ε)-spanner algorithm for n points. In dimensions d ≥ 2, the dynamic algorithm DefSpanner of Gao et al. [33] maintains a (1 + ε)-spanner with O d (ε −(d+1) n) edges and O d (ε −(d+1) log n) lightness, and works under the online model (as it never deletes edges when new points arrive). However, no lower bound better than the 1-dimensional Ω((ε −1 / log ε −1 ) log n) is currently known in higher dimensions.

Our Contribution
See Table 1 for an overview of our results.
Upper Bounds for Points in R d . Under the L 2 -norm in R d , for arbitrary constant d ∈ N, we present an online algorithm for (1 + ε)-spanner with lightness O d (ε −d log n) and sparsity O(ε 1−d log ε −1 ) (Theorem 2 in Section 2.1). This improves upon the previous lightness bound of O d (ε −(d+1) log n) by Gao et al. [33,Lemma 3.8]. In the plane, we give a tighter analysis of the same algorithm and achieve an almost quadratic improvement of the competitive ratio to O(ε −3/2 log ε −1 log n) (Theorem 6 in Section 2.2). Recall that in the offline setting, Θ(ε −2 ) is a tight worst-case bound for the lightness of a (1 + ε)-spanner in the plane [47]. We obtain a better dependence on ε by comparing the online spanner with an instance-optimal spanner directly, bypassing the comparison to an MST (i.e., lightness). The logarithmic dependence on n cannot be eliminated in the online setting, based on the lower bound in R 1 [14].
Lower Bounds for Points in R d . As a counterpart, we design a sequence of points that yields a Ω d (ε −d ) lower bound for the competitive ratio for online (1 + ε)-spanner algorithms in R d under the L 1 -norm (Theorem 13 in Section 3). This improves the previous bound of Ω(ε −2 / log ε −1 ) in R 2 under the L 1 -norm [14]. It remains open whether a similar lower bound holds in R d under the L 2 -norm; the current best lower bound is Ω((ε −1 / log ε −1 ) log n), established in [14], holds already for the real line (d = 1).

18:4
Online Spanners in Metric Spaces Table 1 Overview of online spanners algorithms. In the last three rows, we compare the spanner weight directly with the optimum weight (rather than the MST) to bound the competitive ratio.

Stretch # of edges Lightness Reference
General metrics Family Stretch # of edges Comp. Ratio Reference Points in General Metrics. In Section 4, we study online spanners in general metrics. Note that it is not possible to obtain a spanner with stretch less than 3 with a subquadratic number of edges, even in the offline settings, for general metrics. We analyze an online version of the celebrated greedy spanner algorithm, dubbed ordered greedy. With stretch factor t = (2k − 1)(1 + ε) for k ≥ 2 and ε ∈ (0, 1), we show that it maintains a spanner with O(ε −1 log ε −1 ) · n 1+ 1 k edges and O(ε −1 n 1 k log 2 n) lightness for a sequence of n points in a metric space (Theorem 14). We show (in Theorem 19) that these bounds cannot be significantly improved, by introducing an instance where every online algorithm will have Ω( 1 k · n 1/k ) competitive ratio on both sparsity and lightness. Next, we establish the trade-off among stretch, number of edges and lightness for points in ultrametrics. Specifically, we show (in the full paper) that it is possible to maintain a (2 + ε)-spanner with O(ε −1 log ε −1 ) · n edges and O(ε −2 ) lightness in ultrametrics. Note that as the uniform metric (shortest path on a clique) is an ultrametric, any subquadratic spanner must have stretch at least 2.

Dynamic & Streaming Algorithms for Graph Spanners
for all pairs of vertices u, v ∈ V . That is, the stretch t is the maximum distortion between the graph distances δ G and δ H . Importantly, when G changes (under edge/vertex insertions or deletions), the underlying metric δ G changes, as well. The distance δ G (u, v) may dramatically decrease upon the insertion of the edge uv. In contrast, our model assumes that the distances in the underlying metric space M = (P, δ) remain fixed, but the algorithm can only see the distances between the points that have been presented. For this reason, our results are not directly comparable to models where the underling graph changes dynamically.
For unweighted graphs with n vertices, the current best fully dynamic and single-pass streaming algorithms can maintain spanners that achieve almost the same stretch-sparsity trade-off available for the static case: 2k − 1 stretch and O(n 1+ 1 k ) edges, for k ≥ 1, which is attained by the greedy algorithm [4], and conjectured to be optimal due to the Erdős girth conjecture [28]. In the dynamic model, the objective is design algorithms and data structures that minimize the worst-case update time needed to maintain a t-spanner for S over all steps, regardless of its weight, sparsity, or lightness. See [7,9,11,16] for some excellent work on dynamic spanners. In the streaming model the input is a sequence (or stream) of edges representing the edge set E of the graph G. A (single-pass) streaming algorithm decides, for each newly arriving edge, whether to include it in the spanner. The graph G is too large to fit in memory, and the objective is to optimize work space and update time [6,8,26,29,30,49].

Incremental Algorithms for Geometric Spanners
We briefly review three previously known incremental (1 + ε)-spanner algorithms in Euclidean d-space from the perspective of competitive analysis.

Well-Separated Pair Decomposition (WSPD).
Well-separated pair decomposition was introduced by Callahan and Kosaraju [21] (see also [37,41,51,58]). For a set S in a metric space, a WSPD is a collection of unordered pairs Given a WSPD with separation ratio ϱ > 4, any graph that contains at least one edge between A i and B i , for all i ∈ I, is a spanner with stretch t = 1 + 8/(ϱ − 4). Setting ϱ ≥ 12ε −1 for 0 < ε < 1, we obtain t ≤ 1 + ε.
Hierarchical clustering provides a WSPD [41,Ch. 3]. Perhaps the simplest hierarchical subdivisions in R d are quadtrees. Let T be a quadtree for a finite set S ⊂ R d . The root of T is an axis-aligned cube of side length a 0 , which contains S; it is recursively subdivided into 2 d congruent cubes until each leaf cube contains at most one point in S. For all pairs of cubes  [41,42] and lightness O d (ε −(d+1) log n) [14].
For point insertions in R d , a dynamic quadtree only adds nodes, which in turn creates new pairs in the WSPD, and new edges in the spanner. This is an online algorithm with the same guarantees as DefSpanner [14,42] (see also [32] for an efficient implementation).
Ordered Yao-Graphs and Θ-Graphs. Among the first constructions for (offline) sparse (1 + ε)-spanners in the Euclidean d-space were Yao-and Θ-graphs [24,45,56]. Incremental versions of Yao-graphs and Θ-graphs were introduced by Bose et al. [20]. Let S = {s 1 , . . . , s n } be an ordered set of points in R 2 . For each s i ∈ S, partition the plane into k cones with apex s and aperture 2π/k. The ordered Yao-graph Y k (S) contains an edge between s i and 18:6 Online Spanners in Metric Spaces a closest previous point in {s j : j < i} in each cone. The graph Θ k (S) is defined similarly, but in each cone the distance to the apex is measured by the orthogonal projection to a ray within the cone. Bose et al. [20] showed that the ordered Yao-and Θ-graphs have spanning ratio at most 1/(1 − 2 sin(π/k)) for k > 8; tighter bounds were later obtained in [19]. In particular, the ordered Yao-and Θ-graphs are (1 + ε)-spanners for k ≥ Ω(ε −1 ).
The construction generalizes to R d for all d ∈ N [56]. For an angle α ∈ (0, π), let A ⊂ S d−1 be a maximal set of points in the (d − 1)-sphere such that min a,b∈A dist(a, b) ≤ α (in radians). A standard volume argument shows that |A| ≤ O d (α 1−d ). For each a i ∈ A, create a cone C i with apex at the origin o, aperture α, and symmetry axis oa i . Note that R d ⊆ i C i . Given a finite set P ⊂ R d , we translate each cone C i to a cone C i (p) with apex p ∈ P . For every cone C i (p), the Yao-graph contains an edge between p and a closest point in P ∩ C i (p). For every ε > 0 and d ∈ N, there exists an angle α = α(d, ε) = Θ d (ε) for which the Yao-graph is a (1 + ε)-spanner for every finite set P ⊂ R d .
Ordered Yao-and Θ-graphs give online algorithms for maintaining a (1 + ε)-spanner for a sequence of points in R d . The sparsity of these spanners is bounded by the number of cones per vertex, O d (ε 1−d ), which matches the (offline) lower bound of Ω d (ε 1−d ) [47]. However, their weight may be significantly higher than optimal: For n equally spaced points in a unit circle, in any order, Yao-and Θ-graphs yield ( Online Steiner Spanners. An important variant of online spanners is when it is allowed to use auxiliary points (Steiner points) which are not part of the input sequence of points, but are present in the metric space. An online algorithm is allowed add Steiner points, however, the spanner must achieve the given stretch factor only for the input point pairs. It has been observed through a series of work in recent years, that Steiner points allow for substantial improvements over the bounds on the sparsity and lightness of Euclidean spanners in the offline settings . Highly nontrivial insights are required to argue the bounds for Steiner spanners, and often they tend to be even more intricate than their non-Steiner counterpart; see [12,13,47,48]. Bhore and Tóth [14] showed that if an algorithm can use Steiner points, then the competitive ratio for weight improves to O(ε (1−d)/2 log n) in the Euclidean d-space.

Upper Bounds in Euclidean Spaces
We present an online algorithm for a sequence of n points in the Euclidean d-space (Section 2.1). It combines features from several previous approaches, and maintains a (1 + ε)-spanner of Lightness is an upper bound for the competitive ratio for weight; the sparsity almost matching the optimal bound O d (ε 1−d ) attained by ordered Yao-graphs. In the plane (d = 2), we show that the same algorithm achieves competitive ratio O(ε −3/2 log ε −1 log n) using a tighter analysis: A charging scheme that charges the weight of the online spanner to a minimum weight spanner (Section 2.2).

An Improvement in All Dimensions
We combine features from two incremental algorithms for geometric spanners, and obtain an online (1 + ε)-spanner algorithm for a sequence of n points in R d . We maintain a dynamic quadtree for hierarchical clustering, and use a modified ordered Yao-graph in each level of the hierarchy. In particular, we limit the weight of the edges in the Yao-graph in each level of the hierarchy (thereby avoiding heavy edges). We start with an easy observation.
∥e∥ ≤ w} is the set of edges of weight at most w. Then for every a, b ∈ S with ∥ab∥ < w/t, graph G ′ contains an ab-path of weights at most t ∥ab∥.
Proof. Since G is a t-spanner, it contains an ab-path P ab of weight at most t ∥ab∥ ≤ w. By the triangle inequality, every edge in this path has weight at most w, hence present in G ′ .
The set of the first n points is denoted by S n = {s i : 1 ≤ i ≤ n}. For every n, we dynamically maintain a quadtree T n for S n . Every node of T n corresponds to a cube. The root of T n , at level 0, corresponds to a cube Q 0 of side length a 0 = Θ(diam(S n )). At every level ℓ ≥ 0, there are at most For every nonempty cube Q, we maintain a representative s(Q) ∈ Q ∩ S n , selected at the time when Q becomes nonempty. At each level ℓ, let P ℓ be the sequence of representatives, in the order in which they are created.
For each level ℓ, we maintain a modified ordered Yao-graph G ℓ = (P ℓ , E ℓ ) as follows.
Note that Theorem 2 implies that the competitive ratio of this algorithm is also O d (ε −d log n). Proof.
Stretch Analysis. We give a bound on the stretch factor in two steps: First, we define an auxiliary graph H = (S, E ′ ) which is a (1 + ε)-spanner for S by the analysis of WSPDs. Then we show that G contains an ab-path of weight at most (1 + ε)∥ab∥ for each edge of H.

18:8 Online Spanners in Metric Spaces
Weight Analysis. We may assume w.l.o.g. that the root of the quadtree T n is the unit cube (1). Assume further that n > 1, and . In particular, every edge at level ℓ ≥ 2 log n has weight O d (ε −1 /n 2 ); and the total weight of these edges It remains to bound the weight of the edges on levels ℓ = 1, . . . , ⌊2 log n⌋. At level ℓ of the quadtree T n , there are at most 2 dℓ nodes, hence By the definition of ordered Yao-graphs, each vertex inserted into P ℓ adds Θ(ε 1−d ) new edges, each of weight O(ε −1 2 −ℓ ). The total weight of the edges in G ℓ is at most We next derive a lower bound for ∥MST(S n )∥ in terms of |P ℓ |, when |P ℓ | > 1 and ℓ > 2, using a standard volume argument. Define a graph on the vertex set P ℓ such that two nodes p, q ∈ P ℓ are adjacent iff p and q lie in neighboring quadtree cells of level ℓ. Since every quadtree cell has 3 d − 1 neighbors, this graph is (3 d − 1)-degenerate, and contains an independent set I ℓ of size at least (3 d The distance between any two disjoint quadtreee cells at level ℓ is at least 2 −ℓ . Consequently, the open balls of radius 2 −(ℓ+1) centered at the points in I ℓ are pairwise disjoint. None of the balls contains S n for ℓ > 2, as the diameter of each of ball is 2 −ℓ while diam(S n ) ≥ 1 4 . For all ℓ > 2, MST(S n ) contains the center of each ball and a point in its exterior; hence the intersection of MST(S n ) and each ball contains a path from the center to a boundary point, which has weight at least 2 −(ℓ+1) . Summation over |I ℓ | disjoint balls yields Comparing inequalities (1) and (2), we obtain Sparsity Analysis. In the full paper, we show that G has O(ε 1−d log ε −1 ) · n edges. ◀

Further Improvements in the Plane
We presents a tighter analysis of algorithm ALG 1 for d = 2 that compares the spanner weight to the offline optimum weight, and bypasses the comparison with the MST (i.e., lightness).

Minimum-Weight Euclidean (1 + ε)-Spanner.
For any a, b ∈ R d , an ab-path P ab of Euclidean weight at most (1 + ε)∥ab∥ lies in the ellipsoid E ab with foci a and b and great axes of weight (1 + ε)∥ab∥; see Figure 1. A key observation is that the minor axis of E ab is ((1 + ε) 2 − 1 2 ) 1/2 ∥ab∥ ≈ √ 2ε ∥ab∥. Furthermore, Bhore and Tóth [13] recently observed that the directions of "most" edges of the path P ab are "close" to the direction of ab. Specifically, if we denote by E(α) the set of edges e in P ab with ∠(ab, e) ≤ α, then the following holds.
▶ Lemma 3 (Bhore and Tóth [13]). Let a, b ∈ R d and let P ab be an ab-path of weight ∥P ab ∥ ≤ (1 + ε)∥ab∥. Then for every i ∈ {1, . . . , N (a, b), where N (a, b) is the annulus bounded by two concentric spheres centered at a, of radii 1+ε 2 ∥ab∥ and ∥ab∥; see Figure 1 for an example.  R(a, b) is the part of the ellipse E ab between two concentric circles centered at a. ▶ Lemma 4. If 0 < ε < 1 9 , then every ab-path P ab of weight at most ∥P ab ∥ ≤ (1 + ε)∥ab∥ contains interior-disjoint line segments s ⊂ R(a, b) of total weight at least 1 9 ∥ab∥ such that Proof. Since the distance between the two concentric circles is 1−ε 2 ∥ab∥, every ab-path contains a subpath of weight at least 1−ε 2 ∥ab∥ in the annulus N (a, b). Let P ab be an ab-path of weight at most (1 + ε)∥ab∥. As noted above P ab ⊂ E ab .
Claim 7 immediately implies ∥G∥ ≤ O(ε −3/2 log ε −1 log n) · OPT. For every level ℓ ≥ 0, G ℓ = (P ℓ , E ℓ ) is a graph on the representatives P ℓ . Note that G * is a Steiner spanner with respect to the point set P ℓ , as G * is a spanner on all n points of the input. We prove Claim 7 using a charging scheme: We charge the weight of every edge in G ℓ to G * (more precisely, to line segments along the edges of G * ), and then show that each line segment of weight w in G * receives O(ε −3/2 log ε −1 ) · w charge. For every point p ∈ P ℓ , algorithm ALG 1 greedily covers R 2 by Θ(ε −1 ) cones of aperture π/k = Θ(ε −1 ) and apex p, and adds an edge pq i in each nonempty cone C i . For the competitive analysis, we greedily cover R 2 by Θ(ε −1/2 ) cones of aperture √ ε and apex p. We use translates of the same cone cover for all p ∈ P ℓ . Standard volume argument implies that a cone of aperture √ ε intersects O(ε −1/2 ) cones of aperture Θ(ε −1 ). We describe the charging scheme for each such cone C.
Case 2: ∥pq 0 ∥ ≥ 2 · 2 −ℓ . The optimal spanner G * contains a pq 0 -path P 0 of weight at most (1 + ε)∥pq 0 ∥. Recall P 0 lies in the ellipse E 0 with foci p and q 0 , and R(p, q 0 ) is the half of E 0 that contains q 0 (cf. Figure 1). Let E * ( C) be the set of maximal line segments e along edges in E * such that e ⊂ P 0 ∩ R(p, q 0 ) and ∠(e, pq 0 ) ≤ 3 · √ ε. By Lemma 4, we have ∥E * ( C)∥ ≥ 1 9 ∥pq 0 ∥. We distribute the weight of all edges in E( C) uniformly among the line segments in E * ( C). That is, each segment of weight w in E * ( C) receives a charge of This completes the description of the charging scheme in Case 2.

Charges Received.
A point along an edge of the optimal spanner G * may receive charges from several cones C, possibly with different apices p ∈ P ℓ . Let L be a maximal line segment along an edge of G * such that every point in L receives the same charges.
For a cone C of aperture √ ε, let K denote a cone with the same apex and axis as C, but aperture 3 √ ε; refer to Figure 2.
▷ Claim 8. If L receives charges from C, then L ⊂ K.
Indeed, if L receive charges from C, then L ⊂ R(p, q 0 ) ⊂ E 0 , where E 0 is the ellipse with foci p and the closest point q 0 ∈ C ∩ P ℓ . By Lemma 5, R(p, q 0 ) lies in a cone with apex p, aperture 2 √ ε, and axis pq 0 . Consequently L ⊂ R(p, q 0 ) ⊂ K, which proves Claim 8. Note that if L receives positive charge from a cone C with apex p and closest point q 0 , then ∠(L, pq 0 ) ≤ 3 · √ ε. Since the aperture of the cones C is √ ε, then L receives charges from cones C with at most O(1) different orientations. We may restrict ourselves to cones C that are translates of each other (but have different apices in P ℓ ). Figure 2 Left: There consecutive cones, C0, C1, and C1, with apex p and aperture √ ε. Point q0 is the closest to p in P ℓ ∩ C1; and R(p, q0) ⊂ K1 = C0 ∪ C1 ∪ C2. Right: No point in P ℓ is in the blue sector K, but there may be points in the pink sectors.
Let A be the set of all translates of a cone C with aperture √ ε and apices in P ℓ , and L receives positive charge from C. We partition A into O(log ε −1 ) classes as follows. For j = 1, . . . , ⌈log(2ε −1 )⌉, let A j be the set of cones C ∈ A such that 2 j−ℓ ≤ ∥pq 0 ∥ < 2 j+1−ℓ , where p ∈ P ℓ is the apex of C and q 0 is the closest point in P ℓ ∩ C to p.
▷ Claim 9. For each j, segment L receives O(ε −3/2 ) ∥L∥ total charges from all cones in A j .
For a cone C ∈ A j , the bound (3) is replaced by while ∥E * ( C)∥ ≥ 1 9 ∥pq 0 ∥ ≥ Ω(2 j−ℓ ) by Lemma 4. Refining (4), L receives a charge from each cone in A j . To prove Claim 9, it is enough to show that Figure 3 The union U of triangles C ∩ h − , where L receives charges from the cones C.
By Claim 8, L received charges from cones of O(1) different orientations. We consider each orientation separately. We may assume w.l.o.g. that the symmetry axis of every cone in A j is parallel to the x-axis, and their apex is their leftmost point. Let h be a vertical line that contains the left endpoint of L, and let h − be the left halfplane bounded by h; see Figure 3. Let U be the union of the triangles C ∩ h − for all C ∈ A j . The interior of C ∩ h − does not contain any point in P ℓ . Consequently, the apices of all cones lie on the boundary ∂U of U . The part of ∂U in h − is a y-monotone curve with slopes ± √ ε. It follows that . This, in turn, implies that ∂U intersects O(2 j ) cubes of side length a 0 2 −ℓ at level ℓ of the quadtree, and so |A j | ≤ O(2 j ) ≤ O(ε −1 ), as required. This completes the proof Claim 9, and hence the proof of Theorem 6. ◀

Lower Bounds in R d Under the L 1 Norm
In this section we introduce a strategy based on the points on the integer lattice Z d , that achieves a new lower bound for the competitive ratio of an online (1 + ε)-spanner algorithm in R d under the L 1 norm.

Figure 4
A sketch of the construction for the lower bound in two dimensions. Any online algorithm is required to add the red pairs.

Construction.
We describe an adversary strategy with Ω d (ε −d ) points and show that any online algorithm returns a (1 + ε)-spanner whose weight is Ω d (ε −d ) times the optimum weight. One can extend this result for arbitrary number of points, but that does not necessarily improve the lower bound. The final point set X consists of the points of the integer lattice Z d in the hypercube [0, 1 εd ) d , where ε < 1 d . The points are presented in stages in order to deceive the online algorithm to add more edges than needed. In step 2i, where 0 ≤ i < 1 2ε , points x ∈ X such that ∥x∥ 1 = i will be given to the algorithm. In step 2i + 1, where 0 ≤ i < 1 2ε , the adversary presents points x ∈ X such that ∥x∥ 1 = ⌈1/ε⌉ − i (Figure 4). In other words, points are presented in batches according to their L 1 norms.

Competitive Ratio.
Denote by X i the set of points presented in step i. The idea is to show that there has to exist many edges between X i and X i+1 in order to guarantee the 1 + ε stretch-factor. Specifically, we define an ordered-pair as follows.
▶ Definition 10 (ordered-pair). A pair of points (x, y) in R d is an ordered-pair if x ∈ X 2i and y ∈ X 2i+1 for some i, and x k ≤ y k for all k, where x k and y k are the k-th coordinates of x and y respectively. Now we show that any ordered-pair (x, y) ∈ X 2i × X 2i+1 requires an edge in the spanner immediately after x and y are presented. To prove this, we show (in the full paper) that previously presented points cannot serve as via points in a (1 + ε)-path between x and y.
▶ Lemma 11. Let (x, y) be an ordered-pair. Then there is no (1 + ε)-path between x and y that goes through any other point z ∈ X j with j ≤ i + 1.
We next show that the total weight of the edges between ordered pairs is Ω d (ε −2d ).
▶ Lemma 12. The total weight of the edges between the ordered-pairs is Ω d (ε −2d ). x = (x 1 , . . . , x d ) and y = (y 1 , . . . , y d ) be two points in X. We show that if

Proof. Let
then there is a choice of y d that makes (x, y) an ordered-pair. This would imply that there are Ω d (ε −2d+1 ) ordered-pairs and by Lemma 11, each pair requires an edge of weight Ω d (ε −1 ), thus the total weight of required edges would be Ω d (ε −2d ).
In order to find such a y d , recall that ∥x∥ 1 + ∥y∥ 1 = ⌈ε −1 ⌉ holds because (x, y) is an ordered-pair. This equality uniquely determines the value of y d , We just need to prove the inequalities y k ≥ x k and y k ≤ 1/(εd) for this unique y k . This can simply be done by plugging the maximum (and minimum) values of x k s and other y k s and calculating the result, Also, Now we can prove the main theorem of this section.
▶ Theorem 13. The competitive ratio of any online Proof. For the point set X ⊂ R d , the unit-distance graph is a Manhattan network: It contains a path of weight ∥xy∥ 1 for all x, y ∈ X. Its weight is Θ d (ε −d ) which is an upper bound for the weight of a (1 + ε)-spanner for any ε ≥ 1. By Lemma 12, any online algorithm returns a spanner of weight Ω d (ε −2d ). Thus its competitive ratio is Ω d (ε −d ). ◀

General Metrics: The Ordered Greedy Spanner
In this section we study the online spanners problem on general metric spaces. The points arrive one by one, where for each new point we also receive its distances to all previously introduced points.
In the offline setting, the celebrated greedy spanner algorithm [4] sorts the edges by increasing weight, and then processes them one by one, adding each edge if by the time of examination, the distance between its endpoints is too large. This algorithm achieves the existentially optimal 2 sparsity and lightness as a function of the stretch factor [31]. However, in the online model, we do not receive the edges in a sorted order, and therefore cannot execute the greedy algorithm. As an alternative, we propose here the ordered greedy algorithm. This is a deterministic algorithm working against an adaptive adversary. The algorithm receives a stretch factor t, and works naturally as follows: We maintain a spanner H. When a point v i arrives, we order its edges 3 in the original metric by weight. Each edge Note that this algorithm can be easily executed in an online fashion.
Proof. The bounded stretch of our spanner is straightforward by construction, as every pair was examined at some point, and taken care of. Next we analyze the lightness.
In the online spanning tree problem, points of a finite metric space arrive one-by-one, and we need to connect each new point to a previous point to maintain a spanning tree. The ordered greedy algorithm connects each vertex v i , to the closest vertex in {v 1 , . . . , v i−1 }. As was shown by Imase and Waxman [44], the tree created by the ordered greedy algorithm has lightness O(log n), which is the best possible [44]. Denote the online spanning tree by T G . Note that the ordered greedy spanner H will contain T G , as a shortest edge between a new vertex to a previously introduced vertex is always added to the spanner H. The following clustering lemma is frequently used for spanner constructions (see e.g. [3,22,27]). We provide a proof for the sake of completeness.
▷ Claim 15. For every i ∈ N, the point set X can be partitioned into clusters C i of diameter Proof. Let N i be a maximal set of vertices such that for every x, y ∈ N i , δ T G (x, y) > 1 2 · D i . For every vertex x ∈ N i let C x = z : x = argmin y∈Ni δ X (z, y) be the Voronoi cell of x. Clearly, diam(C x ) ≤ D i for all x. Further, consider a continuous version of T G (where each edge is an interval). Then as the graph T G is connected, each cluster C x contains at least 1 4 D i length of edges (as the balls B T G (x, 1 4 D i ) x∈Ni are pairwise disjoint). It follows that We are now ready to bound the lightness and the sparsity of the ordered greedy spanner. This is accomplished in the next two claims, with proofs in the full paper.
This completes the proof of Theorem 14. ◀

Lower Bound for General Metrics
In this section we prove an Ω( 1 k · n 1 k ) lower bound on the competitive ratio of an online (2k − 1)-spanner of n-vertex graphs. Our lower bound holds in both cases where the quality is measured by number of edges or the weight. It follows that our upper bound in Theorem 14 cannot be substantially improved, even if we consider competitive ratio instead of lightness/sparsity.
Recall that the Erdős Girth Conjecture [28] states that for every n, k ≥ 1, there exists an n-vertex graph with Ω(n 1+ 1 k ) edges and girth 2k + 2. The proof of the following lemma is based on a counting argument form the recent lower bound proof for (static) vertex fault tolerant emulators by Bodwin, Dinitz, and Nazari [15].
Proof. Let G = (V, E G ) be the graph fulfilling the Erdős girth conjecture. That is, G is an unweighted n-vertex graph with girth 2k + 2 and |E G | = Ω(n 1+ 1 k ) edges. Set a metric δ X over V as follows, 4 We say that an edge e ′ ∈ E ′ covers an edge e ∈ E G , if there is a shortest path in G between the endpoints of e ′ going through e of weight at most k. Note that as e ′ has weight at most k, there is a unique shortest path in G between its endpoints. In particular, each edge e ∈ E ′ can cover at most k edges in E G .
Consider an edge e = {v 0 , v s } ∈ E G \ E H . We argue that some edge e ′ ∈ E ′ must cover e. Suppose for contradiction otherwise, and let P = (v 0 , v 1 , . . . , v s ) be the shortest path in H between the endpoints v 0 , v s of e. Suppose first that P contains an edge It follows that P has weight at least 2k + 1, a contradiction to the fact that H is a 2k − 1 spanner. We conclude that for every i ∈ {0, . . . , As no edge covers e, e does not belong to any of these paths. The concatenation of this paths P 0 • P 1 • · · · • P s−1 is a path in G of at most 2k − 1 edges between the endpoints of e. It follows that G contains a 2k-cycle, a contradiction.
For conclusion, as every edge in E G \ E H is covered, and every edge in In particular, To bound the weight, for each edge e ′ = {s, t} ∈ E ′ , let A e ′ be the set of edges in E G covered by e ′ . Note that w H (e ′ ) = δ G (s, t) = |A e ′ |. As all the edges in E G \ E H are covered, we conclude . ◀ ▶ Theorem 19. Assuming Erdős girth conjecture, the competitive ratio of any online (2k − 1)spanner algorithm for n-point metrics is Ω( 1 k · n 1 k ), for both weight and number of edges. In more details, there is an n-point metric space (X, δ X ) with a (2k − 1)-spanner H OPT = (X, E OPT ), and order over X for which every (2k−1)-spanner produced by an online algorithm will have Ω( 1 k · n 1 k ) · |E OPT | edges, and Ω( 1 k · n 1 k ) · w(H OPT ) weight.
Proof. Consider the metric space (X, δ X ) from Lemma 18 with parameters n − 1 and k. Let X ′ be the metric space X with an additional point r at distance 2k−1 2 from all the points in X. Note that no pairwise distance is changed due to the introduction of r. The adversary provides the online algorithm the points in X first (in some arbitrary order), and the point r last. After the algorithm received all the points in X ′ , it has a 2k − 1-spanner H n−1 . According to Lemma 18, H n−1 has Ω( 1 k · (n − 1) 1+ 1 k ) = Ω( 1 k · n 1+ 1 k ) edges, and Ω(n 1+ 1 k ) weight.
Next the algorithm introduces r. Consider the spanner S = (X ′ , E S ) consisting of n − 1 edges with r as a center. Note that the maximum distance in S is 2k − 1, and hence S is a 2k − 1 spanner as required. Note that S contains n − 1 edges of weight 2k−1 2 each, and thus have total weight of O(nk). We conclude |E Hn | ≥ |E Hn−1 | = Ω( 1 k · n 1+ 1 k ) = Ω( 1 k · n 1 k ) · |E S | .

Conclusion
We studied online spanners for points in metric spaces. In the Euclidean d-space, we presented an online (1 + ε)-spanner algorithm with competitive ratio O(ε 1−d log n), improving the previous bound of O d (ε −(d+1) log n) from [14]. In fact, the spanner maintained by the algorithm has O d (ε 1−d log ε −1 ) · n edges, almost matching the (offline) optimal bound of O d (ε 1−d ) · n. Moreover, in the plane, a tighter analysis of the same algorithm provides an almost quadratic improvement of the competitive ratio to O(ε −3/2 log ε −1 log n), by comparing the online spanner with an instance-optimal spanner directly, circumventing the comparison to an MST (i.e., lightness). Note that, the logarithmic dependence on n is unavoidable due to a Ω((ε −1 / log ε −1 ) log n) lower bound in the real line [14]. However, our lower bound Ω(ε −d ) under the L 1 -norm in R d shows a dependence on the dimension. This leads to the following question. Interestingly, for t ∈ [(1 + ε) √ 2, (1 − ε)2], we can show that every online t-spanner algorithm in R d must have competitive ratio 2 Ω(ε 2 d) (see the full paper for further details).
Next, we studied online spanners in general metrics. We showed that the ordered greedy algorithm maintains a spanner with O(ε −1 log ε −1 )·n 1+ 1 k edges and O(ε −1 n 1 k log 2 n) lightness, with stretch factor t = (2k − 1)(1 + ε) for k ≥ 2 and ε ∈ (0, 1), for a sequence of n points in a metric space. Moreover, we show that these bounds cannot be significantly improved, by introducing an instance that achieves an Ω( 1 k · n 1/k ) competitive ratio on both sparsity and lightness. Finally, we established the trade-off among stretch, number of edges and lightness for points in ultrametrics, showing that one can maintain a (2 + ε)-spanner for ultrametrics with O(ε −1 log ε −1 ) · n edges and O(ε −2 ) lightness.