Parameterized complexity of finding a spanning tree with minimum reload cost diameter

We study the minimum diameter spanning tree problem under the reload cost model (DIAMETER-TREE for short) introduced by Wirth and Steffan (2001). In this problem, given an undirected edge-colored graph $G$, reload costs on a path arise at a node where the path uses consecutive edges of different colors. The objective is to find a spanning tree of $G$ of minimum diameter with respect to the reload costs. We initiate a systematic study of the parameterized complexity of the DIAMETER-TREE problem by considering the following parameters: the cost of a solution, and the treewidth and the maximum degree $\Delta$ of the input graph. We prove that DIAMETER-TREE is para-NP-hard for any combination of two of these three parameters, and that it is FPT parameterized by the three of them. We also prove that the problem can be solved in polynomial time on cactus graphs. This result is somehow surprising since we prove DIAMETER-TREE to be NP-hard on graphs of treewidth two, which is best possible as the problem can be trivially solved on forests. When the reload costs satisfy the triangle inequality, Wirth and Steffan (2001) proved that the problem can be solved in polynomial time on graphs with $\Delta = 3$, and Galbiati (2008) proved that it is NP-hard if $\Delta = 4$. Our results show, in particular, that without the requirement of the triangle inequality, the problem is NP-hard if $\Delta = 3$, which is also best possible. Finally, in the case where the reload costs are polynomially bounded by the size of the input graph, we prove that DIAMETER-TREE is in XP and W[1]-hard parameterized by the treewidth plus $\Delta$.


Introduction
Motivation. Numerous network optimization problems can be modeled by edge-colored graphs. Wirth and Steffan introduced in [33] the concept of reload cost, which refers to the cost that arises in an edge-colored graph while traversing a vertex via two consecutive edges of different colors. The value of the reload cost depends on the colors of the traversed edges. Although the reload cost concept has many important applications in telecommunication networks, transportation networks, and energy distribution networks, it has surprisingly received attention only recently.
In heterogeneous communication networks, routing requires switching among different technologies such as cables, fibers, and satellite links. Due to data conversion between incompatible subnetworks, this switching causes high costs, largely outweighing the cost of routing the packets within each subnetwork. The recently popular concept of vertical handover [11], which allows a mobile user to have undisrupted connection during transitioning between different technologies such as 3G (third generation) and wireless local area network (WLAN), constitutes another application area of the reload cost concept. Even within the same technology, switching between different service providers incurs switching costs. Another paradigm that has received significant attention in the wireless networks research community is cognitive radio networks (CRN), a.k.a. dynamic spectrum access networks. Unlike traditional wireless technologies, CRNs operate across a wide frequency range in the spectrum and frequently requires frequency switching; therefore, the frequency switching cost is indispensable and of paramount importance. Many works in the CRNs literature focused on this frequency switching cost from an application point of view (for instance, see [1, 3-5, 14, 21, 31]) by analyzing its various aspects such as delay and energy consumption. Operating in a wide range of frequencies is indeed a property of not only CRNs but also other 5G technologies. Hence, applications of the reload cost concept in communication networks continuously increment. In particular, the energy consumption aspect of this switching cost is especially important in the recently active research area of green networks, which aim to tackle the increasing energy consumption of information and communication technologies [6,8].
Reload cost concept finds applications also in other networks such as transportation networks and energy distribution networks. For instance, a cargo transportation network uses different means of transportation. The loading and unloading of cargo at junction points is costly and this cost may even outweigh the cost of carrying the cargo from one point to another [15]. In energy distribution networks, reload costs can model the energy losses that occur at the interfaces while transferring energy from one type of carrier to another [15].

Problem
Parameterized complexity with parameter Polynomial k + tw k + ∆ tw + ∆ k + tw + ∆ cases  Table 1 Summary of our results, where k, tw, ∆ denote the cost of the solution, the treewidth, and the maximum degree of the input graph, respectively. NPh stands for NP-hard. The symbol ' ' denotes that the result above still holds for polynomial costs.
We first prove, by a reduction from 3-Sat, that Diameter-Tree is NP-hard on outerplanar graphs (which have treewidth at most 2) with only one vertex of degree greater than 3, even with three different costs that satisfy the triangle inequality, and k = 9. Note that,

XX:4
Parameterized complexity of finding a spanning tree with minimum reload cost diameter in the case where the costs satisfy the triangle inequality, having only one vertex of degree greater than 3 is best possible, as if all vertices have degree at most 3, the problem can be solved in polynomial time [33]. Note also that the bound on the treewidth is best possible as well, since the problem is trivially solvable on graphs of treewidth 1, i.e., on forests.
Toward investigating the border of tractability of the problem with respect to treewidth, we exhibit a polynomial-time algorithm on a relevant subclass of the graphs of treewidth at most 2: cactus graphs. This algorithm is quite involved and, in a nutshell, processes in a bottom-up manner the block tree of the given cactus graph, and uses at each step of the processing an algorithm that solves 2-Sat as a subroutine.
Back to hardness results, we also prove, by a reduction from a restricted version of 3-Sat, that Diameter-Tree is NP-hard on graphs with ∆ ≤ 3, even with only two different costs, k = 0, and bounded number of colors. In particular, this settles the complexity of the problem on graphs with ∆ ≤ 3 in the general case where the triangle inequality is not necessarily satisfied, which had been left open in previous work [15,33]. Note that ∆ ≤ 3 is best possible, as Diameter-Tree can be easily solved on graphs with ∆ ≤ 2.
As our last NP-hardness reduction, we prove, by a reduction from Partition, that the Diameter-Tree problem is NP-hard on planar graphs with tw ≤ 3 and ∆ ≤ 3.
The above hardness results imply that the Diameter-Tree problem is para-NP-hard for any combination of two of the three parameters k, tw, and ∆. On the positive side, we show that Diameter-Tree is FPT parameterized by the three of them, by using a (highly nontrivial) dynamic programming algorithm on a tree decomposition of the input graph.
Since our para-NP-hardness reduction with parameter tw + ∆ is from Partition, which is a typical example of weakly NP-complete problem [19], a natural question is whether Diameter-Tree, with parameter tw + ∆, is para-NP-hard, XP, W[1]-hard, or FPT when the reload costs are polynomially bounded by the size of the input graph. We manage to answer this question completely: we show that in this case the problem is in XP (hence not para-NP-hard) and W[1]-hard parameterized by tw + ∆. The W[1]-hardness reduction is from the Unary Bin Packing problem parameterized by the number of bins, proved to be W[1]-hard by Jansen et al. [26].
Altogether, our results provide an accurate picture of the (parameterized) complexity of the Diameter-Tree problem.
Organization of the paper. We start in Section 2 with some brief preliminaries about graphs, the Diameter-Tree problem, parameterized complexity, and tree decompositions. In Section 3 we provide the para-NP-hardness results. In Section 4 we present the polynomialtime algorithm on cactus graphs, and in Section 5 we present the FPT algorithm on general graphs parameterized by k + tw + ∆. In Section 6 we focus on the case where the reload costs are polynomially bounded. Finally, we conclude the article in Section 7.

