Finding k-secluded trees faster

We revisit the k -Secluded Tree problem. Given a vertex-weighted undirected graph G , its objective is to ﬁnd a maximum-weight induced subtree T whose open neighborhood has size at most k . We present a ﬁxed-parameter tractable algorithm that solves the problem in time 2 O ( k log k ) · n O ( 1 ) , improving on a double-exponential running time from earlier work by Golovach, Heggernes, Lima, and Montealegre. Starting from a single vertex, our algorithm grows a k -secluded tree by branching on vertices in the open neighborhood of the current tree T . To bound the branching depth, we prove a structural result that can be used to identify a vertex that belongs to the neighborhood of any k -secluded supertree T (cid:3) ⊇ T once the open neighborhood of T becomes suﬃciently large. We extend the algorithm to enumerate compact descriptions of all maximum-weight k -secluded trees, which allows us to count them as well. © 2023 The Author(s). Published by Elsevier Inc. This is an open access article under the CC BY license (http://creativecommons .org /licenses /by /4 .0/).


Introduction
Background We revisit a problem from the field of parameterized complexity: Given a graph G with positive weights on the vertices, find a connected induced acyclic subgraph H of maximum weight such that the open neighborhood of H in G has size at most k.
A parameterized problem is fixed-parameter tractable (FPT) [4,5] if there is an algorithm that given an instance I with parameter k, solves the problem in time f (k) • |I| O (1) for some computable function f .For problems that are FPT, such algorithms allow NP-hard problems to be solved efficiently on instances whose parameter is small.It is therefore desirable for the function f to grow slowly in terms of k, both out of theoretical interest as well as improving the practical relevance of these algorithms.
We say that a vertex set If H is also a tree, we say that H is a k-secluded tree in G.We use N + to denote the positive integers.Formally, the problem we study in this work is defined as follows.

Large Secluded Tree (LST)
Parameter: k Input: An undirected graph G, a non-negative integer k, and a weight function w : V (G) → N + .
Task: Find a k-secluded tree H of G of maximum weight, or report that no such H exists.
Golovach et al. [10] consider the more general Connected Secluded -Subgraph, where the k-secluded induced subgraph of G should belong to some target graph class .They mention that (Large) Secluded Tree is FPT and can be solved in time 2 2 O(k log k) • n O (1) using the recursive understanding technique, the details of which can be found in the arXiv version [9].For the case where is characterized by a finite set of forbidden induced subgraphs F , they show that the problem is FPT with a triple-exponential dependency.They pose the question whether it is possible to avoid these doubleand triple-exponential dependencies on the parameter.They give some examples of for which this is the case, namely for being a clique, a star, a d-regular graph, or an induced path.
Results Our main result is an algorithm for Large Secluded Tree that takes 2 O(k log k) • n 4 time.This answers the question of Golovach et al. [10] affirmatively for the case of trees.We solve a more general version of the problem, where a set of vertices is given that should be part of the k-secluded tree.Our algorithm goes one step further by allowing us to find all maximum-weight solutions.As we will later argue, it is not possible to output all such solutions directly in the promised running time.Instead, the output consists of a bounded number of solution descriptions such that each maximumweight solution can be constructed from one such description.This is similar in spirit to the work of Guo et al. [11], who enumerate all minimal solutions to the Feedback Vertex Set problem in O(c k •m) time.They do so by giving a list of compact representations, a set C of pairwise disjoint vertex subsets such that choosing exactly one vertex from every set results in a minimal feedback vertex set.Our descriptions are non-redundant (no two descriptions describe the same secluded tree), which allows us to count the number of maximum-weight k-secluded trees containing a specified vertex in the same running time.
Techniques Rather than using recursive understanding, our algorithm is based on bounded-depth branching with a nontrivial progress measure.Similarly to existing algorithms to compute spanning trees with many leaves [12], our algorithm iteratively grows the vertex set of a k-secluded tree T .If we select a vertex v in the neighborhood of the current tree T , then for any k-secluded supertree T of T there are two possibilities: either v belongs to the neighborhood of T , or it is contained in T ; the latter case can only happen if v has exactly one neighbor in T .Solutions of the first kind can be found by deleting v from the graph and searching for a (k − 1)-secluded supertree of T .To find solutions of the second kind we can include v in T , but since the parameter does not decrease in this case we have to be careful that the recursion depth stays bounded.Using a reduction rule to deal with degree-1 vertices, we can essentially ensure that v has at least three neighbors (exactly one of which belongs to T ), so that adding v to T strictly increases the open neighborhood size |N(T )|.
Our main insight to obtain an FPT algorithm is a structural lemma showing that, whenever |N(T )| becomes sufficiently large in terms of k, we can identify a vertex u that belongs to the open neighborhood of any k-secluded supertree T ⊇ T .At that point, we can remove u and decrease k to make progress.
Related work Secluded versions of several classic optimization problems have been studied intensively in recent years [1][2][3]7,13], many of which are discussed in Till Fluschnik's PhD thesis [6].Marx [14] considers a related problem Cutting k (connected) vertices, where the aim is to find a (connected) set S of size exactly k with at most neighbors.Without the connectivity requirement, the problem is W [1]-hard by k + .The problem becomes FPT when S is required to be connected, but remains W [1]-hard by k and separately.Fomin et al. [8] consider the variant where |S| ≤ k and show that it is FPT parameterized by .
Organization We introduce our enumeration framework in Section 2. We present our algorithm that enumerates maximumweight k-secluded trees in Section 3 and present its correctness and running time analyses.We give some conclusions in Section 4.

