1 Introduction

Nowadays there is an increasing demand for an efficient and resilient information exchange in communication networks. This means to design on one hand a logical structure onto a given communication infrastructure, which optimizes some sought routing protocol in the absence of failures, and on the other hand, to make such a structure resistant against possible link/node malfunctioning, by suitably adding to it a set of redundant links, which will enter into operation as soon as a failure takes place.

More formally, the depicted situation can be modeled as follows: the underlying communication network is an n-vertex and m-edge undirected input graph \(G=(V(G),E(G),w)\), with positive real edge weights defined by w, the logical (or primary) structure is a (spanning) subgraph H of G, and finally the additional links is a set of edges A in \(E(G) \setminus E(H)\). Under normal circumstances, communication takes place on H, by following a certain protocol, but as soon as an edge in H fails, then one or more edges in A come into play, and the communication protocol is suitably adjusted.

In particular, if the primary structure is a (spanning) tree of G, then a very effective way of defining the set of additional edges is the following: with each tree edge, say e, we associate a so-called best swap edge, namely a non-tree edge that will replace e once it (transiently) fails, in such a way that the resulting swap tree enjoys some nice property in terms of the currently implemented communication protocol. By doing in this way, rerouting and set-up costs will be minimized, in general, and the quality of the post-failure service remains guaranteed. Then, an all best swap edges (ABSE) problem is that of finding efficiently (in term of time complexity) a best swap edge for each tree edge.

Due to their fault-tolerance application counterpart, ABSE problems received a large attention by the algorithmic community. In such a framework, a key role has been played by the Shortest-Path Tree (SPT) structure, which is commonly used for implementing efficiently the broadcasting communication primitive. Indeed, it is was shown already in [15] that an effective post-swap broadcast protocol can be put in place just after the original SPT undergoes an edge failure. Not surprisingly then, several ABSE problems w.r.t. an SPT have been studied in the literature, for many different swap criteria.

Previous work on swapping in an SPT. Since an SPT enjoys several optimality criteria when looking at distances from the source, say s, several papers have analyzed the problem in various respects. However, most of the efforts focused on the minimization w.r.t. the following two swap criterion: the maximum/average distance from s to any node which remained disconnected from s after a failure. The currently fastest solutions for these two ABSE problems run in \(O(m \log \alpha (m,n))\) time [5] and \(O(m \, \alpha (n,n) \log ^2 n)\) time [8], respectively. Moreover, it has been shown that in the swap tree the maximum (resp., average) distance of the disconnected nodes from s is at most twice (resp., triple) that of the new optimum SPT [18], and these bounds are tight.

Other interesting swap criteria which have been analyzed include the minimization of the maximum increase (before and after the failure) of the distance from s, and the minimization of the distance from s to the root of the subtree that gets disconnected after the failure [17]. Besides the centralized setting, all these swap problems have been studied also in a distributed framework (e.g., see [7, 10,11,12]).

On the other hand, no results are known for the case in which one is willing to select a BSE with the goal of minimizing either the maximum or the average stretch from the source s of the disconnected nodes, where the stretch of a node is measured as the ratio between its distance from s in the swap tree and in a new optimum SPT. This is very surprising, since they are (especially the former one) the universally accepted criterion leading to the design of a spanner, i.e., a sparse subgraph preserving shortest paths (between pairs of vertices of interest) in a graph (also in the presence of failures).

In this paper, we aim to fill this gap, by providing efficient solutions exactly for these two swap criteria.

Our results. Let us denote by ABSE-MS and ABSE-AS the ABSE problem w.r.t. the maximum and the average stretch swap criterion, respectively. For such problems, we devise two efficient algorithms running in \(O(m n +n^2 \log n)\) and \(O(m n \log \alpha (m,n))\) time, respectively. Notice that both solutions incorporate the running time for computing all the replacement shortest paths from the source after the failure of every edge of the SPT, as provided in [13], whose computation essentially dominates in an asymptotic sense the time complexity. Our two solutions are based on independent ideas, as described in the following:

  • for the ABSE-MS problem, we develop a centroid decomposition of the SPT, and we exploit a distance property that has to be enjoyed by a BSE w.r.t. a nested and log-depth hierarchy of centroids, which will be defined by the subtree detached from the source after the currently analyzed edge failure. A further simple filtering trick on the set of potential swap edges will allow to reduce them from O(m) to O(n), thus returning the promised \(O(n^2 \log n)\) time.

  • for the ABSE-AS problem, we instead suitably combine a set of linearly-computable (at every edge fault) information, that essentially will allow to describe in O(1) time the quality of a swap edge. This procedure is in principle not obvious, since to compute the average stretch we need to know, for each swap edge, the O(n) distances to all the nodes in the detached subtree. Again, by filtering on the set of potential swap edges, we will get an \(O(n^2)\) running time, which will be absorbed by the all-replacement paths time complexity.