Preliminaries
Graphs and sets. We use standard graph-theoretic notation, and we refer the reader to [12] for any undefined term. Given a graph G and a set S ⊆ V (G), we define adj G (S) to be the set of edges of G that intersect S. We also define For a graph G and an edge e ∈ E(G), we let G − e = (V (G), E(G) \ e). Given a graph G and a set S ⊆ V (G), we say that S is good for G if each connected component of G contains at least one vertex of S. Given two integers i and j with i ≤ j, we denote by [i, j] the set of all integers k such that i ≤ k ≤ j. For an integer i ≥ 1, we denote by [i] the set of all integers k such that 1 ≤ k ≤ i.
If for every three distinct edges e 1 , e 2 , e 3 of G incident to the same node, it holds that c(e 1 , e 3 ) ≤ c(e 1 , e 2 ) + c(e 2 , e 3 ), we say that the reload cost function c satisfies the triangle inequality. This assumption is sometimes used in practical applications [33].
Parameterized complexity. We refer the reader to [9,13] for basic background on parameterized complexity, and we recall here only some basic definitions. A parameterized problem is a language L ⊆ Σ * × N. For an instance I = (x, k) ∈ Σ * × N, k is called the parameter.
A parameterized problem is fixed-parameter tractable (FPT) if there exists an algorithm A, a computable function f , and a constant c such that given an instance I = (x, k), A (called an FPT algorithm) correctly decides whether I ∈ L in time bounded by f (k) · |I| c . For instance, the Vertex Cover problem parameterized by the size of the solution is FPT.
A parameterized problem is in XP if there exists an algorithm A and two computable functions f and g such that given an instance I = (x, k), A (called an XP algorithm) correctly decides whether I ∈ L in time bounded by f (k) · |I| g(k) . For instance, the Clique problem parameterized by the size of the solution is in XP.
A parameterized problem with instances of the form I = (x, k) is para-NP-hard if it is NP-hard for some fixed constant value of the parameter k. For instance, the Vertex Coloring problem parameterized by the number of colors is para-NP-hard. Note that, unless P = NP, a para-NP-hard problem cannot be in XP, hence it cannot be FPT either.
Within parameterized problems, the class W[1] may be seen as the parameterized equivalent to the class NP of classical optimization problems. Without entering into details (see [9,13] for the formal definitions), a parameterized problem being W[1]-hard can be seen as a strong evidence that this problem is not FPT. For instance, the Clique problem parameterized by the size of the solution is the canonical example of a W[1]-hard problem. To transfer W[1]-hardness from one problem to another, one uses a parameterized reduction, which given an input I = (x, k) of the source problem, computes in time f (k) · |I| c , for some computable function f and a function c, an equivalent instance I = (x , k ) of the target problem, such that k is bounded by a function depending only on k.
Tree decompositions. A tree decomposition of a graph G is a pair D = (Y, X ), where Y is a tree and X = {X t | t ∈ V (Y )} is a collection of subsets of V (G) such that:

XX:6
Parameterized complexity of finding a spanning tree with minimum reload cost diameter for every edge {u, v} ∈ E, there is a t ∈ V (Y ) such that {u, v} ⊆ X t , and for each {x, y, z} ⊆ V (Y ) such that z lies on the unique path between x and y in Y , X x ∩ X y ⊆ X z . We call the vertices of Y nodes of D and the sets in X bags of D. The width of the tree decomposition D = (Y, X ) is max t∈V (Y ) |X t | − 1. The treewidth of G, denoted by tw(G), is the smallest integer w such that there exists a tree decomposition of G of width at most w.
Nice tree decompositions. Let D = (Y, X ) be a tree decomposition of G, r be a vertex of Y , and G = {G t | t ∈ V (Y )} be a collection of subgraphs of G, indexed by the vertices of Y . We say that the triple (D, r, G) is nice if the following conditions hold: X r = ∅ and G r = G, each node of D has at most two children in Y , for each leaf t ∈ V (Y ), X t = ∅ and G t = (∅, ∅). Such a t is called a leaf node, if t ∈ V (T ) has exactly one child t , then either where e insert is an edge of G with endpoints in X t . The node t is called edge-introduce node and the edge e insert is the insertion edge of X t , or The node t is called forget node and v forget is the forget vertex of X t . if t ∈ V (Y ) has exactly two children t and t , then X t = X t = X t , and E(G t ) ∩ E(G t ) = ∅. The node t is called a join node.
The notion of a nice triple defined above is essentially the same as the one of nice tree decomposition in [10] (which in turn is an enhancement of the original one, introduced in [28]). As already argued in [10,28], it is possible, given a tree decomposition to transform it in polynomial time to a new one D of the same width and construct a collection G such that the triple (D, r, G) is nice.
Transfer triples and their fusion. Let (F, R, α) be a triple where F is a forest, R ⊆ V (F ), and α : . Keep in mind that R F contains all vertices and edges of F except from the edges that are incident to vertices in R. We call (F, R, α) a transfer triple if, given a (v, a) ∈ R × R F , α(v, a) = ⊥ if and only if v and a belong in different connected components of F . The function α will be used for indicating for each pair (v, a) the "cost of transfering" from v to a in F (α is not necessarily a distance function).
Let (F 1 , R 1 , α 1 ) and (F 2 , R 2 , α 2 ) be two transfer triples where We require a function α 1 ⊕ β α 2 : R×R F → [0, k]∪{⊥} that builds the transferring costs of moving in F by taking into account the corresponding transferring costs in F 1 and F 2 . The values of α 1 ⊕ β α 2 are defined as follows: Let (v, a) ∈ R × R F . Let P be the shortest path in F containing v and a and let V (P ) = {v 0 , . . . , v r }, ordered in the way these vertices appear in P and assuming that v 0 = v. To simplify notation, we assume that {v 0 , v 1 } is an edge of F 1 (otherwise, exchange the roles of F 1 and F 2 ). Given i ∈ [r − 1], we define e − i (resp. e + i ) as the edge incident to v i that appears before (resp. after) v i when traversing P from v to a. We define the set of indices i and e + i belong to different sets of {E(F 1 ), E(F 2 )}}.

XX:7
Let I = {i 1 , . . . , i q }, where numbers are ordered in increasing order and we also set i 0 = 0. Then we set Throughout the paper, we let n, ∆, and tw denote the number of vertices, the maximum degree, and the treewidth of the input graph, respectively. When we consider the (parameterized) decision version of the Diameter-Tree problem, we let also k denote the desired cost of a solution.