Framework for enumerating secluded trees
We consider simple undirected graphs with vertex set V (G) and edge set E(G).We use standard notation pertaining to graph algorithms, such as presented by Cygan et al. [4].When the graph G is clear from context, we denote |V (G)| and |E(G)| by n and m respectively.The open neighborhood of a vertex set X in a graph G is denoted by N G (X), where the subscript may be omitted if G is clear from context.For a subgraph H of G, we may write a weight function, then for any S ⊆ V (G) let w(S) := v∈S w(s) and for any subgraph H of G we may denote w(V (H)) by w(H).
It is not possible to enumerate all maximum-weight k-secluded trees in FPT time, as the number of such trees can in general not be bounded by f (k) • n O (1) for any function f ; see Fig. 1.However, it is possible to give one short description for such an exponential number of k-secluded trees.Definition 1.For a graph G, a description is a pair (r, X ) consisting of a vertex r ∈ V (G) and a set X of pairwise disjoint subsets of V (G − r) such that for any set S consisting of exactly one vertex from each set X ∈ X , the connected component H of G − S containing r is acyclic and N(H) = S, i.e., H is a |X |-secluded tree in G.The order of a description is equal to |X |.We say that a k-secluded tree H is described by a description (r, X ) if N(H) consists of exactly one vertex of each X ∈ X and r ∈ V (H).
Note that a single k-secluded tree H can be described by multiple descriptions.For example, for a path on v 1 , . . ., v 4 the 1-secluded tree induced by {v 1 , v 2 } is described by (v 1 , {{v 3 , v 4 }), (v 1 , {{v 3 }}), and (v 2 , {{v 3 }}).We define the concept of redundancy in a set of descriptions.Definition 2. For a graph G, a set of descriptions X of maximum order k is called redundant for G if there is a k-secluded tree H in G such that H is described by two distinct descriptions in X.We say X is non-redundant for G otherwise.Definition 3.For a graph G and a set of descriptions X of maximum order k, let T G (X) denote the set of all k-secluded trees in G described by a description in X.
Observation 4. For a graph G and two sets of descriptions X 1 , X 2 we have: Observation 5.For a graph G, a set of descriptions X, and non-empty vertex sets X 1 , X 2 disjoint from (r,X )∈X ({r} For an induced subgraph H of G and a set F ⊆ V (G), we say that H is a supertree of F if H induces a tree and F ⊆ V (H).Let S k G (F ) be the set of all k-secluded supertrees of F in G.For a set X of subgraphs of G let maxset w (X) := {H ∈ X | w(H) ≥ w(H ) for all H ∈ X}.We focus our attention to the following version of the problem, where some parts of the tree are already given.

Enumerate Large Secluded Supertrees (ELSS)
Parameter: k , then the answer is trivially the empty set.In the end we solve the general enumeration problem by solving ELSS with F = T = {v} for each v ∈ V (G) and reporting only those k-secluded trees of maximum weight.Intuitively, our algorithm for ELSS finds k-secluded trees that "grow" out of T .In order to derive some properties of the types of descriptions we compute, we may at certain points demand that certain vertices non-adjacent to T need to end up in the k-secluded tree.For this reason the input additionally has a set F , rather than just T .
Our algorithm solves smaller instances recursively.We use the following abuse of notation: in an instance with graph G and weight function w : V (G) → N + , when solving the problem recursively for an instance with induced subgraph G of G, we keep the weight function w instead of restricting the domain of w to V (G ).

Enumerate large secluded supertrees
Section 3.1 proves the correctness of a few subroutines used by the algorithm.Section 3.2 describes the algorithm to solve ELSS.In Section 3.3 we prove its correctness and in Section 3.4 we analyze its time complexity.In Section 3.5 we show how the algorithm for ELSS can be used to count and enumerate maximum-weight k-secluded trees containing a specified vertex.

Subroutines for the algorithm
Similar to the Feedback Vertex Set algorithm given by Guo et al. [11], we aim to get rid of degree-1 vertices.In our setting there is one edge case however.The reduction rule is formalized as follows.
Reduction Rule 1.For an ELSS instance (G, k, F , T , w) with a degree-1 vertex v in G such that F = {v}, contracting v into its neighbor u yields the ELSS instance (G − v, k, F , T , w ) where the weight of u is increased by w(v) and: The precondition F = {v} ensures that a maximum-weight k-secluded supertree H of F contains v if and only if it contains u.A supertree containing u but not v can be transformed into a heavier one by adding v, which does not increase the size of the open neighborhood.Conversely, if F = {v} then a supertree H of F that includes v also includes at least one other vertex in F , thereby ensuring the unique neighbor u of v is contained in the connected graph H .The reduction rule therefore effectively merges vertices v and w while summing their weights.Note that if F = {v}, a maximum-weight k-secluded supertree may consist simply of {v} and avoid u.
We prove the correctness of the reduction rule, that is, the descriptions of the reduced instance form the desired output for the original instance.Lemma 8. Let I = (G, k, F , T , w) be an ELSS instance.Suppose G contains a degree-1 vertex v such that {v} = F .Let I = (G − v, k, F , T , w ) be the instance obtained by contracting v into its neighbor u.If X is a non-redundant set of descriptions for G − Proof.We first argue that X is a valid set of descriptions for the graph G.For any (r, X ) ∈ X, we have r ∈ V (G − v) and X consists of disjoint subsets of V (G − {v, r}), which trivially implies that r ∈ V (G) and that X consists of disjoint subsets of V (G −r).Consider any set S consisting of exactly one vertex from each X ∈ X .The connected component H of (G − v) − S containing r is acyclic and Clearly H is acyclic as it is obtained from H by possibly adding a degree-1 vertex.We argue that N G (H ) = S.By construction of H we have N G (H ) ⊆ S. For the sake of contradiction suppose that there is some p Observe that any maximum-weight k-secluded supertree H of F in G containing u, contains its neighbor v as well: adding v to an induced tree subgraph containing u does not introduce cycles since v has degree one, does not increase the size of the neighborhood, and strictly increases the weight since w(v) > 0 by definition.Conversely, any (maximum-weight) k-secluded supertree H of F in G that contains v also contains u: tree H contains all vertices of the non-empty set F and F = {v}, so H contains at least one vertex other than v, which implies by connectivity that it contains the unique neighbor u of v. Hence a maximum-weight k-secluded supertree H of F in G contains u if and only if it contains v.
Using this fact, we relate the sets maxset w (S k G (F )) and maxset w (S k G−v (F )).For any H ∈ maxset w (S k G (F )), there is a k-secluded supertree of F in G − v of the same weight under w : Conversely, for any k-secluded supertree H of F in G − v, there is a k-secluded supertree of F in G of the same weight under w: These transformations imply that the maximum w-weight of trees in S k G (F ) is identical to the maximum w -weight of trees in S k G−v (F ).
We say an instance is almost leafless if the reduction rule above cannot be applied.
Hence there is at most one degree-1 vertex.
The following lemma exploits the property of being almost leafless to guarantee that when |N G (T )| becomes sufficiently large, the branching algorithm can make progress in one of two possible ways.

concludes that G does not contain a k-secluded supertree of F (Fig. 2).
Proof.We aim to find a vertex v ∈ V (G) \ F with k + 2 distinct paths P 1 , . . ., P k+2 from N G (T ) to v that intersect only in v and do not contain vertices from T .We first argue that such a vertex v satisfies the first condition, if it exists.
Consider some k-secluded supertree H of F .Since the paths P 1 , . . ., P k+2 are disjoint apart from their common endpoint v while |N G (H)| ≤ k, there are two paths P i , P j with i = j ∈ [k + 2] for which P i \ {v} and P j \ {v} do not intersect N G (H).These paths are contained in H since they contain a neighbor of T ⊆ F ⊆ V (H).
As P i and P j form a cycle together with a path through the connected set T , which cannot be contained in the acyclic graph H , this implies v ∈ N G (H).
Next we argue that if G has a k-secluded supertree H of F ⊇ T , then there exists such a vertex v. Consider an arbitrary such H and root it at a vertex t ∈ T .For each vertex u ∈ N G (T ), we construct a path P u disjoint from T that starts in u and ends in N G (H), as follows.
• If u / ∈ H , then u ∈ N G (H) and we take P u = (u).• If u ∈ H , then let u be an arbitrary leaf in the subtree of H rooted at u; possibly u = u .Since T is connected and H ⊇ T is acyclic and rooted in t ∈ T , the subtree rooted at Because u is a leaf of H this implies that N G ( u ) contains a vertex y other than the parent of u in H , so that y ∈ N G (H).We let P u be the path from u to u through H , followed by the vertex y ∈ N G (H).
The paths we construct are distinct since their startpoints are.Two constructed paths cannot intersect in any vertex other than their endpoints, since they were extracted from different subtrees of H . Since we construct |N G (T )| > k(k + 1) paths, each of which ends in N G (H) which has size at most k, some vertex v ∈ N G (H) is the endpoint of k + 2 of the constructed paths.As shown in the beginning the proof, this establishes that v belongs to the neighborhood of any k-secluded supertree of F .Since F ⊆ V (H) we have v / ∈ F .All that is left to show is that we can find such a vertex v in the promised time bound.After contracting T into a source vertex s, for each v ∈ V (G) \ F , do k + 2 iterations of the Ford-Fulkerson algorithm in order to check if there are k + 2 internally vertex-disjoint sv-paths.If so, then return v.If for none of the choices of v this holds, then output that there is no k-secluded supertree of F in G.In order to see that this satisfies the claimed running time bound, note that there are O(n) choices for v, and k + 2 iterations of Ford-Fulkerson runs can be implemented to run in O(k The last ingredient we need to describe the algorithm is the notion of an extending path; see Fig. 3. ) defined by the following process.
1. Initialize P as the 1-vertex path starting and ending in v = v 1 .
2. Let v i be the last vertex currently on P .
to the path and repeat.(b) Otherwise terminate the procedure: the path P constructed so far is the extending path of v.

Observe that when deg
The general behavior of our algorithm consists of branching on an extending path, to consider three options for how this path P interacts with the desired maximum-weight k-secluded supertrees H of F that have to be enumerated: H can avoid the last vertex v (but must then include (v 1 , . . ., v −1 ) to be of maximum weight), it can avoid a single intermediate vertex on the path (but then has to contain all others and v ), or it can contain the entire path P .
The algorithm will explore these different cases, while also accounting for the setting that some vertices of P belong to F .
The definition of extending path is chosen to ensure that the algorithm can make some type of progress in all cases.For example, if the path P ends in a vertex v such that v has two neighbors in V (P ) ∪ T , then adding the entire path P to T would yield a cycle, and as such this branch does not have to be executed as it does not lead to solutions.Observe that if an ELSS instance is almost leafless, then the extending path of a vertex v cannot end in a vertex of degree 1, and therefore ends at a vertex whose degree is larger than 2, or at a vertex which has two neighbors in V (P ) ∪ T .We capture this in the following observation.
of v satisfies at least one of the following: The case that deg G (v ) ≥ 3 will be useful to ensure some form of progress for the branching algorithm.We will later show (see Lemma 29) that when all of P is added to the tree T , this leads to an increase of the size of the open neighborhood of the tree (or triggers an easy corner case).

The algorithm
In this section we present an algorithm that, given an instance (G, k, F , T , w) of ELSS, produces a valid output in time Otherwise we remove all connected components of G that do not contain a vertex of F .If more than one connected component remains, return ∅.Then, while there is a degree-1 vertex v such that F = {v}, contract v into its neighbor as per Rule 1.While We proceed by considering the neighborhood of T as follows: 1.If any vertex v ∈ N G (T ) has two neighbors in T , then recursively run this algorithm to obtain a set of descriptions X . ., v ) be the unique extending path of v, given by Definition 11. (See Otherwise take X 2 = ∅.(We find the k-secluded trees containing both endpoints of P which have one vertex in P as a neighbor.These can be reconstructed from the (k ] is acyclic, obtain a set of descriptions X 3 by recursively solving (G, k, F ∪ V (P ), T ∪ V (P ), w).Otherwise take X 3 = ∅.(We find the k-secluded trees containing the entire path P .)Let M be the set of minimum weight vertices in P − F − v and define: For each i ∈ [3] let w i be the weight of an arbitrary H ∈ T G (X i ), or 0 if X i = ∅.Return the set X defined as {i∈ [3]|w i =max{w 1 ,w 2 ,w 3 }} X i .

Proof of correctness
In this section we argue that the algorithm described in Section 3.2 solves the ELSS problem.In various steps we identify a vertex v such that the neighborhood of any maximum-weight k-secluded supertree must include v.We argue that for these steps, the descriptions of the current instance can be found by adding {v} to every description of the supertrees of T in G − v if some preconditions are satisfied.

Lemma 13. Let (G, k, F , T , w) be an ELSS instance and let
Then we have: For the sake of contradiction, suppose there is In the other direction, consider some tree J ∈ T G (X ).We show that For the sake of contradiction, suppose that there is The next lemma will be used to argue correctness of Step 3(b) of the algorithm, in which we find k-secluded trees which avoid a single vertex from path P .One should think of P as being an extending path without its last vertex.Lemma 14.Let (G, k, F , T , w) be an ELSS instance and let P be a path in G with deg G (v) = 2 for all v ∈ V (P ) and N G (P ) = {a, b} for some a, b ∈ F .Let X be a set of descriptions for G − V (P ) Then for all p ∈ V (P ) \ F we have: Proof.For any p ∈ V (P ) \ F we define X p = {(r, X ∪{{p}}) | (r, X ) ∈ X}.We show X p is a valid set of descriptions for G.Note that for any set S consisting of exactly one vertex from each set X ∈ X ∪ {{p}} there is an Observe that H − p is acyclic and connected and since p ∈ V (P ) ⊆ V (H ) we have that p ∈ N G (H − p), hence N G (H − p) = S and X p is a valid set of descriptions for G.
G (F ) which has maximum weight (with respect to w) among those satisfying p ∈ N G (H).We show that H ∈ T G (X p ).By Note 7 we have that For the sake of contradiction, suppose there is )), we have that there is a description (r, X ) ∈ X for G − V (P ) that describes H − V (P ).Then (r, X ∪{{p}}) ∈ X p is a description for H in G and we conclude that H ∈ T G (X p ) as required.
Finally we show Suppose for contradiction that there exists such a J for which w( J ) < w( J ). Observe that J − V (P ) and J − V (P ) are both (k − 1)-secluded supertrees of F \ V (P ) in G − V (P ), i.e., they are con- When the algorithm reaches Step 3, it recursively searches for k-secluded supertrees of three different types.The following lemma is used to argue that each relevant tree will be found by exactly one of these recursive calls, so that the combination of their results is non-redundant.
Lemma 15.Let (G, k, F , T , w) be an almost leafless ELSS instance such that G is connected and N G (F ) = ∅.Fix some v ∈ N G (T ) and let P = (v = v 1 , v 2 , . . ., v ) be the extending path of v, given by Definition 11.Then for any maximum-weight k-secluded supertree H of F , exactly one of the following holds: Proof.First note that such a vertex v exists since N G (F ) = ∅ and G is connected, so N G (T ) = ∅.If there is no k-secluded supertree of F , then there is nothing to show.So suppose H is a maximum-weight k-secluded supertree of F .We have v ∈ V (P ) is a neighbor of T ⊆ F ⊆ V (H), so either V (P ) ⊆ V (H) or V (P ) contains a vertex from N(H).In the first case Condition 3 holds, in the second case we have |N(H) ∩ V (P )| ≥ 1.First suppose that |N(H) ∩ V (P )| ≥ 2. Let i ∈ [ ] be the smallest index such that v i ∈ N(H) ∩ V (P ).Similarly let j ∈ [ ] be the largest such index.We show that in this case we can contradict the fact that H is a maximum-weight k-secluded supertree of F .Observe that H = V (H) ∪ {v i , . . ., v j−1 } induces a tree since (v i , . . ., v j−1 ) forms a path of degree-2 vertices (this easily follows from Definition 11) and the neighbor v j of v j−1 is not in H . Furthermore H has a strictly smaller neighborhood than H and it has larger weight as vertices have positive weight.Since F ⊆ V (H ), this contradicts that H is a maximum-weight k-secluded supertree of F .
We conclude that |N(H) ∩ V (P )| = 1.Let i ∈ [ ] be the unique index such that N(H) ∩ V (P ) = {v i }.Clearly v i / ∈ F .In the case that i = , then Condition 1 holds.Otherwise if i < , the first condition of Condition 2 holds.In order to argue that the second condition also holds, suppose that v / ∈ V (H).Then V (H) ∪ {v i , . . ., v −1 } is a k-secluded supertree of F in G and it has larger weight than H as vertices have positive weight.This contradicts the fact that H has maximum weight, hence the second condition of Condition 2 holds as well.
Armed with Lemmas 13 to 15 we are now ready to prove correctness of the algorithm.
Lemma 16.The algorithm for ELSS described in Section 3.2 is correct.
Proof.Let I = (G, k, F , T , w) be an ELSS instance.We prove correctness by induction on |V (G)

Before Step 1
We first prove correctness when the algorithm terminates before Step 1, which includes the base case of the induction.
Note that if G[F ] contains a cycle, then no induced subgraph H of G with F ⊆ V (H) can be acyclic.Therefore the set of maximum-weight k-secluded trees containing F is the empty set, so we correctly return ∅.Otherwise G[F ] is acyclic.
Clearly any connected component of G that has no vertices of F can be removed.If there are two connected components of G containing vertices of F , then no induced subgraph of G containing all of F can be connected, again we correctly return the empty set.In the remainder we have that G is connected.By iteratively applying Lemma 8 we conclude that a solution to the instance obtained after iteratively contracting (most) degree-1 vertices is also a solution to the original instance.Hence we can proceed to solve the new instance, which we know is almost leafless.In addition, observe that the contraction of degree-1 vertices maintains the property that G is connected and G[F ] is acyclic.
After exhaustively adding vertices v ∈ N G (T ) In the case that N G (F ) = ∅, then since G is connected it follows that F = T = V (G) and therefore T is the only maximum-weight ksecluded tree.For any r ∈ V (G), the description (r, ∅) describes this k-secluded tree, so we return {(r, ∅)}.In the remainder we have N G (F ) = ∅.
Since N G (F ) = ∅ and the instance is almost leafless, we argue that there is no 0-secluded supertree of F .Suppose G contains a 0-secluded supertree H of F , so |N G (H)| = 0 and since H ⊇ F is non-empty and G is connected we must have H = G, hence G is a tree with at least two vertices (since F and N G (F ) are both non-empty) so G contains at least two vertices of degree-1, contradicting that the instance is almost leafless.So there is no k-secluded supertree of F in G and the algorithm correctly returns ∅ if k = 0.
Observe that the value |V (G) \ F | cannot have increased since the start of the algorithm since we never add vertices to G and any time we remove a vertex from F it is also removed from G. Hence we can still assume in the remainder of the proof that the algorithm is correct for any input Step 1 Before arguing that the return value in Step 1 is correct, we observe the following.

Claim 18. If H is an induced subtree of G that contains T and v ∈ N G (T ) has at least two neighbors in T , then v ∈ N G (H).
Proof.Suppose v / ∈ N G (H), then since v ∈ N G (T ) and T ⊆ V (H) we have that v ∈ V (H).But then since T is connected, subgraph H contains a cycle.This contradicts that H is a tree and confirms that v ∈ N G (H).

Now consider the case that in
Step 1 we find a vertex v ∈ N G (T ) with two neighbors in T , and let X be the set of descriptions as obtained by the algorithm through recursively solving the instance We argue non-redundancy of the output.Suppose that two descriptions (r, X ∪ {{v}}) and (r , X ∪ {{v}}) describe the same supertree H of F in G.Note that then (r, X ) and (r , X ) describe the same supertree H of F in G − v, which contradicts the induction hypothesis that the output of the recursive call was correct and therefore non-redundant.
Concluding this part of the proof, we showed that if the algorithm terminates during Step 1, then its output is correct.On the other hand, if the algorithm continues after Step 1 we can make use of the following in addition to Property 17.

Property 19. If the algorithm does not terminate before reaching Step 2 then no vertex v ∈ N G (T ) has two neighbors in T .
Step 2 In Step 2 we use Lemma 10 if |N G (T )| > k(k + 1).The preconditions of the lemma are satisfied since k > 0 and the instance is almost leafless by Property 17.If it concludes that G does not contain a k-secluded supertree of F , then the algorithm correctly outputs ∅.Otherwise it finds a vertex v ∈ V (G) \ F such that any k-secluded supertree H of F in G satisfies v ∈ N G (H).We argue that the algorithm's output is correct.Let X be the set of descriptions as obtained through , and therefore v ∈ N G (H).It follows that Lemma 13 applies to X so we can conclude that T G ({(r, X ∪ {{v}}) | (r, X ) ∈ X }) is the set of maximum-weight k-secluded supertrees H of F in G for which v ∈ N G (H).Since we know there are no k-secluded supertrees H of F in G for which v / ∈ N G (H), it follows that T G ({(r, X ∪ {{v}}) | (r, X ) ∈ X}) is the set of maximum-weight k-secluded supertrees of F in G as required.Nonredundancy of the output follows as in Step 1.
To summarize the progress so far, we have shown that if the algorithm terminates before it reaches Step 3, then its output is correct.Alternatively, if we proceed to Step 3 we can make use of the following property, in addition to Properties 17 and 19, which we will use later in the running time analysis.

Step 3
Fix some v ∈ N G (T ), which exists as N G (T ) = ∅ by Property 17.Let P = (v = v 1 , . . ., v ) be the extending path of v given by Definition 11.By Lemma 15 we can partition the set maxset w (S k G (F )) of maximum-weight k-secluded supertrees of F in G into the following three sets: Consider the sets X 1 , X 2 , and X 3 of descriptions as obtained through recursion in Step 3 of the algorithm.By induction we have the following: Let X 1 , X 2 , and X 3 be the sets of descriptions as computed in Step 3 of the algorithm.
Claim 21.The sets X 1 , X 2 , and X 3 consist of valid descriptions for G.
Proof.To argue that X 1 = {(r, X ∪ {{v }}) | (r, X ) ∈ X 1 } consists of valid descriptions for G we show for an arbitrary description (r, X ) ∈ X 1 for G − v that (r, X ∪ {{v }}) is a valid description for G. Clearly r ∈ V (G) and X ∪ {{v }} consists of pairwise disjoint subsets of V (G − r).Consider any set S consisting of exactly one vertex from each set X ∈ X ∪ {{v }}.
Next we argue X 2 consists of valid descriptions for G. Recall that X 2 = {(r, X ∪ {M}) | (r, X ) ∈ X 2 } where M is the set of minimum weight vertices in P − F − v , so it suffices to show for an arbitrary description (r, X ) ∈ X 2 for G − V (P − v ) that (r, X ∪ {M}) ∈ X 2 is a valid description for G. Again it is easy to see that r ∈ V (G) and X ∪ {M} consists of pairwise disjoint subsets of V (G − r).Consider any set S consisting of exactly one vertex from each set X ∈ X ∪ {M}.
r is a supergraph of H and so S ⊆ N G (H ).All that is left to argue is that H is acyclic and m ∈ N G (H ).Let u be the vertex in T that is adjacent to v 1 .Note that this vertex is uniquely defined since no vertex in N G (T ) has two neighbors in T .Since H is a supertree of (F \ V (P )) ∪{v } and u, v ∈ F , it follows that P − v is a path between two vertices in H , of which S contains exactly one vertex chosen from M. Consequently, the component Finally since X 3 is a set of descriptions for G and X 3 = X 3 , the claim holds for X 3 .
Before we proceed to show that the output of the algorithm is correct, we prove two claims about intermediate results obtained by modifying the output of a recursive call.
Proof.We show Lemma 14 applies to the instance (G, k, F ∪ {v }, T , w).Recall that by induction We now show that all maximum-weight k-secluded supertrees of F in G are described by some description in our output.More formally, we show that maxset 3] in Claims 24 to 26.Claim 22).Since H ∈ T 1 was arbitrary we conclude T 1 ⊆ T G (X 1 ) completing the proof.
It suffices to show that when considering a set S consisting of one element from each set of a description (r, X As the two neighbors of V (P − v ) both belong to F ∪ {v }, the subpath of P before u and subpath after u are both reachable from r in G − S. Hence Proof.Recall X 3 is defined to be equal to X 3 , so we show in G − v , and clearly H is described by both (r 1 , X 1 \ {{v }}) and (r 2 , X 2 \ {{v }}), contradicting that X 1 is nonredundant for G − v. • If (r 1 , X 1 ) ∈ X 2 , then without loss of generality we can assume that (r 2 , X 2 ) / ∈ X 1 since otherwise we can swap the roles of (r 1 , X 1 ) and (r 2 , X 2 ) and the previous case would apply.Recall that X 2 = {(r, X ∪ {M}) | (r, X ) ∈ X 2 } where M ⊆ V (P − F − v ), so (r 1 , X 1 \ {M}) ∈ X 2 and (r 2 , X 2 \ {M}) ∈ X 2 .By construction we have that V (P ) ⊇ M ∩ N G (H) = ∅.Suppose that (r 2 , X 2 ) ∈ X 3 = X 3 , then H ∈ T G (X 3 ) and we have by induction that T G (X 3 ) = maxset w (S k G (F ∪ V (P ))) hence v ∈ F ∪ V (P ) ⊆ V (H).This contradicts that M ∩ N G (H) = ∅.This leaves as only option that (r 2 , X 2 ) ∈ X 2 .Since X 2 is a set of valid descriptions for G − V (P − v ) (by induction) we have that X 1 \ {M} and X 2 \ {M} contain only subsets of V (G) Observe that since the path P − v is connected to H := H − V (P − v ) only via its endpoints, and H does not contain m ∈ V (P ) we have that H remains connected so H is a (k − 1)-secluded tree in G − V (P − v ) described by (r 1 , X 1 \ {M}) as well as (r 2 , X 2 \ {M}).However this contradicts that X 2 is a non-redundant set of descriptions for G − V (P − v ) as given by induction.
• If (r 1 , X 1 ) ∈ X 3 = X 3 , then without loss of generality we can assume (r 2 , X 2 ) ∈ X 3 = X 3 since otherwise we can swap the roles of (r 1 , X 1 ) and (r 2 , X 2 ) and one of the previous cases would apply.But then H is a k-secluded tree in G described by two distinct descriptions from X 3 , i.e.X 3 is redundant for G contradicting the induction hypothesis.
This concludes the proof of Lemma 16 and establishes correctness.

Runtime analysis
If all recursive calls in the algorithm would decrease k then, since for k = 0 it does not make any further recursive calls, the maximum recursion depth is k.However in Step 3(c) the recursive call does not decrease k.In order to bound the recursion depth, we show the algorithm cannot make more than k(k + 1) consecutive recursive calls in Step 3(c), that is, the recursion depth cannot increase by more than k(k + 1) since the last time k decreased.We do this by showing in The following lemma states that under certain conditions, the neighborhood of T does not decrease during the execution of a single recursive call.
Lemma 28.Let (G 0 , k 0 , F 0 , T 0 , w 0 ) be an ELSS instance such that all leaves of G 0 are contained in T 0 .If the algorithm does not terminate before Step 3,then  Proof.Since the algorithm does not terminate before Step 3 it follows that Steps 1 and 2 are not executed, so consider the part of the algorithm before Step 1.Throughout the proof we use (G, k, F , T , w) to refer to the instance at the time the algorithm evaluates it; initially (G, k, F , T , w) = (G 0 , k 0 , F 0 , T 0 , w 0 ), but actions such as contracting leaves may change the instance during the execution.Suppose that all leaves of G are contained in T .We infer that G[F ] is acyclic, as otherwise the algorithm would return ∅ before reaching Step 3. Removing the connected components of G that do not contain a vertex of F does not alter |N G (T )|.Afterwards we know that G is connected, as otherwise the algorithm would return ∅.Consider a single degree-1 contraction step of a vertex v with F = {v} that results in the instance (G − v, k, F * , T * , w * ).Since we assume that all leaves are contained in T , we have that v ∈ T .Let u be the neighbor of v.By Rule 1 we have Next consider the step where if Again these arguments can be applied iteratively.For the instance (G, k, F , T , w) to which this step can no longer be applied, Next we get that N G (F ) = ∅ as otherwise the algorithm would return {(r, ∅)} for some r ∈ F .We also get k > 0, as otherwise ∅ would have been returned.
Since none of the steps decreased the size of the neighborhood of T , for the instance (G , k , F , T , w ) at the time Step 3 is executed we conclude |N G (T )| ≥ |N G 0 (T 0 )| as required.
In the next lemma we show that as we make the recursive call in Step 3(c), either the size of the neighborhood of T strictly increases, or a vertex u appears in the neighborhood of the augmented tree T ∪ V (P ) having least two neighbors in T ∪ V (P ).Such a vertex u will trigger Step 3(a), which leads to a decrease in k.Definition 11 and Observation 12).The precondition of Step 3(c) gives that G[F ∪ V (P )] is acyclic.Since T ⊆ F , this implies that G[T ∪ V (P )] is acyclic.Due to Observation 12, it follows that V (P )