Concerning the quality of the corresponding swap trees, we instead show that the guaranteed (either maximum or average, respectively) stretch factor w.r.t. the paths emanating from the source (in the surviving graph) is equal to 3, and this is tight. By using a different terminology, our structures can then be revised as edge-fault-tolerant single-source 3-spanners, and we qualified them as effective since they can be computed quickly, are very sparse, provide a very simple alternative post-failure routing, and finally have a small (either maximum or average) stretch.

Although the proposed solutions are quite efficient, their running time can become prohibitive for large and dense input graphs, since in this case they would amount to a time cubic in the number of vertices. Unfortunately, it turns out that their improvement is unlikely to be achieved, unless one could avoid the explicit recomputation of all post-failure distances from the source. To circumvent this problem, we then adopt a different approach, which by the way finds application for the (most relevant) max-stretch measure only: we renounce to optimality in the detection of a BSE, in return of a substantial improvement (in the order of a linear factor in n) in the runtime. More precisely, for such a measure, we will compute in an almost linear \(O(m \log \alpha (m,n))\) time a set of good swap edges (GSE), each of which will guarantee a relative approximation factor on the maximum stretch of 3 / 2 (tight) as opposed to that provided by the corresponding BSE. Moreover, a GSE will still guarantee an absolute maximum stretch factor w.r.t. the paths emanating from the source (in the surviving graph) equal to 3 (tight).

Besides that, we also point out another important feature concerned with the computation in a distributed setting of all our good swap edges. Indeed, in [7] it was shown that they can be computed in an asynchronous message passing system in essentially optimal ideal time,Footnote 1 space usage, and message complexity, as opposed to the recomputation of all the corresponding BSE, for which no efficient solution is currently available.

Other related results. Besides swap-based approaches, an SPT can be made edge-fault-tolerant by further enriching the set of additional edges, so that the obtained structure has almost-shortest paths emanating from the source, once an edge fails. The currently best trade off between the size of the set of additional edges and the quality of the resulting paths emanating from s is provided in [3], where the authors showed that for any arbitrary constant \(\varepsilon >0\), one can compute in polynomial time a slightly superlinear (in n, and depending on \(\varepsilon \)) number of additional edges in such a way that the resulting structure retains \((1+\varepsilon )\)-stretched post-failure paths from the source.

For the sake of completeness, we also quickly recall the main results concerned with ABSE problems. For the minimum spanning tree (MST), a BSE is of course one minimizing the cost of the swap tree, i.e., a swap edge of minimum cost. This problem is also known as the MST sensitivity analysis problem, and can be solved in \(O(m\log \alpha (m,n))\) time [19]. Concerning the minimum diameter spanning tree, a BSE is instead one minimizing the diameter of the swap tree [14, 17], and the best solution runs in \(O(m \log \alpha (m,n))\) time [5]. Regarding the minimum routing-cost spanning tree, a BSE is clearly one minimizing the all-to-all routing cost of the swap tree [21], and the fastest solutions for solving this problem has a running time of \(O\left( m 2^{O(\alpha (n,n))}\log ^2 n\right) \) [4]. Finally, for a tree spanner, a BSE is one minimizing the maximum stretch w.r.t. the all pair distances, and the fastest solution to date run in \(O(m^2 \log \alpha (m,n))\) time [1].

To conclude, we point out that the general problem of designing fault-tolerant spanners for the all-to-all case has been extensively studied in the literature, and we refer the interested reader to [2, 6, 9] and the references therein.

2 Problem Definition