Para-NP-hardness results
We start with the para-NP-hardness result with parameter k + tw.

Theorem 1.
The Diameter-Tree problem is NP-hard on outerplanar graphs with only one vertex of degree greater than 3, even with three different costs that satisfy the triangle inequality, and k = 9. Since outerplanar graphs have treewidth at most 2, in particular, Diameter-Tree is para-NP-hard parameterized by tw and k.
Proof. We present a simple reduction from 3-Sat. Given a formula ϕ with n variables and m clauses, we create an instance (G, χ, c) of Diameter-Tree as follows. We may assume that there is no clause in ϕ that contains a literal and its negation. The graph G contains a distinguished vertex r and, for each clause c j = ( 1 ∨ 2 ∨ 3 ), we add a clause gadget This completes the construction of G. Note that G does not depend on the formula ϕ except for the number of clause gadgets, and that it is an outerplanar graph with only one vertex of degree greater than 3; see Figure 1 for an illustration. Figure 1 Example of the graph G built in the reduction of Theorem 1.
Let us now define the coloring χ and the cost function c. For simplicity, we associate a distinct color with each edge of G, and thus, with slight abuse of notation, it is enough to describe the cost function c for every pair of incident edges of G, as we consider symmetric cost functions. We will use just three different costs: 1, 5 and 10. We set Parameterized complexity of finding a spanning tree with minimum reload cost diameter Note that this cost function satisfies the triangle inequality since the reload costs between edges incident to r are 5 and 10, and the reload costs between edges incident to other vertices are 1.
We claim that ϕ is satisfiable if and only if G contains a spanning tree with diameter at most 9. Since r is a cut vertex and every clause gadget is a connected component of G − r, in every spanning tree, the vertices of C j together with r induce a tree with four vertices. Moreover the reload cost associated with a path from r to a leaf of this tree is always at most 2. Therefore, the diameter of any spanning tree is at most 4 plus the maximum reload cost incurred at r by a path of T .
Assume first that ϕ is satisfiable, fix a satisfying assignment ψ of ϕ, and let us construct a spanning tree T of G with diameter at most 9. For each clause c j , the tree T j is the tree spanning C j and containing the edge between r and an arbitrarily chosen literal of c j that is set to true by ψ. T is the union of all the trees T j constructed in this way. The reload cost incurred at r by any path of T traversing it is at most 5, since we never choose a literal and its negation. Therefore, it holds that diam(T ) ≤ 9.
Conversely, let T be a spanning tree of G with diam(T ) ≤ 9. Then, the reload cost incurred at r by any path traversing it is at most 5 since otherwise diam(T ) ≥ 10. For every j ∈ [m], let T j be the subtree of T induced by C j and let {r, v j i j } be one of the edges incident to r in T j . We note that for any pair of clauses c j1 , c j2 we have ij 1 = ij 2 , since otherwise a path using these two edges would incur a cost of 10 at r. The variable in the literal ij is set by ψ so that ij is true. All the other variables are set to an arbitrary value by ψ. Note that ψ is well-defined, since we never encounter a literal and its negation during the assignment process. It follows that ψ is a satisfying assignment of ϕ.
We proceed with the para-NP-hardness result with parameter k + ∆.

