1 Introduction

Reoptimization is a setting in which we are given an instance I of an optimization problem paired with an either optimal or approximate solution S for I and a local modification that, once applied to I, generates a new instance \(I'\) that slightly differs from I. The main goal is that of finding a good approximate solution of \(I'\). The idea beyond reoptimization is to exploit the structural properties of S when computing a good solution for \(I'\). This approach leads to the design of reoptimization algorithms that, when compared to classical algorithms that compute feasible solutions from scratch by ignoring both S and I, are much more efficient in terms of running time and/or output solutions that guarantee a better approximation ratio. Thus, reoptimization finds applications in many settings, like scheduling problems or network design problems, where prior knowledge is often at our disposal and a problem instance can arise from a local modification of a previously solved problem instance (for example, a scheduled job is canceled or some links of the network fail).

The term reoptimization was mentioned for the first time in the paper of Schäffter [35], where the author addressed an \(\textsf {NP}\)-hard scheduling problem with forbidden sets in the scenario of adding/removing a forbidden set. Since then, reoptimization has been successfully applied to other \(\textsf {NP}\)-hard problems includingFootnote 1: the Steiner tree problem  [8, 11, 13,14,15, 31, 32, 37], the traveling salesman problem and some of its variants  [1, 5, 7, 12, 15,16,17,18,19, 34], scheduling problems [6, 21], the minimum latency problem [28, 29], the minimum spanning tree problem [24], the rural postman problem [3], many covering problems [10], the shortest superstring problem [9], the knapsack problem [2], the maximum-weight induced hereditary subgraph problems [22], and the maximum \(P_k\) subgraph problem [23]. Some overviews on other \(\textsf {NP}\)-hard reoptimization problems can be found in [4, 25, 36].

1.1 Our Results

In this paper we address Steiner tree reoptimization. Steiner tree reoptimization is a collection of optimization problems that are built on top of the famous Steiner tree problem (\( STP \) for short). An \( STP \) instance consists of an n-vertex, connected undirected graph G with non-negative edge costs, where each vertex can be either terminal or Steiner. The goal in \( STP \) is to find a minimum-cost tree contained in G that spans all the terminals. It is well-known that \( STP \) is not approximable within a factor better that 96/95, unless \(\textsf {P}=\textsf {NP}\) [27], but can be approximated, in polynomial time, within a factor of \(\sigma =\ln 4 + \varepsilon \approx 1.387\), for every constant \(\varepsilon > 0\) [26].

In the Steiner tree reoptimization problems we address in this paper we modify the instance by either changing the cost of an edge (the edge cost can either increase or decrease) or by changing the status of a vertex, from Steiner to terminal or from terminal to Steiner. We observe that the edge-cost modifications also capture the scenarios in which we either add an edge to the graph or we delete an edge from the graph. In fact, the addition of an edge can be modeled by changing the cost of the edge from a very large value to the desired value, while the deletion of an edge can be modeled by changing the cost of the edge to a very large value.

All the Steiner tree reoptimization problems addressed in this paper are strongly \(\textsf {NP}\)-hard [14, 15], which implies that none of them admits a fully polynomial-time approximation scheme, unless \(\textsf {P}= \textsf {NP}\). In this paper we improve upon all the constant-factor approximation algorithms that have been developed in the last decades (see  [8, 11, 13,14,15, 31, 32, 37]) by designing polynomial-time approximation schemes. More precisely, for a given \(\rho \)-approximate solution S of the instance I and for every constant \(\varepsilon > 0\), all our algorithms compute a \((\rho +\varepsilon )\)-approximate solution of \(I'\) in polynomial time. For the scenarios in which the cost of an edge decreases or a terminal vertex becomes Steiner, our polynomial-time approximation schemes hold under the assumption that S is an optimal solution of I, i.e., \(\rho =1\). We observe that this assumption is somehow necessary since Goyal and Mömke  [32] proved that in both scenarios, unless \(\rho =1\), any \(\sigma \)-approximation algorithm for the reoptimization problem with polynomial running time could be used to design a polynomial-time \(\sigma \)-approximation algorithm for the \( STP \). Remarkably, prior to this paper, no approximation algorithm better than recomputing a \((\ln 4 + \varepsilon )\)-approximate solution from scratch using the algorithm in [26] was known for the elusive scenario in which the cost of a single edge decreases.

The current state of the art of Steiner tree reoptimization is summarized in Table 1. We observe that the only problem that remains open is the design of a reoptimization algorithm for the scenario in which a vertex, that can be either terminal or Steiner, is added to the graph. In fact, as proved by Goyal and Mömke [32], the scenario in which a vertex is removed from the graph is as hard to approximate as the \( STP \).Footnote 2

Table 1 The state of the art of the approximability of Steiner tree reoptimization before and after our paper

1.2 Used Techniques

All the polynomial-time approximation schemes proposed in this paper make a clever use of the following three algorithms:

  • the algorithm \(\textsc {Connect}\) that takes as inputs an STP instance I and a Steiner forest of I. The algorithm augments the Steiner forest with a minimum-cost set of edges to obtain a Steiner tree of I. This algorithm has been introduced by Böckenhauer et al. [14] and has been subsequently used in several other papers on Steiner tree reoptimization  [11, 13, 32, 37].

  • the algorithmic proof of Borchers and Du [20] that, for every \(\xi > 0\), converts a Steiner tree S into an k-restricted Steiner tree \(S_{\xi }\), with \(k=2^{\lceil 1/\xi \rceil }\), such that the cost of \(S_{\xi }\) is at most a \((1+\xi )\)-factor away from the cost of S. This algorithm has been used for the first time in Steiner tree reoptimization by Goyal and Mömke [32];

  • a novel algorithm, that we call \(\textsc {BuildST}\), that takes a k-restricted Steiner forest \(S_{\xi }\) of S with q trees and a positive integer h as inputs and computes a minimum-cost Steiner tree \(S'\) among those solutions that can be obtained by swapping all the edges contained in up to h full components of \(S_{\xi }\) with a minimum-cost set of edges. The running time of this algorithm is polynomial when all the three parameters kq, and h are constant.

The algorithm \(\textsc {BuildST}\) computes several feasible solutions \(S_1, \dots , S_\ell \) for \(I'\) and returns the cheapest of them. We prove that the average cost of the computed feasible solutions is at most a \(\rho +\varepsilon \) factor away from the cost of an optimal solution for \(I'\). This clearly implies that the returned solution is \((\rho +\varepsilon )\)-approximate. Intuitively, each \(S_i\) is obtained by swapping up to h suitable full components, say \(H_i\), of a suitable k-restricted version of a forest in S, say \(S_{\xi }\), with a minimal set of full components, say \(H'_i\), of a \(k'\)-restricted version of a fixed optimal solution \( OPT '\). This implies that we can easily bound the cost of each \(S_i\) by a function that depends on the cost of \(S_{\xi }\), the cost of \(H_i\), and the cost of \(H'_i\). However, to prove that the computed solution is indeed a \((\rho +\varepsilon )\)-approximation of \( OPT '\), we need to define \(H_{i+1}\) as a function of both \( OPT '\) and \(H'_i\), and \(H'_{i}\) as a function of both \(S_{\xi }\) and \(H_i\). In this way, we obtain different upper bounds on the cost of the computed solutions for which we can easily compute the average.

The paper is organized as follows: in Sect. 2 we provide the basic definitions and some preliminaries; in Sect. 3 we describe the three main tools that are used in all our algorithms; in Sects. 456, and 7 we describe and analyze the algorithms for all the four local modifications addressed in this paper. Section 8 concludes the paper with a list of open problems in the field.

2 Basic Definitions and Preliminaries

The Steiner tree problem (\( STP \) for short) is defined as follows: The input is a triple \(I=\langle G, c, R\rangle \). \(G=(V(G),E(G))\) is an n-vertex connected undirected graph, where V(G) and E(G) denote the set of vertices and the set of edges, respectively, c is a function that associates a real value \(c(e)\ge 0\) to each edge \(e \in E(G)\), and \(R\subseteq V(G)\) is the set of terminal vertices. The problem asks to compute a minimum-cost Steiner tree of I, i.e., a tree contained in G that spans R and that minimizes the overall sum of its edge costs.

In Steiner tree reoptimization we are given a triple \(\langle I, S, I'\rangle \), where I is an \( STP \) instance, S is a \(\rho \)-approximate Steiner tree of I, and \(I'\) is another \( STP \) instance which slightly differs from I. The problem asks to find a \(\rho \)-approximate Steiner tree of \(I'\).

The vertices in \(V(G)\setminus R\) are also called Steiner vertices. With a slight abuse of notation, for any (not necessarily proper) subgraph H of G, we denote by \(c(H):=\sum _{e \in E(H)}c(e)\) the cost of H.

For a forest F of G and a set of edges \(E'\subseteq E(G)\), we denote by \(F+E'\) a forest yielded by the addition of all the edges in \(E'\setminus E(F)\) to F, i.e., we scan all the edges of \(E'\) one by one in any fixed order and we add the currently scanned edge to the forest only if the resulting graph remains a forest. Analogously, we denote by \(F-E'\) the forest yielded by the removal of all the edges in \(E'\cap E(F)\) from F. We use the shortcuts \(F+e\) and \(F-e\) to denote \(F+\{e\}\) and \(F-\{e\}\), respectively. Furthermore, if \(F'\) is another forest of G we also use the shortcuts \(F+F'\) and \(F-F'\) to denote \(F+E(F')\) and \(F-E(F')\), respectively. For a set of vertices \(U \subseteq V(G)\), we define \(F+U:=(V(F)\cup U, E(F))\) and use the shortcut \(F+v\) to denote \(F+\{v\}\).

W.l.o.g., in this paper we tacitly assume that all the leaves of the Steiner trees we compute are terminals. Indeed, if a Steiner tree S contains a leaf which is not a terminal, then we can always remove such a leaf from S to obtain another Steiner tree \(S'\) such that \(c(S')\le c(S)\). Analogously, we tacitly assume that all the leaves of a Steiner forest, i.e., a forest spanning all the terminals, are terminals. A full component of a Steiner forest F – so a Steiner tree as well – is a maximal (w.r.t. edge insertion) subtree of F whose leaves are all terminals and whose internal vertices are all Steiner vertices. We observe that each tree of a Steiner forest can always be decomposed into full components. A k-restricted Steiner forest is a Steiner forest where each of its full components has at most k terminals.

In the rest of the paper, for any superscript s (the empty string is included), we denote by \(I^s\) an \( STP \) instance (we tacitly assume that \(I^s=\langle G^s,c^s,R^s\rangle \) as well as that \(G^s\) has n vertices), by \( OPT ^s\) a fixed optimal solution of \(I^s\), by \(d^s\) the shortest-path metric induced by \(c^s\) in \(G^s\) (i.e, \(d^s(u,v)\) is equal to the cost of a shortest path between u and v in \(G^s\) w.r.t. cost function \(c^s\)), by \(K^s\) the complete graph on \(V(G^s)\) with edge costs \(d^s\), and by \(K^s_n\) the complete graph consisting of n copies of \(K^s\), where the cost of an edge between a vertex and any of its copies is equal to 0, while the cost of an edge (uv), with u not being a copy of v, is \(d^s(u,v)\). With a little abuse of notation, we use \(d^s\) to denote the cost function of \(K^s_n\). Moreover, we say that a subgraph H of \(K^s_n\) spans a vertex \(v \in V(G^s)\) if H spans – according to the standard terminology used in graph theory – any of the n copies of v. Finally, with a little abuse of notation, we denote by \(I_n^s\) the \( STP \) instance \(I_n^s=\langle K_n^s, d^s, R^s\rangle \).

Let I be an \( STP \) instance. We observe that any forest F of G is also a forest of K such that \(d(F)\le c(F)\). Moreover, any forest \(\bar{F}\) of K can be transformed in polynomial time into a forest F of G spanning \(V(\bar{F})\) and such that \(c(F)\le d(\bar{F})\). In fact, F can be build from an empty graph on V(G) by iteratively adding –according to our definition of graph addition– a shortest path between u and v in G, for every edge \((u,v) \in E(\bar{F})\).

We also observe that any forest F of K can be viewed as a forest of \(K_n\). Conversely, any forest F of \(K_n\) can be transformed in polynomial time into a forest of K spanning V(F) and having the same cost of F: it suffices to identify each of the 0-cost edges of F between any vertex and any of its copies. Therefore, we have polynomial-time algorithms that convert any forest F of any graph in \(\{G, K, K_n\}\) into a forest \(F'\) of any graph in \(\{G,K,K_n\}\) such that \(F'\) always spans V(F) and the cost of \(F'\) (according to the cost function associated with the corresponding graph) is less than or equal to the cost of F (according to the cost function associated with the corresponding graph). All these polynomial-time algorithms will be implicitly used in the rest of the paper; for example, we can say that a Steiner tree of \(I_n\) is also a Steiner tree of I or that a forest of \(I_n\) that spans v is also a forest of I that spans v. However, we observe that some of these polynomial-time algorithms do no preserve useful structural properties; for example, when transforming a k-restricted Steiner tree of \(I_n\) into a Steiner tree of I we may lose the property that the resulting tree is k-restricted. Therefore, whenever we refer to a structural property of a forest, we assume that such a property holds only w.r.t. the underlying graph the forest belongs to.

3 General Tools

In this section we describe the three main tools that are used by all our algorithms.

The first of them is the algorithm \(\textsc {Connect}\) that has been introduced by Böckenhauer et al. in [14]. This algorithm takes an \( STP \) instance I together with a Steiner forest F of I as inputs and computes a minimum-cost set of edges of G whose addition to F yields a Steiner tree of I. The algorithm \(\textsc {Connect}\) transforms I into a smaller \( STP \) instance, where each terminal vertex in the reduced instance corresponds to a tree of F. The algorithm then uses the famous Dreyfus-Wagner algorithm in [30] to find an optimal solution of the reduced instance.Footnote 3 The running time of the algorithm \(\textsc {Connect}\) is \(O^*(3^q)\), where q is the number of terminals in the reduced instance.Footnote 4 We observe that the algorithm \(\textsc {Connect}\) has polynomial running time when q is polylogarithmic in n. The call of the algorithm \(\textsc {Connect}\) with input parameters I and F is denoted by \(\textsc {Connect}(I,F)\).

The second tool is the algorithmic proof of Borchers and Du on k-restricted Steiner trees [20] that has already been used in Steiner tree reoptimization by Goyal and Mömke [32]. In their paper, Borchers and Du proved that, for every \( STP \) instance I and every \(\xi > 0\), there exists a k-restricted Steiner tree \(S_{\xi }\) of \(I_n\), with \(k=2^{\lceil {1/\xi }\rceil }\), such that \(d(S_{\xi }) \le (1+\xi )c( OPT )\). Furthermore, \(S_\xi \) can be constructed in polynomial time if we know \( OPT \). As the following theorem shows, the algorithmic proof of Borchers and Du immediately extends to any (not necessarily optimal) Steiner tree of \(I_n\).

Theorem 1

[20] Let I be an \( STP \) instance, S a Steiner tree of I, and \(\xi > 0\) a constant value. There is a polynomial time algorithm that computes a k-restricted Steiner tree \(S_{\xi }\) of \(I_n\), with \(k=2^{\lceil {1/\xi }\rceil }\), such that \(d(S_{\xi }) \le (1+\xi ) c(S)\).

Proof

Consider the \( STP \) instance \(I'=\langle G',d',R'\rangle \) in which \(G'\) is the complete graph on V(S), \(d'\) is the shortest path metric induced by c in S, and \(R'=R\). By construction, \(d'(S)=c(S)\). We claim that S is an optimal solution for \(I'\). Before proving this fact, we show its implications. As shown by Borchers and Du [20], we can compute a k-restricted Steiner tree \(S_\xi \) of \(I'\), with \(k=2^{\lceil {1/\xi }\rceil }\), such that \(d'(S_\xi ) \le (1+\xi )d'(S)=(1+\xi )c(S)\) in polynomial time. As S is a subgraph of G, for any two vertices \(u,v\in V(S)\), we have \(d(u,v) \le d'(u,v)\). Therefore, \(d(S_\xi ) \le d'(S_\xi )\). Hence, \(d(S_\xi )\le (1+\xi )c(S)\).

Therefore, to prove the theorem statement, it remains to show that S is an optimal solution for \(I'\). Let \(S'\) be a Steiner tree for \(I'\). For any edge \(e'\) of \(S'\), let \(P_{e'}\) be the unique path in S between the endvertices of \(e'\). By construction, we have that \(d'(e')=d'(P_{e'})\). Therefore, to show that \(d'(S)\le d'(S')\), it is enough to prove that any edge e of S is also an edge of \(P_{e'}\), for some edge \(e'\) of \(S'\). To see this, consider the forest \(S-e\) containing two trees, say \(T_1\) and \(T_2\), each of which spans some terminal vertices of R. As \(S'\) also spans R, there is an edge \(e'\) of \(S'\) that has one endvertex in \(T_1\) and the other endvertex in \(T_2\). As a consequence, e is an edge of \(P_{e'}\). \(\square \)

The call of Borchers and Du algorithm with input parameters I, S, and \(\xi \), is denoted by \(\textsc {RestrictedST}(I,S,\xi )\). By construction, the algorithm of Borchers and Du also guarantees the following properties:

  1. (a)

    if v is a Steiner vertex that has degree at least 3 in S, then \(S_{\xi }\) spans v;

  2. (b)

    if the degree of a terminal t in S is 2, then the degree of t in \(S_{\xi }\) is at most 4.

As shown in the following corollary, these two properties are useful if we need that a specific vertex of S is also contained in the k-restricted Steiner tree \(S_{\xi }\) of \(I_n\).

Corollary 1

Let I be an \( STP \) instance, S a Steiner tree of I, v a vertex of S, and \(\xi > 0\) a constant value. There is a polynomial time algorithm that computes a k-restricted Steiner tree \(S_{\xi }\) of \(I_n\), with \(k=2^{2+\lceil {1/\xi }\rceil }\), such that \(d(S_{\xi }) \le (1+\xi ) c(S)\) and \(v \in V(S_{\xi })\).

Proof

The cases in which \(v \in R\) immediately follows from Theorem 1. Moreover, the claim trivially holds by property (a) when v is a Steiner vertex of degree greater than or equal to 3 in S. Therefore we assume that v is a Steiner vertex of degree 2 in S. Let \(I' = \langle G,c,R\cup \{v\}\rangle \). In this case, the call of \(\textsc {RestrictedST}\big (I',S,\xi \big )\) outputs a \(k'\)-restricted Steiner tree \(S_{\xi }\) of \(I'_n\), with \(k'=2^{\lceil {1/\xi }\rceil }\), such that \(d(S_{\xi }) \le (1+\xi ) c(S)\). Since v is a terminal in \(I'\), by property (b) the degree of v in \(S_{\xi }\) is at most 4; in other words, v is contained in at most 4 full components of \(S_{\xi }\). Therefore, \(S_{\xi }\) is a k-restricted Steiner tree of I, with \(k=4 k'=2^{2+\lceil {1/\xi }\rceil }\). \(\square \)

The call of Borchers and Du algorithm with parameters I, S, \(\xi \), and v, where we want to force vertex v to be in the restricted Steiner tree that is computed by the algorithm, is denoted by \(\textsc {RestrictedST}(I,S,\xi ,v)\).

The third and last tool, which is the novel idea of this paper, is the algorithm \(\textsc {BuildST}\) (see Algorithm 1 for the pseudocode). The algorithm \(\textsc {BuildST}\) takes as inputs an \( STP \) instance I, a Steiner forest F of \(I_n\), and a positive integer value h. The algorithm computes a Steiner tree of I by selecting, among several feasible solutions, the one of minimum cost. More precisely, the algorithm computes a feasible solution for each forest \(\bar{F}\) that is obtained by removing from F all the edges of h full components of F (when F contains fewer than h full components the algorithm computes an optimal solution from scratch). The Steiner tree of I associated with \(\bar{F}\) is obtained by the call of \(\textsc {Connect}\big (I_n,\bar{F}\big )\). If F contains at most h full components, then the algorithm computes a minimum-cost Steiner tree of I from scratch. The call of the algorithm \(\textsc {BuildST}\) with input parameters I, F, and h is denoted by \(\textsc {BuildST}(I,F, h)\). The proof of the following lemma is immediate.

Algorithm 1
figure a

The pseudocode of the algorithm \(\textsc {BuildST}(I,F,h)\).

Lemma 1

Let I be an \( STP \) instance, F a Steiner forest of \(I_n\), \(\bar{F}\) a Steiner forest of \(I_n\) that is obtained from F by removing up to h of its full components, and H a minimum-cost subgraph of \(K_n\) such that \(\bar{F}+H\) is a Steiner tree of I. Then the cost of the Steiner tree of I returned by the call of \(\textsc {BuildST}(I,F,h)\) is at most \(c(\bar{F})+c(H)\).

Moreover, the following lemmas hold.

Lemma 2

Let I be an \( STP \) instance and F a forest of G spanning R. If F contains q trees, then every minimal (w.r.t. the deletion of entire full components) subgraph H of any graph in \(\{G,K,K_n\}\) such that \(F+H\) is a Steiner tree of I contains at most \(q-1\) full components.

Proof

Since H is minimal, each full component of H contains at least 2 vertices each of which respectively belongs to one of two distinct trees of F. Therefore, if we add the full components of H to F one after the other, the number of connected components of the resulting graph strictly decreases at each iteration because of the minimality of H. Hence, H contains at most \(q-1\) full components. \(\square \)

Lemma 3

Let I be an \( STP \) instance and F a Steiner forest of \(I_n\) of q trees. If each tree of F is k-restricted, then the call of \(\textsc {BuildST}(I,F,h)\) outputs a Steiner tree of I in time \(O^*(|R|^h 3^{q+hk})\).

Proof

If F contains at most h full components, then the number of terminals is at most \(q+hk\) and the call of \(\textsc {Connect}(I,(R,\emptyset ))\) outputs a Steiner tree of I in time \(O^*(3^{q+hk})\). Therefore, we assume that F contains a number of full components that is greater than or equal to h. In this case, the algorithm \(\textsc {BuildST}(I,F,h)\) computes a feasible solution for each forest that is obtained by removing up to h full components of F from itself. As the number of full components of F is at most |R|, the overall number of feasible solutions evaluated by the algorithm is \(O(h|R|^{h})\). Let \(\bar{F}\) be any forest that is obtained from F by removing h of its full components. Since F is k-restricted, \(\bar{F}\) contains at most \(q+hk\) trees. Therefore the call of \(\textsc {Connect}(I_n, \bar{F})\) requires \(O^*(3^{q+hk})\) time to output a solution. Hence, the overall time needed by the call of \(\textsc {BuildST}(I,F,h)\) to output a solution is \(O^*(|R|^h3^{q+hk})\). \(\square \)

For the rest of the paper, we denote by \(\langle I, S, I'\rangle \) an instance of the Steiner tree reoptimization problem, where \(I=\langle G,c,R\rangle \) and \(I'=\langle G',c',R'\rangle \). Furthermore, we also assume that \(\rho \le 2\) as well as \(\varepsilon \le 1\), as otherwise we can use classical time-efficient algorithms to compute a 2-approximate solution of \(I'\).

4 A Steiner Vertex Becomes a Terminal

In this section we consider the local modification in which a Steiner vertex \(t \in V(G)\setminus R\) becomes a terminal. Clearly, \(G'=G\), \(c'=c\), \(d'=d\), whereas \(R'=R\cup \{t\}\). Therefore, for the sake of readability, we will drop the superscripts from \(G'\), \(c'\), and \(d'\).

Let \(\xi = \varepsilon /10\) and \(h =2^{2\lceil 2/\varepsilon \rceil \lceil 1/\xi \rceil }\). Algorithm 2 computes a Steiner tree of \(I'\) first by calling \(\textsc {RestrictedST}(I,S,\xi )\) to obtain a k-restricted Steiner tree \(S_{\xi }\) of \(I_n\), with \(k=2^{\lceil {1/\xi }\rceil }\), and then by calling \(\textsc {BuildST}(I',S_{\xi }+t,h)\). Intuitively, the algorithm guesses the full components of \(S_{\xi }\) to be replaced with the corresponding full components of a suitable \(k'\)-restricted version of a new (fixed) optimal solution, for suitable values of \(k'\).

Algorithm 2
figure b

A Steiner vertex \(t \in V(G)\setminus R\) becomes a terminal.

Theorem 2

Let \(\langle I, S, I' \rangle \) be an instance of Steiner tree reoptimization, where S is a \(\rho \)-approximate solution of I and \(I'\) is obtained from I by changing the status of a single vertex from Steiner to terminal. Then Algorithm 2 computes a \((\rho +\varepsilon )\)-approximate Steiner tree of \(I'\) in polynomial time.

Proof

Theorem 1 implies that the computation of \(S_{\xi }\) requires polynomial time. Since \(S_{\xi }\) is a Steiner tree of \(I_n\), \(S_{\xi }+t\) is a Steiner forest of \(I'_n\) of at most two trees (observe that \(S_{\xi }\) may already contain t). Therefore, using Lemma 3 and the fact that h is a constant value, the call of \(\textsc {BuildST}(I',S_{\xi }+t,h)\) outputs a solution \(S'\) in polynomial time. Hence, the overall time complexity of Algorithm 2 is polynomial.

In the following we show that Algorithm 2 returns a \((\rho +\varepsilon )\)-approximate solution. Let \( OPT '\) be a fixed optimal solution of \(I'\). Let \(S'_{\xi }\) denote the Steiner tree of \(I'_n\) that is returned by the call of \(\textsc {RestrictedST}(I', OPT ',\xi )\) and let \(H'_0\) be any fixed full component of \(S'_{\xi }\) that spans t (ties are broken arbitrarily). For every \(i=1,\dots ,\ell \), with \(\ell = \lceil 2/\varepsilon \rceil \), we define:

  • \(H_i\) as the forest consisting of a minimal set of full components of \(S_{\xi }\) whose addition to \(S'_{\xi }-H'_{i-1}\) yields a Steiner tree of \(I_n\) (see Fig. 1 (b) and (d));

  • \(H'_i\) as the forest consisting of a minimal set of full components of \(S'_{\xi }\) whose addition to \(S_{\xi }-H_i\) yields a Steiner tree of \(I'_n\) (see Fig. 1 (c)).

For the rest of the proof, we denote by \(S_i\) the Steiner tree of \(I'\) yielded by the addition of \(H'_i\) to \(S_{\xi }-H_i\).

Fig. 1
figure 1

An example that shows how \(H_i\) and \(H'_i\) are defined. In (a) it is depicted a Steiner tree reoptimization instance where square vertices represent the terminals, while circle vertices represent the Steiner vertices. The Steiner vertex t of I that becomes a terminal in \(I'\) is represented as a terminal vertex of grey color. Solid edges are the edges of \(S_{\xi }\), while dashed edges are the edges of \(S'_{\xi }\). The full component \(H'_0\) of \(S'_{\xi }\) is highlighted in (a). The forests \(S'_{\xi }-H'_0\) and \(H_1\) are shown in (b). The forests \(S_{\xi }-H_1\) and \(H'_1\) are shown in (c). Finally, the forests \(S'_{\xi }-H'_1\) and \(H_2\) are shown in (d)

Let \(k=2^{\lceil {1/\xi }\rceil }\) and observe that both \(S_{\xi }\) and \(S'_{\xi }\) are k-restricted Steiner trees of \(I_n\) and \(I'_n\), respectively (see Theorem 1). Therefore \(H'_0\) spans at most k terminals. Furthermore, by repeatedly using Lemma 2, \(H_i\) contains at most \(k^{2i-1}\) full components and spans at most \(k^{2i}\) terminals, while \(H'_i\) contains at most \(k^{2i}\) full components and spans at most \(k^{2i+1}\) terminals. This implies that the number of the full components of \(H_i\), with \(i=1,\dots ,\ell \), is at most

$$\begin{aligned} k^{2i-1} \le k^{2\ell }= 2^{2\lceil 2/\varepsilon \rceil \lceil {1/\xi }\rceil } = h. \end{aligned}$$

Therefore, by Lemma 1, the cost of the solution returned by the call of the algorithm \(\textsc {BuildST}(I',S_{\xi }+t,h)\) is at most \(c(S_i)\). As a consequence

$$\begin{aligned} c(S') \le \frac{1}{\ell }\sum _{i=1}^\ell c(S_i). \end{aligned}$$
(1)

Now we prove an upper bound to the cost of each \(S_i\). Let \(\Delta _{ OPT }=(1+\xi )c( OPT ')-c( OPT )\). As any Steiner tree of \(I'\) is also a Steiner tree of I, \(c( OPT ')\ge c( OPT )\); therefore \(\Delta _{ OPT }\ge 0\). Since the addition of \(H_{i}\) to \(S'_{\xi }-H'_{i-1}\) yields a Steiner tree of I, the cost of this tree is lower bounded by the cost of \( OPT \). As a consequence, using Theorem 1 in the second inequality that follows, \(c( OPT )\le d(S'_{\xi }) - d(H'_{i-1}) + d(H_{i})\le (1+\xi )c( OPT ') - d(H'_{i-1}) + d(H_{i})\), i.e.,

$$\begin{aligned} d(H_{i}) \ge d(H'_{i-1}) - \Delta _{ OPT }. \end{aligned}$$
(2)

Using Theorem 1 in the first inequality that follows we have that

$$\begin{aligned} d(S_{\xi }) \le (1+\xi )c(S) \le \rho (1+\xi )c( OPT )\le \rho (1+\xi )^2 c( OPT ')-\Delta _{ OPT }. \end{aligned}$$
(3)

Using both (2) and (3) in the second inequality that follows, we can upper bound the cost of \(S_i\) with

$$\begin{aligned} c(S_i) \le d(S_{\xi })-d(H_i)+d(H'_i) \le \rho (1+\xi )^2c( OPT ')-d(H'_{i-1})+d(H'_i). \end{aligned}$$
(4)

Observe that the overall sum of the last two terms on the right-hand side of (4) for every \(i\in \{1,\dots ,\ell \}\) is a telescoping sum. As a consequence, if for every \(i\in \{1,\dots ,\ell \}\) we substitute the term \(c(S_i)\) in (1) with the corresponding upper bound in (4), and use Theorem 1 to derive that \(d(H'_\ell ) \le d(S'_{\xi }) \le (1+\xi )c( OPT ')\), we obtain

$$\begin{aligned} c(S')\le \frac{1}{\ell }\sum _{i=1}^\ell c(S_i) \le \rho (1+\xi )^2 c( OPT ')+\frac{1+\xi }{\ell } c( OPT ')\le (\rho +\varepsilon )c( OPT '), \end{aligned}$$

where last inequality holds by the choice of \(\xi \) and \(\ell \), and because \(\rho \le 2\) and \(\varepsilon \le 1\). This completes the proof. \(\square \)

5 The Cost of an Edge Increases

In this section we consider the local modification in which the cost of an edge \(e=(u,v) \in E(G)\) increases by \(\Delta > 0\). More formally, we have that \(G'=G\), \(R'=R\), whereas, for every \(e' \in E(G)\),

$$\begin{aligned} c'(e')= {\left\{ \begin{array}{ll} c(e) + \Delta &{}\quad \text {if e'=e;}\\ c(e') &{}\quad \text {otherwise.} \end{array}\right. } \end{aligned}$$

For the sake of readability, in this section we drop the superscripts from \(G'\) and \(R'\). Furthermore, we denote by \(c_{-e}\) the edge-cost function c restricted to \(G-e\) and by \(d_{-e}\) the corresponding shortest-path metric.

Let \(\xi = \varepsilon /10\) and \(h = 2^{2(1+\lceil 1/\xi \rceil )\lceil 2/\varepsilon \rceil }\). The algorithm, whose pseudocode is reported in Algorithm 3, first checks whether \(e \in E(S)\). If this is not the case, then the algorithm returns S. If \(e \in E(S)\), then let \(S_u\) and \(S_v\) denote the two trees of \(S-e\) containing u and v, respectively. The algorithm first computes a k-restricted Steiner tree \(S_{u,\xi }\) (resp., \(S_{v,\xi }\)), with \(k=2^{2+\lceil 1/\xi \rceil }\), of \(S_u\) (resp., \(S_v\)) such that \(u \in V(S_{u,\xi })\) (resp., \(v \in V(S_{v,\xi })\)). Then the algorithm computes a solution \(S'\) via the call of \(\textsc {BuildST}(I',S_{u,\xi }+S_{v,\xi },h)\), and, finally, it returns the cheapest solution between S and \(S'\). As we will see, the removal of e from S is necessary to guarantee that the cost of the processed Steiner forest of \(I'\) (i.e., \(S-e\)) is upper bounded by the cost of \( OPT '\).

Algorithm 3
figure c

The cost of an edge \(e=(u,v)\) increases by \(\Delta > 0\).

Theorem 3

Let \(\langle I, S, I' \rangle \) be an instance of Steiner tree reoptimization, where S is a \(\rho \)-approximate solution of I and \(I'\) is obtained from I by increasing the cost of a single edge. Then Algorithm 3 computes a \((\rho +\varepsilon )\)-approximate Steiner tree of \(I'\) in polynomial time.

Proof

Corollary 1 implies that the computation of both \(S_{u,\xi }\) and \(S_{v,\xi }\) requires polynomial time. Therefore, using Lemma 3 and the fact that h is a constant value, the call of \(\textsc {BuildST}(I',S_{\xi },h)\) outputs a solution \(S'\) in polynomial time. Hence, the overall time complexity of Algorithm 3 is polynomial.

In the following we show that Algorithm 3 returns a \((\rho +\varepsilon )\)-approximate solution. Observe that the local modification does not change the set of feasible solutions, i.e., a tree is a Steiner tree of I iff it is a Steiner tree of \(I'\). This implies that \( OPT '\) is a Steiner tree of I as well. Thanks to this observation, if \(e \not \in E(S)\) we have that

$$\begin{aligned} c'(S) = c(S) \le \rho c( OPT ) \le \rho c( OPT ') \le \rho c'( OPT '), \end{aligned}$$

i.e., the solution returned by the algorithm is a \(\rho \)-approximate solution. Moreover, if \(e \in E( OPT ')\), then \(c'( OPT ')=c( OPT ')+\Delta \) or, equivalently, \(c( OPT ') = c'( OPT ')-\Delta \). As a consequence,

$$\begin{aligned} c'(S) \le c(S)+\Delta \le \rho c( OPT ) + \Delta \le \rho c( OPT ') + \Delta \le \rho c'( OPT '), \end{aligned}$$

i.e., once again, the solution returned by the algorithm is a \(\rho \)-approximate solution. Therefore, in the rest of the proof, we assume that \(e \in E(S)\) as well as \(e \not \in E( OPT ')\).

Let \(S'_{\xi }\) denote the Steiner tree of \(\langle K_n,d_{-e},R \rangle \) that is returned by the call of \(\textsc {RestrictedST}(\langle G-e,c_{-e},R\rangle , OPT ',\xi )\). Using Theorem 1 and the fact that \(e \not \in E( OPT ')\) we have that

$$\begin{aligned} d_{-e}(S'_{\xi }) \le (1+\xi )c_{-e}( OPT ') = (1+\xi )c'( OPT '). \end{aligned}$$
(5)

Let \(H'_0\) be a full component of \(S'_{\xi }\) whose addition to \(S_{\xi }\) yields a Steiner tree of \(I'_n\) (ties are broken arbitrarily). For every \(i=1,\dots ,\ell \), with \(\ell = \lceil 2/\varepsilon \rceil \), we define:

  • \(H_i\) as the forest consisting of a minimal set of full components of \(S_{\xi }\) such that the addition of \(H_i\) and e to \(S'_{\xi }-H'_{i-1}\) yields a Steiner tree of \(I_n\)Footnote 5;

  • \(H'_i\) as the forest consisting of a minimal set of full components of \(S'_{\xi }\) whose addition to \(S_{\xi }-H_{i}\) yields a Steiner tree of \(I'_n\).

For the rest of the proof, we denote by \(S_i\) the Steiner tree of \(I'\) obtained by augmenting \(S_{\xi }-H_{i}\) with \(H'_i\). Observe that \(S_i\) does not contain e. Therefore

$$\begin{aligned} c'(S_i) \le c_{-e}(S_i) \le d_{-e}(S_{\xi })-d_{-e}(H_{i})+d_{-e}(H'_i). \end{aligned}$$
(6)

Let \(k=2^{2+\lceil 1/\xi \rceil }\) and \(r=2^{\lceil 1/\xi \rceil }\). Observe that \(S_{\xi }\) is a k-restricted Steiner forest of \(I_n\) (see Corollary 1), while \(S'_{\xi }\) is an r-restricted Steiner tree of \(I'_n\) (see Theorem 1). Therefore, \(H'_0\) spans at most r terminals. Moreover, by repeatedly using Lemma 2, \(H_i\) contains at most \(k^{i-1}r^{i}\) full components and spans at most \(k^{i} r^{i}\) terminals, while \(H'_i\) contains at most \(k^{i}r^{i}\) full components and spans at most \(k^{i} r^{i+1}\) terminals. This implies that the number of full components of \(H_i\), with \(i=1,\dots ,\ell \), is at most

$$\begin{aligned} k^{i-1} r^{i} \le k^{\ell } r^\ell =2^{2(1+\lceil 1/\xi \rceil )\lceil 2/\varepsilon \rceil }= h. \end{aligned}$$

Therefore, by Lemma 1, the cost of the solution returned by the call of algorithm \(\textsc {BuildST}(I',S_{\xi },h)\) is at most the cost of \(S_i\). As a consequence

$$\begin{aligned} c'(S') \le \frac{1}{\ell }\sum _{i=1}^\ell c'(S_i). \end{aligned}$$
(7)

Now we prove an upper bound to the cost of each \(S_i\), with \(i\in \{1,\dots ,\ell \}\). Let \(\Delta _{ OPT }=(1+\xi )c'( OPT ')-c( OPT )\) and observe that \(\Delta _{ OPT }\ge 0\). Since the addition of \(H_{i}\) and e to \(S'_{\xi }-H'_{i-1}\) yields a Steiner tree of I, the cost of this tree is lower bounded by the cost of \( OPT \). As a consequence, using (5) together with Theorem 1 in the third inequality that follows,

$$\begin{aligned} c( OPT )&\le d(S'_{\xi }-H'_{i-1})+d(H_i)+d(e) \le d_{-e}(S'_{\xi }-H'_{i-1})+d_{-e}(H_i)+c(e)\\&= d_{-e}(S'_{\xi }) - d_{-e}(H'_{i-1}) + d_{-e}(H_{i})+c(e) \\&\le (1+\xi )c'( OPT ') - d_{-e}(H'_{i-1}) + d_{-e}(H_{i})+c(e), \end{aligned}$$

from which we derive

$$\begin{aligned} d_{-e}(H_{i}) \ge d_{-e}(H'_{i-1}) - \Delta _{ OPT } - c(e). \end{aligned}$$
(8)

Using Corollary 1 twice in the first inequality that follows we have that

$$\begin{aligned} d_{-e}(S_{\xi })&= d_{-e}(S_{u,\xi }) +d_{-e}(S_{v,\xi }) \le (1+\xi )c_{-e}(S_u)+(1+\xi )c_{-e}(S_v) \nonumber \\&= (1+\xi )c(S)-(1+\xi )c(e) \le \rho (1+\xi )c( OPT )-c(e) \nonumber \\&\le \rho (1+\xi )^2c'( OPT ')-\Delta _ OPT -c(e). \end{aligned}$$
(9)

Starting from (6) and using both (8) and (9) in the second inequality that follows, we can upper bound the cost of \(S_i\), for every \(i \in \{1,\dots ,\ell \}\), with

$$\begin{aligned}{} & {} c'(S_i) \le d_{-e}(S_{\xi })-d_{-e}(H_{i})+d_{-e}(H'_i) \nonumber \\{} & {} \quad \le \rho (1+\xi )^2c'( OPT ')-d_{-e}(H'_{i-1})+d_{-e}(H'_{i}). \end{aligned}$$
(10)

As a consequence, if for every \(i\in \{1,\dots ,\ell \}\) we substitute the term \(c'(S_i)\) in (7) with the corresponding upper bound in (10), and use (5) to derive \(d_{-e}(H'_\ell ) \le d_{-e}(S'_{\xi }) \le (1+\xi )c'( OPT ')\), we obtain

$$\begin{aligned} c'(S')\le \frac{1}{\ell }\sum _{i=1}^\ell c'(S_i) \le \rho (1+\xi )^2 c'( OPT ')+\frac{1+\xi }{\ell } c'( OPT ')\le (\rho +\varepsilon )c'( OPT '), \end{aligned}$$

where last inequality holds by the choice of \(\xi \) and \(\ell \), and because \(\rho \le 2\) and \(\varepsilon \le 1\). This completes the proof. \(\square \)

6 A Terminal Becomes a Steiner Vertex

In this section we consider the local modification in which a terminal vertex \(t \in R\) becomes a Steiner vertex. More precisely, the input instance satisfies the following: \(G'=G\), \(c'=c\), whereas \(R'=R\setminus \{t\}\). Therefore, for the sake of readability, in this section we drop the superscripts from \(c'\), \(d'\), and \(G'\). We recall that, unless \(\rho =1\), the problem is as hard to approximate as the \( STP \) [32]. Therefore, in this section we assume that \(S= OPT \) is an optimal solution, i.e., \(\rho =1\).

Let \(\xi = \varepsilon /10\) and \(h = (1+\lceil 1/\xi \rceil )2^{2(1+\lceil 1/\xi \rceil )\lceil 2/\varepsilon \rceil }\). As \(c( OPT ')\) may be much smaller than \(c( OPT )\), we first need to remove a path from \( OPT \) to ensure that the obtained Steiner forest of \(I'\) has a constant number of trees and a cost upper bounded by \((1+\xi ) c( OPT ')\). The algorithm, whose pseudocode is reported in Algorithm  4, precomputes a maximal (w.r.t. hop-length) path \(P^*\) of \( OPT \) having t as one of its endvertices and such that \( OPT -P^*\) is a Steiner forest of \(I'\) with at most \(1+\lceil 1/\xi \rceil \) trees (we recall that only trees of the forest spanning one or more terminals are kept; therefore, the Steiner vertices of \(P^*\) having degree 2 in S are not contained in \( OPT -P^*\)). As the following lemma shows, \(P^*\) is exactly the path we are searching for.

Algorithm 4
figure d

A terminal t of G becomes a Steiner vertex.

Lemma 4

\( OPT -P^*\) is a Steiner forest of \(I'\) with at most \(1+\lceil 1/\xi \rceil \) trees and \(c(P^*) \ge c( OPT )-(1+\xi )c( OPT ')\).

Proof

By definition of \(P^*\), \( OPT -P^*\) is a Steiner forest of \(I'\) with at most \(1+\lceil 1/\xi \rceil \) trees. To show that \(c(P^*) \ge c( OPT )-(1+\xi )c( OPT ')\), we split the proof into two cases, depending on whether \(P^*\) spans additional terminals other than t.

We consider the case in which \(P^*\) spans additional terminals other than t. In this case \( OPT '+P^*\) is a Steiner tree of I. Therefore, \(c( OPT )\le c( OPT ')+c(P^*)\), from which we derive \(c(P^*) \ge c( OPT )-c( OPT ')\ge c( OPT )-(1+\xi )c( OPT ')\).

Now, we consider the case in which \(P^*\) does not span another terminal other than t. In this case \( OPT -P^*\) yields a Steiner forest of \(I'\) of exactly \(1+\lceil 1/\xi \rceil \) trees. This implies that \( OPT -P^*\) contains at least \(1+\lceil 1/\xi \rceil \) pairwise edge-disjoint paths connecting vertices of \(P^*\) with terminals in \(R'\). Let P be any of these paths that minimizes its cost (ties are broken arbitrarily). As the addition of both \(P^*\) and P to \( OPT '\) yields a Steiner tree of I, \((1+\lceil 1/\xi \rceil )c(P)+c(P^*)\le c( OPT )\le c( OPT ')+c(P)+c(P^*)\), from which we derive \(c(P)\le \xi c( OPT ')\). As a consequence \(c( OPT )\le c( OPT ')+c(P)+c(P^*) \le c( OPT ')+\xi c( OPT ')+c(P^*)\), i.e., \(c(P^*) \ge c( OPT )-(1+\xi )c( OPT ')\). \(\square \)

The algorithm then computes a k-restricted Steiner forest \(S_{\xi }\) of \( OPT -P^*\), with \(k=2^{2+\lceil 1/\xi \rceil }\), such that \(S_{\xi }+P^*\) yields a Steiner tree of I. Finally, the algorithm calls \(\textsc {BuildST}(I',S_{\xi },h)\) to compute a feasible solution \(S'\) and returns the cheapest solution between \( OPT \) and \(S'\).

Theorem 4

Let \(\langle I, OPT , I' \rangle \) be an instance of Steiner tree reoptimization, where \( OPT \) is an optimal solution of I and \(I'\) is obtained from I by changing the status of a single vertex from terminal to Steiner. Then Algorithm 4 computes a \((1+\varepsilon )\)-approximate Steiner tree of \(I'\) in polynomial time.

Proof

Corollary 1 implies that the computation of each \(S_{v,\xi }\), with \(v \in V(P^*)\), requires polynomial time. By Lemma 4, \(S_{\xi }\) is a Steiner forest of \(I_n\) with a constant number of trees. Therefore, using Lemma 3 and the fact that h is a constant value, the call of \(\textsc {BuildST}(I',S_{\xi },h)\) outputs a solution in polynomial time. Hence, the overall time complexity of Algorithm 4 is polynomial.

In the following we show that Algorithm 4 returns a \((1+\varepsilon )\)-approximate solution. W.l.o.g., we can assume that \(c( OPT )>(1+\varepsilon )c( OPT ')\) as otherwise the solution returned by the algorithm, whose cost is less than or equal to \(c( OPT )\), would already be a \((1+\varepsilon )\)-approximate solution.

Let \(S'_{\xi }\) be the Steiner tree of \(I'_n\) that is returned by the call of algorithm \(\textsc {RestrictedST}(I', OPT ',\xi )\) and let \(H'_0\) be the forest consisting of a minimal set of full components of \(S'_{\xi }\) whose addition to \(S_{\xi }\) yields a Steiner tree of \(I'_n\). For every \(i=1,\dots ,\ell \), with \(\ell = \lceil 2/\varepsilon \rceil \), we define:

  • \(H_i\) as the forest consisting of a minimal set of full components of \(S_{\xi }\) such that the addition of \(H_i\) and \(P^*\) to \(S'_{\xi }-H'_{i-1}\) yields a Steiner tree of \(I_n\)Footnote 6;

  • \(H'_i\) as the forest consisting of a minimal set of full components of \(S'_{\xi }\) whose addition to \(S_{\xi }-H_{i}\) yields a Steiner tree of \(I'_n\).

For the rest of the proof, we denote by \(S_i\) the Steiner tree of \(I'\) obtained by augmenting \(S_{\xi }-H_{i}\) with \(H'_i\).

Let \(k=2^{2+\lceil 1/\xi \rceil }\) and \(r=2^{\lceil 1/\xi \rceil }\). Observe that \(S_{\xi }\) is a k-restricted Steiner forest of \(I_n\) (see Corollary 1), while \(S'_{\xi }\) is an r-restricted Steiner tree of \(I'_n\) (see Theorem 1). Using Lemma 2, \(H'_0\) contains at most \((1+\lceil 1/\xi \rceil )\) full components and spans at most \((1+\lceil 1/\xi \rceil ) r\) terminals. By repeatedly using Lemma 2, \(H_i\) contains at most \((1+\lceil 1/\xi \rceil ) k^{i-1}r^{i}\) full components and spans at most \((1+\lceil 1/\xi \rceil ) k^{i}r^{i}\) terminals, while \(H'_i\) contains at most \((1+\lceil 1/\xi \rceil ) k^{i}r^{i}\) full components and spans at most \((1+\lceil 1/\xi \rceil ) k^{i}r^{i+1}\) terminals. This implies that the number of full components of \(H_i\), with \(i=1,\dots ,\ell \), is at most

$$\begin{aligned} (1+\lceil 1/\xi \rceil ) k^{i-1}r^{i} \le (1+\lceil 1/\xi \rceil ) k^{\ell }r^{\ell }= (1+\lceil 1/\xi \rceil )2^{2(1+\lceil 1/\xi \rceil )\lceil 2/\varepsilon \rceil }= h. \end{aligned}$$

Therefore, by Lemma 1, the cost of the solution returned by the algorithm is at most the cost of \(S_i\), for every \(i=1,\dots ,\ell \). As a consequence

$$\begin{aligned} c(S') \le \frac{1}{\ell }\sum _{i=1}^\ell c(S_i). \end{aligned}$$
(11)

Now we prove an upper bound to the cost of each \(S_i\). Let \(\Delta _{ OPT }=c( OPT )-(1+\xi )c( OPT ')\) and observe that \(\Delta _{ OPT } \ge 0\) by our assumption. Since the addition of \(H_{i}\) and \(P^*\) to \(S'_{\xi }-H'_{i-1}\) yields a Steiner tree of I, the cost of this tree is lower bounded by the cost of \( OPT \). As a consequence, using Theorem 1 in the second inequality that follows,

$$\begin{aligned} c( OPT )&\le d(S'_{\xi })-d(H'_{i-1})+d(H_{i})+d(P^*)\\&\le (1+\xi )c( OPT ') - d(H'_{i-1}) + d(H_{i})+c(P^*), \end{aligned}$$

from which we derive

$$\begin{aligned} d(H_{i}) \ge d(H'_{i-1}) + \Delta _{ OPT } - c(P^*). \end{aligned}$$
(12)

Using Corollary 1 and Lemma 4 in the first and last inequality that follows, respectively, we have that

$$\begin{aligned} d(S_{\xi })&= \sum _{v \in V(P^*)}d(S_{v,\xi }) \le (1+\xi )c( OPT -P^*) \le (1+\xi )c( OPT )-(1+\xi )c(P^*)\nonumber \\&\le (1+\xi )^2c( OPT ')+(1+\xi )\Delta _ OPT -(1+\xi )c(P^*)\nonumber \\&\le (1+\xi )^2c( OPT ')+\Delta _ OPT -c(P^*). \end{aligned}$$
(13)

Using both (12) and (13) in the second inequality that follows, we can upper bound the cost of \(S_i\), for every \(i \in \{1,\dots ,\ell \}\), with

$$\begin{aligned} c(S_i) \le d(S_{\xi })-d(H_{i})+d(H'_i) \le (1+\xi )^2c( OPT ')-d(H'_{i-1})+d(H'_{i}). \end{aligned}$$
(14)

Therefore, if for every \(i\in \{1,\dots ,\ell \}\) we substitute the term \(c(S_i)\) in (11) with the corresponding upper bound in (14), and use Theorem 1 to derive \(d(H'_\ell ) \le d(S'_{\xi }) \le (1+\xi )c( OPT ')\), we obtain

$$\begin{aligned} c(S')\le \frac{1}{\ell }\sum _{i=1}^\ell c(S_i) \le (1+\xi )^2 c( OPT ')+\frac{1+\xi }{\ell } c( OPT ')\le (1+\varepsilon )c( OPT '), \end{aligned}$$

where last inequality holds by the choice of \(\xi \) and \(\ell \), and because \(\varepsilon \le 1\). This completes the proof. \(\square \)

7 The Cost of an Edge Decreases

In this section we consider the local modification in which the cost of an edge \(e=(u,v) \in E\) decreases by \(0<\Delta \le c(e)\). More precisely, the input instance satisfies the following: \(G'=G\), \(R'=R\), whereas for every \(e' \in E\),

$$\begin{aligned} c'(e')= {\left\{ \begin{array}{ll} c(e) - \Delta &{}\quad \text {if e'=e;}\\ c(e') &{}\quad \text {otherwise.} \end{array}\right. } \end{aligned}$$

For the sake of readability, in this section we drop the superscripts from \(G'\) and \(R'\). Furthermore, for the rest of this section, we denote by \(c_{-e}\) the edge-cost function c restricted to \(G-e\) and by \(d_{-e}\) the corresponding shortest-path metric. We recall that, unless \(\rho =1\), the problem is as hard to approximate as the \( STP \) [32]. Therefore, in this section we assume that \(S= OPT \) is an optimal solution, i.e., \(\rho =1\).

Let \(\xi = \varepsilon /10\) and \(h = 2(1+\lceil 1/\xi \rceil )2^{2(2+\lceil 1/\xi \rceil )\lceil 2/\varepsilon \rceil }\). As \(c'( OPT ')\) may be much smaller than \(c'( OPT )\), we first need to remove a path from \( OPT \) to ensure that the obtained Steiner forest of I has a constant number of trees and a cost upper bounded by \((1+\xi ) c'( OPT ')\). The algorithm, whose pseudocode is reported in Algorithm  5, precomputes a set \(\mathcal {H}\) containing all the paths of \( OPT \) such that, for every \(P \in \mathcal {P}\), \( OPT -P\) is a Steiner forest of I with at most \(2(1+\lceil 1/\xi \rceil )\) trees. As the following lemma shows, there exists \(P^* \in \mathcal {H}\), which is exactly the path we are searching for when \(c'( OPT ')\) is much smaller than \(c'( OPT )\).

Algorithm 5
figure e

The cost of an edge \(e=(u,v)\) of G decreases by \(0 < \Delta \le c(e)\).

Lemma 5

If \(e \in E( OPT ')\) and \(e \not \in E( OPT )\), then there exists \(P^* \in \mathcal {H}\) s.t. \(c'(P^*) \ge c( OPT )-(1+\xi )c'( OPT ')\).

Proof

Let \(S'_u\) and \(S'_v\) denote the trees of \( OPT '-e\) containing u and v, respectively. Let \(R_u=V(S'_u)\cap R\) and \(R_v=V(S'_v)\cap R\). As \(e \not \in E( OPT )\), there exists a path in \( OPT \), say \(\bar{P}\), that connects a terminal in \(R_u\), say \(u'\), with a terminal in \(R_v\), say \(v'\), and such that all the internal vertices of \(\bar{P}\) are Steiner vertices. Let \(\sigma \) be the number of Steiner vertices of \(\bar{P}\) whose corresponding degrees in \( OPT \) are all greater than or equal to 3. We divide the proof into two complementary cases depending on the value of \(\sigma \). In both cases, we prove that \(P^*\) is a subpath of \(\bar{P}\).

We consider the case in which \(\sigma \le 2(1+\lceil 1/\xi \rceil )\). Let \(P^*=\bar{P}\). Clearly \(P^* \in \mathcal {H}\) and \( OPT '-e+P^*\) is a Steiner tree of I. Therefore, \(c( OPT )\le c'( OPT '-e)+c'(P^*)\le c'( OPT ')+c'(P^*)\), from which we derive \(c'(P^*) \ge c( OPT )-c'( OPT ')\ge c( OPT )-(1+\xi )c'( OPT ')\).

Now, we consider the case in which \(\sigma > 2(1+\lceil 1/\xi \rceil )\). Let X be the set of the \(\sigma \) Steiner vertices of \(\bar{P}\) whose corresponding degrees in \( OPT \) are all greater than or equal to 3. Let \(x_1,\dots ,x_{\sigma }\) be the vertices in X in order in which they are encountered while traversing \(\bar{P}\) from \(u'\) to \(v'\). Finally, let \(x_0=u'\) and \(x_{\sigma +1}=v'\). We associate a label \(\lambda (i)\in \{u,v\}\) with each \(x_i\) to indicate the existence of a path in \( OPT \) between \(x_i\) and a terminal in \(R_{\lambda (i)}\) that is edge-disjoint from \(\bar{P}\) (if \(\lambda (i)\) can assume both values, we arbitrarily choose one of them). We set \(\lambda (0)=u\) and \(\lambda (\sigma +1)=v\) to indicate that \(u'\) and \(v'\) have the trivial paths towards themselves, respectively. For \(i=0,\dots , \sigma -2\lceil 1/\xi \rceil \), let \(L_i=\lambda (i),\dots ,\lambda (i+1+2\lceil 1/\xi \rceil ))\) be the sequence of \(2(1+\lceil 1/\xi \rceil )\) consecutive labels starting from i. One of the following holds:

  1. (a)

    \(L_0\) contains at least \(1+\lceil 1/\xi \rceil \) occurrences of v;

  2. (b)

    \(L_{\sigma -2\lceil 1/\xi \rceil }\) contains at least \(1+\lceil 1/\xi \rceil \) occurrences of u;

  3. (c)

    there is an index i such that the sequence \(L_i\) contains exactly \(1+\lceil 1/\xi \rceil \) occurrences of u and \(1+\lceil 1/\xi \rceil \) occurrences of v.

Indeed, let \(\mu _i\) and \(\nu _i\) denote the occurrences of u and v in \(L_i\), respectively. Observe that \(|\mu _{i}-\mu _{i+1}|\in \{0,1\}\) as well as \(|\nu _{i}-\nu _{i+1}|\in \{0,1\}\). More precisely:

  • \(\mu _i=\mu _{i+1}\) iff \(\nu _i=\nu _{i+1}\);

  • \(\mu _{i}=\mu _{i+1}+1\) iff \(\nu _{i}=\nu _{i+1}-1\);

  • \(\mu _{i}=\mu _{i+1}-1\) iff \(\nu _{i}=\nu _{i+1}+1\).

Therefore, if neither (a) nor (b) holds, i.e., \(\mu _0 > \nu _0\) and \(\mu _{\sigma -2\lceil 1/\xi \rceil } < \nu _{\sigma -2\lceil 1/\xi \rceil }\), then (c) must hold.

Let \(P^*\) be the path containing exactly the Steiner vertices corresponding to a sequence \(L_i\) that satisfies any of the above three conditions (ties are broken arbitrarily). Observe that \(P^* \in \mathcal {H}\). Let \(P_u\) (resp., \(P_v\)) be a minimum-cost path between a vertex of \(P^*\) and a vertex of \(R_u\) (resp., \(R_v\)) that is edge-disjoint from \(P^*\). W.l.o.g., if \(P^*\) contains \(u'\), then we can assume that \(P_u\) is the path containing only vertex u; similarly, if \(P^*\) contains \(v'\), then we can assume that \(P_v\) is the path containing only vertex v. As the addition of both \(P^*\), \(P_u\) and \(P_v\) to \( OPT '-e\) yields a Steiner tree of I, \((1+\lceil 1/\xi \rceil )(c'(P_u)+c'(P_v))+c'(P^*)=(1+\lceil 1/\xi \rceil )(c(P_u)+c(P_v))+c(P^*)\le c( OPT )\le c'( OPT ')+c'(P_u)+c'(P_v)+c'(P^*)\), from which we derive \(c'(P_u)+c'(P_v)\le \xi c'( OPT ')\). As a consequence \(c( OPT )\le c'( OPT ')+c'(P_u)+c'(P_v)+c'(P^*) \le c'( OPT ')+\xi c'( OPT ')+c'(P^*)\), i.e., \(c'(P^*) \ge c( OPT )-(1+\xi )c( OPT ')\). \(\square \)

The algorithm always returns a solution whose cost is upper bounded by \(c'( OPT )\). This allows us to guarantee that the output of the algorithm is a \((1+\varepsilon )\)-approximate solution when \(e \not \in E( OPT ')\) or \(e \in E( OPT )\). In the complementary case in which \(e \in E( OPT ')\) and \(e \not \in E( OPT )\) the algorithm computes a \((1+\varepsilon )\)-approximate solution using the path \(P^*\) that satisfies the conditions stated in Lemma 5. More precisely, the algorithm computes a k-restricted Steiner forest \(S_{\xi }\) of \( OPT -P^*\) w.r.t. the \( STP \) instance \(\langle G-e,c_{-e},R\rangle \), with \(k=2^{2+\lceil 1/\xi \rceil }\), such that \(S_{\xi }+P^*\) yields a Steiner tree of I. Finally, the algorithm calls \(\textsc {BuildST}(I',S_{\xi },h)\) to compute a feasible solution \(S''\) and returns a solution whose cost is upper bounded by \(c'(S'')\).

Theorem 5

Let \(\langle I, OPT , I' \rangle \) be an instance of Steiner tree reoptimization, where \( OPT \) is an optimal solution of I and \(I'\) is obtained from I by decreasing the cost of a single edge. Then Algorithm 5 computes a \((1+\varepsilon )\)-approximate Steiner tree of \(I'\) in polynomial time.

Proof

Corollary 1 implies that the computation of each \(S_{v,\xi }\), with \(v \in V(P)\), requires polynomial time. Observe that \( OPT -P\) is a Steiner forest of I of at most \(2(1+\lceil 1/\xi \rceil )\) trees. As a consequence \(S_{\xi }\) is a Steiner forest of \(I_n\) with at most \(2(1+\lceil 1/\xi \rceil )\) trees. Therefore, using Lemma 3 and the fact that h is a constant value, the call of \(\textsc {BuildST}(I',S_{\xi },h)\) outputs a solution in polynomial time. Finally, since \(\mathcal {H}\) contains \(O(n^2)\) paths (one path for each pair of vertices in the worst case), the overall time complexity of Algorithm 5 is polynomial.

In the following we show that Algorithm 5 returns a \((1+\varepsilon )\)-approximate solution. W.l.o.g., we can assume that \(c( OPT )>(1+\varepsilon )c( OPT ')\), as otherwise, the solution returned by the algorithm, whose cost is always less then or equal to \(c'( OPT )\le c( OPT )\), would already be a \((1+\varepsilon )\)-approximate solution. As a consequence, we have that \(e \not \in E( OPT )\) as well as \(e \in E( OPT ')\): indeed, if even one of these two conditions were not satisfied, then \( OPT \) would be an optimal solution of \(I'\).

Let \(S'_u\) and \(S'_v\) be the two trees of \( OPT '-e\) that contain u and v, respectively. Let \(S'_{u,\xi }\) and \(S'_{v,\xi }\) be the two k-restricted trees of \(I'_n\), with \(k=2^{2+1/\xi }\), that are returned by the call \(\textsc {RestrictedST}(\langle G-e,c_{-e},R\rangle ,S'_u,\xi ,u)\) and \(\textsc {RestrictedST}(\langle G-e,c_{-e},R\rangle ,S'_v,\xi ,v)\), respectively. Finally, let \(S'_{\xi }=S'_{u,\xi }+S'_{v,\xi }\), \(P^* \in \mathcal {H}\) the path satisfying the conditions stated in Lemma 5, and \(S_{\xi }\) the k-restricted Steiner forest of I that is computed by the algorithm when \(P=P^*\). Let \(H'_0\) be the forest consisting of a minimal set of full components of \(S'_{\xi }\) such that the addition of \(H'_0\) and e to \(S_{\xi }+e\) yields a Steiner tree of \(I'_n\). For every \(i=1,\dots ,\ell \), with \(\ell = \lceil 2/\varepsilon \rceil \), we define:

  • \(H_i\) as the forest consisting of a minimal set of full components of \(S_{\xi }\) such that the addition of \(H_i\) and \(P^*\) to \(S'_{\xi }-H'_{i-1}\) yields a Steiner tree of \(I_n\)Footnote 7;

  • \(H'_i\) as the forest consisting of a minimal set of full components of \(S'_{\xi }\) such that the addition of \(H'_i\) and e to \(S_{\xi }-H_{i}\) yields a Steiner tree of \(I'_n\).Footnote 8

For the rest of the proof, we denote by \(S_i\) the Steiner tree of \(I'\) obtained by augmenting \(S_{\xi }-H_{i}\) with \(H'_i\) and e.

Let \(k=2^{2+\lceil 1/\xi \rceil }\). Observe that \(S_{\xi }\) and \(S'_{\xi }\) are k-restricted Steiner forests of \(I_n\) and \(I'_n\), respectively (see Corollary 1). Observe that \(S_{\xi }+e\) is a forest of at most \(1+2(1+\lceil 1/\xi \rceil )\) trees. Therefore, using Lemma 2, \(H'_0\) contains at most \(2(1+\lceil 1/\xi \rceil )\) full components and spans at most \(2(1+\lceil 1/\xi \rceil )k\) terminals. Therefore, by repeatedly using Lemma 2, \(H_i\) contains at most \(2(1+\lceil 1/\xi \rceil ) k^{2i-1}\) full components and spans at most \(2(1+\lceil 1/\xi \rceil ) k^{2i}\) terminals, while \(H'_i\) contains at most \(2(1+\lceil 1/\xi \rceil ) k^{2i)}\) full components and spans at most \(2(1+\lceil 1/\xi \rceil ) k^{2i+1}\) terminals. This implies that the number of full components of \(H_i\), with \(i=1,\dots ,\ell \), is at most

$$\begin{aligned} 2(1+\lceil 1/\xi \rceil ) k^{2i-1} \le 2(1+\lceil 1/\xi \rceil ) k^{2\ell }= 2(1+\lceil 1/\xi \rceil )2^{2(2+\lceil 1/\xi \rceil )\lceil 2/\varepsilon \rceil }= h. \end{aligned}$$

Therefore, by Lemma 1, the cost of the solution returned by the algorithm cannot be worse than the cost of \(S_i\), for every \(i=1,\dots ,\ell \). As a consequence

$$\begin{aligned} c'(S') \le \frac{1}{\ell }\sum _{i=1}^\ell c'(S_i). \end{aligned}$$
(15)

Now we prove an upper bound to the cost of each \(S_i\). Let \(\Delta _{ OPT }=c( OPT )-(1+\xi )c'( OPT ')\) and observe that \(\Delta _{ OPT } \ge 0\) by our assumption. Since the addition of \(H_{i}\) and \(P^*\) to \(S'_{\xi }-H'_{i-1}\) yields a Steiner tree of I, the cost of this tree is lower bounded by the cost of \( OPT \). As a consequence, using Corollary 1 in the third inequality that follows,

$$\begin{aligned} c( OPT )&\le d_{-e}(S'_{\xi })-d_{-e}(H'_{i-1})+d_{-e}(H_{i})+d_{-e}(P^*) \\&\le (1+\xi )c_{-e}( OPT '-e) - d_{-e}(H'_{i-1}) + d_{-e}(H_{i})+d_{-e}(P^*) \\&\le (1+\xi )c'( OPT ')-c'(e) - d_{-e}(H'_{i-1}) + d_{-e}(H_{i})+d_{-e}(P^*) \\&\le (1+\xi )c'( OPT ') - d_{-e}(H'_{i-1}) + d_{-e}(H_{i})+c'(P^*)-c'(e), \end{aligned}$$

from which we derive

$$\begin{aligned} d_{-e}(H_{i}) \ge d_{-e}(H'_{i-1}) + \Delta _{ OPT } - c'(P^*)+c'(e). \end{aligned}$$
(16)

Using Corollary 1 and Lemma 5 respectively in the first and last inequality that follows we have that

$$\begin{aligned} d_{-e}(S_{\xi })&= \sum _{v \in V(P^*)}d_{-e}(S_{v,\xi }) \le (1+\xi )c_{-e}( OPT -P^*)\nonumber \\&\le (1+\xi )c( OPT )-(1+\xi )c(P^*)\nonumber \\&\le (1+\xi )^2c'( OPT ')+(1+\xi )\Delta _ OPT -(1+\xi )c'(P^*)\nonumber \\&\le (1+\xi )^2c'( OPT ')+\Delta _ OPT -c'(P^*). \end{aligned}$$
(17)

Using both (16) and (17) in the second inequality that follows, we can upper bound the cost of \(S_i\), for every \(i \in \{1,\dots ,\ell \}\), with

$$\begin{aligned} c'(S_i)&\le d_{-e}(S_{\xi })-d_{-e}(H_{i})+d_{-e}(H'_i)+c'(e)\nonumber \\&\le (1+\xi )^2c'( OPT ')-d_{-e}(H'_{i-1})+d_{-e}(H'_{i}). \end{aligned}$$
(18)

Therefore, if for every \(i\in \{1,\dots ,\ell \}\) we substitute the term \(c(S_i)\) in (15) with the corresponding upper bound in (18), and use Corollary 1 to derive \(d_{-e}(H'_\ell ) +c'(e)\le (1+\xi )c_{-e}( OPT '-e)+c'(e)\le (1+\xi )c'( OPT ')\), we obtain

$$\begin{aligned} c'(S')\le \frac{1}{\ell }\sum _{i=1}^\ell c'(S_i) \le (1+\xi )^2 c'( OPT ')+\frac{1+\xi }{\ell } c'( OPT ')\le (1+\varepsilon )c'( OPT '), \end{aligned}$$

where last inequality holds by the choice of \(\xi \) and \(\ell \), and because \(\varepsilon \le 1\). This completes the proof. \(\square \)

8 Conclusions

In this paper we developed polynomial-time approximation schemes for some Steiner tree reoptimization problems and consider the local modifications in which the cost of a single edge can change or a single vertex can change its status, from terminal to Steiner or from Steiner to terminal. We believe that our algorithms can be unified to provide polynomial-time approximation schemes for more involved scenarios in which the local modification affects, at the same time, the cost of a constant number of edges and the status of a constant number of vertices. We leave this extension as an interesting open problem.

It is known that the Steiner tree problem can be optimally solved when the number of terminals is polylogarithmic in n using, for instance, the famous algorithm by Dreyfus and Wagner [30]. Therefore, a very challenging open problem is that of understanding whether polynomial-time approximation schemes still exist when the local modification affects a number of edge-costs and vertices of the graph that are polylogarithmic in n.

Finally, albeit our results are interesting from a theoretical perspective as they are best possible in terms of approximation factor guarantee, our algorithms are too slow to be used in the practice. Unfortunately, this is somehow a weakness of all the most recent approximation algorithms that have been developed for the Steiner tree problem and Steiner tree reoptimization. Therefore, an interesting scenario is that of designing reoptimization algorithms that guarantee a hopefully good constant approximation ratio, but are also efficient in terms of running time and can also be used for practical applications.