Let \(G = (V(G), E(G), w)\) be a 2-edge-connected, edge-weighted, and undirected graph with cost function \(w : E(G) \rightarrow \mathbb {R}^+\). We denote by n and m the number of vertices and edges of G, respectively. If \(X \subseteq V\), let E(X) be the set of edges incident to at least one vertex in X. Given an edge \(e \in E(G)\), we will denote by \(G-e\) the graph obtained from G by removing edge e. Similarly, given a vertex \(v \in V(G)\), we will denote by \(G-v\) the graph obtained from G by removing vertex v and all its incident edges. Let T be an SPT of G rooted at \(s \in V(G)\). Given an edge \(e \in E(T)\), we let C(e) be the set of all the swap edges for e, i.e., all edges in \(E(G) \setminus \{ e \}\) whose endpoints lie in two different connected components of \(T-e\), and let C(eX) be the set of all the swap edge for e incident to a vertex in \(X \subseteq V(G)\). For any \(e \in E(T)\) and \(f \in C(e)\), let \(T_{e/f}\) denote the swap tree obtained from T by replacing e with f. Let \(T_v = (V(T_v), E(T_v))\) be the subtree of T rooted at \(v \in V(G)\). Given a pair of vertices \(u,v \in V(G)\), we denote by \(d_G(u,v)\) the distance between u and v in G. Moreover, for a swap edge \(f=(x,y)\), we assume that the first appearing endvertex is the one closest to the source, and we may denote by w(xy) its weight. We define the stretch factor of y w.r.t. sTG as \(\sigma _G(T,y) = \frac{d_T(s,y)}{d_G(s,y)}\).

Given an SPT T of G, the ABSE-MS problem is that of finding, for each edge \(e=(a,b) \in E(T)\), a swap edge \(f^*\) such that:

$$\begin{aligned} f^* \in \arg \min _{f \in C(e)} \left\{ \mu (f):= \max _{v\in V(T_b)}\sigma _{G-e}\big (T_{e/f},v\big ) \right\} . \end{aligned}$$

Similarly, the ABSE-AS problem is that of finding, for each edge \(e=(a,b) \in E(T)\), a swap edge \(f^*\) such that:

$$\begin{aligned} f^* \in \arg \min _{f \in C(e)} \Bigg \{ \lambda (f):=\frac{1}{|V(T_b)|}\sum _{v\in V(T_b)} \sigma _{G-e}\big (T_{e/f},v\big ) \Bigg \}. \end{aligned}$$

We will call \(\mu (f)\) (resp., \(\lambda (f)\)) the max-(resp., avg-)stretch of f w.r.t. e.

3 An Algorithm for ABSE-MS

In this section we will show an efficient algorithm to solve the ABSE-MS problem in \(O(mn + n^2 \log n)\) time. Notice that a brute-force approach would require \(O(mn^2)\) time, given by the O(n) time which is needed to evaluate the quality of each of the O(m) swap edges, for each of the \(n-1\) edges of T. Our algorithm will run through \(n-1\) phases, each returning in \(O(m+n\log n)\) time a BSE for a failing edge of T, as described in the following.

Let us fix \(e=(a,b)\) as the failing edge. First, we compute in \(O(m+ n \log n)\) time all the distances in \(G-e\) from s. Then, we filter the O(m) potential swap edges to O(n), i.e., at most one for each node v in \(T_b\). Such a filtering is simply obtained by selecting, out of all edges \(f=(x,v) \in C(e, \{ v \})\), the one minimizing the measure \(d_G(s,x)+w(f)\). Indeed, it is easy to see that the max-stretch of such selected swap edge is never worse than that of every other swap edge in C(e). This filtering phase will cost O(m) total time. As a consequence, we will henceforth assume that \(|C(e)| = O(n)\).

Then, out of the obtained O(n) swap edges for e, we further restrict our attention to a subset of \(O(\log n)\) candidates as BSE, which are computed as follows. Let \(\varLambda \) denote a generic subtree of \(T_b\), and assume that initially \(\varLambda =T_b\). First of all, we compute in \(O(|V(\varLambda )|)\) time a centroid c of \(\varLambda \), namely a node whose removal from \(\varLambda \) splits \(\varLambda \) in a forest F of subtrees, each having at most \(|V(\varLambda )|/2\) nodes [16]; then, out of all the swap edges, we select a candidate edge f minimizing the distance from s to c in \(T_{e/f}\), i.e.,

$$\begin{aligned} f \in \displaystyle \arg \min _{(x',v') \in C(e)} \big \{d_T(s,x')+w(x',v')+d_{T}(v',c)\big \}; \end{aligned}$$