Theorem 2.
The Diameter-Tree problem is NP-hard on graphs with ∆ ≤ 3, even with two different costs, k = 0, and bounded number of colors. In particular, it is para-NP-hard parameterized by k and ∆.
Proof. We present a reduction from the restriction of 3-Sat to formulas where each variable occurs in at most three clauses; this problem was proved to be NP-complete by Tovey [32]. It is worth mentioning that one needs to allow for clauses of size two or three, as if all clauses have size exactly three, then it turns out that all instances are satisfiable [32].
We may assume that each variable occurs at least once positively and at least once negatively, as otherwise we may set such variable x to the value that satisfies all clauses in which it appears, and delete x together with those clauses from the formula. We may also assume that each variable occurs exactly three times in the given formula ϕ. Indeed, let x be a variable occurring exactly two times in the formula. We create a new variable y and we add to ϕ two clauses (x ∨ y) and (y ∨ y). Let ϕ be the new formula. Clearly ϕ and ϕ are equivalent, and both x and y occur three times in ϕ . Applying these operations exhaustively clearly results in an equivalent formula where each variable occurs exactly three times. Summarizing, we may assume the following property: Each variable occurs exactly three times in the given formula ϕ of 3-Sat. Moreover, each variable occurs at least once positively and at least once negatively in ϕ.
Given a formula ϕ with n variables and m clauses, we create an instance (G, χ, c) of Diameter-Tree with ∆(G) ≤ 3 as follows. Let the variables in ϕ be x 1 , . . . , x n . For every i ∈ [n], we add to G a variable gadget consisting of five vertices u i , v i , p i , r i , n i and five , the clause gadget in G consists of a single vertex c j . We now proceed to explain how we connect the variable and the clause gadgets. For each variable x i , we connect vertex p i (resp. n i ) to a vertex corresponding to a clause of ϕ in which x i appears positively (resp. negatively). Finally, we connect vertex r i to the remaining clause in which x i appears (positively or negatively). Note that these connections are well-defined because of property . This completes the construction of G, and note that it indeed holds that ∆(G) ≤ 3; see Figure 2(a) for an example of the construction of G for a specific satisfiable formula ϕ with n = 4 and m = 5.
Let us now define the coloring χ and the cost function c. We use nine colors 1, 2, . . . , 9 associated with the edges of G as follows. For i ∈ [n], we set χ({p i , r i }) = 1 and χ({r i , n i }) = 2, and all edges incident to u i or v i have color 3. Finally, for j ∈ [m], we color the edges containing c j with colors in {4, 5, 6, 7, 8, 9}, so that incident edges get different colors, and edges corresponding to positive (resp. negative) occurrences get colors in {4, 5, 6} (resp. {7, 8, 9}); note that such a coloring always exists as each clause contains at most three variables; see Figure 2(b). We will again use only two costs, namely 0 and 1, and recall that we consider just symmetric cost functions. We set c(1, All other costs are set to 0. The vertices pi, ri, ni corresponding to positive (resp. negative) occurrences are depicted with circles (resp. squares). An assignment satisfying ϕ is given by x1 = x2 = 1 and x3 = x4 = 0, and a solution spanning tree T with diameter 0 is emphasized with thicker edges. (b) The (possible) colors associated with edge edge of G are depicted in blue.
We claim that ϕ is satisfiable if and only if G contains a spanning tree with diameter 0. Assume first that ϕ is satisfiable, fix a satisfying assignment ψ of ϕ, and let us construct a spanning tree T of G with diameter 0. For every i ∈ [n], tree T contains all the edges containing vertex u i or v i . If variable x i is set to true by ψ, we include the edge {r i , n i } to T , and otherwise, that is, if x i is set to false by ψ, we include the edge {p i , r i }. Finally, for j ∈ [m], we add to T one of the edges containing c j that corresponds to a literal satisfying that clause. It can be easily checked that T is a spanning tree of G with diameter 0; see Figure 2(a) for an example.
Conversely, let T be a spanning tree of G with diameter 0. Since the cost associated with any two distinct colors in {4, 5, 6, 7, 8, 9} is 1, it follows that, for j ∈ [m], vertex c j has degree one in T . Therefore, the variable gadgets need to be connected in T via the a r X i v vertices u i , implying that all edges containing u i , for i ∈ [n], belong to T . For i ∈ [n], in order for T to contain all four vertices v i , p i , r i , n i , by construction of G and since all clause vertices have degree one in T , tree T necessarily contains exactly three out of the four edges of the 4-cycle defined by v i , p i , r i , n i . Since c(1, 2) = 1 and diam(T ) = 0, the missing edge is necessarily either {p i , r i } or {r i , n i }. We define an assignment ψ of the variables x 1 , . . . , x n as follows: for i ∈ [n], if the edge {r i , n i } belongs to T , we set x i to true; otherwise, we set x i to false. We claim that ψ satisfies ϕ. Indeed, let c j be a vertex in G corresponding to an arbitrary clause of ϕ. Since c j has degree one in T , it is attached to exactly one of the vertices p i , r i , n i for some i ∈ [n]. Suppose that the edge containing c j corresponds to a positive occurrence of x i , the other case being symmetric. Then, by construction, necessarily the edge containing c j is either {c j , p i } or {c j , r i }. In both cases, if the edge {p i , r i } were in T , this edge together with {c j , p i } or {c j , r i } would incur a cost of 1 in T , contradicting the hypothesis that diam(T ) = 0. Therefore, the edge {p i , r i } cannot be in T , implying that the edge {r i , n i } must be in T . According to the definition of the assignment ψ, this implies that variable x i is set to true in ψ, and therefore the clause corresponding to c j is satisfied by variable x i . This concludes the proof.
Note that in the above reduction the cost function c does not satisfy the triangle inequality at vertices p i or n i for i ∈ [n], and recall that this is unavoidable since otherwise the problem would be polynomial [33]. It is worth mentioning that using the ideas in the proof of [22, Theorem 4 of the full version] it can be proved that the Diameter-Tree problem is also NP-hard on planar graphs with ∆ ≤ 4, k = 0, and bounded number of colors; we omit the details here.
Finally, we present the para-NP-hardness result with parameter tw + ∆.
Theorem 3. The Diameter-Tree problem is NP-hard on planar graphs with tw ≤ 3 and ∆ ≤ 3. In particular, it is para-NP-hard parameterized by tw and ∆.
Proof. We present a reduction from the Partition problem, which is a typical example of a weakly NP-complete problem [19]. An instance of Partition is a multiset S = {a 1 , a 2 , . . . , a n } of n positive integers, and the objective is to decide whether S can be partitioned into two subsets S 1 and S 2 such that x∈S1 Given an instance S = {a 1 , a 2 , . . . , a n } of Partition, we create an instance (G, χ, c) of Diameter-Tree as follows. The graph G contains a vertex r, called the root, and for every integer a i where i ∈ [n], we add to G six vertices We denote by H i the subgraph induced by these six vertices and seven edges. We add the edges Let G be the graph constructed so far. We then define G to be the graph obtained from two disjoint copies of G by adding an edge between both roots. Note that G is a planar graph with ∆(G) = 3 and tw(G) = 3. (The claimed bound on the treewidth can be easily seen by building a path decomposition of G with consecutive bags of the form Let us now define the coloring χ and the cost function c. Again, for simplicity, we associate a distinct color with each edge of G, and thus it is enough to describe the cost function c for every pair of incident edges of G. We define the costs for one of the copies of G , and the same costs apply to the other copy. For every edge e being either {u i , u i+1 } or a 1 a 1 a n a n r 2   Figure 3 for an illustration, where (some of) the reload costs are depicted in blue, and a typical solution spanning tree of G is drawn with thicker edges.
We claim that the instance S of Partition is a Yes-instance if and only if G has a spanning tree with diameter at most B.
Assume first that S is a Yes-instance of Partition, and let S 1 , S 2 ⊆ S be a solution. We define a spanning tree T of G with diameter B as follows. We describe the subtree of T restricted to one of the copies of G , say T . The spanning tree T of G is defined by union of two symmetric copies of T , one in each copy of G , together with the edge {r 1 , r 2 }. Tree T consists of the two edges {r, u 1 }, {r, d 1 } and two paths P u , P d (corresponding to the upper and the lower path, respectively defined as follows; see Figure 3). For i ∈ [n − 1], the path P u (resp. P d ) contains the edge {u i , u i+1 } (resp. {d i , d i+1 }), and if a i ∈ S 1 we add the three edges {u i , m i }, {m i , m i }, {m i , u i } to P u , and the edge {d i , d i } to P d . Otherwise, if a i ∈ S 2 , we add the edge {u i , u i } to P u and the three edges 2 , it can be easily checked that both paths P u and P d have diameter B 2 in each of the two copies of G , and therefore T is a spanning tree of G with diameter B. Conversely, let T be a spanning tree of G with diam(T ) ≤ B. Let G 1 , G 2 be the two copies of G in G, and let r 1 , r 2 be their respective roots. Since the edge {r 1 , r 2 } is a bridge of G, it necessarily belongs to T . By the construction of G, the choice of the reload costs, and since diam(T ) ≤ B − 1, it can be verified that, for j ∈ {1, 2}, T ∩ G j consists of two paths P j u , P j d intersecting at the root r i . Furthermore, P j u (resp. P j d ) contains the edge {u i , u i+1 } (resp. {d i , d i+1 }) of the corresponding copy of G , and the intersection of P j u (resp. P j d ) with the subgraph H i in the corresponding copy of G is given by either the three edges . . , n} such that the edge {m i , m i } belongs to path P j x . Note also that, for j ∈ {1, 2}, by construction we have that d j On the other hand, by the structure of T it holds that Equation (1)

A polynomial-time algorithm on cactus graphs
In this section we present a polynomial-time algorithm to solve the Diameter-Tree problem on cactus graphs, equivalently called cacti. We first need some definitions. A biconnected component, or block, of a graph is a maximal biconnected induced subgraph of it. The block tree of a graph G is a tree T whose nodes are the cut vertices and the blocks of G. Every cut vertex is adjacent in T to all the blocks that contain it. Two blocks share at most one vertex. The block tree of a graph is unique and can be computed in polynomial time [12]. A graph is a cactus graph if every block of it is either a cycle or a single edge. We term these blocks as cycle block and edge block, respectively. It is well-known that cacti have treewidth at most 2. Given a forest F and two vertices x and y, we define cost F (x, y) to be dist c T (x, y) if x and y are in the same tree T of F and where c is the given reload cost function, and ⊥ otherwise. Given a tree T and a vertex v ∈ V (T ), we define the eccentricity We present a polynomial-time algorithm that solves the decision version of the problem, which we call Diameter-Tree*: the input is an edge-colored graph G and an integer k, and the objective is to decide whether the input graph G has a spanning tree with reload cost diameter at most k. The algorithm to solve Diameter-Tree* uses dynamic programming on the block tree of the input graph.
As we aim at a truly polynomial-time algorithm to solve Diameter-Tree, we cannot afford to solve the decision version for all values of k. To overcome this problem, we perform a double binary search on the possible solution values and two appropriate eccentricities, resulting (skipping many technical details) in an extra factor of (log opt) 2 in the running time of the algorithm, where opt is the diameter of a minimum cost spanning tree. This yields a polynomial-time algorithm solving Diameter-Tree in cactus graphs.
Roughly speaking, the algorithm first fixes an arbitrary non-cut vertex r of G and the block B r that contains it. Then it processes the block tree of G in a bottom-up manner starting from its leaves, proceeding towards B r while maintaining partial solutions for each block. At each step of the processing, it uses an algorithm that solves an instance of the 2-Sat problem as a subroutine. The intuition behind the instances of 2-Sat created by the algorithm is the following.
Suppose that we are dealing with a cycle block B of the block tree of G (the case of an edge block being easier). Note that any spanning tree of G contains all edges of B except one. Let G B be the graph processed so far (including B). For each potential partial solution Q in G B , we associate, with each edge e of B, a variable that indicates that e is the non-picked edge by the solution in B. Now, for any two such variables corresponding to intersecting blocks, we add to the formula of 2-Sat essentially two types of clauses: the first set of clauses, namely φ 1 , guarantees that the non-picked edges (corresponding to the variables set to true in the eventual assignment) indeed define a spanning tree of G B , while the second one, namely φ 2 , forces this solution to have diameter and eccentricity not exceeding the given budget k. The fact the G is a cactus allows to prove that these constraints containing only two variables are enough to compute an optimal solution in G B . Proof. We start with a few more definitions needed in the algorithm. Given a graph G, we denote by S(G) the set of spanning trees of G, and by B(G) the set of blocks of G. We omit G from the notation if no ambiguity arises. We assume without loss of generality that G is connected. For a block B, we denote by C(B) the set of blocks that are immediate descendants of B in the block tree. With a slight abuse (since we ignore the cut vertices in the block tree), we will refer to them as the children of B. The parent of a block B is the first block after B on the path from B to B r in the block tree. We denote by G B the subgraph of G induced by the union of all descendants B (including B itself). The anchor a(B) of a block B is the cut vertex separating B from its parent if B = B r , and r if B = B r .
Let B be a cycle block, e = {x, y}, and assume, without loss of generality, that y = a(B). Clearly, the graph G B − e is connected. Moreover, a(B) is a cut vertex of  Given an edge block B, a subgraph T of G B , and an integer i, we say that T satisfies the (i)-condition if: T is a tree of diameter at most k and the eccentricity of a(B) in T is at most i.

Let us fix a block B, and an edge e of E(B).
In the sequel our goal is to describe how to compute λ B (e). We can assume that for every child C of B, the function λ C has already been computed and C contains at least one edge e such that λ C (e ) = ⊥, since otherwise the algorithm would have stopped.
We define T e to be the tree obtained by taking the union of all the following: the graph B if B is an edge block, and λ C (e C ) for every child C of B that is an edge block containing only the edge e C .
For every child C of B that is a cycle block, for every edge e of C such that λ C (e ) = ⊥ and for x ∈ e , the tree R x ,e C is λ C (e ) [S x ,e B ]. Note that, given a child C of B that is a cycle block, and three vertices For Q ⊆ R B we denote by T e Q the graph obtained by taking the union of T e and Q. If there exists R ∈ R B such that Q = {R}, we write T e R instead of T e Q . We define close R B (Q) to be the set of elements of R B that are subgraphs of T e Q . Note that T e Q = T e close R B (Q) . If B is a cycle block, we define for each i, j ∈ [0, k] the set R (e,i,j) B = {R ∈ R B | T e R satisfies the (e, i, j)-condition}. If B is an edge block, we define for each i ∈ [0, k] the set R (i) R satisfies the (i)-condition}. Note that, if B is a cycle block (resp. an edge block), then for each i, j ∈ [0, k] and for each R 1 , With a slight abuse of notation, we say that a set Q ⊆ R B satisfies a formula φ over these variables if φ is satisfied when each variable of {v(R) | R ∈ Q} is set to true and each variable of {v(R) | R ∈ R B \ Q} is set to false simultaneously. In the following we are going to build three formulas φ 0 , φ 1 , and φ 2 , and if Q ⊆ R B satisfies φ 0 ∧ φ 1 ∧ φ 2 then this implies that T e Q is a correct value for λ B (e).
Along with the description, the reader is referred to Figure 5 to get some intuition about the formulas φ 0 , φ 1 , and φ 2 . In this figure, we have a cycle block B with two children Figure 5 Example of a cycle block B with two children C1 and C2.
and C 2 . As we will see later, when computing λ B (e) in this example, we have: )), and for every two vertices of V (C 1 ) ∪ V (C 2 ), say v and w , the ) is a clause of φ 2 if and only if the path defined by v , v, w, w has diameter greater than k. In the general case, the clauses deal with T e instead of the path v , v, w, w , but the main idea behind the clauses is the same.
We construct a 2-Sat formula φ 0 such that for each R 1 , R 2 ∈ R B where R 2 is a subgraph of R 1 , φ 0 contains the clause v(R 1 ) ⇒ v(R 2 ). It is easy to show that given Q ⊆ R B , Q satisfies φ 0 if and only if Q = close R B (Q).
We construct a 2-Sat formula φ 1 as follows. For every child C of B that is a cycle block, and every two consecutive edges With this definition of φ 1 , we now state the following lemma.
Proof. Let Q ⊆ R B . First assume that T e Q is a spanning tree of G B . Let C ∈ C(B) be a cycle block, and let e 1 = {v 1 , v 2 } and e 2 = {v 2 , v 3 } be two consecutive edges of C such that e 1 = e 2 , v 1 = a(C), and v 2 = a(C). As T e Q is connected, the clause v v2,e1 C ∨ v v2,e2 C is satisfied. As T e Q does not contain any cycle, the clause v v2,e1 C is satisfied. Assume now that Q satisfies φ 1 , and let z be a vertex of G B . If z ∈ V (B), then there is a path from z to a(B) in T e and hence also in T e Q . Otherwise, let C z ∈ C(B) be the block a r X i v XX:16 Parameterized complexity of finding a spanning tree with minimum reload cost diameter such that z ∈ V (G Cz ), and let s(z) be the only vertex of V (C z ) such that s(z) = a(C z ) and each path in G B from a(B) to z contains s(z). Note that if z ∈ V (C z ), then s(z) = z. If C z is an edge block, then z ∈ V (T e ); therefore, there is a path from a(B) to z in T e Q . Otherwise, if C z is a cycle block, then the condition v v2,e1 and that there is a path in T e Q from a(B) to z. Thus, T e Q is connected and V (T e Q ) = V (G B ). We need to show that T e Q does not contain any cycle. By construction of T e Q , if it contains a cycle, this cycle should be C where C ∈ C(B). The condition v v2,e1 We build a formula φ 2 over the variables has diameter greater than k, then we add the clause v(R 1 ) ∨ v(R 2 ) to φ 2 . With this definition of φ 2 , we now state the following lemma. First assume that T e Q is a spanning tree of G B that satisfies the (e, i, j)-condition. This directly implies that T e also satisfies the (e, i, j)-condition. It remains to show that Q satisfies φ 2 . For this, assume that there exist R 1 and R 2 in Q such that T e {R1,R2} has diameter more than k. Since T e {R1,R2} is a subtree of T e Q , this implies that T e Q also has diameter more than k, which is a contradiction because T e Q satisfies the (e, i, j)-condition. Assume now that Q satisfies φ 2 and T e satisfies the (e, i, j)-condition. As Q satisfies φ 1 , we know by Lemma 5 that T e Q is a spanning tree of G B . As Q ⊆ R , we obtain that cost T e Q (a(b), z) ≤ i The same argument applies if z ∈ S y,e B . It remains to show that T e Q is of diameter at most k. Let z and z be two vertices of T e Q . If both z and z are in V (B), then as T e satisfies the (e, i, j)-condition, this implies that cost T e Q (z, z ) ≤ k. If z ∈ V (B) and z ∈ V (B) then, as T e Q is a spanning tree of G B , there exists R ∈ Q such that z ∈ V (R ). As R ∈ R (e,i,j) B , cost T e Q (z, z ) ≤ k. Otherwise, if both z and z are not in V (B), since T e Q is a spanning tree of G B , there exist R, R ∈ Q such that z ∈ V (R) and z ∈ V (R ). If R = R , then as R ∈ R (e,i,j) B , cost T e Q (z, z ) ≤ k. Otherwise, as Q satisfies φ 2 , then T e {R,R } has diameter at most k; therefore, cost T e Q (z, z ) ≤ k. The same arguments apply if B is an edge block. Proof. For readability, we consider the case where B is an edge block. Let x = a(B). Assume that there existsT B , a spanning tree of G B , that satisfies the (i)-condition for some

