Algorithmica (2018) 80:2909–2940 https://doi.org/10.1007/s00453-017-0358-5 1 1 Bernhard Bliem · Stefan Woltran Received: 2 January 2017 / Accepted: 6 August 2017 / Published online: 14 August 2017 © The Author(s) 2017. This article is an open access publication Abstract A secure set S in a graph is deﬁned as a set of vertices such that for any X ⊆ S the majority of vertices in the neighborhood of X belongs to S.Itisknown that deciding whether a set S is secure in a graph is co-NP-complete. However, it is still open how this result contributes to the actual complexity of deciding whether for a given graph G and integer k, a non-empty secure set for G of size at most k exists. In this work, we pinpoint the complexity of this problem by showing that it is -complete. Furthermore, the problem has so far not been subject to a parameterized complexity analysis that considers structural parameters. In the present work, we prove that the problem is W[1]-hard when parameterized by treewidth. This is surprising since the problem is known to be FPT when parameterized by solution size and “subset problems” that satisfy this property usually tend to be FPT for bounded treewidth as well. Finally, we give an upper bound by showing membership in XP, and we provide a positive result in the form of an FPT algorithm for checking whether a given set is secure on graphs of bounded treewidth. Keywords Secure set · Complexity analysis · Parameterized complexity · Treewidth · Parameterized algorithms 1 Introduction The objective of many problems that can be modeled as graphs is ﬁnding a group of vertices that together satisfy some property. In this respect, one of the concepts B Bernhard Bliem bliem@dbai.tuwien.ac.at Institute of Information Systems 184/2, TU Wien, Favoritenstrasse 9-11, 1040 Vienna, Austria 123 2910 Algorithmica (2018) 80:2909–2940 that has been quite extensively studied [31] is the notion of a defensive alliance [20], which is a set of vertices such that for each element v at least half of its neighbors are also in the alliance. The name “defensive alliance” stems from the intuition that the neighbors of such an element v that are also in the alliance can help out in case v is attacked by its other neighbors. Notions like this can be applied to ﬁnding groups of nations, companies or individuals that depend on each other, but also to more abstract situations like ﬁnding groups of websites that form communities [18]. In this work, we are looking at a natural generalization of defensive alliances called secure sets, which have been introduced by Brigham et al. [11]. While defensive alliances make sure that each element of an alliance can defend itself against attacks from its neighbors, they do not account for attacks on multiple vertices at the same time. To this end, we can employ a stronger concept: A secure set of a graph G is a subset S of the vertices of G such that for each X ⊆ S, the number of vertices in N [X]∩ S is not less than the number of vertices in N [X ]\S.Here N [X ] denotes the closed neighborhood of X in G, i.e., X together with all vertices adjacent to X.The Secure Set problem can now be stated as follows: Given a graph G and an integer k, does there exists a secure set S of G such that 1 ≤|S|≤ k? It is known that deciding whether a given set S is secure in a graph is co-NP- complete [21], so it would not be surprising if ﬁnding (non-trivial) secure sets is also a very hard problem. Unfortunately, the exact complexity of this problem has so far remained unresolved. This is an unsatisfactory state of affairs because it leaves the possibility open that existing approaches for solving the problem (e.g., [1]) are sub- optimal in that they employ unnecessarily powerful programming techniques. Hence we require a precise complexity-theoretic classiﬁcation of the problem. Due to its high complexity, it makes sense to look at the parameterized complex- ity [13,16,19,26] of the problem and to study if Secure Set becomes tractable under the assumption that certain parameters of the problem instances are small. For some parameters, this may be a reasonable assumption in practice. For instance, it has been shown that Secure Set can be solved in linear time if the solution size is bounded by a constant [17]. If we are only interested in small secure sets, the resulting algorithm is therefore a good choice. However, we often cannot make the assumption that the solutions are small. In such cases, it is a common strategy to consider structural parameters instead, which measure in a certain way how complex the graph underlying a problem instance is. One of the most studied structural parameters is treewidth [5,7,27], which indicates how close a graph is to being a tree. Treewidth is an attractive parameter because many hard problems become tractable on instances of bounded treewidth, and in several practical applications it has been observed that the considered problem instances exhibit small treewidth [5,24,30]. In [22] it has been shown that a certain variant of Secure Set becomes easy on trees, but the complexity of Secure Set parameterized by treewidth is listed as an open problem in that work and has so far remained unresolved. The ﬁrst main contribution of our paper is to show that Secure Set is -complete. Unlike the existing co-NP-hardness proof [21], which uses a (quite involved) reduction from Dominating Set, we base our proof on a reduction from a problem in the area of logic. To be speciﬁc, we ﬁrst show that the canonical -complete problem Qsat can be reduced to a variant of Secure Set, where vertices can be forced to be in 123 Algorithmica (2018) 80:2909–2940 2911 or out of every solution, and pairs of vertices can be speciﬁed to indicate that every solution must contain exactly one element of each such pair. In order to prove the desired complexity result, we then successively reduce this variant to the standard Secure Set problem. At the same time, we show -completeness for the exact variants of these problems, where we are interested in secure sets exactly of a certain size. Membership in the class is rather obvious; in fact, [1] presents a polynomial- time reduction to Answer Set Programming [10] and thus shows this result implicitly. Together with our corresponding hardness result, it follows that Secure Set is - complete, and it turns out that all the problem variants we consider in this paper are -complete. We thus complete the picture of the precise complexity of the Secure Set problem, and we also provide completeness results for variants of the problem that have already been proposed [22] but for which no complexity analysis has been performed so far. Our results underline that Secure Set is among the few rather natural problems in graph theory that are complete for the second layer of the polynomial hierarchy (like, e.g., Clique Coloring [25]or 2- Coloring Extension [28]). Moreover, -hardness of Secure Set indicates that an efﬁcient reduction to the Sat problem is not possible (unless the polynomial hierarchy collapses). The second main contribution of our paper is a parameterized complexity analysis of Secure Set with treewidth as the parameter. We show that this problem is hard for the class W[1], which rules out a ﬁxed-parameter tractable algorithm under commonly held complexity-theoretic assumptions. This result is rather surprising for two reasons: First, the problem is tractable on trees [22] and often problems that become easy on trees turn out to be ﬁxed-parameter tractable when parameterized by treewidth. Second, this makes Secure Set one of the very few “subset problems” that are ﬁxed- parameter tractable w.r.t. solution size but not w.r.t. treewidth. Problems with this kind of behavior are rather rare, as observed by Dom et al. [15]. Beside this parameterized hardness result, we also give an upper bound by showing that Secure Set is in the class XP, which means that it can be solved in polynomial time on instances of bounded treewidth. We do so by providing an algorithm where the degree of the polynomial depends on the treewidth. Finally, we present a positive result for the co-NP-complete problem of checking whether a given set of vertices is secure in a graph: We provide an algorithm that solves the problem in linear time for graphs of bounded treewidth. This paper is organized as follows: We ﬁrst provide the necessary background in Sect. 2. Then we analyze the complexity of Secure Set in Sect. 3, where we show that this problem, along with several variants, is -complete. In Sect. 4, we consider the parameterized complexity of Secure Set where treewidth is our parameter of interest. Section 5 concludes the paper with a discussion. The present work extends a conference paper [4], which did not contain any results about the parameterized complexity of the considered problems. Beside the new results in Sect. 4, we also slightly modiﬁed some of the reductions that prove -hardness so To be precise, [22] shows that a slight variant of Secure Set is tractable on trees, since Secure Set on trees is trivial. Our results, however, also imply W[1]-hardness for this particular variant. 123 2912 Algorithmica (2018) 80:2909–2940 Fig. 1 A graph with a minimum non-empty secure set indicated by circled vertices c e that they preserve bounded treewidth, which allows us to reuse them for our parameter- ized hardness proofs. We also added a reduction (which eliminates necessary vertices), which made one of the reductions (from the exact variant of the problem to the non- exact variant) from the previous paper redundant. 2 Background All graphs are undirected and simple unless stated otherwise. We denote the set of vertices and edges of a graph G by V (G) and E (G), respectively. We denote an undirected edge between vertices u and v as (u,v) or equivalently (v, u). It will be clear from the context whether an edge (u,v) is directed or undirected. Given a graph G,the open neighborhood of a vertex v ∈ V (G), denoted by N (v),isthe setofall vertices adjacent to v, and N [v]= N (v) ∪{v} is called the closed neighborhood G G of v.Let S ⊆ V (G). We abuse notation by writing N (S) and N [S] to denote G G N (v) and N [v], respectively. If it is clear from the context which graph G G v∈S v∈S is meant, we write N (·) and N [·] instead of N (·) and N [·], respectively. G G Deﬁnition 1 Given a graph G,aset S ⊆ V (G) is secure in G if for each X ⊆ S it holds that |N [X]∩ S|≥|N [X ]\S|. We often write “S is secure” instead of “S is secure in G” if it is clear from the context which graph is meant. By deﬁnition, the empty set is secure in any graph. Thus, in the following decision problems we ask for secure sets of size at least 1. The following is our main problem: Secure Set Input: A graph G and an integer k with 1 ≤ k ≤|V (G)| Question: Does there exist a set S ⊆ V (G) with 1 ≤|S|≤ k that is secure? Figure 1 shows a graph together with a minimum non-empty secure set S ={a, b, c}. Observe that for any X ⊆ S the condition |N [X]∩ S|≥|N [X ]\S| is satisﬁed. Note that the well-known Defensive Alliance problem is a special case of Secure Set where only those subsets X of S are considered that have size 1. For exam- ple, in Fig. 1,the set S ={a, b} is a defensive alliance as |N [v]∩ S |≥|N [v]\S | holds for each v ∈ S ,but S is not a secure set, since for X = S it holds that |N [X ]∩ S | < |N [X ]\S |. We now deﬁne three variants of the Secure Set problem that we require in our proofs. Secure Set generalizes the Secure Set problem by designating some “for- bidden” vertices that may never be in any solution. This variant can be formalized as follows: 123 Algorithmica (2018) 80:2909–2940 2913 Secure Set Input: A graph G, an integer k and a set V ⊆ V (G) Question: Does there exist a set S ⊆ V (G)\V with 1 ≤|S|≤ k that is secure? FN Secure Set is a further generalization that, in addition, allows “necessary” vertices to be speciﬁed that must occur in every solution. FN Secure Set Input: A graph G, an integer k,aset V ⊆ V (G) and a set V ⊆ V (G) Question: Does there exist a set S ⊆ V (G)\V with V ⊆ S and 1 ≤|S|≤ k that is secure? FNC Finally, we introduce the generalization Secure Set . Here we may state pairs of “complementary” vertices where each solution must contain exactly one element of every such pair. FNC Secure Set Input: A graph G, an integer k,aset V ⊆ V (G),aset V ⊆ V (G) and a set C ⊆ V (G) Question: Does there exist a set S ⊆ V (G)\V with V ⊆ S and 1 ≤|S|≤ k that is secure and, for each pair (a, b) ∈ C, contains either a or b but not both? For our results on structural parameters, we need a way to represent the structure of a FNC Secure Set instance by a graph that augments G with the information in C: FNC Deﬁnition 2 Let I be a Secure Set instance, let G be the graph in I and let C the set of complementary vertex pairs in I.Bythe primal graph of I we mean the graph G with V (G ) = V (G) and E (G ) = E (G) ∪ C. While the Secure Set problem asks for secure sets of size at most k,wealso consider the Exact Secure Set problem that concerns secure sets of size exactly k. Note that a secure set may become insecure by adding or removing elements, so this is a non-trivial problem variant. Analogously, we also deﬁne exact versions of the three generalizations of Secure Set presented above. When the task is not to ﬁnd secure sets but to verify whether a given set is secure, the following problem is of interest: Secure Set Verification Input: A graph G and a set S ⊆ V (G) Question: Is S secure? This problem is known to be co-NP-complete [21]. In this paper’s ﬁgures, we often indicate necessary vertices by means of a triangular node shape, and forbidden vertices by means of either a square node shape or a superscript square in the node name. If two vertices are complementary, we often 123 2914 Algorithmica (2018) 80:2909–2940 Fig. 2 Illustration of forbidden, a = c necessary and complementary vertices express this in the ﬁgures by putting a = sign between them. For example, in Fig. 2, the vertices b and c are complementary and occur in no solution together; also the vertices b and e are complementary. Note, however, that by putting a = sign between two vertices we do not mean to express that there is an edge between them. For instance, there is no edge between b and c, but there is an edge between b and e, which is explicitly drawn. The vertex a and the “anonymous” vertex adjacent to c are necessary and occur in every solution; d and the “anonymous” vertex adjacent to e are forbidden and occur in no solution. In this ﬁgure, the unique minimum non- empty secure set satisfying the conditions of forbidden, necessary and complementary vertices consists of a, b and the “anonymous” necessary vertex adjacent to c. The following terminology will be helpful: We often use the terms attackers and defenders of a subset X of a secure set candidate S. By these we mean the sets N [X ]\S and N [X]∩ S, respectively. To show that a subset X of a secure set candidate S is not a witness to S being insecure, we sometimes employ the notion of a defense of X w.r.t. S, which assigns to each attacker a dedicated defender: If we are able to ﬁnd an injective mapping μ : N [X ]\S → N [X]∩ S, then obviously |N [X ]\S|≤|N [X]∩ S|, and we call μ a defense of X w.r.t. S. Given such a defense μ, we say that a defender d repels an attack on X by an attacker a whenever μ(a) = d. Consequentially, when we say that a set of defenders D can repel attacks on X from a set of attackers A, we mean that there is a defense that assigns to each element of A a dedicated defender in D. To warm up, we make some easy observations that we will use in our proofs. First, for every set R consisting of a majority of neighbors of a vertex v, whenever v is in a secure set, also some element of R must be in it: Observation 1 Let S be a secure set in a graph, let v ∈ S and let R ⊆ N (v).If |R| > N [v], then S contains an element of R. Proof Suppose that |R| > |N [v]| and S contains no element of R. Since all elements of R attack v, |N [v]\S| > |N [v]|. Hence 2|N [v]\S| > |N [v]| = |N [v]∩ S|+ |N [v]\S|, and we obtain the contradiction |N [v]\S| > |N [v]∩ S|. Next, if one half of the neighbors of an element v of a secure set attacks v, then the other half of the neighbors must be in the secure set: Observation 2 Let S be a secure set in a graph, let v ∈ S and let N (v) be partitioned into two equal-sized sets A, D. If A ∩ S =∅, then D ⊆ S. Proof Since N (v) is partitioned into A and D such that A ∩ S =∅, we get N (v) ∩ S = D ∩ S. If some element of D is not in S, then D ∩ S ⊂ D and A ⊂ N [v]\S.By |D|=|A|, we get |D ∩ S|+ 2 ≤|N [v]\S|.From |N [v]∩ S|= 1 +|N (v) ∩ S|= 1 +|D ∩ S| we now obtain the contradiction |N [v]∩ S| < |N [v]\S|. 123 Algorithmica (2018) 80:2909–2940 2915 In particular, if half of the neighbors of v are forbidden, then v can only be in a given secure set if all non-forbidden neighbors are also in the secure set. Finally, we recapitulate some background from complexity theory. The class is the class of problems that are solvable in polynomial time by a nondeterministic Turing machine that has access to an NP oracle. The canonical problem complete for this class is Qsat , which asks, given a formula ∃x ... ∃x ∀y ... ∀y ψ, where 2 1 n 1 n x y ψ is a propositional 3-DNF formula, whether there is a truth assignment to the x variables such that for all truth assignments to the y variables ψ evaluates to true. In parameterized complexity theory [13,16,19,26], we study problems that consist not only of an input and a question, but also of some parameter of the input that is represented as an integer. A problem is in the class FPT (“ﬁxed-parameter tractable”) if it can be solved in time f (k) · n , where n is the input size, k is the parameter, f is a computable function that only depends on k, and c is a constant that does not depend on k or n. We call such an algorithm an FPT algorithm, and we call it ﬁxed-parameter linear if c = 1. Similarly, a problem is in the class XP (“slice-wise g(k) polynomial”) if it can be solved in time f (k) · n , where f and g are computable functions. Note that here the degree of the polynomial may depend on k, so such algorithms are generally slower than FPT algorithms. For the class W[1] it holds that FPT ⊆ W[1]⊆ XP, and it is commonly believed that the inclusions are proper, i.e., W[1]-hard problems do not admit FPT algorithms. W[1]-hardness of a problem can be shown using parameterized reductions, which are reductions that run in FPT time and produce an equivalent instance whose parameter is bounded by a function of the original parameter. For problems whose input can be represented as a graph, one important parameter is treewidth, which is a structural parameter that, roughly speaking, measures the “tree-likeness” of a graph. It is deﬁned by means of tree decompositions, originally introduced in [27]. The intuition behind tree decompositions is to obtain a tree from a (potentially cyclic) graph by subsuming multiple vertices under one node and thereby isolating the parts responsible for cyclicity. Deﬁnition 3 A tree decomposition of a graph G is a pair T = (T,χ) where T is a V (G) (rooted) tree and χ : V (T ) → 2 assigns to each node of T a set of vertices of G (called the node’s bag), such that the following conditions are met: 1. For every vertex v ∈ V (G), there is a node t ∈ V (T ) such that v ∈ χ(t ). 2. For every edge (u,v) ∈ E (G), there is a node t ∈ V (T ) such that {u,v}⊆ χ(t ). 3. For every v ∈ V (G), the subtree of T induced by {t ∈ V (T ) | v ∈ χ(t )} is connected. We call max |χ(t )|−1the width of T .The treewidth of a graph is the minimum t ∈V (T ) width over all its tree decompositions. In general, constructing an optimal tree decomposition (i.e., a tree decomposition with minimum width) is intractable [2]. However, the problem is solvable in linear O(w ) time on graphs of bounded treewidth (speciﬁcally in time w · n, where w is the treewidth) [6] and there are also heuristics that offer good performance in practice [8, 14]. In this paper we will consider so-called nice tree decompositions: 123 2916 Algorithmica (2018) 80:2909–2940 Fig. 3 Agraph G and a nice tree decomposition T of G rooted at the leftmost node Deﬁnition 4 A tree decomposition T = (T,χ) is nice if each node t ∈ V (T ) is of one of the following types: 1. Leaf node: The node t has no child nodes. 2. Introduce node: The node t has exactly one child node t such that χ(t )\χ(t ) consists of exactly one element. 3. Forget node: The node t has exactly one child node t such that χ(t )\χ(t ) consists of exactly one element. 4. Join node: The node t has exactly two child nodes t and t with χ(t ) = χ(t ) = 1 2 1 χ(t ). Additionally, the bags of the root and the leaves of T are empty. A tree decomposition of width w for a graph with n vertices can be transformed into a nice one of width w with O(wn) nodes in ﬁxed-parameter linear time [23]. For any tree decomposition T and an element v of some bag in T ,weuse the T T notation t to denote the unique “topmost node” whose bag contains v (i.e., t does v v not have a parent whose bag contains v). Figure 3 depicts a graph and a nice tree decomposition, where we also illustrate the t notation. When we speak of the treewidth of an instance of Secure Set, Secure Set , FN F FN Secure Set , Exact Secure Set, Exact Secure Set or Exact Secure Set , FNC we mean the treewidth of the graph in the instance. For an instance of Secure Set FNC or Exact Secure Set , we mean the treewidth of the primal graph. 3 Complexity of the Secure Set Problem This section is devoted to proving the following theorem: Theorem 1 The following problems are all -complete: Secure Set, Exact F F FN Secure Set, Secure Set , Exact Secure Set , Secure Set , Exact Secure FN FNC FNC Set , Secure Set and Exact Secure Set . We prove this by providing a chain of polynomial reductions from Qsat to the problems under consideration. 3.1 Hardness of Secure Set with Forbidden, Necessary and Complementary Vertices FNC FNC Lemma 1 Secure Set and Exact Secure Set are -hard. 123 Algorithmica (2018) 80:2909–2940 2917 1 (n ) = = t 1 t 1 1 x = = = (n +1) 2 y = = t t 2 2 2 x = = (n − 1) 2 t 2 t = = t t 3 3 x = = t y 3 t 2 d d 1 2 Fig. 4 Graph corresponding to the Qsat formula ∃x ∃x ∃x ∀y ∀y (¬x ∧ x ∧ y ) ∨ (x ∧¬y ∧ 2 1 2 3 1 2 1 2 1 3 1 y ) ∨ (x ∧¬y ∧¬y ) . To avoid clutter, we omit labels for the vertices from Y , Y , Y , T , T and 2 3 1 2 T , and we draw some edges in a dashed style FNC Proof We reduce from Qsat to Secure Set . This also proves -hardness for the exact variant because our reduction makes sure that all solutions of the FNC Secure Set instance have the same size. We are given a quantiﬁed Boolean for- mula ϕ =∃x ... ∃x ∀y ... ∀y ψ, where ψ is in 3-DNF and contains n terms. We 1 n 1 n t x y assume that no term contains both a variable and its complement (since such a term can never be satisﬁed) and that each term contains at least one universally quantiﬁed variable (since ϕ is trivially true otherwise). FNC We construct an instance (G, k, V , V , C ) of Secure Set in the following. For an illustration, see Fig. 4. We deﬁne a graph G by choosing the union of the following sets as V (G): X ={x ,..., x } X ={x ,..., x } 1 n 1 n x x Y ={y ,..., y } Y ={y ,..., y } 1 n 1 n y y Y = y , y | 1 ≤ i ≤ n , 1 ≤ j ≤ n Y = y | 1 ≤ j ≤ n − 1 i, j y t t i, j j Y = y | 1 ≤ i ≤ n , 1 ≤ j ≤ n + 1 H = d , d , t y t i, j 1 2 T ={t ,..., t } T = t ,..., t 1 n 1 n t t T = t ,..., t T = t ,..., t 1 n 1 n t t T ={t ,..., t } T ={t ,..., t } 1 n n t 1 t T = t ,..., t T = t ,..., t 1 n 1 n t t 123 2918 Algorithmica (2018) 80:2909–2940 Next we deﬁne the set of edges. In the following, whenever we sloppily speak of a literal in the context of the graph G, we mean the vertex corresponding to that literal (i.e., some x , x , y or y ), and we proceed similarly for terms. Furthermore, when we i i i i are dealing with a (vertex corresponding to a) literal l, then l shall denote the (vertex corresponding to the) complement of l. For any term t ,let L (t ) and L (t ) denote i X i Y i the set of existentially and universally quantiﬁed literals, respectively, in t . E (G) = t , t , t , t , t , t , t , t | t ∈ T ∪ T × (Y ∪ Y ) i i i i i i i i ∪ l, t ,(l, t ) | t ∈ T , l ∈ L (t ) i i i X i ∪ l, t | t ∈ T , l ∈ L (t ) i Y i ∪ d , t | t ∈ T , |L (t )|≤ 1 ∪ d , t | t ∈ T , L (t ) =∅ i i X i i i X i 1 2 ∪ y , y , y , y | 1 ≤ i ≤ n , 1 ≤ j ≤ n i i i, j y t i, j ∪ y , y , y , y | y ∈ Y ∪ Y × (Y ∪ Y ) i i i, j i, j i, j Finally, we deﬁne V = Y ∪ Y ∪ Y ∪ Y ∪ T , V = Y ∪ T ∪ T ∪ T ∪ H, C ={(x , x ) | 1 ≤ i ≤ n }∪ t , t , t , t , t , t | 1 ≤ i ≤ n , i i x i i i t i i i and k =|V |+ n + 2n . x t The following observations are crucial: Elements of X ∪ X are only adjacent to vertices from T (which are forbidden) and T . For any i, each element of X ∪ X is adjacent to t ∈ T iff it is adjacent to t ∈ T . Furthermore, for any i, j,if x or x i i i i is adjacent to t , then setting the variable x to true or false, respectively, falsiﬁes the j i term t . Finally, for any i, j,if y or y is adjacent to t , then setting the variable y to j i i i true or false, respectively, falsiﬁes the term t . The intuition is that the complementary pairs (x , x ) guess a truth assignment to i i the existentially quantiﬁed variables. We now need to check if such a truth assignment has the property that the formula ψ is true for all extensions of this assignment to the universally quantiﬁed variables. Trying out all these extensions amounts to going through all subsets of a solution candidate and comparing the numbers of attackers and defenders. To illustrate, let S be a solution candidate (i.e., a set of vertices) and suppose S satisﬁes the conditions on forbidden, necessary and complementary vertices. We denote the truth assignment to x ,..., x encoded in S by I . Moreover, let R be a 1 n S subset of S containing either y or y for each universally quantiﬁed variable y .We j j j denote the extension of I to y ,..., y encoded in R by I . For any term t that is S 1 n S,R i falsiﬁed already by I , the vertex t attacks all vertices y and y . At the same time, S j j for any term t that is not falsiﬁed by I , the vertex t attacks y or y if setting the i S j j 123 Algorithmica (2018) 80:2909–2940 2919 variable y to true or false, respectively, falsiﬁes t . Hence, the number of attacks from j i vertices of the form t or t on R is exactly the number of terms that are falsiﬁed by i i I . With the help of the vertices in Y , we can afford up to n − 1 falsiﬁed terms, S,R t but if we falsify all n terms, then R is a witness that S is not secure. FNC The Secure Set instance (G, k, V , V , C ) can be constructed in time poly- nomial in the size of ϕ. We claim that ϕ is true iff (G, k, V , V , C ) is a positive FNC instance of Secure Set . “Only if ” direction If ϕ is true, then there is an assignment I to x ,..., x such that, 1 n for all assignments extending I to y ,..., y , some term in ψ is satisﬁed. We deﬁne 1 n aset S = V ∪{x ∈ X | I (x ) = true}∪{x ∈ X | I (x ) = false} i i i i ∪ t ∈ T , t ∈ T | there is some l ∈ L (t ) such that I | l i X i ∪ t ∈ T , t ∈ T | for all l ∈ L (t ) it holds that I | l . i X i We observe that |S|= k, V ∩ S =∅, V ⊆ S, and that for any (a, b) ∈ C it holds that a ∈ S iff b ∈ / S. By construction, whenever some element of X ∪ X is in S, then all its neighbors in T are in S; and whenever some t is in S, then some neighbor of t i i in X ∪ X is in S. We claim that S is a secure set in G.Let R be an arbitrary subset of S.Weshow that R has at least as many defenders as attackers by constructing a defense, which assigns to each attacker of R a dedicated defender in N [R]∩ S. We distinguish cases regarding the origins of the attacks on R. – We repel each attacker t ∈ T using t . Since t attacks R, R must contain i i i some element of X ∪ X that is adjacent to t and thus also to t ,so t ∈ N [R]∩ S. i i i – Each attacker from X ∪ X ∪{d , d } is adjacent to some t ∈ T ∩ R. We repel 1 2 that attacker using t , which is adjacent to t . Note that it cannot be the case that i i t is attacked by more than one vertex in X ∪ X ∪{d , d } because t has exactly i i 1 2 two neighbors from that set and would not be in S if neither of these neighbors was in S. –If t attacks R, then it attacks at least one element of T ∩ R, which is adjacent to some element of X ∪ X that is also in S. We repel t using any such element of X ∪ X. – Any attack from some t ∈ T on R must be on t . Since t ∈ / S, t is not i i i i consumed for repelling an attack on t , so we repel t with t . i i i –If some t ∈ T attacks R (by attacking t ), we repel t with t . i i i i – Analogously, we repel each attacker t ∈ T with t . i i – If, for some i with 1 ≤ i ≤ n , the vertices y for 1 ≤ j ≤ n + 1 attack R, then y t i, j we distinguish the following cases: If y is in R, then the adjacent vertices y for i, j 1 ≤ j ≤ n are in the neighborhood of R, too. We then repel each y with y for i, j i, j 1 ≤ j ≤ n , and we repel y with y . Otherwise, y is in R, and we proceed t i i i,n +1 symmetrically using y and y as dedicated defenders. i, j i 123 2920 Algorithmica (2018) 80:2909–2940 – In order to account for attacks from T ∪ T on R, we distinguish two cases. –If,forsome i with 1 ≤ i ≤ n , both y and y are in R, then, in the step before, y i i we have repelled each y with the respective y or y , but all y are still i i, j i, j i, j free. These vertices can repel all attacks from T ∪ T , as there are at most n such attacks. – Otherwise we show that there are at most n − 1 attacks from T ∪ T , and they can be repelled using Y . Consider the (partial) assignment J that assigns the same values to the variables x ,..., x as the assignment I above, and, for any 1 n variable y ,sets y to true or false if R contains the vertex y or y , respectively. i i i i By assumption we know that our assignment to x ,..., x is such that for 1 n all assignments to y ,..., y some term t in ψ is true. In particular, it must 1 n i therefore hold that J falsiﬁes no existentially quantiﬁed literal in t . Then, by construction of S, the vertex t is not in S. We also know that J falsiﬁes no universally quantiﬁed literal in t . But then the vertices from Y ∪ Y adjacent to the vertex t are not in R due to our construction of J,so t does not attack i i any vertex in R. From this it follows that there are at most n − 1 attacks from T ∪ T on R. We can repel all these attacks using the vertices y ,..., y . 1 n −1 This allows us to conclude |N [R]∩ S|≥|N [R]\S|. Therefore S is secure. “If ” direction Suppose S is a secure set in G satisfying the conditions regarding forbidden, necessary and complementary vertices. First observe that |S|= k because the complementary vertex pairs make sure that S contains exactly half of V (G)\(V ∪ V ). If S contains some l ∈ X ∪ X, then N (l) ∩ T ⊆ S by Observation 2.If S contains some t ∈ T , then t must be adjacent to some element of X ∪ X that is also in S by i i Observation 1. We construct an interpretation I on the variables x ,..., x that sets exactly those 1 n x to true where the corresponding vertex x is in S, and we claim that for each extension i i of I to the universally quantiﬁed variables there is a satisﬁed term in ψ. To see this, suppose to the contrary that some assignment J to all variables extends I but falsiﬁes all terms in ψ. Then we deﬁne a set R consisting of all vertices y such that J (y ) = true, i i all vertices y such that J (y ) = false, and all vertices in (T ∪ T ) ∩ S that are adjacent i i to these vertices y or y . We show that this contradicts S being secure: Clearly, R is a i i subset of S and has |R| defenders due to itself, n − 1 defenders due to Y , and n · n t y t defenders due to N (R) ∩ Y . This amounts to |N [R]∩ S|=|R|+ n − 1 + n · n . t y t On the other hand, there are n attacks on R from T ∪ T . This is because for any term t in ψ one of the following cases applies: –The term t is falsiﬁed already by I . Then t ∈ S and thus t ∈ / S. The vertex t , i i i however, is adjacent to every element of Y ∪ Y , so it attacks R. –The term t is not falsiﬁed by I but by J . Then t ∈ / S, and L (t ) contains some i Y i literal l with l ∈ N (t ) and J | l,so l is in R and attacked by t . i i In addition to these n attackers, R has |R ∩ (T ∪ T )| attackers in N (R)∩(T ∪T ), as well as n · (n + 1) attackers in Y .As |R|= n +|R ∩ (T ∪ T )|, we obtain in y t y total 123 Algorithmica (2018) 80:2909–2940 2921 |N [R]\S|= n +|R ∩ (T ∪ T )|+ n · (n + 1) t y t =|R|+ n + n · n > |N [R]∩ S|. t y t This contradicts S being secure, so for each extension of I to the universally quantiﬁed vertices, ψ is true; hence ϕ is true. 3.2 Hardness of Secure Set with Forbidden and Necessary Vertices FNC Next we present a transformation τ that eliminates complementary vertex pairs by FNC FN turning a Secure Set instance into an equivalent Secure Set instance. Along FNC FNC FNC with τ , we deﬁne a function σ , for each Secure Set instance I , such that FNC the solutions of I are in a one-to-one correspondence with those of τ (I ) in such a way that any two solutions of I have the same size iff the corresponding solutions of FNC τ (I ) have the same size. We use these functions to obtain a polynomial-time reduc- FNC FN FNC tion from Secure Set to Secure Set as well as from Exact Secure Set FN to Exact Secure Set . Before we formally deﬁne our reduction, we brieﬂy describe the underlying intuition. The gadget in Fig. 5 is added for every complementary pair (a, b). It is constructed in such a way that every solution must either contain all of ab ab ab ab ab {a, a , a ,..., a } or none of them, and the same holds for {b, b , b ,..., 1 n+4 1 ab ab b }. By making the vertex necessary, every solution must contain one of these n+4 two sets. At the same time, the bound on the solution size makes sure that we cannot afford to take both sets for any complementary pair. FN FNC Deﬁnition 5 We deﬁne a function τ , which assigns a Secure Set instance FNC to each Secure Set instance I = (G, k, V , V , C ). For this, we use n to FNC denote |V (G)| and ﬁrst deﬁne a function σ : x → x +|C|· (n + 6).For ab ab ab each (a, b) ∈ C, we introduce new vertices a , b and as well as, for any ab ab ab ab ab ab ab x ∈{a, b}, sets of new vertices Y ={x ,..., x }, Z ={x , x , x }, x x 1 n+1 n+2 n+3 n+4 ab ab ab ab ab ab ab Y ={x ,..., x } and Z ={x , x , x }. We use the notation 1 n+1 n+2 n+3 n+4 x x u ⊕ v to denote the set of edges {(u,v), (u, u ), (v, v ), (u,v ), (v, u )}.Now we FN FNC FNC deﬁne the Secure Set instance τ (I ) = (G , k , V , V ), where k = σ (k), ab ab ab ab ab V = V ∪ (Y ∪ Y ∪ Z ∪ Z ), V = V ∪ { } and G (a,b)∈C (a,b)∈C a b a b is the graph deﬁned by ab ab ab ab ab ab ab V (G ) = V (G) ∪ { , a , b }∪ Y ∪ Y ∪ Y ∪ Y a b a b (a,b)∈C ab ab ab ab ∪ Z ∪ Z ∪ Z ∪ Z , a b a b ab ab ab ab ab E (G ) = E (G) ∪ {( , x )}∪ ({x}× Y ) ∪ ({x }× Z ) x x (a,b)∈C x ∈{a,b} ab ab ∪ x ⊕ x . i i +1 1≤i ≤n+3 123 2922 Algorithmica (2018) 80:2909–2940 ab ab ab ab a a b b 1 1 1 1 ab ab ab ab a a b b 2 2 2 2 . . . . . . . . . . . . ab ab ab ab a a b b n+1 n+1 n+1 n+1 ab ab ab ab a a b b n+2 n+2 n+2 n+2 ab ab ab ab ab ab ab a b a b a b n+3 n+3 n+3 n+3 ab ab ab ab a a b b n+4 n+4 n+4 n+4 FNC Fig. 5 Gadget for a pair of complementary vertices (a, b) in the reduction from Secure Set to FN Secure Set . The vertices a and b may have additional neighbors from the original graph We illustrate our construction in Fig. 5. FNC Lemma 2 Let I = (G, k, V , V , C ) be a Secure Set instance, let A be the set FNC of solutions of I and let B be the set of solutions of τ (I ). There is a bijection FNC g : A → B such that |g(S)|= σ (|S|) holds for every S ∈ A. Proof We use the same auxiliary notation as in Deﬁnition 5 and we deﬁne g as S → ab ab ab ab S ∪ ({ , x }∪ Y ∪ Z ). For every S ∈ A, we thus obtain x x (a,b)∈C, x ∈S∩{a,b} FNC |g(S)|= σ (|S|), and we ﬁrst show that indeed g(S) ∈ B. Let S ∈ A and let S denote g(S). Obviously S satisﬁes V ∩ S =∅ and V ⊆ S . To see that S is secure in G ,let X be an arbitrary subset of S . Since S is secure in G and X ∩ V (G) ⊆ S, there is a defense μ : N [X ∩ V (G)]\S → N [X ∩ V (G)]∩ S. G G We now construct a defense μ : N [X ]\S → N [X ]∩ S . For any attacker v of G G X in G , we distinguish three cases. ab ab ab –If v is some x ∈ Y ∪ Z for some (a, b) ∈ C and x ∈{a, b},weset i x x ab ab μ (v) = x . This element is in N [X ] since v is only adjacent to x or neighbors i i of it. ab ab ab –If v is a or b for some (a, b) ∈ C, its only neighbor in X can be and we ab set μ (v) = . – Otherwise v is in N [X ∩V (G)]\S (by our construction of S ). Since the codomain of μ is a subset of the codomain of μ ,wemay set μ (v) = μ(v). Since μ is injective, each attack on X in G can be repelled by S . Hence S is secure in G . Clearly g is injective. It remains to show that g is surjective. Let S be a solution FNC of τ (I ). First we make the following observations for each (a, b) ∈ C and each x ∈{a, b}: 123 Algorithmica (2018) 80:2909–2940 2923 ab ab ab ab –If some x ∈ Y is in S , then Y ∪ Z ∪{x}⊆ S by Observation 2. x x x ab ab ab ab ab –If some x ∈ Z is in S , then Y ∪ Z ∪{x }⊆ S for the same reason. x x x ab –If x ∈ S , then Y ∩ S =∅. To see this, suppose x ∈ S .Let D consist cd of those pairs (c, d) ∈ C such that x ∈{c, d} and Y ∩ S =∅, and let A cd consist of those pairs (c, d) ∈ C such that x ∈{c, d} and Y ∩ S =∅.Now let cd cd X ={x}∪{x ,..., x | (c, d) ∈ D }. By the previous observations, X ⊆ S . cd The defenders of X are the element x,the |D |· (n +1) elements of Y (c,d)∈D x and perhaps some elements of N (x ), which consists of at most n −1 vertices. The cd attackers of X are the |D |· (n + 1) elements of Y ,the |A |· (n + 1) x x (c,d)∈D x x cd elements of Y and perhaps some elements of N (x ).Thus,if A is G x (c,d)∈A x nonempty, then the set X has more attackers than defenders in G . However, S is ab secure, so A must be empty, which implies Y ∩ S =∅. ab ab –If x ∈ S , then Z ∩ S =∅ by Observation 1. ab So for each (a, b) ∈ C and x ∈{a, b}, S contains either all or none of {x , x }∪ ab ab Y ∪ Z . x x ab ab ab For every (a, b) ∈ C, S contains a or b , since ∈ S , whose neighbors ab ab are a and b . It follows that |S | > |C|· (n + 6) even if S contains only one of each (a, b) ∈ C. If, for some (a, b) ∈ C, S contained both a and b, we could FNC derive a contradiction to |S |≤ σ (k) = k +|C|· (n + 6) because then |S | > FNC (|C|+ 1) · (n + 6)>σ (k).So S contains either a or b for any (a, b) ∈ C. We construct S = S ∩ V (G) and observe that S = g(S), V ⊆ S, V ∩ S =∅, and |S ∩{a, b}| = 1 for each (a, b) ∈ C. It remains to show that S is secure in G. ab Let X be an arbitrary subset of S. We construct X = X ∪ Y (a,b)∈C,x ∈X ∩{a,b} x ab ab ab and observe that each Y we put into X entails |Y ∪{x }| = n + 2 additional x x n+2 ab ab defenders and |Y ∪{x }| = n + 2 additional attackers of X in G compared to n+2 X in G;so |N [X ]∩ S |−|N [X]∩ S|=|N [X ]\S |−|N [X ]\S|. Clearly X G G G G is a subset of S ,so |N [X ]∩ S |≥|N [X ]\S | as S is secure in G . We conclude G G |N [X]∩ S|≥|N [X ]\S|. Hence S is secure in G. G G FNC As τ is clearly computable in polynomial time, the following result follows: FN Corollary 1 Secure Set is -hard. FNC The instances of Secure Set are identical to the instances of the exact variant, FNC so τ is also applicable to the exact case. In fact it turns out that this gives us also FNC FN a reduction from Exact Secure Set to Exact Secure Set . FN Corollary 2 Exact Secure Set is -hard. FNC FN FNC Proof Let I and I = τ (I ) be our Exact Secure Set and Exact Secure Set instances, respectively, and let k and k denote their respective solution sizes. By Lemma 2, there is a bijection g between the solutions of I and the solutions of I such FNC that, for every solution S of I , g(S) has σ (k) = k elements, and for every solution FNC −1 S of I , g (S ) has k elements since σ is invertible. 123 2924 Algorithmica (2018) 80:2909–2940 Fig. 6 Result of the FN transformation τ applied to an example graph with two adjacent vertices a and b,where b is necessary. Every solution in the depicted graph contains b, w and w 3.3 Hardness of Secure Set with Forbidden Vertices FN Now we present a transformation τ that eliminates necessary vertices. Our trans- formation not only operates on a problem instance, but also requires an ordering of the necessary vertices. For now, we can consider this as an arbitrary ordering. It will become more important in Sect. 4.1, where we reuse this transformation for showing W[1]-hardness w.r.t. treewidth. FN Before formally deﬁning the transformation τ , we refer to Fig. 6, which shows the result for a simple example graph with only two vertices a and b, of which b is necessary. The basic idea is that the vertex w must be in every solution S because any vertex that is in S also eventually forces w to be in S. Once w ∈ S, the construction to the right of w makes sure that b ∈ S. FN Deﬁnition 6 We deﬁne a function τ , which assigns a Secure Set instance to FN each pair (I, ), where I = (G, k, V , V ) is a Secure Set instance and is an ordering of the elements of V . For this, let V denote V (G)\(V ∪ V ).Weuse n to FN denote |V (G)|, and we ﬁrst deﬁne a function σ : x → xn +3x +n −|V |+|V |+2. We use W to denote the set of new vertices {w}∪{w ,w ,w ,w | v ∈ V }.The v v v intention is for each w and w to be forbidden, for w and each w to be in every v v v secure set, and for w to be in a secure set iff v is in it at the same time. We write V to denote V ∪ V ∪{w}; for each v ∈ V ,weuse A to denote the set of new vertices {v ,...,v ,v ,...,v }, and we use shorthand notation A ={v ,...,v } 1 n+1 1 n+1 1 n+1 and A ={v ,...,v }. The intention is for each v to be forbidden and for each 1 n+1 i v to be in a secure set iff v is in it at the same time. We use the notation u ⊕ v to denote the set of edges {(u,v), (u, u ), (v, v ), (u,v ), (v, u )}.If V =∅, let P =∅; otherwise let P be the set consisting of all pairs (u,v) such that v is the direct successor of u according to , as well as the pair (u,w), where u is the FN greatest element according to . Now we deﬁne τ (I, ) = (G , k , V ), where 123 Algorithmica (2018) 80:2909–2940 2925 a w a a a w 1 2 ··· n+1 a w a a w w 1 2 n+1 a a Fig. 7 Illustration of the gadget that makes sure w and w are in every secure set. The vertex a is a non- FN necessary, non-forbidden vertex from the Secure Set instance and may have other neighbors from this instance. The vertex w has two neighbors (as depicted here) for each non-necessary, non-forbidden vertex FN from the Secure Set instance, and additionally the neighbors depicted in Fig. 8 x w x y y y w x x ··· n+1 1 2 ··· n+1 w w ··· n+1 1 2 1 2 x y w x x y y w w 1 2 n+1 1 2 n+1 1 2 n+1 Fig. 8 Illustration of the gadget that makes sure every secure set contains all necessary vertices as it must contain w. Here we assume there are the two necessary vertices x and y, and we use the ordering x y FN V = V ∪{w ,w | v ∈ V }∪ + A , k = σ (k), and G is the graph v v v∈V v deﬁned by V (G ) = V (G) ∪ W ∪ A , v∈V E (G ) = E (G) ∪{(v, v ) | v ∈ V , 1 ≤ i ≤ n + 1} ∪ v ⊕ v ∪ u ⊕ v i i +1 n+1 1 v∈V , 1≤i ≤n (u,v)∈P ∪ v ⊕ w ∪ (w, w ), (w, w ), (w ,w ), (w ,w ) | v ∈ V . n+1 v v v v v v v v∈V We illustrate our construction in Figs. 7 and 8. FN We now prove that τ yields a correct reduction for any ordering . FN Lemma 3 Let I = (G, k, V , V ) be a Secure Set instance, let be an ordering FN of V , let A be the set of solutions of I and let B be the set of solutions of τ (I, ). FN There is a bijection g : A → B such that |g(S)|= σ (|S|) holds for every S ∈ A. Proof We use the same auxiliary notation as in Deﬁnition 6 and we deﬁne g as S → S ∪ A ∪ A ∪{w}∪{w | v ∈ V }∪{w | v ∈ S ∩ V }. For every S ∈ A,we v∈S v w v FN thus obtain |g(S)|=|S|+|S|(n + 1) + (n + 1) + 1 +|V |+ (|S|−|V |) = σ (|S|), and we ﬁrst show that indeed g(S) ∈ B. Let S ∈ A and let S denote g(S). Obviously S satisﬁes V ∩ S =∅.Tosee that S is secure in G ,let X be an arbitrary subset of S . Since S is secure in G and 123 2926 Algorithmica (2018) 80:2909–2940 X ∩ V (G) ⊆ S, there is a defense μ : N [X ∩ V (G)]\S → N [X ∩ V (G)]∩ S. G G We now construct a defense μ : N [X ]\S → N [X ]∩ S . For any attacker a of G G X in G , we distinguish the following cases: –If a is some v ∈ A for some v ∈ V , then a can only attack either v or a neighbor of v , all of which are in S , and we set μ (a) = v . i i – Similarly, if a is w for some v ∈ V , then we set μ (a) = w . –If a is w for some v ∈ V , then a attacks w and we set μ (a) = w . v v –If a is w for some v ∈ V , then it attacks w or w , which is not used for repelling any attack because w cannot attack X ,soweset μ (a) = w . v v – Otherwise a is in N [X ∩V (G)]\S (by our construction of S ). Since the codomain of μ is a subset of the codomain of μ ,wemay set μ (a) = μ(a). Since μ is injective, each attack on X in G can be repelled by S . Hence S is secure in G . Clearly g is injective. It remains to show that g is surjective. Let S be a solution of FN τ (I, ). We ﬁrst show that V ∪{w}⊆ S : –If S contains some v ∈ V ∪ V , then S contains an element of A by Observa- tion 1. –If S contains an element of A for some v ∈ V , then {v}∪ A ⊆ S by v v Observation 2. –If v ∈ S for some v ∈ V , then w ∈ S for the same reason. n+1 v – Furthermore, if S contains an element of A for some v ∈ V ∪{w}, then also A ⊆ S for every u ∈ V ∪{w} for the same reason. –If w ∈ S for some v ∈ V , then {w, w ,v }⊆ S by Observation 2. v n+1 –If w ∈ S for some v ∈ V , then w ∈ S because at least w or w must be in S and the former implies w ∈ S as we have seen. – The previous observations show that any vertex being in S implies w ∈ S . Since S is nonempty, it follows that w ∈ S . We now show that S contains an element of A . Suppose the contrary, let U = S ∩{w | v ∈ V },let U = S ∩{w | v ∈ V } w v and consider X ={w}∪U. The defenders of X consist of exactly 1+|U |+2|U | elements, whereas there are exactly (n + 1) + (|V |−|U |) + (|V |−|U |) + 3|U | attackers. With |V |≥|U |≥|U | and n > 0 in mind, we arrive at the contradiction |N [X ]∩ S | < |N [X ]\S |. G G – The previous observations show that for every v ∈ V ∪{w} it holds that {v}∪ A ⊆ S . Finally, we show that {w | v ∈ V }⊆ S . Suppose, for the sake of v v contradiction, that there is some u ∈ V such that w ∈ / S . We have seen that the latter can only be the case if u ∈ / S . Observe that {w}∪{w | 2 ≤ i ≤ n +1}∪{w | i v v ∈ V ∩ S } is a subset of S that is attacked by {w }∪ A ∪{v ,w ,w | u w v v n+1 v ∈ V ∩ S }∪{w | v ∈ V \S }, but the defenders are a proper subset of {w}∪ A ∪{v ,w ,w | v ∈ V ∩ S }∪{w | v ∈ V \S }. This contradicts S n+1 v w v v being secure in G . Let S = S ∩ V (G). By the previous observations, it is easy to see that S = g(S). It remains to show that S is secure in G.Let X be an arbitrary subset of S.We construct X = X ∪ A and observe that the number of additional defenders of v∈X v X in G compared to X in G is equal to the number of additional attackers; formally 123 Algorithmica (2018) 80:2909–2940 2927 |N [X ]∩ S |−|N [X]∩ S|=|N [X ]\S |−|N [X ]\S|. Clearly X ⊆ S ,so G G G G |N [X ]∩ S |≥|N [X ]\S | as S is secure in G . Consequently |N [X]∩ S|≥ G G G |N [X ]\S|. Hence S is secure in G. FN Given an ordering , clearly τ (I, ) is computable in polynomial time. We can FN F thus easily obtain a reduction from Secure Set to Secure Set by ﬁrst computing an arbitrary ordering of the necessary vertices in polynomial time. This also gives us a hardness result for the exact case, analogous to Corollary 2. F F Corollary 3 Secure Set and Exact Secure Set are -hard. 3.4 Hardness of Secure Set We now introduce a transformation τ that eliminates forbidden vertices. The basic idea is that we ensure that a forbidden vertex f is never part of a solution by adding so many neighbors to f that we could only defend f by exceeding the bound on the solution size. Deﬁnition 7 We deﬁne a function τ , which assigns a Secure Set instance to each Secure Set instance I = (G, k, V ). For each f ∈ V , we introduce new vertices f , f ,..., f . Now we deﬁne τ (I ) = (G , k), where G is the graph deﬁned by 1 2k V (G ) = V (G) ∪{ f , f ,..., f | f ∈ V }, 1 2k E (G ) = E (G) ∪{( f, f ), ( f , f ) | f ∈ V , 1 ≤ i ≤ 2k}. i i Lemma 4 Every Secure Set instance I has the same solutions as the Secure Set instance τ (I ). Proof Let I = (G, k, V ) and τ (I ) = (G , k). Each secure set S in G is also secure in G because the subgraph of G induced by N [S] is equal to the subgraph of G induced by N [S].Now let S be a solution of τ (I ). For every f ∈ V , neither f nor f are in S because each of these vertices has at least 2k neighbors, and S cannot contain any f because N ( f ) ={ f, f }. Hence S is also secure in G as the i G i subgraphs induced by the respective neighborhoods are again equal. This immediately yields the following result. Corollary 4 Secure Set and Exact Secure Set are -hard. 4 Complexity of Secure Set Parameterized by Treewidth In this section we study the parameterized complexity of the Secure Set problem when treewidth is the parameter. We ﬁrst show that all variants of Secure Set considered in this paper are W[1]- hard for this parameter by reusing some reductions from Sect. 3 and proving that they 123 2928 Algorithmica (2018) 80:2909–2940 preserve bounded treewidth. Under the widely held assumption that FPT = W[1], this rules out ﬁxed-parameter tractable algorithms for these problems. Second, we show that the co-NP-complete Secure Set Verification problem is solvable in linear time on instances whose treewidth is bounded by a constant. We do this by providing a ﬁxed-parameter linear algorithm that performs dynamic programming on a tree decomposition of the input graph. Although bounded treewidth most likely does not lead to ﬁxed-parameter tractability of the problem of ﬁnding secure sets, this proves that it does for the problem of verifying whether a given set is secure. Third, we show that all the variants of the Secure Set problem considered in this paper are solvable in polynomial time on instances whose treewidth is bounded by a constant. We again do this by providing a polynomial-time dynamic programming algorithm, but this time the degree of the polynomial depends on the treewidth. 4.1 Hardness of Secure Set Parameterized by Treewidth In this subsection, we prove the following theorem: Theorem 2 The following problems are all W[1]-hard when parameterized by F F treewidth: Secure Set, Exact Secure Set, Secure Set , Exact Secure Set , FN FN FNC FNC Secure Set , Exact Secure Set , Secure Set , and Exact Secure Set . To prove this, we reduce from the following problem [3], which is known to be W[1]- hard [29] parameterized by the treewidth of the graph: Minimum Maximum Outdegree Input: A graph G, an edge weighting w : E (G) → N given in unary and a positive integer r Question: Is there an orientation of the edges of G such that, for each v ∈ V (G), the sum of the weights of outgoing edges from v is at most r? FNC FNC Lemma 5 Secure Set and Exact Secure Set , both parameterized by the treewidth of the primal graph, are W[1]-hard. Proof Let an instance of Minimum Maximum Outdegree be given by a graph G, an edge weighting w : E (G) → N in unary and a positive integer r.From FNC FNC this we construct an instance of both Secure Set and Exact Secure Set .An example is given in Fig. 9. For each v ∈ V (G), we deﬁne the set of new vertices v v H ={h ,..., h }, and for each (u,v) ∈ E (G), we deﬁne the sets of new vertices 1 r −1 v v u u V ={u ,..., u } and V ={v ,...,v }. We now deﬁne the graph G uv vu 1 w(u,v) 1 w(u,v) with V (G ) = V (G) ∪ H ∪ (V ∪ V ), v uv vu v∈V (G) (u,v)∈E (G) E (G ) ={(v, h) | v ∈ V (G), h ∈ H } ∪{(u, x ) | (u,v) ∈ E (G), x ∈ V } uv 123 Algorithmica (2018) 80:2909–2940 2929 a a b h b h 1 1 1 a b h a b h a 2 Fig. 9 Result of our transformation on a sample Minimum Maximum Outdegree instance with r = 3 and two vertices a, b that are connected by an edge of weight 3. Complementary vertex pairs are shown via dashed lines. Necessary vertices have a symbol next to their name ∪{(x,v) | (u,v) ∈ E (G), x ∈ V } vu v u ∪ u ,v | (u,v) ∈ E (G), 1 ≤ i ≤ w(u,v) . i i v u We also deﬁne the set of complementary vertex pairs C ={(u ,v ) | (u,v) ∈ i i u v E (G), 1 ≤ i ≤ w(u,v)}∪{(v , u ) | (u,v) ∈ E (G), 1 ≤ i <w(u,v)}. i i +1 Finally, we deﬁne the set of necessary vertices V = V (G) ∪ H and v∈V (G) k =|V |+ w(u,v).Weuse I to denote (G , k, C, V , ∅), which is an (u,v)∈E (G) FNC FNC instance of Secure Set and also of Exact Secure Set . Obviously I is a pos- FNC FNC itive instance of Secure Set iff it is a positive instance of Exact Secure Set because the necessary and complementary vertices make sure that every solution FNC of the Secure Set instance I has exactly k elements. Hence we only consider FNC Secure Set . The intention is that for each orientation of G we have a solution candidate S in I such that an edge orientation from u to v entails V ⊆ S and V ∩ S =∅, and the vu uv other orientation entails V ⊆ S and V ∩ S =∅. For each outgoing edge of v in uv vu the orientation of G, there are as many attackers of v in I as the weight of that edge. Together with H , v can repel up to r such attacks. The other neighbors of v that are in S cannot help v since they are in turn attacked by their neighbors. Clearly I can be computed in polynomial time. We now show that the treewidth of the primal graph of I depends only on the treewidth of G.Wedosobymodifyingan optimal tree decomposition T of G as follows: 1. For each (u,v) ∈ E (G), we take an arbitrary node whose bag B contains both u and v and add to its children a chain of nodes N ,..., N such that the bag 1 w(u,v)−1 v v u u of N is B ∪{u , u ,v ,v }. i i +1 i i +1 2. For each v ∈ V (G), we take an arbitrary node whose bag B contains v and add to its children a chain of nodes N ,..., N such that the bag of N is B ∪{h }. 1 r −1 i It is easy to verify that the result is a valid tree decomposition of the primal graph of I and its width is at most the treewidth of G plus four. We claim that (G,w, r ) is a positive instance of Minimum Maximum Outdegree FNC iff I is a positive instance of Secure Set . “Only if ” direction Let D be the directed graph given by an orientation of the edges of G such that for each vertex the sum of weights of outgoing edges is at most r.The u u set S = V ∪{v ,...,v | (u,v) ∈ E (D)} is secure in G:Let X be an arbitrary 1 w(u,v) v u u subset of S. Every attacker must be some element u .If v ∈ X, then we can use v to i i i repel the attack from u . Otherwise u ∈ X, so we can use either u or one of the r − 1 123 2930 Algorithmica (2018) 80:2909–2940 elements of H to repel the attack from u . These are sufﬁciently many defenders: For every vertex v ∈ V (G) ∩ X,atmost r neighbors attack v as otherwise the sum of weights of outgoing edges of v in D would be greater than r. Finally, it is easy to verify that |S|= k, V ⊆ S, and exactly one element of each pair of complementary vertices is in S. “If ” direction Let S be a solution of I . For every (u,v) ∈ E (G), either V ⊆ S uv or V ⊆ S due to the complementary vertex pairs. We deﬁne a directed graph D vu by V (D) = V (G) and E (D) ={(u,v) | V ⊆ S}∪{(v, u) | V ⊆ S}. Suppose vu uv there is a vertex v in D whose sum of weights of outgoing edges is greater than r. We construct X ={v}∪ V , which is a subset of S.Now v has more vu (u,v)∈E (D) than r attacking neighbors, but all defenders except v and H must already defend themselves against their attacking neighbor. This contradicts S being secure. FNC FN Now we reduce from Secure Set to Secure Set to show W[1]-hardness of FNC the latter problem. We reuse the function τ from Deﬁnition 5 and show that this gives us a reduction that preserves bounded treewidth. FN Lemma 6 Secure Set , parameterized by the treewidth of the graph, is W[1]-hard. FNC Proof Let I be a Secure Set instance whose primal graph we denote by G.We FN FNC obtain an equivalent Secure Set instance τ (I ), whose graph we denote by G . This reduction is correct, as shown in Lemma 2. It remains to show that the treewidth of G is bounded by a function of the treewidth of G.Let T be an optimal nice tree decomposition of G. We build a tree decomposition T of G by modifying a copy of T in the following way: For every pair (a, b) of complementary vertices, we pick an arbitrary node t in T whose bag B contains both a and b, and we add a chain of nodes N ,..., N between t and its parent such that, for 1 ≤ i ≤ n + 1, the bag 1 2n+3 ab ab ab ab ab ab ab ab of N is B ∪{a , a , a , a }, the bag of N is B ∪{a , b , }∪ Z ∪ i n+2 i i i +1 i +1 ab ab ab ab ab ab ab Z ∪ Z ∪ Z , and the bag of N is B ∪{b , b , b , b }. n+2+i b n+3−i n+3−1 n+2−i n+2−i a b It is easy to verify that T is a valid tree decomposition of G . Furthermore, the width of T is at most the width of T plus 15. Just like before, we get an analogous result for the exact variant. It can be proved in the same way as Corollary 2. FN Corollary 5 Exact Secure Set , parameterized by the treewidth of the graph, is W[1]-hard. F FN We next show W[1]-hardness of Secure Set by reducing from Secure Set FN FN using the function τ from Deﬁnition 6. This function maps a Secure Set instance, together with an ordering of the necessary vertices, to an equivalent Secure Set instance. We show that by choosing appropriately, this gives us a reduction that preserves bounded treewidth. Lemma 7 Secure Set , parameterized by the treewidth of the graph, is W[1]-hard. FN Proof Let I = (G, k, V , V ) be a Secure Set instance and let T be an optimal nice tree decomposition of G. We can compute such a tree decomposition in FPT 123 Algorithmica (2018) 80:2909–2940 2931 time [6]. Let be the ordering of the elements of V that is obtained in linear time by doing a post-order traversal of T and sequentially recording the elements that occur FN for the last time in the current bag. We obtain the Secure Set instance τ (I, ), whose graph we denote by G . This reduction is correct, as shown in Lemma 3, and computable in FPT time. It remains to show that the treewidth of G is bounded by a function of the treewidth of G. To this end, we use T to build a tree decomposition T of G . We initially set T := T and modify it by the following steps: 1. We insert w into every bag. 2. For every (u,v) ∈ P, we add v, v and v into the bag of every node between T T T (and including) t and t . Note that the bag of t contains both u and v.After u v u this step, we have increased the bag size of each node by at most ﬁve. + T T 3. For each v ∈ V ,weuse B to denote the bag of t and replace t by a v v chain of nodes N ,..., N , where N is the topmost node and the bag of N is 1 n n i B ∪{v ,v ,v ,v }. After this step, note that, for each (u,v) ∈ P, the bag v i i +1 i i +1 of the new node t contains u , u , v and v . n+1 1 n+1 1 4. For each v ∈ V , we add w , w , w and w to the bag of t , which already v v v v contains w, v , v . n+1 n+1 It is easy to verify that T is a valid tree decomposition of G . Furthermore, the width of T is at most the width of T plus twelve. We again get an analogous result for the exact variant. Corollary 6 Exact Secure Set , parameterized by the treewidth of the graph, is W[1]-hard. Finally, we show W[1]-hardness of Secure Set by reducing from Secure Set while preserving bounded treewidth. Lemma 8 Secure Set, parameterized by the treewidth of the graph, is W[1]-hard. Proof Let I = (G, k, V ) be a Secure Set instance, let G denote the graph of τ (I ) and let T be an optimal nice tree decomposition of G. We build a tree decomposition T of G by modifying a copy of T in the following way: For every f ∈ V ,wepickan arbitrary node t in T whose bag B contains f , and we add a chain of nodes N ,..., N 1 2k between t and its parent such that, for 1 ≤ i ≤ 2k, the bag of N is B ∪{ f , f }.Itis i i easy to verify that T is a valid tree decomposition of G . Furthermore, the width of T is at most the width of T plus two. We again get an analogous result for the exact variant. Corollary 7 Exact Secure Set, parameterized by the treewidth of the input graph, is W[1]-hard. 4.2 A Fixed-Parameter Tractable Algorithm for Secure Set Veriﬁcation While we have seen in Sect. 4.1 that Secure Set parameterized by treewidth is most likely not FPT, we now present a positive result: The co-NP-complete [21] Secure 123 2932 Algorithmica (2018) 80:2909–2940 Set Verification problem, which consists of checking whether a given set S is secure inagraph G, is FPT parameterized by the treewidth of G. We show this by giving a ﬁxed-parameter linear algorithm that follows the principle of dynamic programming on a tree decomposition T of G. The core idea is the following: For each node t of T and each X ⊆ S ∩ χ(t ), we store an integer c (X ), which indicates that X can be S,t extended to a set X ⊆ S using “forgotten” vertices from further down in T in such a way that the difference between defenders and attackers of X is c (X ) and X is S,t the “worst” subset of S that can be obtained in this way. To compute these values, we traverse T from the bottom up and use recurrence relations to compute the values for the current node t of T based on the values we have computed for the children of t.If we then look at the values we have computed at the root of T , we can decide if there is a subset of S that is “bad enough” to witness that S is not secure. Dynamic programming algorithms like this are quite common for showing FPT membership w.r.t. treewidth and some examples can be found in [13,26]. Proving their correctness is a usually rather tedious structural induction argument along the tree decomposition: At every node t of T , we have to prove that the recurrence relations indeed characterize the value they are supposed to represent. Examples of such proofs can be found in [13]. We now formally deﬁne the values that we will compute at each tree decomposition node. Let G be a graph with a nice tree decomposition T and let S ⊆ V (G) be the candidate for which we want to check if it is secure. For each node t of T and each set of vertices A, we deﬁne A ={a ∈ A | a ∈ χ(t ), t is a descendant of t }.For any X ⊆ S, we call |N [X ] ∩ S|−|N [X ] \S| the score of X w.r.t. S at t (or just G t G t thescoreof X if S and t are clear from the context) and denote it by score (X ). S,t Furthermore, we call |N [X]∩ χ(t ) ∩ S|−|(N [X]∩ χ(t ))\S| the local score of X G G w.r.t. S at t and denote it by lscore (X ). Finally, for each X ⊆ S ∩ χ(t ), we deﬁne S,t the value c (X ) = min score (X ) . S,t S,t X ⊆S , X ∩χ(t )=X When r is the root of T , both S = S and χ(r ) =∅ hold, so S is secure if and only if c (∅) is nonnegative. S,r We now describe how to compute all such values in a bottom-up manner by dis- tinguishing the node type of t, and we prove the correctness of our computation by structural induction along the way. In this correctness proof, we use additional ter- minology: We say that a set X is an extension of X w.r.t. S at t if it is one of those sets considered in the deﬁnition of c (X ) that has minimum score; formally X ⊆ S , S,t X ∩ χ(t ) = X and score (X ) = c (X ). We may omit S or t if they are clear from S,t S,t the context. Leaf node.If t is a leaf node, then its bag is empty and obviously c (∅) = 0 S,t holds. Introduce node.Let t be an introduce node with child t ,let v be the unique element of χ(t )\χ(t ),let X ⊆ S ∩ χ(t ) and let X = X \{v}. We prove that the following equation holds: 123 Algorithmica (2018) 80:2909–2940 2933 ⎪ c (X ) +1if v ∈ N [X]∩ S ⎨ S,t c (X ) = c (X ) −1if v ∈ N [X ]\S S,t S,t c (X ) otherwise S,t First consider the case where v ∈ N [X]∩ S.Let X be an extension of X at t, so score (X ) = c (X ).From v/ ∈ N [X \{v}] and v ∈ N [X ] ∩ S we G G t S,t S,t infer score (X ) = score (X \{v}) + 1. Moreover, the set X \{v} is one of S,t S,t the candidates considered for an extension of X in the deﬁnition of c ,sowe S,t obtain c (X ) ≤ score (X \{v}). In total, this gives us c (X ) ≥ c (X ) +1. S,t S,t S,t S,t Conversely, let X be an extension of X at t , so score (X ) = c (X ).We S,t S,t distinguish two cases. 1. If v ∈ X, then from v/ ∈ N [X ] and v ∈ N [X ∪{v}] ∩ S we infer G G t score (X ∪{v}) = score (X )+1. Since X = X ∪{v} and X = X ∩χ(t ), S,t S,t it holds that X = (X ∪{v}) ∩ χ(t ). Hence the set X ∪{v} is one of the candidates considered for an extension of X in the deﬁnition of c and we S,t obtain c (X ) ≤ score (X ∪{v}). S,t S,t 2. Otherwise v/ ∈ X. In this case X = X , v/ ∈ X and X = X ∩ χ(t ). Hence the set X is considered in the deﬁnition of c (X ) and we get c (X ) ≤ S,t S,t score (X ). Since v is adjacent to an element of X, we infer score (X ) = S,t S,t score (X ) + 1. S,t In both cases, we obtain c (X ) ≤ c (X )+1, so indeed c (X ) = c (X )+1. S,t S,t S,t S,t Next consider the case where v ∈ N [X ]\S. Clearlyv/ ∈ X.Let X be an extension of X at t, so score (X ) = c (X ).Fromv/ ∈ N [X ] and v ∈ N [X ] \S we now G t G t S,t S,t infer score (X ) = score (X ) − 1. Similar to before, by deﬁnition of c (X ) S,t S,t S,t we obtain c (X ) ≤ score (X ). In total, this gives us c (X ) ≥ c (X ) − 1. S,t S,t S,t S,t Conversely, let X be an extension of X at t , so score (X ) = c (X ). Since S,t S,t v/ ∈ X and X = X ∩ χ(t ), X is considered in the deﬁnition of c (X ) and S,t we get c (X ) ≤ score (X ). Since v is adjacent to an element of X, we infer S,t S,t score (X ) = score (X ) − 1. We obtain c (X ) ≤ c (X ) − 1, so indeed S,t S,t S,t S,t c (X ) = c (X ) − 1. S,t S,t Finally consider the remaining case where v/ ∈ N [X ] and, in particular, v/ ∈ X holds as well as X = X . Using elementary set theory with S \{v}= S and t t χ(t ) = χ(t ) ∪{v} in mind, we can prove that {X ⊆ S | X ∩ χ(t ) = X } is equal to {X ⊆ S | X ∩ χ(t ) = X }. Hence a set X is considered in the deﬁnition of c (X ) iff it is considered in the deﬁnition of c (X ). For every X ⊆ S such that S,t S,t X ∩ χ(t ) = X, observe that v/ ∈ N [X ] , since v is not adjacent to any element G t of X and if it were adjacent to some element of X \X, then T would not be a valid tree decomposition. This proves that every such X has the same score at t and t . Hence c (X ) = c (X ). S,t S,t Forget node.Let t be a forget node with child t ,let v be the unique element of χ(t )\χ(t ) and let X ⊆ S ∩ χ(t ). We prove that the following equation holds: 123 2934 Algorithmica (2018) 80:2909–2940 min{c (X ), c (X ∪{v})} if v ∈ S S,t S,t c (X ) = S,t c (X ) otherwise S,t Clearly S = S and all scores at forget nodes are identical to those in the respec- tive child node. The case where v/ ∈ S is trivial as then S ∩ χ(t ) = S ∩ χ(t ), i.e., the domains of c and c are equal, and the sets considered in the deﬁnitions S,t S,t of c (X ) and c (X ) are the same. Hence we consider the case where v ∈ S. S,t S,t Let X be an extension of X at t,so c (X ) = score (X ) = score (X ).If S,t S,t S,t v/ ∈ X, then X ∩ χ(t ) = X, so we obtain c (X ) ≤ score (X ) by deﬁnition S,t S,t of c (X ). On the other hand, if v ∈ X, then X ∩ χ(t ) = X ∪{v}, so we obtain S,t c (X ∪{v}) ≤ score (X ). As one of these two inequalities applies, we get S,t S,t c (X ) ≥ min{c (X ), c (X ∪{v})}. S,t S,t S,t Conversely, every extension X of X at t is considered in the deﬁnition of c (X ),so c (X ) ≤ score (X ) = score (X ) = c (X ). Moreover, every S,t S,t S,t S,t S,t extension X of X ∪{v} at t is also considered in the deﬁnition of c (X ), S,t so c (X ) ≤ score (X ) = score (X ) = c (X ∪{v}). If we combine S,t S,t S,t S,t these two inequalities, we get c (X ) ≤ min{c (X ), c (X ∪{v})}. Hence S,t S,t S,t c (X ) = min{c (X ), c (X ∪{v})}. S,t S,t S,t Join node.Let t be a join node with children t , t such that χ(t ) = χ(t ) = χ(t ), and let X ⊆ S ∩ χ(t ). We prove that the following equation holds: c (X ) = c (X ) + c (X ) − lscore (X ) S,t S,t S,t S,t Let X be an extension of X at t, so score (X ) = c (X ).The set X = X ∩ S S,t S,t satisﬁes X ∩ χ(t ) = X,so c (X ) ≤ score (X ). Symmetrically, for S,t S,t X = X ∩ S it holds that c (X ) ≤ score (X ). S,t S,t There is no element of V (G) \χ(t ) that is adjacent to an element of X \X, other- wise T would not be a valid tree decomposition. Hence N [X ] = N [X ] , and G t G t symmetrically N [X ] = N [X ] . This entails score (X ) = score (X ) G t G t S,t S,t and score (X ) = score (X ). S,t S,t Since N [X ] ∩ S is the union of N [X ] ∩ S and N [X ] ∩ S, and these latter G t G t G t two sets have N [X]∩ χ(t ) ∩ S as their intersection, we can apply the inclusion- exclusion principle to obtain |N [X ] ∩ S|=|N [X ] ∩ S|+|N [X ] ∩ S|− G t G t G t |N [X]∩ χ(t ) ∩ S|. In a similar way, we get |N [X ] \S|=|N [X ] \S|+ G G t G t |N [X ] \S|−|(N [X]∩ χ(t ))\S)|. We can establish score (X ) = score (X ) G t G S,t S,t +score (X )−lscore (X ) by putting these equations together. The inequalities S,t S,t we have derived before now allow us to conclude c (X ) ≥ c (X ) + c (X ) − S,t S,t S,t lscore (X ). S,t Now let X and X be extensions of X at t and at t , respectively. We have that c (X ) = score (X ) and c (X ) = score (X ).The set X = X ∪ X S,t S,t S,t S,t is clearly considered in the deﬁnition of c (X ),so c (X ) ≤ score (X ).Fol- S,t S,t S,t lowing the same reasoning as before, we obtain score (X ) = score (X ) + S,t S,t 123 Algorithmica (2018) 80:2909–2940 2935 score (X ) − lscore (X ). This gives us c (X ) ≤ c (X ) + c (X ) − S,t S,t S,t S,t S,t lscore (X ). Hence c (X ) = c (X ) + c (X ) − lscore (X ). S,t S,t S,t S,t S,t Using these recurrence relations, we can traverse the tree decomposition T in a bottom-up way and compute at each node t of T the value c (X ) for each X ⊆ S,t S ∩ χ(t ). Hence for each node of T we compute at most 2 values, where w is the width of T . By choosing the right data structure for adjacency tests [13, Exercise 7.16], each value can be computed in time O(w ). Since T has O(w·|V (G)|) many nodes and O(w ) T can be computed in ﬁxed-parameter linear time [6], (in fact in time 2 ·|V (G)| as observed by [9]), we thus get an algorithm with ﬁxed-parameter linear running time for checking whether a given set S is secure. Theorem 3 Given a graph G, a tree decomposition of G of weight w and a set w 4 S ⊆ V (G), we can decide in time O(2 · w ·|V (G)|) whether S is secure in G. Our algorithm can easily be adjusted to ﬁnd a witness if S is not secure, i.e., to print a subset of S that has more attackers than defenders. After c has been computed S,t for each t, this can be done via a ﬁnal top-down traversal by a standard technique in dynamic programming on tree decompositions [26]: Alongside each value c (X ), S,t we store the “origin” of this value and recursively combine the origins of c (∅), S,r where r is the root of T . In our deﬁnition of the Secure Set Verification problem, we were only con- cerned with checking whether a set is secure, but we did not mention the additional constructs that we consider in this paper, like complementary vertex pairs or necessary or forbidden vertices. However, these additions pose no difﬁculty at all because we can just check the respective conditions in linear time. 4.3 A Polynomial Algorithm for Secure Set on Bounded Treewidth We now present an algorithm for ﬁnding secure sets, not just verifying whether a given set is secure. Our algorithm works by dynamic programming on a tree decomposition of the input and extends the algorithm from Sect. 4.2. For graphs of bounded treewidth, the algorithm presented in this section runs in polynomial time. However, in contrast to the algorithm in Sect. 4.2, it is not an FPT algorithm since the degree of the polynomial depends on the treewidth. This is to be expected since the problem of ﬁnding secure sets of a certain size is W[1]-hard when parameterized by treewidth, as we have shown in Lemma 8. Our algorithm provides an upper bound for the complexity of this problem, namely membership in the class XP. Let G be a graph with a nice tree decomposition T , and let t be a node of T .In Sect. 4.2, we were given one particular secure set candidate S that we wanted to check, so we only computed one value for each X ⊆ S ∩ χ(t ), namely the lowest score of any X ⊆ S whose intersection with χ(t ) is X. Here, in contrast, we cannot restrict ourselves to only one secure set candidate, and multiple candidates may have the same intersection with χ(t ). We therefore compute multiple objects for each subset of χ(t ), since two subsets of V (G) that have the same intersection with χ(t ) mayhavetobe distinguished due to their subsets having different scores. 123 2936 Algorithmica (2018) 80:2909–2940 Let S ⊆ χ(t ).By F we denote the set of functions from 2 to an integer. Let c ∈ F S S and let k be an integer. We say that a set S ⊆ V (G) is (S, t, c, k)-characterized if |S|= k, S ∩ χ(t ) = S and, for each X ⊆ S, it holds that c(X ) = c (X ), where c S,t S,t is the function deﬁned in Sect. 4.2. For each S ⊆ χ(t ), we now deﬁne the set C ={(c, k) | there is a (S, t, c, k) − characterized set}. S,t When r is the root of T , there is a secure set of size k in G if and only if there is an element (c, k) ∈ C such that c(∅) ≥ 0. To see this, ﬁrst suppose there is a secure ∅,r set S of size k in G. Then there is a function c :{∅} → Z such that S is (∅, r, c, k)- characterized, so (c, k) ∈ C and c(∅) = c (∅), which means that c(∅) is the ∅,r S,r lowest score of any subset of S. Since S is secure in G, this number is nonnegative. For the other direction, let (c, k) ∈ C such that c(∅) ≥ 0. Then there is a (∅, r, c, k)- ∅,r characterized set S, obviously of size k. Since c(∅) ≥ 0, the lowest score of any subset of S is nonnegative, which proves that S is secure in G. We now describe how to compute all such values in a bottom-up manner. Leaf node. If t is a leaf node, its bag is empty and obviously C ={(c, 0)} holds, ∅,t where c maps ∅ to 0. Introduce node. Let t be an introduce node with child t and let v be the unique element of χ(t )\χ(t ). For each S ⊆ χ(t ) and each function c ∈ F , we deﬁne S\{v} a function c ⊕ v : 2 → Z. Its intended purpose is to obtain a version of c that S,t applies to t instead of t .If v ∈ S, we need to increase scores where v can serve as an additional defender, and otherwise we need to decrease scores where v can serve as an additional attacker. We now make this formal. Let S ⊆ χ(t ), X ⊆ S, X = X \{v} and c ∈ F . S\{v} c(X ) +1if v ∈ N [X]∩ S (c ⊕ v)(X ) = c(X ) −1if v ∈ N [X ]\S S,t G c(X ) otherwise For each S ⊆ χ(t ) and each function c ∈ F there is a unique function c ∈ F S S\{v} such that c = c ⊕ v, and we denote c by origin (c). S,t S,t The following statements can be proved by arguments similar to those in Sect. 4.2: Let S ⊆ V (G) , S = S ∩ χ(t ) and (c, k) ∈ C such that S is (S, t , c, k)- t S,t characterized. The set S∪{v} is (S∪{v}, t, c⊕ v, k+1)-characterized and S is S∪{v},t (S, t, c ⊕ v, k)-characterized. Hence (c ⊕ v, k +1) ∈ C and (c ⊕ S,t S∪{v},t S∪{v},t S,t v, k) ∈ C . Conversely, let S ⊆ V (G) , S = S ∩ χ(t ) and (c, k) ∈ C such that S,t t S,t S is (S, t, c, k)-characterized, and let c = origin (c) and k = k −|S ∩{v}|. S,t The set S\{v} is (S\{v}, t , c , k )-characterized. Hence (c , k ) ∈ C . S\{v},t From these observations, the following equation follows for every S ⊆ χ(t ): C ={(c ⊕ v, k +|S ∩{v}|) | (c, k) ∈ C } S,t S,t S\{v},t Forget node. Let t be a forget node with child t and let v be the unique element of χ(t )\χ(t ). For each S ⊆ χ(t ) and each function c ∈ F , we deﬁne a function S∪{v} 123 Algorithmica (2018) 80:2909–2940 2937 c v, and for each S ⊆ χ(t ) and each function c ∈ F , we deﬁne a function S,t ∈ / c v. Each of these functions maps every subset of S to an integer. S,t c v (X ) = min{c(X ), c(X ∪{v})} S,t ∈ / c v (X ) = c(X ) S,t ∈ ∈ / Next we deﬁne functions origin and origin that map each element of F to a S,t S,t set of elements of F and F , respectively: S∪{v} S ∈ ∈ origin (c) = c ∈ F | c = c v S∪{v} S,t S,t ∈ / ∈ / origin (c) = c ∈ F | c = c v S,t S,t The following statements can be proved by arguments similar to those in Sect. 4.2: Let S ⊆ V (G) , S = S ∩ χ(t ) and (c, k) ∈ C such that S is (S, t , c, k)- t S,t ∈ ∈ characterized. If v ∈ S, then S is (S\{v}, t, c v, k)-characterized and (c S,t S,t ∈ / ∈ / v, k) ∈ C ; otherwise S is (S, t, c v, k)-characterized and (c v, k) ∈ S\{v},t S,t S,t C . Conversely, let S ⊆ V (G) , S = S ∩ χ(t ) and (c, k) ∈ C such that S is S,t t S,t (S, t, c, k)-characterized. If v ∈ S, then there is some c ∈ origin (c) such that S S,t is (S ∪{v}, t , c , k)-characterized and (c , k) ∈ C ; otherwise there is some S∪{v},t ∈ / c ∈ origin (c) such that S is (S, t , c , k)-characterized and (c , k) ∈ C . S,t S,t From these observations, the following equation follows for every S ⊆ χ(t ): ∈ ∈ / C = c v, k | (c, k) ∈ C ∪ c v, k | (c, k) ∈ C S,t S∪{v},t S,t S,t S,t Join node. Let t be a join node with children t , t such that χ(t ) = χ(t ) = χ(t ). For each S ⊆ χ(t ), and each c , c ∈ F , we deﬁne a function c ⊗ c , which S S,t maps each subset of S to an integer. (c ⊗ c )(X ) = c (X ) + c (X ) − lscore (X ) S,t S,t Next we deﬁne a function origin that maps each element of F to a subset of S,t F × F : S S origin (c) ={(c , c ) ∈ F × F | c = c ⊗ c } S S S,t S,t The following statements can be proved by arguments similar to those in Sect. 4.2: Let S ⊆ V (G) , S ⊆ V (G) , S = S ∩ S , (c , k ) ∈ C and (c , k ) ∈ C t t S,t S,t such that S is (S, t , c , k )-characterized and S is (S, t , c , k )-characterized, and let c = c ⊗ c and k = k + k −|S|.The set S ∪ S is (S, t, c, k)- S,t characterized and (c, k) ∈ C . Conversely, let S ⊆ V (G) , S = S ∩ χ(t ) S,t t and (c, k) ∈ C such that S is (S, t, c, k)-characterized. There is some (c , c ) ∈ S,t origin (c) as well as integers k , k such that k = k +k −|S|,theset S∩V (G) is S,t (S, t , c , k )-characterized and S ∩ V (G) is (S, t , c , k )-characterized. Hence (c , k ) ∈ C and (c , k ) ∈ C . S,t S,t 123 2938 Algorithmica (2018) 80:2909–2940 From these observations, the following equation follows for every S ⊆ χ(t ): C ={(c ⊗ c , k + k −|S|) | (c , k ) ∈ C ,(c , k ) ∈ C } S,t S,t S,t S,t We can now traverse the tree decomposition T in a bottom-up way and at each node t of T compute the set C for each S ⊆ χ(t ).Let n denote the number of S,t vertices of G and w denote the width of T . Every element of C is a pair (c, k), S,t where c is a function that maps each subset of S to an integer between −n and n, there are at most 2 subsets of S, and k is an integer between 0 and n. Hence there are at most (2n + 1) · (n + 1) elements of C . Each individual element of C S,t S,t w w can be computed in time O(2 ). Finally, there are at most 2 possible values for S and O(wn) many nodes in T . We thus get an algorithm that takes as input an integer k together with a graph G whose treewidth we denote by w, and determines in time g(w) f (w) · n whether G admits a secure set of size k, where f and g are functions that only depend on w. This algorithm for Exact Secure Set obviously also gives us an algorithm for Secure Set by checking all solution sizes from 1 to k. Finally, we can easily extend it to accommodate complementary vertex pairs as well as necessary and forbidden vertices. Hence we get the following XP membership result: F F Theorem 4 Secure Set, Exact Secure Set, Secure Set , Exact Secure Set , FN FN FNC FNC Secure Set , Exact Secure Set , Secure Set and Exact Secure Set can be solved in polynomial time if the treewidth of the input is bounded by a constant. By keeping track of the origins of our computed values during our bottom-up traversal of the tree decomposition, we can easily adapt the algorithm to ﬁnd solutions if they exist. 5 Conclusion In this work, we have solved a complexity problem in graph theory that, to the best of our knowledge, has remained open since the introduction of secure sets [11] in 2007. We have shown that the problem of deciding whether, for a given graph G and integer k, G possesses a non-empty secure set of size at most k is -complete. We moreover obtained -completeness for seven further variants of this problem. In the second part of this paper, we analyzed the complexity of the Secure Set problem parameterized by the treewidth of the input graph. In particular, we showed that bounded treewidth does not make the problem ﬁxed-parameter tractable unless FPT = W[1]. Nevertheless, we provided a polynomial-time algorithm for ﬁnding secure sets on graphs of bounded treewidth and thus showed membership in the class XP. As a positive result, we could show that the co-NP-complete problem of verify- ing whether a given set is secure can be solved in ﬁxed-parameter linear time when parameterized by treewidth. There are several interesting directions for future research. One open question is which additional restrictions beside bounded treewidth need to be imposed on Secure Set instances to achieve ﬁxed-parameter tractability. On the other hand, the Secure 123 Algorithmica (2018) 80:2909–2940 2939 Set Verification problem may remain FPT for parameters that are less restrictive than treewidth. We showed W[1]-hardness and XP-membership of Secure Set,so a tight bound is still lacking, albeit perhaps more of theoretical interest due to the fact that problems at a certain level of the weft hierarchy generally do not admit faster algorithms than problems at higher levels. To classify a problem as FPT w.r.t. treewidth, a common approach is to express it in monadic second-order logic (MSO) and then invoke Courcelle’s Theorem [12], which immediately proves that the problem is FPT. We showed that Secure Set Verification is FPT, but it is not clear if it can be expressed in MSO. If it cannot, then our FPT result could hint at possible extensions of MSO whose model-checking problem is still FPT. Similarly, we believe that MSO can be extended in such a way that Secure Set can be expressed and that a variant of Courcelle’s Theorem for showing membership in XP instead of FPT holds. Finally, some of our results seem to be transferable to (variants of) the Defensive Alliance problem, so it would be interesting to investigate if some of our reductions and algorithms can help in the study of such related problems. Acknowledgements Open access funding provided by Austrian Science Fund (FWF). This work was supported by the Austrian Science Fund (FWF) projects P25607 and Y698. The authors would like to thank the anonymous referees for their helpful feedback. Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 Interna- tional License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. References 1. Abseher, M., Bliem, B., Charwat, G., Dusberger, F., Woltran, S.: Computing secure sets in graphs using answer set programming. J. Log. Comput. (2015, accepted) 2. Arnborg, S., Corneil, D.G., Proskurowski, A.: Complexity of ﬁnding embeddings in a k-tree. SIAM J. Algebr. Discrete Methods 8(2), 277–284 (1987) 3. Asahiro, Y., Miyano, E., Ono, H.: Graph classes and the complexity of the graph orientation minimizing the maximum weighted outdegree. Discrete Appl. Math. 159(7), 498–508 (2011) 4. Bliem, B., Woltran, S.: Complexity of secure sets. In: Mayr, E.W. (ed.) Revised Papers of the 41st International Workshop on Graph-Theoretic Concepts in Computer Science (WG 2015), June 17–19, 2015, Garching, Germany. Lecture Notes in Computer Science, vol. 9224, pp. 64–77. Springer (2016) 5. Bodlaender, H.L.: A tourist guide through treewidth. Acta Cybern. 11(1–2), 1–21 (1993) 6. Bodlaender, H.L.: A linear-time algorithm for ﬁnding tree-decompositions of small treewidth. SIAM J. Comput. 25(6), 1305–1317 (1996) 7. Bodlaender, H.L.: Discovering treewidth. In: Vojtás, P., Bieliková, M., Charron-Bost, B., Sýkora, O. (eds.) Proceedings of the 31st Conference on Current Trends in Theory and Practice of Computer Science (SOFSEM 2005), January 22–28, 2005, Liptovský Ján, Slovakia. Lecture Notes in Computer Science, vol. 3381, pp. 1–16. Springer (2005) 8. Bodlaender, H.L., Koster, A.M.C.A.: Treewidth computations I. Upper bounds. Inf. Comput. 208(3), 259–275 (2010) 9. Bojanczyk, ´ M., Pilipczuk, M.: Optimizing tree decompositions in MSO. In: Vollmer, H., Vallée, B. (eds.) Proceedings of the 34th Symposium on Theoretical Aspects of Computer Science (STACS 2017), March 8–11, 2017, Hannover, Germany. LIPIcs – Leibniz International Proceedings in Informatics, vol. 66, pp. 15:1–15:13. Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2017) 10. Brewka, G., Eiter, T., Truszczynski, ´ M.: Answer set programming at a glance. Commun. ACM 54(12), 92–103 (2011) 123 2940 Algorithmica (2018) 80:2909–2940 11. Brigham, R.C., Dutton, R.D., Hedetniemi, S.T.: Security in graphs. Discrete Appl. Math. 155(13), 1708–1714 (2007) 12. Courcelle, B.: The monadic second-order logic of graphs I: recognizable sets of ﬁnite graphs. Inf. Comput. 85(1), 12–75 (1990) 13. Cygan, M., Fomin, F.V., Kowalik, Ł., Lokshtanov, D., Marx, D., Pilipczuk, M., Pilipczuk, M., Saurabh, S.: Parameterized Algorithms. Springer, Cham (2015) 14. Dermaku, A., Ganzow, T., Gottlob, G., McMahan, B.J., Musliu, N., Samer, M.: Heuristic methods for hypertree decomposition. In: Gelbukh, A.F., Morales, E.F. (eds.) Proceedings of the 7th Mexican International Conference on Artiﬁcial Intelligence (MICAI 2008), October 27–31, 2008, Atizapán de Zaragoza, Mexico. Lecture Notes in Computer Science, vol. 5317, pp. 1–11. Springer (2008) 15. Dom, M., Lokshtanov, D., Saurabh, S., Villanger, Y.: Capacitated domination and covering: a param- eterized perspective. In: Proceedings of the 3rd International Workshop on Parameterized and Exact Computation (IWPEC 2008), May 14–16, 2008, Victoria, Canada. Lecture Notes in Computer Science, vol. 5018, pp. 78–90. Springer (2008) 16. Downey, R.G., Fellows, M.R.: Parameterized Complexity. Monographs in Computer Science. Springer, New York (1999) 17. Enciso, R.I., Dutton, R.D.: Parameterized complexity of secure sets. Congr. Numer. 189, 161–168 (2008) 18. Lawrence, S., Giles, C.L., Coetzee, F.: Self-organization and identiﬁcation of web communities. IEEE Comput. 35(3), 66–71 (2002) 19. Flum, J., Grohe, M.: Parameterized Complexity Theory. Texts in Theoretical Computer Science. Springer, New York (2006) 20. Haynes, T.W., Hedetniemi, S.T., Henning, M.A.: Global defensive alliances in graphs. Electron. J. Comb. 10 (2003) 21. Ho, Y.Y.: Global Secure Sets of Trees and Grid-Like Graphs. PhD thesis, University of Central Florida, Orlando, FL, USA (2011) 22. Ho, Y.Y., Dutton, R.D.: Rooted secure sets of trees. AKCE Int. J. Graphs Comb. 6(3), 373–392 (2009) 23. Kloks, T.: Treewidth: Computations and Approximations, vol. 842. Lecture Notes in Computer Science. Springer, New York, NY, USA (1994) 24. Kornai, A., Tuza, Z.: Narrowness, pathwidth, and their application in natural language processing. Discrete Appl. Math. 36(1), 87–92 (1992) 25. Marx, D.: Complexity of clique coloring and related problems. Theor. Comput. Sci. 412(29), 3487– 3500 (2011) 26. Niedermeier, R.: Invitation to Fixed-Parameter Algorithms. Oxford Lecture Series in Mathematics and its Applications, vol. 31. Oxford University Press, Oxford (2006) 27. Robertson, N., Seymour, P.D.: Graph minors. III. Planar tree-width. J. Comb. Theory Ser. B 36(1), 49–64 (1984) 28. Szeider, S.: Generalizations of matched CNF formulas. Ann. Math. Artif. Intell. 43(1), 223–238 (2005) 29. Szeider, S.: Not so easy problems for tree decomposable graphs. CoRR, arXiv:1107.1177 (2011) 30. Thorup, M.: All structured programs have small tree-width and good register allocation. Inf. Comput. 142(2), 159–181 (1998) 31. Yero, I.G., Rodríguez-Velázquez, J.A.: Defensive alliances in graphs: a survey. CoRR, arXiv:1308.2096 (2013)
Algorithmica – Springer Journals
Published: Aug 14, 2017
It’s your single place to instantly
discover and read the research
that matters to you.
Enjoy affordable access to
over 18 million articles from more than
15,000 peer-reviewed journals.
All for just $49/month
Query the DeepDyve database, plus search all of PubMed and Google Scholar seamlessly
Save any article or search result from DeepDyve, PubMed, and Google Scholar... all in one place.
Get unlimited, online access to over 18 million full-text articles from more than 15,000 scientific journals.
Read from thousands of the leading scholarly journals from SpringerNature, Elsevier, Wiley-Blackwell, Oxford University Press and more.
All the latest content is available, no embargo periods.
“Hi guys, I cannot tell you how much I love this resource. Incredible. I really believe you've hit the nail on the head with this site in regards to solving the research-purchase issue.”
Daniel C.
“Whoa! It’s like Spotify but for academic articles.”
@Phil_Robichaud
“I must say, @deepdyve is a fabulous solution to the independent researcher's problem of #access to #information.”
@deepthiw
“My last article couldn't be possible without the platform @deepdyve that makes journal papers cheaper.”
@JoseServera
DeepDyve Freelancer | DeepDyve Pro | |
---|---|---|
Price | FREE | $49/month |
Save searches from | ||
Create lists to | ||
Export lists, citations | ||
Read DeepDyve articles | Abstract access only | Unlimited access to over |
20 pages / month | ||
PDF Discount | 20% off | |
Read and print from thousands of top scholarly journals.
Already have an account? Log in
Bookmark this article. You can see your Bookmarks on your DeepDyve Library.
To save an article, log in first, or sign up for a DeepDyve account if you don’t already have one.
All DeepDyve websites use cookies to improve your online experience. They were placed on your computer when you launched this website. You can change your cookie settings through your browser.
ok to continue