Lemma 29. If the instance when executing Step 3 is (G, k, F , T , w) and Step 3(c) branches on the instance
Then the second condition holds; u has at least one neighbor in T as u ∈ N G (T ) \ {v} and u is adjacent to v / ∈ T \ {v}.
) is adjacent to at least two vertices in T ∪ V (P ).Since we know that the recursive call on (G , k , F ∪ V (P ), T ∪ V (P ), w ) reaches Step 3 with the instance (G, k, F , T , w), we can rule out that some vertex u ∈ N G (T ∪ V (P )) is adjacent to at least two vertices in T ∪ V (P ) as this would mean the recursive call ends in Step 1.We can conclude instead that |N G (T ∪ Note that since (G , k , F , T , w ) is the instance in Step 3 we have that Properties 17, 19 and 20 apply.In particular, (G , k , F , T , w ) is almost leafless, implying that all leaves in G are contained in T .It follows that all leaves in G are also contained in T ∪ V (P ), so Lemma 28 applies to the input instance (G , k , F ∪ V (P ), T ∪ V (P ), w ) (as recursively solved in Step 3) and the instance (G, k, F , T , w) (as considered in Step 3 of that recursive call).So we ob- Since we know in Step 3 that |N G (T )| ≤ k(k + 1) (by Property 20) we can now claim that there are at most k(k + 1) consecutive recursive calls of Step 3(c), leading to a bound on the recursion depth of O(k 3 ).We argue that each recursive call takes O(kn 3 ) time and since we branch at most three ways, we obtain a running time of 3 However, with a more careful analysis we can give a better bound on the number of nodes in the recursion tree.
Lemma 31.The algorithm described in Section 3.2 can be implemented to run in time 2 O(k log k) • n 3 .
Proof.Consider the recursion tree of the algorithm.We first prove that each recursive call takes O(kn 3 ) time (not including the time further recursive calls require).We then show that the recursion tree contains at most 2 O(k log k) nodes.from T G (X i ) for any i ∈ [3] involves selecting and arbitrary description (r, X ) ∈ X i and then selecting, for each X ∈ X and arbitrary vertex v ∈ X .Now the tree can be found using DFS starting from r exploring an acyclic graph until it reaches the selected vertices from a set X ∈ X .This all takes O(n) time.The weights of the selected secluded trees can be found in O(n) time as well.Finally we take the union of (a selection of) the three sets of descriptions.Since these sets are guaranteed to be disjoint, this can be done in constant time when representing each set as a linked list and updating the pointers between them.

Number of nodes
We now calculate the number of nodes in the recursion tree.To do this, label each edge in the recursion tree with a label from the set {1, 2, 3a, 3b, 3c} indicating where in the algorithm the recursive call took place.Now observe that each node in the recursion tree can be uniquely identified by a sequence of edge-labels corresponding to the path from the root of the tree to the relevant node.We call such a sequence of labels a trace.
Note that for all recursive calls made in 1, 2, 3a, and 3b the parameter (k) decreases, and for the call made in 3c the parameter remains the same.If k ≤ 0 we do not make further recursive calls, so the trace contains at most k occurrences of 1, 2, 3a, and 3b.Next, we argue there are at most k(k + 1) consecutive occurrences of 3c in the trace.Suppose for the sake of contradiction that the trace contains k(k + 1) + 1 consecutive occurrences of 3c.Let (G, k, F , T , w) be the instance considered in Step 3 where the last of these recursive calls is made.By Lemma 30 we have |N G (T )| > k(k + 1).This contradicts Property 20, so we can conclude the trace contains at most k(k + 1) consecutive occurrences of 3c.Hence any valid trace has a total length of at most k • k(k + 1) = O(k 3 ), since no further recursive calls are done once k reaches 0.
In order to count the number of nodes in the recursion tree, it suffices to count the number of different valid traces.
Since a trace contains at most k occurrences that are not 3c we have that the total number of traces of length is k We derive the following bound on the total number of valid traces of length ≥ 1: Using the fact that (k c ) k = (2 log(k c ) ) k = 2 O(k log k) , we can conclude that the total number of nodes in the recursion tree is at most 2 O(k log k) so the overall running time is 2

Counting, enumerating, and finding large secluded trees
With the algorithm of Section 3.2 at hand we argue that we are able to enumerate k-secluded trees, count such trees containing a specified vertex, and solve LST.
Theorem 32.There is an algorithm that, given a graph G, weight function w, and integer k, runs in time 2 O(k log k) • n 4 and outputs a set of descriptions X such that T G (X) is exactly the set of maximum-weight k-secluded trees in G.Each such tree H is described by |V (H)| distinct descriptions in X.
Proof.Given the input (G, k, w), we proceed as follows.For each v ∈ V (G), let X v be the output of the ELSS instance (G, k, F = {v}, T = {v}, w) and let w v be the weight of an arbitrary k-secluded supertree in T G (X v ), or 0 if X v = ∅.Note that all k-secluded trees described by X v have weight exactly w v .Let w * := max v∈V (G) w v .If w * = 0 then there are no k-secluded trees in G and we output X = ∅; otherwise we output X : Clearly T G (X) is the set of all k-secluded trees in G of maximum weight.Since each X v is non-redundant, each maximum-weight k-secluded tree H is described by exactly |V (H)| descriptions in X.
By returning an arbitrary maximum-weight k-secluded tree described by any description in the output of Theorem 32, we have the following consequence.The following theorem captures the consequences for counting.
Theorem 34.There is an algorithm that, given a graph G, vertex v ∈ V (G), weight function w, and integer k, runs in time 2 O(k log k) •n 3   and counts the number of k-secluded trees in G that contain v and have maximum weight out of all k-secluded trees containing v.
Proof.Construct the ELSS instance (G, k, F = {v}, T = {v}, w) and let X be the output obtained by the algorithm described in Section 3.2.Note that this takes 2 O(k log k) n 3 time by Lemma 31.Since the definition of ELSS guarantees that X is nonredundant, each maximum-weight tree containing v is described by exactly one description in X.To solve the counting problem it therefore suffices to count how many distinct k-secluded trees are described by each description in X.

Fig. 2 .
Fig. 2. Setting of Lemma 10 with k = 2. Since the instance is almost leafless, |N G (T )| ≥ 7, and there is a k-secluded supertree H of the encircled set T , there must exist a vertex v which is the endpoint of k + 2 = 4 paths from N G (T ) intersecting only at v. Such a vertex, along with 4 paths, is drawn in the right image.This vertex must belong to the neighborhood of any k-secluded supertree of T .

Fig. 3 .
Fig. 3. Branching done in Step 3 for the extending path P shown at the top.The encircled vertex set represents T = F .In the bottom row, the dashed lines show 2-secluded supertrees of F that are found in the various branches.Left shows the instance solved recursively in Step 3a.The transparent vertex is the removed part.Similarly, middle and right show Steps 3b and 3c respectively.

Property 20 .
If the algorithm does not terminate before reaching Step 3 then |N G (T )| ≤ k(k + 1).
the following three lemmas that |N G (T )| increases as consecutive recursive calls in Step 3(c) are made.Since the algorithm executes Step 2 if |N G (T )| > k(k + 1), this limits the number of consecutive recursive calls in Step 3(c).
and therefore their size is equal.If u / ∈ T , then observe that u cannot be a leaf in G by assumption and thereforeN G (u) \ {v} = ∅.Since T is connected and v is a leaf in T we get (N G (u) \ {v}) ∩ T = ∅.It follows that |N G−v (T * )| ≥ |N G (T )|.These arguments can be applied for each consecutive contraction step to infer |N G (T )| ≥ |N G 0 (T 0 )| for the instance (G, k, F , T , w) after all contractions.
Consider the input instance (G, k, F , T , w) with n = |V (G)| and m = |E(G)|.We can verify that G[F ] is acyclic in O(|F |) time using DFS.Again using DFS, in O(n +m) time identify all connected components of G and determine whether they contain a vertex of F .We can then in linear time remove all connected components that contain no vertex of F and return ∅ if more than one component remains.Finally exhaustively contracting degree-1 vertices into their neighbor is known to take O(n) time.Updating F and T only results in O(1) overhead for each contraction.Exhaustively adding vertices v ∈ N G (T ) ∩ F to T can be done in O(n) time since it corresponds to finding a connected component in G[F ] which is acyclic.For Step 1 we can find a vertex v ∈ N G (T ) with two neighbors in T in O(n 2 ) time by iterating over all neighbors of each vertex in T .Determining the size of the neighborhood in Step 2 can be done in O(n 2 ) time.Applying Lemma 10 takes O(kn 3 ) time.So excluding the recursive call, Step 2 can be completed in O(kn 3 ) time.For Step 3 an arbitrary v ∈ N G (T ) can be selected in O(1) time, and the path P can be found in O(|P |) = O(n) time as described in Definition 11.Finally the results of the three recursive calls in Step 3 are combined.Selecting an arbitrary tree

Corollary 33 .
There is an algorithm that, given a graph G, weight function w, and integer k, runs in time 2 O(k log k) • n 4 and outputs a maximum-weight k-secluded tree in G if one exists.
Since any H ∈ maxset w (S k G (F )) contains u if and only if it contains v, they also show that an induced subgraph H of G containing either both {u, v} or none belongs to maxset w (S k G (F )) if and only if H Finally we combine Lemmas 28 and 29 to show |N G (T )| is an upper bound to the number of consecutive recursive calls in Step 3(c).If the recursion tree generated by the algorithm contains a path of i ≥ 1 consecutive recursive calls in Step 3(c), and (G, k, F , T , w) is the instance considered in Step 3 where the i-th of these recursive calls is made, then |N G (T )| ≥ i.Proof.We use induction of i.First suppose i = 1 and let (G, k, F , T , w) be the instance considered in Step 3 where the first of these recursive calls is made.If |N G (T )| = 0, then G[T ] is a connected component of G.However, since (G, k, F , T , w) is an instance considered inStep 3we know that Properties 17, 19 and 20 apply.In particular N G (F ) = ∅, ruling out that T = F .However if T = F , then there are at least two connected components in G containing a vertex from F , contradicting that G is connected (Property 17).By contradiction we can conclude that |N G (T )| ≥ 1 = i.Suppose i ≥ 2 and let (G, k, F , T , w) be the instance considered in Step 3 where the i-th recursive call is made.Let (G , k , F , T , w ) be the instance considered in Step 3 where the (i − 1)-th recursive call is made.By induction we know |N G (T )| ≥ i − 1.Let P be the extending path as in Step 3 where the (i − 1)-th recursive call is made, then by Lemma 29 we have that |N G