Lemma 7. If B is a cycle block (resp. an edge block) and if there exists a spanning treeT
x ∈ e }) and we claim that Q satisfies φ 0 , φ 1 , and φ 2 . By definition of close R B , Q satisfies φ 0 . It is not difficult to see that T e Q is a spanning tree and so, by Lemma 5, Q satisfies φ 1 . Let z be a vertex of V (G B ) \ V (B), and let C ∈ C(B) such that z ∈ V (G C ). The path inT B and the path in T e Q from a(B) to z use exactly the same edges of C. This implies that cost T e Q (a(B), z) ≤ i. OtherwiseT B [V (G C )] would have been a better value for λ C (e ) for the only compatible edge e ∈ E(C). With the same arguments we show that T e Q has diameter at most k. This implies that T e Q satisfies the (i)-condition, and so Q ⊆ R (i) B and Q satisfies φ 2 . The same arguments also work if B is a cycle block but we should take care about the part that is in S x,e B and the part that is in S y,e B separately.
We now have all the elements to compute the value λ B (e). We assume that B is a cycle block (resp. an edge block). If there is no Q ⊆ R (e,k,k) B (resp. Q ⊆ R (k) B ) that satisfies φ 0 , φ 1 , and φ 2 , or T e does not satisfy the (e, k, k)-condition (resp. (k)-condition), then we set λ B (e) = ⊥. Otherwise, we aim at computing two integers i 0 and j 0 that are the smallest i and j in [0, k] such that there exists Q ⊆ R (e,i,j) B (resp. Q ⊆ R (i) B ) that satisfies φ 0 , φ 1 , and φ 2 and such that T e satisfies the (e, i, j)-condition (resp. (i)-condition). In order to compute i 0 and j 0 , we first fix j to be k and do a binary search on i, between 0 and k, to find the smallest value i 0 such that there exists Q ⊆ R (e,i0,k) B (resp. Q ⊆ R (i0) B ) that satisfies φ 0 , φ 1 , and φ 2 and such that T e satisfies the (e, i 0 , k)-condition (resp. (i 0 )-condition). We fix this value of i 0 and we do a second binary search, this time on j, between 0 and k, to find the smallest value j 0 such that there exists Q ⊆ R (e,i0,j0) B (resp. Q ⊆ R (i0) B ) that satisfies φ 0 , φ 1 , and φ 2 and such that T e satisfies the (e, i 0 , j 0 )-condition (resp. (i 0 )-condition). We fix this value of j 0 and we also fix Q ⊆ R (e,i0,j0) B (resp. Q ⊆ R (i0) B ) that satisfies φ 0 , φ 1 , and φ 2 . We set λ B (e) = T e Q . Using Lemma 5 and Lemma 6, we know that the graph λ B (e) is a spanning tree of G B that satisfies the (e, i 0 , j 0 )-condition (resp. (i 0 )-condition). Moreover, using Lemma 7, we know that there is no spanning subtree of G B that satisfies the (e, i 1 , j 1 )-condition (resp. (i 1 )-condition) with i 1 < i 0 or j 1 < j 0 (resp. i 1 < i 0 ). This finishes the description of the algorithm.
Let us now discuss about the running time of the algorithm. At each step, given a cycle block (resp. an edge block) B and e ∈ E(B), for each i, j ∈ [0, k], we can check if T e satisfies the (e, i, j)-condition (resp. the (i)-condition) in time O(n 2 ). Moreover, the number of elements in R B is linear in n and for each i, j ∈ [0, k], R (e,i,j) B can be computed in time O(n 2 ). As R B contains at most O(n) elements, then the 2-Sat formulas φ 0 , φ 1 , and φ 2 contain at most O(n 2 ) clauses. We can check for each of the O(n 2 ) possible clauses if it is in φ 0 , φ 1 , or φ 2 in time O(n). Hence, we can compute φ 0 , φ 1 and φ 2 in time O(n 3 ). As they contain at most O(n 2 ) clauses, we can solve them in time O(n 2 ). Since for each block B and each edge e ∈ E(B), we perform at most two (independent) binary searches to find i 0 and j 0 , we can compute λ B (e) in time O(n 3 · log k). Because there is a linear number of values λ B (e) to compute, we obtain an algorithm that solves Diameter-Tree* in time O(n 4 · log k). Using again a binary search on k between 0 and 2 log opt , and the previous algorithm that solves Diameter-Tree* as a subroutine, we obtain an algorithm that solves Diameter-Tree in time O(n 4 · (log opt) 2 ) where opt is the diameter of the solution.