then, we compute a critical node z for the selected swap edge f, i.e.,

$$\begin{aligned} z \in \arg \max _{z' \in V(T_b)}\sigma _{G-e}\big (T_{e/f},z'\big ). \end{aligned}$$

We now select a suitable subtree \(\varLambda '\) of the forest F, and we pass to the selection of the next candidate BSE by recursing on \(\varLambda '\), until \(|V(\varLambda ')|=1\). More precisely, \(\varLambda '\) is the first tree of F containing the first vertex of \(V(\varLambda )\) that is encountered by following the path in T from z towards c (see Fig. 1).

Due to the property of the centroid, the number of recursions will be \(O\big (\log |V(T_b)|\big )= O(\log n)\), as promised, each costing O(n) time. Moreover, at least one of the candidate edges will be a BSE for e, and hence it suffices to choose the edge minimizing the maximum stretch among the corresponding \(O(\log n)\) candidate edges. This step is done within the recursive procedure by comparing the current candidate edge f with the best candidate resulting from the nested recursive calls.

A more formal description of each phase is shown in Algorithm 1. In the following we prove the correctness of our algorithm.

Fig. 1.
figure 1

The situation illustrated in Lemma 1. The subtree \(\varLambda \) is represented by the three gray triangles along with the vertex c. \(f=(x,v)\) is the candidate swap edge for e that minimizes \(d_T(s,x)+w(f)+ d_T(v,c)\), and z is its corresponding critical node. The algorithm will compute the next candidate swap edge by recursing on \(\varLambda '\).

Lemma 1

Let \(e=(a,b)\) be a failing edge, and let \(\varLambda \) be a subtree of \(T_b\). Given a vertex \(c \in V(\varLambda )\), let \(f \in \arg \min _{ (x',v') \in C(e)} \big \{ d_T(s,v') + w(x',v') + d_T(v', c) \big \}\) and let z be a critical node for f. Let F be the forest obtained by removing the edges incident to c from \(\varLambda \), and let \(\varLambda '\) be the tree of F containing the first vertex of the path from z to c in T that is also in \(V(\varLambda )\). For any swap edge \(f' \in C(e,V(\varLambda ))\), if \(\mu (f') < \mu (f)\) then \(f' \in C(e, V(\varLambda '))\).

Proof

Let \(f=(x, v)\) and \(f' = (x', v')\). We show that if \(v' \in V(\varLambda ) \setminus V(\varLambda ')\) then \(\mu (f') \ge \mu (f)\) (see also Fig. 1). Indeed:

$$\begin{aligned} \mu (f')&\ge \sigma _{G-e}\big (T_{e/f'}, z\big ) = \frac{ d_{T_{e/f'}}(s,z)}{d_{G-e}(s, z)} = \frac{ d_T(s,x') + w(f') + d_T(v',c) + d_T(c,z) }{d_{G-e}(s, z)} \\&\ge \frac{ d_T(s,x) + w(f) + d_T(v,c) + d_T(c,z) }{d_{G-e}(s, z)} \ge \frac{ d_{T_e/f}(s,z) }{d_{G-e}(s, z)} = \sigma _{G-e}\big (T_{e/f}, z\big ) \\&= \mu (f), \end{aligned}$$

where we used the equality \(d_T(v',z) = d_T(v',c) + d_T(c,z)\), which follows from the fact that the path from \(v'\) to z in T must traverse c as \(v'\) and z are in two different trees of F.    \(\square \)

figure a

Lemma 2

If \(C\big (e, V(\varLambda )\big )\) contains a BSE for e then \(\texttt {ABSE-MS} {}(e, \varLambda )\) returns a BSE for e.

Proof

First of all notice that Algorithm 1 only returns edges in C(e).

We prove the claim by induction on \(|V(\varLambda )|\). If \(|V(\varLambda )|=1\) and \(C\big (e, V(\varLambda )\big )\) contains a BSE \(f^*\) for e, then let f be the edge of C(e) returned by Algorithm 1 and let \(V(\varLambda )=\{c\}\). By choice of f, for every \(v \in V(T_b)\),

$$d_{T_{e/f}}(s,v)\le d_{T_{e/f}}(s,c)+d_T(c,v)=d_{T_{e/f^*}}(s,c)+d_T(c,v) = d_{T_{e/f^*}}(s,v),$$

from which we derive that \(\mu (f) = \mu (f^*)\), and the claim follows.

If \(|V(\varLambda )| > 1\) and \(C\big (e, V(\varLambda )\big )\) contains a BSE for e, we distinguish two cases depending on whether the edge f computed by Algorithm 1 is a BSE for e or not. If that is the case, then \(\mu (f) \le \mu (f'') \, \forall f'' \in C(e)\) and the algorithm correctly returns f. Otherwise, by Lemma 1, any edge \(f' \in C(e, V(\varLambda ))\) such that \(\mu (f') < \mu (f)\) must belong to \(C\big (e, V(\varLambda ')\big )\). It follows that \(\varLambda '\) contains a BSE for e and since \(1 \le |V(\varLambda ')| < |V(\varLambda )|\) we have, by inductive hypothesis, that the edge \(f'\) returned by \(\texttt {ABSE-MS} {}(G, e, \varLambda ')\) is a BSE for e. Clearly \(\mu (f') < \mu (f)\) and hence Algorithm 1 correctly returns \(f'\).    \(\square \)

Since each invocation of Algorithm 1 requires O(n) time, Lemma 2 together with the previous discussions allows us to state the main theorem of this section:

Theorem 1

There exists an algorithm that solves the ABSE-MS problem in \(O(mn + n^2 \log n)\) time.

4 An Algorithm for ABSE-AS

In this section we show how the ABSE-AS problem can be solved efficiently in \(O(mn \log \alpha (m,n))\) time. Our approach first of all, in a preprocessing phase, computes in \(O(m \, n \log \alpha (m,n))\) time all the replacement shortest paths from the source after the failure of every edge of T [13]. Then, the algorithm will run through \(n-1\) phases, each returning in O(m) time a BSE for a failing edge of T, as described in the following. Thus, the overall time complexity will be dominated by the preprocessing step.

Let us fix \(e=(a,b)\in E(T)\) as the failing edge of T. The idea is to show that, after a O(n) preprocessing time, we can compute the avg-stretch \(\lambda (f)\) of any f in constant time. This immediately implies that we can compute a BSE for e by looking at all O(m) swap edges for e.

Let \(U=V(T_b)\) and let y be a node in U, we define:

$$\begin{aligned} M(y)=\sum _{v \in U} \frac{d_T(y,v)}{d_{G-e}(s,v)} \end{aligned}$$

and

$$\begin{aligned}Q = \sum _{v \in U} \frac{1}{d_{G-e}(s,v)}. \end{aligned}$$

Let \(f=(x,y)\) be a candidate swap edge incident in \(y \in U\). The avg-stretch of f can be rewritten as:

$$\begin{aligned} \lambda (f)=\sum _{v \in U}\frac{d_T(s,x)+w(f)+d_T(y,v)}{d_{G-e}(s,v)} = \big (d_T(s,x)+w(f)\big )Q + M(y). \end{aligned}$$

Hence, the avg-stretch of f can be computed in O(1) time, once Q and M(y) are available in constant time. Observe that Q does not depend on y and can be computed in O(n) time. The rest of this section is devoted to show how to compute M(y) for every \(y \in U\) in O(n) overall time.

Computing \({\varvec{M(y)}}\) for all \({\varvec{y}} \in {\varvec{U}}\) . Let y e \(y'\) be two nodes in U such that y is a child of \(y'\) in T. Moreover, let \(U_y=V(T_y)\), and let \(Q_y = \sum _{v \in U_y} \frac{1}{d_{G-e}(s,y)}\). Hence, we can rewrite M(y) and \(M(y')\) as follows:

$$\begin{aligned} M(y) = \sum _{v \in U_y} \frac{d_T(y,v)}{d_{G-e}(s,v)} + \sum _{v \in U-U_y} \frac{w(y,y')+d_T(y',v)}{d_{G-e}(s,v)} \end{aligned}$$

and

$$\begin{aligned} M(y') = \sum _{v \in U_y} \frac{w(y,y')+d_T(y,v)}{d_{G-e}(s,v)} + \sum _{v \in U-U_y} \frac{d_T(y',v)}{d_{G-e}(s,v)}. \end{aligned}$$

Therefore, we have:

$$\begin{aligned} M(y) = M(y') + w(y,y') \big (- Q_y + (Q - Q_y)\big ) = M(y') + w(y,y') \big (Q - 2Q_y\big ). \end{aligned}$$
(1)

The above equation implies that M(y) can be computed in O(1) time, once we have computed \(M(y')\), Q and \(Q_y\). As a consequence, we can compute all the M(y)’s as follows. First, we compute \(Q_y\) for every \(y\in D\) in O(n) overall time by means of a postorder visit of \(T_b\). Notice also that \(Q=Q_b\). Then, we compute M(b) explicitly in O(n) time. Finally, we compute all the other M(y)’s by performing a preorder visit of \(T_b\). When we visit a node y, we compute M(y) in constant time using (1). Thus, the visit will take O(n) time. We have proved the following:

Theorem 2

There exists an algorithm that solves the ABSE-AS problem in \(O(mn \log \alpha (m,n))\) time.

5 An Approximate Solution for ABSE-MS

In this section we show that for the max-stretch measure we can compute in an almost linear \(O(m \log \alpha (m,n))\) time, a set of good swap edges (GSE), each of which guarantees a relative approximation factor on the maximum stretch of 3 / 2 (tight), as opposed to that provided by the corresponding BSE. Moreover, as shown in the next section, each GSE still guarantees an absolute maximum stretch factor w.r.t. the paths emanating from the source (in the surviving graph) equal to 3 (tight).

Lemma 3

Let e be a failing edge in T, let

$$\begin{aligned}g=(x,y) \in \arg \min _{(x',v') \in C(e)}\big \{d_T(s,x')+w(x',v')\big \},\end{aligned}$$

and, finally, let \(f=(x',y')\) be a best swap edge for e w.r.t. ABSE-MS. Then, \(\mu (g)/\mu (f) \le 3/2\).

Proof

Let z be the critical node for the good swap edge g, and let t (resp., \(t'\)) denote the least common ancestor in T between \(y'\) and z (resp., \(y'\) and y). Let \(D=d_T(s,x)+w(x,y)=d_{G-e}(s,y)\). By choice of g, it holds that \(d_{G-e}(s,z) \ge D\) and \(d_{G-e}(s,y' ) \ge D\). We divide the proof into the following two cases, as depicted in Fig. 2: either (1) t is an ancestor of \(t'\) in T, or (2) \(t'\) is an ancestor of t in T. Let ABC denote the distance in T between y and \(t'\), \(t'\) and t, t and z, respectively.

Fig. 2.
figure 2

The figure shows the two cases of the analysis, on the left t is an ancestor of \(t^\prime \), while on the right the opposite holds. The splines denote a path, while the straight lines represent a single edge.

Case 1. Since t is an ancestor of \(t'\) (left side of Fig. 2), we have that \(d_{T_{e/f}}(s,y) \ge D+A\) and we can write:

$$\begin{aligned} \sigma _{G-e}(T_{e/f},y) \ge \frac{D+A}{d_{G-e}(s,y)} = \frac{D+A}{D} \ge \frac{D+A}{d_{G-e}(s,z)}, \end{aligned}$$

and similarly \(\sigma _{G-e}(T_{e/f},z) \ge \frac{D+B+C}{d_{G-e}(s,z)}\). Moreover, by the definition of \(\mu (\cdot )\) we have that \(\mu (f) \ge \max \{\sigma _{G-e}(T_{e/f},y), \sigma _{G-e}(T_{e/f},z)\}\). The previous inequalities together imply:

$$\begin{aligned} \frac{\mu (g)}{\mu (f)} \le \frac{\sigma _{G-e}(T_{e/g},z)}{\max \{\sigma _{G-e}(T_{e/f},y), \sigma _{G-e}(T_{e/f},z)\}} \le \frac{A+B+C+D}{D+\max \left\{ A, B+C \right\} .} \end{aligned}$$
(2)

Now we divide the proof into two subcases, depending on whether \(B+C \ge A\) or \(B+C < A\). Observe that \(D \ge d_G(s,y) \ge A\). If \(B+C \ge A\), then (2) becomes:

$$\begin{aligned} \frac{\mu (g)}{\mu (f)} \le \frac{A+B+C+D}{B+C+D} = 1 + \frac{A}{B+C+D} \le 1 + \frac{A}{2A} = \frac{3}{2}, \end{aligned}$$

otherwise, if \(B+C < A\), then (2) becomes:

$$\begin{aligned} \frac{\mu (g)}{\mu (f)} \le \frac{A+B+C+D}{A+D} < \frac{2A+D}{A+D} = 1 + \frac{A}{A+D} \le 1 + \frac{A}{2A} = \frac{3}{2}. \end{aligned}$$

Case 2. Assume now that \(t'\) is an ancestor of t (right side of Fig. 2). Since

$$\begin{aligned} \mu (f) \ge \sigma _{G-e}(T_{e/f},y) \ge \frac{d_{G-e}(s,y')+A+B}{d_{G-e}(s,y)}=\frac{d_{G-e}(s,y')+A+B}{D}, \end{aligned}$$

we have that:

$$\begin{aligned} \frac{\mu (g)}{\mu (f)}&\le \frac{A+B+C+D}{d_{G-e}(s,z)} \cdot \frac{D}{d_{G-e}(s,y')+A+B} \\&\le \frac{A+B+C+D}{d_{G-e}(s,z)} \cdot \frac{D}{A+B+D} \end{aligned}$$

and since \(d_{G-e}(s,z) \ge d_G(s,z) \ge C\), and recalling that \(d_{G-e}(s,z) \ge D\), we have:

$$\begin{aligned} \frac{\mu (g)}{\mu (f)} \le \frac{A+B+C+D}{A+B+D} \cdot \frac{D}{\max \left\{ C,D \right\} } = \left( 1 + \frac{C}{A+B+D} \right) \cdot \frac{D}{\max \left\{ C,D \right\} }. \end{aligned}$$
(3)

Moreover, notice that also the following holds:

$$\begin{aligned} \nonumber \frac{\mu (g)}{\mu (f)}&\le \frac{\mu (g)}{\sigma _{G-e}(T_{e/f},z)} \le \frac{A+B+C+D}{d_{G-e}(s,z)} \cdot \frac{d_{G-e}(s,z)}{d_{G-e}(s,y') + d_T(y',t)+C} \\&\le \frac{A+B+C+D}{C+D} = 1+ \frac{A+B}{C+D}. \end{aligned}$$
(4)

We divide the proof into the following two subcases, depending on whether \(D \ge C\) or \(D < C\). In the first subcase, i.e., \(D \ge C\), we have that (3) becomes \(\frac{\mu (g)}{\mu (f)} \le 1 + \frac{C}{A+B+D}\), and hence, by combining this inequality with (4), we obtain:

$$\begin{aligned} \frac{\mu (g)}{\mu (f)}&\le 1+ \min \left\{ \frac{C}{A+B+D}, \frac{A+B}{C+D}\right\} \\&\le 1+ \min \left\{ \frac{C}{A+B+C}, \frac{A+B}{2C}\right\} \le 1+\frac{1}{2}=\frac{3}{2}. \end{aligned}$$

In the second subcase, i.e., \(D < C\), (3) becomes:

$$\begin{aligned} \frac{\mu (g)}{\mu (f)} \le \left( 1 + \frac{C}{A+B+D} \right) \cdot \frac{D}{C} \le \frac{D}{C} + \frac{D}{A+B+D} < 1 + \frac{D}{A+B+D}, \end{aligned}$$
(5)

and hence, by combining (5) and (4), we have that:

$$\begin{aligned} \nonumber \frac{\mu (g)}{\mu (f)}&\le 1+ \min \left\{ \frac{D}{A+B+D}, \frac{A+B}{C+D}\right\} \\&\le 1+ \min \left\{ \frac{D}{A+B+D}, \frac{A+B}{2D}\right\} \le 1+\frac{1}{2}=\frac{3}{2}, \end{aligned}$$

from which the claim follows.    \(\square \)

Given the result of Lemma 3, we can derive an efficient algorithm to compute all the GSE for ABSE-MS. More precisely, in [18] it was shown how to find them in \(O(m \, \alpha (m,n))\) time. Essentially, the approach used in [18] was based on a reduction to the SPT sensitivity analysis problem [20]. However, in [19] it was proposed a faster solution to such a problem, running in \(O(m \, \log \alpha (m,n))\) time. Thus, we can provide the following

Theorem 3

There exists a 3 / 2-approximation algorithm that solves the ABSE-MS problem in \(O(m \log \alpha (m,n))\) time.

We conclude this section with a tight example which shows that the analysis provided in Lemma 3 is tight (see Fig. 3).

Fig. 3.
figure 3

A tight example showing that the quality of the good swap edge g computed by the algorithm is a factor of 3 / 2 away from the qualify of a best swap edge f. In the picture, it is assumed that the distance from s to b is equal to 0, while the three dashed edges are assumed to be incident to the source, and the labels correspond to their weight. Then, \(\mu (f) = \sigma _{G-e}(T_{e/f},y) =\frac{2D+\epsilon }{D} \simeq 2\), while \(\mu (g) = \sigma _{G-e}(T_{e/g},z) = \frac{3D}{D+\epsilon }\simeq 3\), for small values of \(\epsilon \).

6 Quality Analysis

As for previous studies on swap edges, it is interesting now to see how the tree obtained from swapping a failing edge \(e=(a,b)\) with its BSE f compares with a true SPT of \(G-e\). According to our swap criteria, we will then analyze the lower and upper bounds of the max- and avg-stretch of f, i.e., \(\mu (f)\) and \(\lambda (f)\), respectively.

As already observed in the introduction, it is well-known [18] that for the swap edge, say g, which belongs to the shortest path in \(G-e\) between s and the root of the detached subtree \(T_b\), we have that for any \(v \in V(T_b)\), \(\sigma _{G-e}(T_{e/g},v) \le 3\). This immediately implies that \(\mu (g),\lambda (g) \le 3\), namely \(\mu (f),\lambda (f) \le 3\). These bounds happen to be tight, as shown in Fig. 4.

Fig. 4.
figure 4

Tight ratios for \(\mu (f)\) and \(\lambda (f)\). In the picture, the SPT T (solid edges) along with the removed edge \(e=(a,b)\) of weight 0; non-tree edges are dashed and the best swap edge (for both the maximum and the average stretch) is easily seen to be \(f=(x,y)\), of weight \(\epsilon >0\). Then, we have that \(\mu (f)=\frac{3D+\epsilon }{D+2 \epsilon }\), which tends to 3 for small values of \(\epsilon \), while \(\lambda (f)\) tends to 3 as well, as soon as the number of leaves grows. Notice that f is also a good swap edge for e.

Let us now analyze the lower and upper bounds of the max-stretch of a good swap edge g, i.e., \(\mu (g)\), as defined in the previous section. First of all, once again it was proven in [17] that for any \(v \in V(T_b)\), \(\sigma _{G-e}(T_{e/g},v) \le 3\), which implies that \(\mu (g) \le 3\). Moreover, the example shown in Fig. 4 can be used to verify that this bound is tight.

7 Conclusions

In this paper we have studied two natural SPT swap problems, aiming to minimize, after the failure of any edge of the given SPT, either the maximum or the average stretch factor induced by a swap edge. We have first proposed two efficient algorithms to solve both problems. Then, aiming to the design of faster algorithms, we developed for the maximum-stretch measure an almost linear algorithm guaranteeing a 3 / 2-approximation w.r.t. the optimum.

Concerning future research directions, the most important open problem remains that of finding a linear-size edge-fault-tolerant SPT with a (maximum) stretch factor w.r.t. the root better than 3, or to prove that this is unfeasible. Another interesting open problem is that of improving the running time of our exact solutions. Notice that both our exact algorithms pass through the computation of all the post-failure single-source distances, and if we could avoid that we would get faster solutions. At a first glance, this sounds very hard, since the stretches are heavily dependant on post-failure distances, but, at least in principle, one could exploit some monotonicity property among swap edges that could allow to skip such a bottleneck. Besides that, it would be nice to design a fast approximation algorithm for the average-stretch measure. Apparently, in this case it is not easy to adopt an approach based on good swap edges as for the maximum-stretch case, since swap edges optimizing other reasonable swap criteria (e.g., minimizing the distance towards the root of the detached subtree, or minimizing the distance towards a detached node) are easily seen to produce an approximation ratio of 3 as opposed to a BSE. A candidate solution may be that of selecting a BSE w.r.t. the sum-of-distances criterium, which can be solved in almost linear time [8], but for which we are currently unable to provide a corresponding comparative analysis.

Finally, we mention that a concrete task which will be pursued is that of conducting an extensive experimental analysis of the true performances of our algorithms, to check whether for real-world instances the obtained stretches are sensibly better or not w.r.t. the theoretical bounds.