5
FPT algorithm parameterized by k + tw + ∆ In this section we prove that the Diameter-Tree problem is FPT on general graphs parameterized by k, tw, and ∆. The proof is based on standard, but nontrivial, dynamic programming on graphs of bounded treewidth. It should be mentioned that we can assume that a tree decomposition of the input graph G of width O(tw) is given together with the input. Indeed, by using for instance the algorithm of Bodlaender et al. [7], we can compute in time 2 O(tw) · n a tree decomposition of G of width at most 5tw. Note that this running time a r X i v is clearly dominated by the running time stated in Theorem 8. Recall also that, by [10,28], it is possible, given a tree decomposition to transform it in polynomial time to a new one D of the same width and construct a collection G such that the triple (D, r, G) is nice.
Proof. Before we start the description of the dynamic programming, we need some definitions. Let F be a forest and let S be a set of vertices in F that is good for G. We define Reduce(F, S) as the forest F that is obtained from F by repetitively applying the following operations to vertices that are not in N F [S] as long as this is possible: removing a vertex of degree 1 and dissolving a vertex of degree 2.
Suppose now that Reduce(F, S) = F . We define the associated reduce function ϕ : For every vertex z ∈ V (F ), we define K z to be the set of vertices x of V (F ) such that there exists a path in F from z to x that does not use any vertex of V (F ) \ {x}. If K z contains only one element x, then we define ϕ(z) = x, otherwise we define ϕ(z) = K z . To show that ϕ is well-defined, we claim that 1 ≤ |K z | ≤ 2 and if |K z | = 2 then K z ∈ E(F ). Indeed, since each connected component of F contains an element of S, we have that |K z | ≥ 1. Assume that K z contains two distinct vertices x 1 and x 2 . By definition, we know that x 1 and x 2 are in the same connected component of F and also of F . Let P i be the path from z to x i , i ∈ {1, 2}, in F and let P be the path from is not an edge of F and let x 3 be a vertex of F on the path from x 1 to x 2 in F . Then x 3 should be in P . This contradicts the fact that V (P ) ∩ V (F ) = {x 1 , x 2 }. As F is a forest, this also implies that |K z | ≤ 2.
We now proceed with the dynamic programming algorithm that solves Diameter-Tree*, the decision version of Diameter-Tree. Let (G, χ, c, k) be an instance of Diameter-Tree*. Consider a nice triple (D, r, G) where D is a tree decomposition D = (Y, X = {X t | t ∈ V (Y )}) of G with width at most tw and G = {G t | t ∈ V (Y )}. For each t ∈ V (Y ) we set w t = |X t | and V t = V (G t ). We also refer to the vertices of X t as t-terminals and to the edges that are incident to vertices in X t as t-terminal edges. We provide a table R t that the dynamic programming algorithm computes for each node of D. For this, we need first the notion of a t-pair, that is a pair (F, α) where: We call the vertices in V (F ) \ N F [X t ] external vertices of F and the edges of {e ∈ E(F ) | e ∩ X t = ∅} external edges of F . We need the function β t : adj G (Xt) 2 → [0, k] ∪ {⊥} so that, for each e 1 , e 2 ∈ adj G (X t ), if there exists x ∈ X t such that e 1 ∩ e 2 = {x}, then β t (e 1 , e 2 ) = c(e 1 , e 2 ), otherwise β t (e 1 , e 2 ) = ⊥.
Let (F, α) be a t-pair. Recall that X F t contains all t-terminals and all non-t-terminal edges of F . Given a t-pair (F, α) as above we say that it is admissible if for every (a, a ) ∈ X F t × X F t one of the following holds: there is no path between a and a in F containing a vertex in X t , one, say a, of a, a is a vertex in X t and α(a, a ) ≤ k, some internal vertex b of the path P between a and a in F belongs in X t and α t (b, a) + β t (e − , e + ) + α t (b, a ) ≤ k, where e + , e − are the two edges in P that are incident to b. Intuitively, the admissibility of a t-pair (F, α) assures that the transferring cost, indicated by α, between any two external elements is bounded by k.
It is now time to give the precise definition of the table R t of our dynamic programming algorithm. A pair (F, α) belongs in R t if G contains a spanning treeT where diam(T ) ≤ k and the forestF =T [V t ] (i.e. the restriction ofT to the part of the graph that has been processed so far) satisfies the following properties: Reduce(F , X t ) = F , with the reduce function ϕ, for each x ∈ X t and y ∈ X F t , α(x, y) = ⊥ if and only if x and y are in two different connected components in F and if α(x, y) = ⊥, then for each z ∈ ϕ −1 (y), costF (x, z) = ⊥ and α(x, y) ≥ costF (x, z).
Notice that each (F, α) as above is a t-pair. Indeed, Conditions 1-3 follow by the fact thatT is a spanning tree of G and thereforeF is a spanning forest of G T . Conditions 4 and 5 follow by the fact that the internal vertices (resp. edges) of a tree with no vertices of degree 2 are at most two less than the number of its leaves (resp. at most twice the number of its leaves minus three). Moreover, the values of α are bounded by k because the diameter ofT is at most k and therefore the same holds for all the connected components ofF . Notice that, for the same reason, all pairs in R t must be admissible.
In the above definition, the external vertices and edges of F correspond to the parts ofF that have been "compressed" during the reduction operation and the function α stores the transfer costs between those parts and the terminals. In this way, the trees in the t-pairs in R t "represent" the restriction of all possible solutions in G t . Moreover, the values of α indicate how these partial solutions interact with the t-terminals.
Our next concern is to bound the size of R t .
Proof. As we impose N [X t ] ⊆ V (F ), we have at most 2 ∆·tw choices for the set {e ∈ E(F ) | e ∩ X t = ∅} and at most (∆ · tw) O(tw) choices for the other edges or vertices. So the number of forest we take into consideration in R t is at most 2 ∆·tw · (∆ · tw) O(tw) . As the number of vertices and the number of edges of F is upper bounded by O(∆ · tw), the number of function α is at most k O(∆·tw 2 ) . So |R t | ≤ k O(∆·tw 2 ) · (∆ · tw) O(tw) and the claim holds.
Clearly, (G, χ, c, k) is a YES-instance if and only if R r = ∅. We now proceed with the description of how to compute the set R t for every node t ∈ T . For this, we will assume inductively that, for every descendent t of t, the set R t has already been computed. We distinguish several cases depending on the type of node t: If t is a leaf node. Then G t = {∅, ∅} and R t = {((∅, ∅), ∅)}. If t is an vertex-introduce node. Let v be the insertion vertex of X t and let t be the child of t.
a r X i v XX:20 Parameterized complexity of finding a spanning tree with minimum reload cost diameter Notice that at this point v is just an isolated vertex of G t . This vertex is added in F and α is updated with the corresponding "void" transfer costs.
If t is an edge-introduce node. Let e = {x, y} be the insertion edge of X t and let t be the child of t. We define F = (X t , {e}) and we set up α : α) is admissible, F is a forest, and there exists a pair (F , α ) ∈ R t such that F = F ∪ F and α = α ⊕ βt α }. In the above case, the single edge graph F is defined and the F of each new t-pair is its union with F . Similarly, the function α encodes the trivial transfer costs in F . Also, α is updated so to include the fusion of the transfer costs of α and α . If t is an forget node. Let v be the forget vertex and let t be the child of t. Then R t contains every t-pair (F, α) such that there exists (F , α ) ∈ R t where: if t is not the root of Y , then the connected component of F containing v also contains an other element v ∈ X t (this is necessary as X t should always be good for F ), F = Reduce(F , X t ), with associated reduce function ϕ, we denote by Z the set of every edge and every vertex that is in F but not in F .
Notice that F is further reduced because v has been "forgotten" in X t . This may change the status of v as follows: either v is not any more in F or v is still in F but it is not a t-terminal. In the first case ϕ(v) is either a vertex or an edge of F and in the second ϕ(v) = v. In any case we should update the values of α(x, φ(v)) for every x ∈ X t to the maximum transition cost (with respect to α ) from x to some element of Z. If t is an join node. Let t and t be the children of t. We define R t = R t ∪ {(F, α) | (F, α) is admissible, F is a forest, and there exist two pairs (F , α ) ∈ R t and (F , α ) ∈ R t such that F = F ∪ F and α = α ⊕ βt α }. The above case is very similar to the case of the edge-introduce node. The only difference is that now F is now taken from R t .
Taking into account Claim 1 on the bound of the size of R t , it is easy to verify that, in each of the above cases, R t can be computed in k O(∆·tw 2 ) · (∆ · tw) O(tw) steps. So we can solve our problem in time k O(∆·tw 2 ) · (∆ · tw) O(tw) · n, and the theorem follows.

Polynomially bounded costs
So far, we have completely characterized the parameterized complexity of the Diameter-Tree problem for any combination of the three parameters k, tw, and ∆. In this section we focus on the special case when the maximum cost value is polynomially bounded by n. The following corollary is an immediate consequence of Theorem 8.

Corollary 9.
If the maximum cost value is polynomially bounded by n, the Diameter-Tree problem is in XP parameterized by tw and ∆.
From Corollary 9, a natural question is whether the Diameter-Tree problem is FPT or W[1]-hard parameterized by tw and ∆, in the case where the maximum cost value is polynomially bounded by n. The next theorem provides an answer to this question. Theorem 10. When the maximum cost value is polynomially bounded by n, the Diameter-Tree problem is W[1]-hard parameterized by tw and ∆.
Proof. We present a parameterized reduction from the Bin Packing problem parameterized by the number of bins. In Bin Packing, we are given n integer item sizes a 1 , . . . , a n and an integer capacity B, and the objective is to partition the items into a minimum number of bins with capacity B. Jansen et al. [26] proved that Bin Packing is W[1]-hard parameterized by the number of bins in the solution, even when all item sizes are bounded by a polynomial of the input size. Equivalently, this version of the problem corresponds to the case where the item sizes are given in unary encoding; this is why it is called Unary Bin Packing in [26].
Given an instance ({a 1 , a 2 , . . . , a n }, B, k) of Unary Bin Packing, where k is the number of bins in the solution and where we can assume that k ≥ 2, we create an instance (G, χ, c) of Diameter-Tree as follows. The graph G contains a vertex r and, for i ∈ [n] and j ∈ [k], we add to G vertices v i , i j , r i j and edges {r, 1 j }, {v i , i j }, {v i , r i j }, and { i j , r i j }. Finally, for i ∈ [n − 1] and j ∈ [k], we add the edge {r i j , i+1 j }. Let G be the graph constructed so far; see Figure 6 for an illustration. Bin Packing is at most B, it can be easily checked that T is a spanning tree of G with diam(T ) ≤ 2B.
Conversely, let T be a spanning tree of G with diam(T ) ≤ 2B, and we proceed to define a solution S 1 , . . . , S k of Unary Bin Packing. Let T 1 and T 2 be the restriction of T to the two copies of G . By the choice of the reload costs and since diam(T ) ≤ 2B, for every i ∈ [n] and every x ∈ {1, 2}, tree T x contains the two edges {v i , i j } and {v i , r i j } for some j ∈ [k], and none of the other edges incident with vertex v i . Therefore, for every x ∈ {1, 2}, tree T x consists of k paths sharing vertex r. This implies that diam(T ) ≥ 1 2 diam(T 1 ) + 1 2 diam(T 2 ), and since diam(T ) ≤ 2B, it follows that there exists x ∈ {1, 2} such that diam(T x ) ≤ B. Assume without loss of generality that x = 1, i.e., that diam(T 1 ) ≤ B. We define the bins S 1 , . . . , S k as follows. For every i ∈ [n], if T 1 contains the two edges {v i , i j } and {v i , r i j }, we add item a i to the bin S j . Let us verify that this defines a solution of Unary Bin Packing. Indeed, assume for contradiction that for some j ∈ [k], the total item size in bin S j exceeds B. As bin S j corresponds to one of the k paths in tree T 1 , the diameter of this path would also exceed B, contradicting the fact that diam(T 1 ) ≤ B. The theorem follows.

Concluding remarks
We provided an accurate picture of the (parameterized) complexity of the Diameter-Tree problem for any combination of the parameters k, tw, and ∆, distinguishing whether the reload costs are polynomial or not. Some questions still remain open. First of all, in the hardness result of Theorem 3, we already mentioned that the bound ∆ ≤ 3 is tight, but the bound tw ≤ 3 might be improved to tw ≤ 2. A relevant question is whether the problem admits polynomial kernels parameterized by k + tw + ∆ (recall that it is FPT by Theorem 8). Theorem 10 motivates the following question: when all reload costs are bounded by a constant, is the Diameter-Tree problem FPT parameterized by tw + ∆? It also makes sense to consider the color-degree as a parameter (cf. [23]). Finally, we may consider other relevant width parameters, such as pathwidth (note that the hardness results of Theorems 1, 3, and 10 also hold for pathwidth), cliquewidth, treedepth, or tree-cutwidth.