# Parameterized and approximation complexity of the detection pair problem in graphs

Florent Foucaud, Ralf Klasing

► To cite this version:

Florent Foucaud, Ralf Klasing. Parameterized and approximation complexity of the detection pair problem in graphs. Journal of Graph Algorithms and Applications, 2017, 21 (6), pp.1039 - 1056. 10.7155/jgaa.00449 . hal-01871140

HAL Id: hal-01871140

https://hal.science/hal-01871140v1

Submitted on 6 Nov 2025

**HAL** is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
<figure><img src="image_2.png" /></figure>

# Parameterized and approximation complexity of the detection pair problem in graphs

Florent Foucaud¹ Ralf Klasing²

¹LIMOS - CNRS UMR 6158 - Université Blaise Pascal, Clermont-Ferrand (France)

²LaBRI - CNRS UMR 5800 - Université de Bordeaux, Talence (France)

## Abstract

We study the complexity of the problem DETECTION PAIR. A detection pair of a graph $G$ is a pair $(W, L)$ of sets of detectors with $W \subseteq V(G)$, the watchers, and $L \subseteq V(G)$, the listeners, such that for every pair $u, v$ of vertices that are not dominated by a watcher of $W$, there is a listener of $L$ whose distances to $u$ and to $v$ are different. The goal is to minimize $|W| + |L|$. This problem generalizes the two classic problems DOMINATING SET and METRIC DIMENSION, that correspond to the restrictions $L = \emptyset$ and $W = \emptyset$, respectively. DETECTION PAIR was recently introduced by Finbow, Hartnell and Young [A. S. Finbow, B. L. Hartnell and J. R. Young. The complexity of monitoring a network with both watchers and listeners. Networks, accepted], who proved it to be NP-complete on trees, a surprising result given that both DOMINATING SET and METRIC DIMENSION are known to be linear-time solvable on trees. It follows from an existing reduction by Hartung and Nichterlein for METRIC DIMENSION that even on bipartite subcubic graphs of arbitrarily large girth, DETECTION PAIR is NP-hard to approximate within a sub-logarithmic factor and $W[2]$-hard (when parameterized by solution size). We show, using a reduction to SET COVER, that DETECTION PAIR is approximable within a factor logarithmic in the number of vertices of the input graph. Our two main results are a linear-time 2-approximation algorithm and an FPT algorithm for DETECTION PAIR on trees.

**Keywords:** Graph theory, Detection pair, Metric dimension, Dominating set, Approximation algorithm, Parameterized complexity

Submitted:
January 2016

Reviewed:
March 2017

Revised:
May 2017

Accepted:
September 2017

Final:
September 2017

Published:
October 2017

Article type:
Regular paper

Communicated by:
G. J. Woeginger

This study has been carried out in the frame of "The Investments for the Future" Programme
IdEx Bordeaux - CPU (ANR-10-IDEX-03-02).

E-mail addresses: florent.foucaud@gmail.com (Florent Foucaud) ralf.klasing@labri.fr (Ralf Klasing)
# 1 Introduction

In order to monitor faults in a network, one can place detectors on its nodes. One possibility is to use “local” devices that are able to detect the location of a fault within distance one (we call them *watchers*). Another kind of detectors, that are more far-reaching, are able to determine the exact distance of a fault to the device, but not its precise location (we call such detectors *listeners*). If we wish to monitor a network by using only watchers, we have the classic problem DOMINATING SET [14, GT2] (see the books [20, 19] for a survey of results on this problem). If, on the other hand, we want to use only listeners, we have the problem METRIC DIMENSION [14, GT61] (see for example the papers [2, 4, 15, 17, 22, 24] and references therein). However, it can be useful to use both kinds of detectors: for example, one watcher is enough to monitor a complete graph of order $n$, while we would need $n-1$ listeners to do so. On the other hand, one listener would suffice to monitor a path of order $n$, but for the same task we would need $\lfloor n/3 \rfloor$ watchers. Therefore, Finbow, Hartnell and Young [12] recently proposed the concept of a *detection pair* in a graph $G$, that is, a pair $(W, L)$ where $W \subseteq V(G)$ is a set of watchers and $L \subseteq V(G)$ is a set of listeners that, together, monitor the graph $G$.

More formally, we say that a vertex $w$ *dominates* all the vertices in the closed neighbourhood $N[w]$ of $w$ (that is, $N[w]$ is the set of neighbours of $w$ together with $w$ itself). Moreover, a vertex $l$ *separates* two vertices $u$ and $v$ if the distance $d(u, l)$ is different from the distance $d(v, l)$. Given a pair $(W, L)$ of sets with $W \subseteq V(G)$ (the watchers) and $L \subseteq V(G)$ (the listeners), we say that a vertex $u$ is *distinguished* by $(W, L)$ either if $u$ is dominated by a watcher of $W$, or if for every other vertex $v$, either $v$ is dominated by a watcher of $W$, or $u$ and $v$ are separated by a listener of $L$. Then, $(W, L)$ is a *detection pair* of $G$ if every vertex of $G$ is distinguished by $(W, L)$. The size of $(W, L)$ is the sum $|W| + |L|$ and is denoted by $|(W, L)|$. Note that we may have $W \cap L \neq \emptyset$ if we choose to place both a listener and a watcher at the same position. We denote by $DP(G)$ the minimum size of a detection pair of $G$. Any vertex of $(W, L)$ is called a *detector*.

If we have a detection pair $(\emptyset, L)$ in a graph $G$, then $L$ is called a *resolving set* of $G$, and the smallest size of a resolving set of $G$ is called its *metric dimension*, denoted $MD(G)$. On the other hand, if we have a detection pair $(W, \emptyset)$, then $W$ is a *dominating set* of $G$, and the smallest size of a dominating set of $G$ is its *domination number*, denoted $\gamma(G)$. Clearly, we have $DP(G) \le \min\{\gamma(G), MD(G)\}$, and the inequality can be strict [12]. It follows that for any graph $G$ without isolated vertices, we have $DP(G) \le \gamma(G) \le |V(G)|/2$ [20].

The goal of this paper is to study the decision and optimization problems that are naturally associated to the notion of a detection pair (other computational problems that are mentioned in this paper are defined formally in Section 2).
**DETECTION PAIR**

*Instance:* A graph *G*, a positive integer *k*.

*Question:* Is there a detection pair (W, L) of G with ||(W, L)|| ≤ *k*?

**OPT-DETECTION PAIR**

*Instance:* A graph *G*.

*Task:* Compute an optimal detection pair of *G*.

A *c*-approximation algorithm for a given optimization problem Π<sub>O</sub> is an algorithm that returns a solution whose size is always at most *c* times the optimum. We refer to the book [1] for more details. For a decision problem Π and for some parameter *p* of the instance, an algorithm for Π is said to be *fixed parameter tractable* (FPT for short) if it runs in time *f(p)n*<sup>*c*</sup>, where *f* is a computable function, *n* is the input size, and *c* is a constant. In this paper we will always consider the solution size *k* as the parameter. We refer to the books [8, 23] for more details.

Finbow, Hartnell and Young proved that DETECTION PAIR is NP-complete on trees [12], while OPT-DETECTION PAIR is linear-time solvable on trees containing no pair of leaves with a common neighbour. This hardness result is quite surprising since the related problems OPT-DOMINATING SET and OPT-METRIC DIMENSION, while being NP-hard in general [14, GT2,GT61], can be solved in linear time on trees (see respectively [5] and [15, 24]). We note that DOMINATING SET is among the most classic and well-studied graph problems (see the books [20, 19]), and that METRIC DIMENSION has enjoyed a lot of interest in the recent years: see the papers [3, 6, 9, 10, 11, 13, 17, 18].

In this paper, we continue the study of the complexity of DETECTION PAIR and OPT-DETECTION PAIR initiated in [12]. In Section 3, we describe a reduction to OPT-SET COVER that shows that OPT-DETECTION PAIR can be solved within a factor logarithmic in the size of the input graph. On the other hand, we observe that a reduction of Hartung and Nichterlein [16, 17] for OPT-METRIC DIMENSION can also be applied to OPT-DETECTION PAIR. This implies that OPT-DETECTION PAIR is NP-hard to approximate within a factor that is sublogarithmic in the input graph's order, and that DETECTION PAIR is W[2]-hard when parameterized by the solution size *k*. (These hardness results hold even for graphs that are bipartite, subcubic, and have arbitrarily large girth.) In Section 4, we prove that OPT-DETECTION PAIR is 2-approximable in linear time on trees. In Section 5, we show that there is an algorithm for DETECTION PAIR running in FPT time 2<sup>O(k log k)</sup>n<sup>2</sup> on trees.<fnref n="1" /> We start the paper with some preliminary considerations in Section 2, and conclude in Section 6.

<footnote n="1">¹In this paper, “log” denotes the natural logarithm function.</footnote>
## 2 Preliminaries

We start with some preliminary considerations.

### 2.1 Definitions of used computational problems

We now formally define a few auxiliary computational problems that are used or mentioned in this paper.

**DOMINATING SET** [14, GT2]

*Instance*: A graph $G$, a positive integer $k$.

*Question*: Do we have $\gamma(G) \le k$, that is, is there a dominating set $D$ of $G$ with $|D| \le k$?

**OPT-DOMINATING SET**

*Instance*: A graph $G$.

*Task*: Compute an optimal dominating set of $G$.

**METRIC DIMENSION** [14, GT61]

*Instance*: A graph $G$, a positive integer $k$.

*Question*: Do we have $MD(G) \le k$, that is, is there a resolving set $R$ of $G$ with $|R| \le k$?

**OPT-METRIC DIMENSION**

*Instance*: A graph $G$.

*Task*: Compute an optimal resolving set of $G$.

**SET COVER** [14, SP5]

*Instance*: A hypergraph $H = (X, S)$, a positive integer $k$.

*Question*: Is there a set cover $C$ of $H$ with $|C| \le k$ (that is, $C \subseteq S$ and each vertex of $X$ belongs to some set of $C$)?

**OPT-SET COVER**

*Instance*: A hypergraph $H$.

*Task*: Compute an optimal set cover of $H$.

### 2.2 Specific terminology

In a graph $G$, a vertex of degree 1 is called a *leaf*. A vertex is called a *branching point* if its degree is at least 3. A branching point $v$ is *special* if there is a path $L$ starting at $v$ and ending at a vertex of degree 1, and whose inner-vertices all have degree 2. Path $L-v$ is called a *leg* of $v$, and we say that $L$ is *attached* to $v$ (note that vertex $v$ does not belong to the leg). A special branching point with $t$ leaves as neighbours is called a *t-stem*.<fnref n="2" />

<footnote n="2">²The previous terminology is from [12] (branching points, stems) and [22] (legs).</footnote>
Given a special branching point $x$ of a tree $T$, we define the subtree $L(x)$ of $T$ as the tree containing $x$ and all legs of $T$ attached to $x$.

## 2.3 The classic algorithm for Opt-Metric Dimension on trees

We will use the following results of Slater [24] about OPT-METRIC DIMENSION on trees, that are classic in the literature about metric dimension. See also [15, 22] for similar considerations.

**Proposition 1 (Slater [24])** Let $T$ be a tree and $R$ be the set of vertices containing, for each special branching point $x$ of $T$ that has $\ell$ legs attached, the leaves of the $\ell - 1$ longest of these legs. Then, $R$ is an optimal resolving set of $T$.

We have the following consequence of Proposition 1.

**Theorem 1 (Slater [24])** OPT-METRIC DIMENSION can be solved optimally in linear time on trees.

## 2.4 Observations and lemmas about detection pairs

The following easy observations and lemmas will be useful.

**Observation 1** Let $G$ be a graph and $B_{2+}$ the set of its special branching points with at least two legs attached. Then, we have $DP(G) \ge |B_{2+}|$.

**Proof:** Let $(W, L)$ be a detection pair of $G$. We show that for each special branching point $x$ of $B_{2+}$, there is at least one detector of $(W, L)$ among $x$ and the vertices belonging to a leg attached to $x$. Indeed, if not, then any two neighbours of $x$ belonging to this set would neither be dominated by a watcher, nor separated by a listener, a contradiction. $\square$

**Lemma 1** Let $x$ be a special branching point of a graph $G$ with a set $S_x$ of t leaf neighbours and a set $\mathcal{L}_x$ of $\ell$ legs of length at least 2 attached to $x$. Let $(W, L)$ be a detection pair of $G$. If there is a watcher at $x$, at least $\ell - 1$ of the legs in $\mathcal{L}_x$ contain a detector of $(W, L)$. Otherwise, at least $t + \ell - 1$ legs attached to $x$ contain a detector.

**Proof:** If there is a watcher at $x$, assume for a contradiction that two legs $L_1$ and $L_2$ of $\mathcal{L}_x$ contain no detector. Then, neither the listeners of $(W, L)$ nor the watcher at $x$ can distinguish the two vertices of $L_1$ and $L_2$ that are at distance 2 from $x$, a contradiction. A similar argument holds for vertices at distance 1 of $x$ when $x$ has no watcher. $\square$

**Lemma 2** Let $G$ be a graph with a special branching point $x$ having a leg attached, whose leaf is $y$. If $G$ has a detection pair $(W, L)$ with $x \in L$, then $(W, L \setminus \{x\} \cup \{y\})$ is also a detection pair of $G$.
**Proof:** Let $V_x$ be the set of vertices containing $x$ and the vertices of the leg attached to $x$ whose leaf is $y$. Clearly, a pair $u, v$ of vertices in $V(G) \setminus V_x$ are separated by $x$ if and only if they are separated by $y$. Moreover, all the vertices in the leg containing $y$ are clearly distinguished, because each such vertex is the unique one with its distance to $y$. This completes the proof. $\square$

## 3 General approximability and non-approximability

In this section, we discuss the general approximation complexity of OPT-DETECTION PAIR.

**Theorem 2** OPT-DETECTION PAIR can be approximated within a factor $2\log n + 1$ on graphs of order $n$.

**Proof:** Given a graph $G$, we build an instance $(X, S)$ of OPT-SET COVER as follows. We let $X$ be the set of vertex pairs of $G$. For each vertex $v$ of $G$, we have a set $W_v$ of $S$ that contains an element $\{x, y\}$ of $X$ if $v$ dominates at least one of $x$ and $y$. We also have a set $L_v$ that contains an element $\{x, y\}$ of $X$ if we have $d(v, x) \neq d(v, y)$. Therefore we have $|X| = \binom{|V(G)|}{2}$ and $|S| = 2|V(G)|$. Now, we claim that we have a one-to-one correspondence between the detection pairs of $G$ and the set covers of $(X, S)$. Indeed, for every vertex $v$ of $G$, the set $W_v$ of $S$ corresponds to a watcher placed at vertex $v$, and the set $L_v$ corresponds to a listener placed at vertex $v$. Moreover set $U_v$ of $S$ (with $U \in \{W, L\}$) covers exactly the elements of $X$ that correspond to a pair that is separated by the according detector placed on $v$ in $G$. Since OPT-SET COVER is approximable within a factor of $\log(|X|) + 1$ in polynomial time [21], the result follows. $\square$

Hartung and Nichterlein [17] provided a reduction from DOMINATING SET to METRIC DIMENSION. This reduction was improved by Hartung in his PhD thesis [16] to get a reduction mapping any instance $(G, k)$ to an instance $(G', k+4)$, where $G'$ is a bipartite graph of maximum degree 3 and has girth $4|V(G)|+6$. In fact, it is not difficult to see that for any detection pair $P$ of $G'$ of size $k'$, there is a detection pair $P'$ of $G'$ of size at most $k'$ containing no watchers. In other words, we have $DP(G') = MD(G')$, and therefore the aforementioned reduction is also a reduction to DETECTION PAIR. Hence we have the following.<fnref n="3" />

**Theorem 3 (Hartung and Nichterlein [16, 17])** OPT-DETECTION PAIR is NP-hard to approximate within a factor of $(1 - \epsilon) \log n$ (for any $\epsilon > 0$) for instances of order $n$, and DETECTION PAIR is $W[2]$-hard (parameterized by the solution size $k$). Let $g \ge 4$ be an arbitrary integer. These results hold even for instances that are bipartite, have maximum degree 3, and girth at least $g$.

<footnote n="3">³Hartung and Nichterlein only state the hardness of approximation for factors in $o(\log n)$, but a recent result on the inapproximability of OPT-SET COVER [7], that transfers to OPT-DOMINATING SET via standard reductions, implies our stronger statement.</footnote>
# 4 A 2-approximation algorithm on trees

In this section, we prove the following approximability result.

**Theorem 4** *There is a linear-time 2-approximation algorithm for OPT-DETECTION PAIR on trees.*

**Proof:** Given an input tree $T$, we denote by $S_{3+}$, the set of vertices of $T$ that are $t$-stems for some $t \ge 3$. Moreover, we define $T'$ as the tree obtained from $T$ as follows. For each vertex $v$ of $S_{3+}$ (that is, $v$ is a $t$-stem for some $t \ge 3$), assuming that there are $\ell$ legs of length at least 2 attached to $v$ in $T$, we remove from $T$: (i) $t-2$ leaf neighbours of $v$ if $\ell = 0$, (ii) $t-1$ leaf neighbours of $v$ if $\ell = 1$, and (iii) all $t$ leaf neighbours of $v$ if $\ell \ge 2$. Therefore, in $T'$, there are at least two legs attached to each vertex of $S_{3+}$.

Let us describe our algorithm $A$.

1. Compute the set $S_{3+}$ and build $T'$ from $T$.

2. Compute an optimal resolving set $R'$ of $T'$.

3. Output $A(T) = (S_{3+}, R')$.

We first prove that $A(T)$ is a detection pair of $T$. Notice that the distances from listeners in $R'$ and vertices of $V(T')$ are the same in $T$ and $T'$. Therefore, all pairs of vertices of $V(T')$ are distinguished in $T$ by the listeners of $A(T)$. On the other hand, all vertices of $V(T) - V(T')$ are dominated by the watchers of $S_{3+}$. Therefore, $A(T)$ is a detection pair of $T$.

Moreover, it is clear that $S_{3+}$ and $T'$ can be computed in linear time, and $R'$ can be computed in linear time using Slater's algorithm (Theorem 1). Therefore $A$ is a linear-time algorithm.

It remains to prove that $||A(T)|| = |S_{3+}| + MD(T') \le 2 \cdot DP(T)$ for any tree $T$. Notice that $A(T)$ contains only vertices that are part of some subtree $L(x)$, where $x$ is a special branching point of $T$; indeed, any vertex of $S_{3+}$ is a special branching point of $T$, and any special branching point of $T'$ is also a special branching point of $T$ (by Proposition 1, any optimal resolving set of $T'$ only contains vertices that belong to some subtree $L(x)$ of $T'$). Therefore, it suffices to prove that for any detection pair $D = (W, L)$ of $T$, for any optimal resolving set $R'$ of $T'$ and for every special branching point $x$ of $T$, we have $|S_{3+} \cap V(L(x))| + |R' \cap V(L(x))| \le 2|W \cap V(L(x))| + 2|L \cap V(L(x))|$. To this end, let us assume that $x$ is a $t$-stem for some $t \ge 0$, and that there are $\ell$ legs of length at least 2 attached to $x$. We distinguish the following cases.

**Case 1:** $\ell \le 1$. Then, $L(x)$ contains at most two detectors of $A(T)$. Indeed, if $t \le 2$, it contains one or two listeners; if $t \ge 3$, it contains one watcher and one listener. By Lemma 1, there is at least one detector in $L(x)$, which completes the proof of this case.

**Case 2:** $\ell \ge 2$. Then, by Lemma 1, any detection pair $(W, L)$ of $T$ has a detector in at least $\ell - 1$ legs of length at least 2 of $L(x)$. If $t \ge 3$ (that is,
$x \in S_{3+})$, $A(T)$ has exactly $\ell - 1$ listeners and one watcher in $L(x)$. Therefore, for any detection pair $(W, L)$ of $T$, we have $2|W \cap V(L(x))| + 2|L \cap V(L(x))| \ge 2\ell - 2 \ge \ell = |S_{3+} \cap V(L(x))| + |R' \cap V(L(x))|$ (because $\ell \ge 2$), and we are done.

Hence, assume that $t \le 2$. Then, $L(x)$ contains only listeners of $A(T)$, that is, precisely $t + \ell - 1$ leaves of $L(x)$ that belong to $R'$. If $t \le 1$, we have $\ell - 1 \ge t$ and then, for any detection pair $(W, L)$ of $T$, we have $2|W \cap V(L(x))| + 2|L \cap V(L(x))| \ge 2\ell - 2 \ge t + \ell - 1 = |S_{3+} \cap V(L(x))| + |R' \cap V(L(x))|$, and we are done. If however, $t = 2$, by Lemma 1, there are at least $\ell$ detectors of $(W, L)$ in $L(x)$. Hence, we have $2|W \cap V(L(x))| + 2|L \cap V(L(x))| \ge 2\ell \ge t + \ell > t + \ell - 1 = |S_{3+} \cap V(L(x))| + |R' \cap V(L(x))|$. This completes the proof. $\square$

There are two infinite families of trees that show that our algorithm has no better approximation ratio than 2.

The first family consists of trees $T_\ell^1$ ($\ell \ge 1$) that are built from $\ell$ disjoint stars with at least three leaves each, all whose centers are adjacent to an additional single vertex. We have $||A(T_\ell^1)|| = 2\ell$ (this solution set contains one watcher and one listener for every star), while $DP(T_\ell^1) \le \ell$ (simply let every center of a star be a watcher, and select no listener). Hence the approximation ratio of $A$ on $T_\ell^1$ is 2.

A second family consists of trees $T_\ell^2$ ($\ell \ge 1$) built from a path $P$ of $\ell + 2$ vertices. For each of the two end-vertices of $P$, add two leaves that are adjacent to this end-vertex. For each degree 2-vertex $v$ of $P$, build a star $S_v$ with three leaves and subdivide one of its edges once. Moreover, the center of $S_v$ is made adjacent to $v$. We have $||A(T_\ell^2)|| = 2\ell + 2$ (each star contains two listeners, and two additional listeners are selected among the four degree 1-vertices adjacent to end-vertices of $P$), while $DP(T_\ell^2) \le \ell + 2$ (put a watcher on each center of a star, and add one neighbour of each endpoint of $P$ as a listener). The approximation ratio of $A$ on $T_\ell^2$ is $2 - \frac{2}{\ell+2}$.

# 5 A fixed parameter tractable algorithm on trees

In this section, we provide an exact algorithm for DETECTION PAIR that is FPT for the natural parameter $k$, the solution size.

The idea of the algorithm is as follows. We first search for a solution with $|L| \le 1$. After this step, we may assume that $|L| \ge 2$, which is a technical condition required for the subsequent steps of the algorithm. Then we proceed in three phases. In the first phase, we handle the solution around the special branching points of the tree. As we will see, there is only a fixed set of possibilities to try for each such branching point. Then, in the second phase, we determine the set of remaining listeners. Here, we are able to compute a set (whose size is bounded in terms of $k$) of possible vertices that may contain a listener in an optimal solution. Finally, in the third phase, we determine the set of remaining watchers, and again we are able to compute a set of vertices (whose
size is bounded in terms of $k$) that may be used as a watcher. The algorithm then checks the validity of each possible choice of these placements.

**Theorem 5** DETECTION PAIR can be solved in time $2^{O(k \log k)} n^2$ on trees of order $n$.

## 5.1 Preliminary lemmas

Before describing the algorithm, we prove a series of lemmas that will be essential.

The first lemma is useful to handle special branching points of the tree, by reducing the problem around these vertices to a fixed number of cases.

**Lemma 3** Let $G$ be a graph with a special branching point $x$ with at least two legs and $(W, L)$ an optimal detection pair of $G$. Let $S_x$ be the set of leaves adjacent to $x$, and let $\mathcal{L}_x$ be the set of legs of length at least 2 attached to $x$. Denote by $V(\mathcal{L}_x)$ the vertices belonging to a leg in $\mathcal{L}_x$, and let $\ell = |\mathcal{L}_x|$ and $t = |S_x|$ (so, $x$ is a t-stem). Then, we can obtain from $(W, L)$ another optimal detection pair of $G$ by replacing all the detectors in $V_x = \{x\} \cup S_x \cup V(\mathcal{L}_x)$ by one of the following sets of detectors:

1. If $\ell \le 1$, we may use:

(a) a single watcher at $x$;

(b) a watcher at $x$, and a listener at the leaf of a longest leg attached to $x$;

(c) if $t + \ell = 2$, a single listener at the leaf of a longest leg attached to $x$.

2. If $\ell \ge 2$, we may use:

(a) a watcher at $x$ and $\ell$ listeners at all leaves of the legs of $\mathcal{L}_x$;

(b) a watcher at $x$ and $\ell - 1$ listeners at all leaves of the legs of $\mathcal{L}_x$ but the shortest one;

(c) if $t \le 1$, $\ell + t$ listeners at all leaves of the legs attached to $x$;

(d) if $t \le 1$, $\ell + t - 1$ listeners at all leaves of the legs attached to $x$, except for a shortest such leg.

**Proof:** Clearly, if there are any watchers among $\{x\} \cup S_x$, we may replace them by a single watcher at $x$ and obtain a valid detection pair. We now distinguish two cases.

**Case 1:** $\ell \le 1$. Then, we have $t \ge 1$. If $V_x$ contained a unique detector of $(W, L)$ that is a watcher, then it must have dominated a leaf neighbour of $x$ (since $t \ge 1$, such a neighbour exists). Then as observed at the beginning of the proof, we may replace this detector by a watcher at $x$, and we are in Case 1(a). If $V_x$ had a unique detector of $(W, L)$ that is a listener, then by Lemma 1 we must have had $t + \ell = 1$. Note that any listener in $V_x$ separates the same set
of pairs of vertices from $V(G) \setminus V_x$. Hence we may replace the existing listener by a listener at the leaf of a longest leg attached to $x$, which separates at least as many vertices as any other listener in $V_x$. Then we are in Case 1(c) and we are done. Hence, we assume that $V_x$ contained at least two detectors of $(W, L)$. Then, using similar arguments one can check that the solution of Case 1(b) yields a valid detection pair of $G$ that is not larger than $(W, L)$.

**Case 2:** $\ell \ge 2$. As observed before, we can replace all watchers in $\{x\} \cup S_x$ by a single watcher at $x$. If $x$ has a watcher, we let $\mathcal{L}_x^+ = \mathcal{L}_x$; otherwise, we let $\mathcal{L}_x^+$ be the set of all legs attached to $x$. Let $\ell^+ = |\mathcal{L}_x^+|$.

By Lemma 1, at least $\ell^+ - 1 \ge 1$ of the legs in $\mathcal{L}_x^+$ contain a detector of $(W, L)$. Assume first that $(W, L)$ contained at least $\ell^+$ detectors of $(W, L)$ on the legs of $\mathcal{L}_x^+$. Then, we replace all such detectors by a listener at the leaf of each leg of $\mathcal{L}_x^+$. Then, any vertex of a leg $L_i$ of $\mathcal{L}_x^+$ is distinguished by its distance to the listener placed at the leaf of $L_i$. Since any listener in $V_x$ separates the same set of pairs in $V(G) \setminus V_x$, we have obtained a valid detection pair that is not larger than $(W, L)$ and we are in Case 2(a) or 2(c).

Suppose now that there are exactly $\ell^+ - 1$ detectors of $(W, L)$ on the legs of $\mathcal{L}_x^+$. We replace these detectors by a listener at the leaf of each of the $\ell^+ - 1$ longest legs of $\mathcal{L}_x^+$. By similar arguments as above, all vertices in $V_x$ that do not belong to the unique leg $L_1$ of $\mathcal{L}_x^+$ without a detector are distinguished. Again, any listener in $V_x$ separates the same set of pairs of $V(G) \setminus V_x$. Hence, if some vertex is not distinguished by the new detection pair, it must be a vertex $u$ of $L_1$ that is not separated from a vertex $v$ of $V(G) \setminus V_x$. This implies that $d(u, x) = d(v, x)$ (otherwise $u$ and $v$ would be separated by any of the listeners placed in $V_x$). We know that $u$ and $v$ were separated by some detector of $(W, L)$, which must have been a detector in the leg $L_1$ (no detector in another leg of $\mathcal{L}_x^+$ could possibly separate $u$ and $v$ since $d(u, x) = d(v, x)$). But we know that there was one leg $L_2$ of $\mathcal{L}_x^+$ that contained no detector of $(W, L)$. Since $L_1$ is a shortest leg of $\mathcal{L}_x^+$, there is a vertex $u'$ in $L_2$ with $d(x, u) = d(x, u')$. But then, $u'$ and $v$ were not distinguished by $(W, L)$, a contradiction. Hence we have a valid detection pair whose size is not greater than $||(W, L)||$ and we are in Case 2(b) or 2(d), and we are done. $\square$

The next two lemmas are used in our algorithm to choose the placement of the listeners.

**Lemma 4** Let $G$ be a graph with two vertices $u$ and $v$ connected by a unique path $P$. Let $V(P^+)$ be the set of vertices of $P$ together with the vertices of each leg attached to an inner-vertex of degree 3 of $P$. Then, by placing listeners on $u$ and on $v$, all vertices of $V(P^+)$ are distinguished (by $u$ and $v$).

**Proof:** For every vertex $x$ of $G$, we let $\delta_{u,v}(x) = d(u, x) - d(v, x)$. Note that if for two vertices $x$ and $y$, $\delta_{u,v}(x) \ne \delta_{u,v}(y)$, then $x$ and $y$ are separated by $u$ and $v$.

Clearly, $u$ and $v$ are distinguished. Let $w$ be a vertex of $V(P^+) \setminus \{u, v\}$, and assume for a contradiction that there is some vertex $z$ with $d(u, w) = d(u, z)$ and $d(v, w) = d(v, z)$. In particular, $\delta_{u,v}(w) = \delta_{u,v}(z)$.
Note that for every two vertices $p, q$ of $P$, we have $\delta_{u,v}(p) \neq \delta_{u,v}(q)$, therefore at most one of the vertices $w$ and $z$ can belong to $P$. We assume w.l.o.g. that $z$ does not belong to $P$.

The shortest paths from $z$ to both $u$ and $v$ must go through an inner-vertex of $P$, say $s$. Then, we have $\delta_{u,v}(z) = \delta_{u,v}(s) = \delta_{u,v}(w)$, which implies that all shortest paths from $w$ to $u$ and $v$ also go through $s$. But then, we have $d(w, s) = d(z, s)$, a contradiction because by the structure of $V(P^+)$ this implies that $w = z$. $\square$

**Lemma 5** Let $G$ be a graph with two vertices $u$ and $v$ connected by a unique path $P$, such that each inner-vertex of $P$ has either degree 2 or a single leg attached. Moreover let $V(P^+)$ be the set of inner-vertices of $P$ together with the vertices of each leg attached to an inner-vertex of degree 3 of $P$. Then, for every detection pair $(W, L)$ of $G$, one can obtain a valid detection pair of $G$ by replacing all detectors of $(W \cup L) \cap V(P^+)$ by two listeners at $u$ and $v$.

**Proof:** By Lemma 4, all vertices in $V(P^+)$ are distinguished by $u$ and $v$. Note that no watcher of $V(P^+)$ could possibly distinguish any vertex outside of $V(P^+) \cup \{u, v\}$ (and $u, v$ are clearly distinguished). Furthermore, since $P$ is the unique path connecting $u$ and $v$, for any listener $l \in L$ in $V(P^+)$, the set of pairs in $V(G) \setminus V(P^+)$ separated by $l$ is the same as the set of pairs separated by $u$ (and by $v$). This completes the proof. $\square$

The next lemma will be used in the algorithm to determine the placement of watchers in parts of the tree where there is no listener.

**Lemma 6** Let $T$ be a tree with a vertex $x$ and an optimal detection pair $(W, L)$ of $T$ with $|L| \ge 1$. Let $T_x$ be a subtree of $T$ containing $x$ and assume that (i) $T_x$ contains no $t$-stems for any $t \ge 2$, (ii) for each listener $l$ of $L$ and each vertex $v$ of $T_x$, the shortest path from $l$ to $v$ goes through $x$ (in particular $T_x - x$ contains no listener) and (iii) $T_x$ is maximal with respect to (i) and (ii). Then, there is a set $X$ of size at most $63|W|^2$ with $W \cap V(T_x) \subseteq X$. Moreover, $X$ can be determined in time linear in $|V(T_x)|$.

**Proof:** We may view $T_x$ as a rooted tree whose root is $x$. Consider the partition $\mathcal{P}$ of $V(T_x)$ into parts $P_0, P_1, \dots, P_d$ where $P_i$ contains the vertices of $V(T_x)$ that have distance $i$ to $x$. Since $|L| \ge 1$ and by (ii) all shortest paths from any listener of $L$ to a vertex of $T_x$ go through $x$, the set $L$ of listeners separates a pair $u, v$ of $V(T_x)$ if and only if $u$ and $v$ belong to different parts of $\mathcal{P}$. Therefore, since $(W, L)$ is a detection pair of $G$, for any two distinct vertices $u$ and $v$ from the same part $P_i$, at least one of $u, v$ is dominated by a watcher of $W$.

Let $S_{2+}$ be the set of parts of $\mathcal{P}$ of size at least 2 (that is, those parts where at least one vertex must be dominated by a watcher). Let $\tilde{F}_x$ be the forest induced by the set of vertices of $T_x$ that belong to some part of $S_{2+}$, together with their neighbours in $T_x$. We let $X = V(\tilde{F}_x)$, and we shall prove that $X$ satisfies the claim. First, we show that $(W \cap V(T_x)) \subseteq X$. Assume by contradiction that this is not the case, and let $w$ be a watcher of $W$ that belongs to $V(T_x) \setminus X$. By
the optimality of $(W, L)$, $(W \setminus \{w\}, L)$ is not a detection pair of $T$. Therefore, there must be some vertex $u$ dominated by $w$ that is not separated by $L$ from some other vertex $v$ (and $v$ is not dominated by a watcher of $W \setminus \{w\}$). In other words, for every listener $l \in L$, we have $d_T(u, l) = d_T(v, l)$. Thus, since $T$ is a tree, all shortest paths from $l$ to both $u$ and $v$ have a common part (say from $l$ until some vertex $y$) and then are disjoint. By (iii), $T_x$ is maximal with respect to (i) and (ii), which implies that $y = x$ and both $u$ and $v$ belong to $T_x$. However, observe that $u$ belongs to a part of $S_{2+}$ (otherwise $w$ would belong to $X$). Therefore, $u$ is uniquely determined (within $T_x$) by its distance to $x$. Since $|L| \ge 1$ and by (ii), this implies that $u$ and $v$ are in fact distinguished by $L$, a contradiction.

Thus, we have shown that $W \cap V(T_x) \subseteq X$. It is moreover clear that $X$ can be computed in time linear in $|V(T_x)|$ by using the distances of the vertices of $T_x$ to $x$. Therefore, it remains only to bound the size of $X$.

First, we show that $\tilde{F}_x$ contains vertices of at most $9|W|$ distinct parts of $\mathcal{P}$. To each part $P_i$ of $S_{2+}$, we can associate the two parts $P_{i-1}$ and $P_{i+1}$, that may have vertices in $\tilde{F}_x$ but that may not be in $S_{2+}$. Hence, the total number of parts with a vertex in $\tilde{F}_x$ is at most $3|S_{2+}|$. Since a watcher may dominate vertices from at most three parts of $S_{2+}$ and each part in $S_{2+}$ has at least one vertex dominated by a watcher, we have $|S_{2+}| \le 3|W|$, hence $\tilde{F}_x$ contains vertices of at most $9|W|$ distinct parts of $\mathcal{P}$.

Second, we prove that $\tilde{F}_x$ has at most $|W| + 2|S_{2+}| \le 7|W|$ leaves. Note that a leaf of $\tilde{F}_x$ is either an actual leaf in $T$, or it is a vertex of a part $P_i$ with $|P_i| = 1$ (or both). We claim that $\tilde{F}_x$ can contain at most $|W|$ leaves of $T$ belonging to a part of $S_{2+}$. Indeed, each such leaf must be dominated by a watcher, but it can be dominated only by itself or by its parent in $T_x$. But since by (i) there are no $t$-stems for $t \ge 2$ in $T_x$, no parent can dominate more than one leaf, which proves the bound. Furthermore, $\tilde{F}_x$ contains vertices from at most $2|S_{2+}|$ parts of $\mathcal{P}$ of size 1, hence the number of leaves of $\tilde{F}_x$ that are not in a part of $|S_{2+}|$ is at most $2|S_{2+}| \le 6|W|$ since $|S_{2+}| \le 3|W|$. Hence in total, we have at most $7|W|$ leaves in $\tilde{F}_x$.

But any rooted forest with at most $9|W|$ levels and with at most $7|W|$ leaves may have at most $63|W|^2$ vertices, hence $X = V(\tilde{F}_x)$ has size at most $63|W|^2$. This completes the proof. $\square$

## 5.2 The algorithm (proof of Theorem 5)

We now describe the claimed FPT algorithm for DETECTION PAIR on trees and prove its correctness and running time.

**Proof:** [Proof of Theorem 5] Let us describe the algorithm, that seeks to build a detection pair $(W, L)$ with at most $k$ detectors of an input tree $T$ of order $n$.

**Preliminary phase: Searching for a solution with $|L| \le 1$.** A first step of the algorithm is to check whether there is a solution with $|L| \le 1$. If we set $L = \emptyset$, the problem is equivalent to finding a dominating set of $T$ of size at most
k. This can be done in linear time [5]. If we set $|L| = 1$, one may try the $n$ possibilities for the placement of the unique listener. For each possibility (say we have placed the listener at vertex $v$), we create a subtree $T_v$ of $T$ rooted at $v$ as follows. First of all, let $T_v = T$. Then, for each $t$-stem $x$ of $T$ with $t \ge 2$ (except if $v$ is a leaf attached to $x$ and $x$ is a $2$-stem), we may assume that $x$ belongs to $W$ (by a similar argument as in the proof of Lemma 3, Cases 1a and 2a.). Thus, we add $x$ to $W$ and we remove from $T_v$ all leaves but one that are attached to $x$ (if $v$ is one such leaf, we keep $v$ in $T_v$). Now $T_v$ has no $t$-stems for $t \ge 2$ and we can apply Lemma 6. Thus, there is a set $X$ of at most $63k^2$ vertices that may contain a watcher ($X$ is computable in linear time). Then, it suffices to try all the possibilities of selecting $k - |W| - 1$ additional watchers from this set. There are at most $\binom{63k^2}{k} \in O(2^{O(k \log k)})$ such possibilities. For each of them, we check in linear time whether we have a valid detection pair. In total this phase takes $2^{O(k \log k)}n^2$ time. If we find a valid solution in this phase, we return YES.

Next, we assume that $|L| \ge 2$ and proceed in three phases.

**Phase 1: Handling the special branching points.** We now do a preprocessing step using Lemma 3. First compute (in linear time) the set of special branching points of $T$, and let $B_{2+}$ be the set of those special branching points that have at least two legs attached. Note that by Observation 1, if $|B_{2+}| > k$ we can return NO. Hence, assume that $|B_{2+}| \le k$. Now, for each special branching point $x$ of $B_{2+}$, by Lemma 3 we can assume that there are at most four different choices for the set of detectors on $x$ and the vertices belonging to a leg attached to $x$. Therefore, we may go through each of the possible combinations of these choices; there are at most $4^k$ of them. Of course we discard the choices for which there are more than $k$ detectors. For a combination $C_i$, Let $(W_i, L_i)$ be the partial detection pair corresponding to $C_i$. In the remainder, we show how to decide whether there is a detection pair $(W, L)$ of $T$ with $W_i \subseteq W$, $L_i \subseteq L$ and $|(W, L)| \le k$.

**Phase 2: determining the set of listeners.** Let $V_i^*$ be the set of vertices of $T$ containing, for each pair $u, v$ of listeners of $L_i$, all the vertices of the path $P_{uv}$ connecting $u$ and $v$, as well as all the vertices of each leg of $T$ attached to a degree 3 inner-vertex of $P_{uv}$. By Lemma 4, all the vertices in $V_i^*$ are distinguished by $(W_i, L_i)$. Clearly, the subgraph $T_i^* = T[V_i^*]$ of $T$ is a connected subtree. Let $X = \{x_1, \dots, x_p\}$ be the set of vertices in $V_i^*$ that have a neighbour in $T - T_i^*$. For each vertex $x_j$ of $X$, we let $T_{x_j}$ be the subtree of $T$ formed by $x_j$ together with all trees of $T - T_i^*$ containing a neighbour of $x_j$. Let $\mathcal{F}$ be the forest consisting of all trees $T_{x_j}$ ($1 \le j \le p$) such that at least one vertex of $T_{x_j}$ is not distinguished by $(W_i, L_i)$. Next, we upper-bound the size of $\mathcal{F}$.

**Claim 1** If there is a detection pair $(W, L)$ of $T$ with $W_i \subseteq W$, $L_i \subseteq L$ and $|(W, L)| \le k$, then $|\mathcal{F}| \le k$.

*Proof of claim.* We prove that each tree of $\mathcal{F}$ must contain a detector of $(W, L)$. Assume for contradiction that there is a tree $T_{x_a}$ of $\mathcal{F}$ such that no detector of
(W, L) belongs to $T_{x_a}$. By definition, $T_{x_a}$ contains a vertex $w$ not distinguished by $(W_i, L_i)$, hence there is a vertex $w'$ of $T - T_i^*$ (say, $w' \in T_{x_b}$) not separated by any listener of $L_i$ and none of $w$, $w'$ is dominated by a watcher of $W_i$. Then, $w'$ must belong to $T_{x_a}$ (hence $a = b$), indeed by definition of $T_i^*$ there are two listeners $u$ and $v$ of $L_i$ whose path contains $x_a$ and $x_b$. But then, if $a \neq b$, clearly $u$ and $v$ would separate $w$ and $w'$, a contradiction. But since $w$ and $w'$ both belong to $T_{x_a}$, no listener outside of $T_{x_a}$ can separate them, and clearly no watcher outside of $T_{x_a}$ can dominate them, which proves the claim. (□)

By Claim 1, if we have $|\mathcal{F}| > k$, we can discard the combination $C_i$; hence, we assume that $|\mathcal{F}| \le k$.

Now, from each tree $T_{x_j}$ of $\mathcal{F}$, we build the subtree $\widehat{T_{x_j}}$ of $T_{x_j}$ as follows: (i) remove all legs in $T_{x_j}$ whose closest special branching point has only one leg attached; (ii) remove each leaf of $T_{x_j}$ that is adjacent to a watcher of $W_i$. We also denote by $\widehat{\mathcal{F}}$ the forest containing each tree $\widehat{T_{x_a}}$ with $T_{x_a} \in \mathcal{F}$. We next claim the following.

**Claim 2** If there is a detection pair (W, L) of T with $W_i \subseteq W$, $L_i \subseteq L$ and $k_a$ detectors on $T_{x_a}$, then $\widehat{T_{x_a}}$ has at most $2k_a$ leaves.

*Proof of claim.* Let us consider the legs of $\widehat{T_{x_a}}$ containing no detector of $(W_i, L_i)$. By (i) of the construction of $\widehat{T_{x_a}}$, such a leg must be attached to a special branching point having at least two legs attached. (Note that operation (i) did not create any new special branching point.) Moreover, by (ii), if this leg has length 1 in $\widehat{T_{x_a}}$, its unique vertex will not be dominated by a watcher, since the set of detectors on this leg and its special branching point are determined by the combination $C_i$. Note that in (ii), if we create a new leg, this leg contains a detector (a watcher).

Let $v$ be a special branching point of $\widehat{T_{x_a}}$ and let $\mathcal{L}_v$ be the set of legs in $\widehat{T_{x_a}}$ attached to $v$ that do not contain any detector of $(W_i, L_i)$. By the previous discussion, we have $|\mathcal{L}_v| \ge 2$. If some leg of $\mathcal{L}_v$ has length 1, as we observed there will be no watcher on $v$. Hence, in order to separate all the neighbours of $v$ on the legs of $\mathcal{L}_v$, we need a detector in at least $|\mathcal{L}_v| - 1 \ge |\mathcal{L}_v|/2$ of these legs. Otherwise, we still need that many detectors in order to separate all the vertices at distance 2 of $v$ on the legs of $\mathcal{L}_v$. Hence, at most half of the leaves of $\widehat{T_{x_a}}$ belong to a leg with no detector, which proves the claim. (□)

By Claim 2, $\widehat{T_{x_j}}$ has at most $2k_j$ leaves (where $k_j$ is the set of detectors placed on $T_{x_j}$). Therefore, if the total number of leaves in the forest $\widehat{\mathcal{F}}$ is more than $2k$, we can discard the current combination $C_i$. Hence, we can assume that the total number of leaves in $\widehat{\mathcal{F}}$ is at most $2k$.

Therefore, the total number of vertices of degree at least 3 in $\widehat{\mathcal{F}}$ is at most $2k$. Let us consider the sets of maximal threads in $\widehat{\mathcal{F}}$ (that is, paths with inner-vertices of degree 2). The endpoints of such threads are vertices of degree 1 or at least 3 in $\widehat{\mathcal{F}}$, and therefore the number of such threads is at most the number of these vertices, which is upper-bounded by $4k$.
Each such thread $P_{uv}$ between two vertices $u$ and $v$ of a tree $\widetilde{T}_{x_j}$ of $\hat{\mathcal{F}}$, corresponds (in $T_{x_j}$) to a path whose inner-vertices either have a single leg attached, or contain a watcher of $W_i$ with a set of leaves attached. Hence, we may assume that $P_{uv}$ contains at most two listeners: if it contained more than two, by Lemma 5, we could replace them with the two endpoints $u$ and $v$ of $P_{uv}$. Moreover, if $P_{uv}$ contained exactly one listener, similarly we may assume it is placed on one of the endpoints of $P_{uv}$. Indeed, since $|L| \ge 2$, there will be another listener in the solution set. If this listener is closer to $u$, similarly as in Lemma 4, a listener on $v$ would distinguish all vertices on $V(P_{uv}^+)$ (where $V(P_{uv}^+)$ contains all vertices of $P_{uv}$ and the vertices of legs attached to inner-vertices of $P_{uv}$). Moreover, the set of pairs of vertices outside of $V(P_{uv}^+)$ separated by $u$ and by $v$ are the same. Note that by Lemma 2, if we choose to place a listener on an endpoint $u$ of a path $P_{uv}$ that is a thread in $\widetilde{T}_{x_j}$ and this endpoint has a leg attached, instead of placing the listener on $u$ we can instead place the listener on the leaf of this leg.

Therefore, for each thread $P_{uv}$ of $\widetilde{T}_{x_a}$, there are four possibilities for the placement of the listeners: a listener on both $u$ and $v$ (or the leaf of a corresponding leg attached to $u$ or $v$); a single listener at $u$; a single listener at $v$; no listener. There are therefore at most $4^{4k}$ possibilities to guess the placement of listeners on tree $T_{x_a}$. For each such placement $P_j$, we obtain a set $L_j$ of listeners (of course, if $||(W, L_i \cup L_j)|| > k$ we do not consider this placement). Now, we can assume that $L = L_i \cup L_j$, that is, that there will be no more listeners in the sought solution $(W, L)$. Hence, it remains to check whether we can obtain a valid solution of size $k$ by only adding watchers.

**Phase 3: Determining the set of watchers.** We compute a tree $T_{i,j}^*$ similarly as $T_i^*$ but using the new set $L_i \cup L_j$ of listeners. Similarly as before, we define the set $X'$ of vertices of $T_{i,j}^*$ having a neighbour in $T - T_{i,j}^*$, and the set of trees $T'_{x_j}$. We also let $\mathcal{F}'$ be the forest containing those trees $T'_{x_j}$ that have at least one vertex not distinguished by $(W_i, L_i \cup L_j)$. We know that for each tree $T'_{x_j}$ of $\mathcal{F}'$, we will use only watchers to distinguish the vertices not yet distinguished. For each tree $T'_{x_j}$ in $\mathcal{F}'$, let $\widetilde{T}'_{x_j}$ be the tree obtained from $T'_{x_j}$ by removing all leaves already dominated by a watcher of $W_i$. If this process has created a $t$-stem with $t \ge 2$, then at least $t-1$ leaf neighbours of this $t$-stem have a watcher of $W_i$; simply remove them. Then, the obtained tree $\widetilde{T}'_{x_j}$ has no $t$-stems with $t \ge 2$. Hence, we can apply Lemma 6 to $\widetilde{T}'_{x_j}$ (if necessary, we augment $\widetilde{T}'_{x_j}$ to satisfy the maximality condition (iii) in Lemma 6). Thus, there is a set $X_j$ of at most $63k^2$ vertices of $\widetilde{T}'_{x_j}$ that may possibly contain a watcher, and $X_j$ can be computed in time linear in $|V(\widetilde{T}'_{x_j})|$. As before, there are at most $k$ trees in $\mathcal{F}'$ and hence in total the set $X = \cup_j X_j$ of possible placements for the remaining watchers has size at most $63k^3$ (and is computable in linear time). Therefore, we can check all the $\binom{63k^3}{k} \in O(2^{O(k \log k)})$ possibilities of placing the remaining watchers. If we find a valid detection pair $(W, L)$ with $W_i \subseteq W$, we return YES; otherwise, we discard the placement $P_j$ and move on to the next possibility.
It is clear, by the lemmas used in the description in the algorithm, that
this algorithm is correct. The running time of the preliminary phase is
$2^{O(k \log k)} n^2$. The running time of Phases 1 to 3 is at most $4^k 4^{4k} 2^{O(k \log k)} n$
which is $2^{O(k \log k)} n$. This completes the proof. $\square$

# 6 Conclusion

We have obtained a linear-time 2-approximation algorithm for OPT-DETECTION PAIR on trees, but perhaps this algorithmic upper bound could be improved to a PTAS? It seems that the reduction of [12] does not show the inapproximability of OPT-DETECTION PAIR for any constant greater than one. Therefore, it remains to settle the exact approximation complexity of OPT-DETECTION PAIR on trees.

As a second question, can the factor $2^{O(k \log k)}$ in our FPT algorithm for DETECTION PAIR be improved to single-exponential FPT time $2^{O(k)}$ (or even sub-exponential time $2^{o(k)}$)? For this, the bottleneck is our use of Lemma 6 in the preliminary phase and in Phase 3 of the algorithm, during which we search through all possible subsets of size *k* of some sets of size *O*(k²) and *O*(k³), respectively. Moreover, it is perhaps possible to obtain a linear running-time (in terms of *n*) by reducing the running-time of the preliminary phase.

As an extension of our results, it would be of interest to determine whether,
on further graph classes, OPT-DETECTION PAIR is constant-factor approximable
and whether DETECTION PAIR is FPT. One natural research direction is to
consider the class of planar graphs or its subclasses, the outerplanar graphs and
the series-parallel graphs (that is, graphs of treewidth 2). These three classes
contain all trees. Although both questions are settled in the affirmative for OPT-
DOMINATING SET and DOMINATING SET (see [19] and [8, 23]), as far as we know
they also remain open for OPT-METRIC DIMENSION and METRIC DIMENSION
(though, a polynomial-time algorithm exists for OPT-METRIC DIMENSION on
outerplanar graphs [6]).

**Acknowledgements.** We thank the anonymous referees for their careful reading and valuable comments. We wish to thank Bert L. Hartnell for sharing the manuscript [12] with us.
## References

[1] G. Ausiello, P. Crescenzi, G. Gambosi, V. Kann, A. Marchetti-Spaccamela, and M. Protasi. *Complexity and approximation*. Springer, 1999. doi: 10.1007/978-3-642-58412-1.

[2] R. F. Bailey and P. J. Cameron. Base size, metric dimension and other invariants of groups and graphs. *Bulletin of the London Mathematical Society*, 43(2):209–242, 2011. doi:10.1112/blms/bdq096.

[3] R. Belmonte, F. V. Fomin, P. A. Golovach, and M. S. Ramanujan. Metric dimension of bounded width graphs. In G. F. Italiano, G. Pighizzini, and D. T. Sannella, editors, *Mathematical Foundations of Computer Science 2015: 40th International Symposium, MFCS 2015*, pages 115–126. Springer, 2015. doi:10.1007/978-3-662-48054-0_10.

[4] G. Chartrand, L. Eroh, M. A. Johnson, and O. R. Oellermann. Resolvability in graphs and the metric dimension of a graph. *Discrete Applied Mathematics*, 105(1):99–113, 2000. doi:10.1016/S0166-218X(00)00198-0.

[5] E. Cockayne, S. Goodman, and S. Hedetniemi. A linear algorithm for the domination number of a tree. *Information Processing Letters*, 4(2):41–44, 1975. doi:10.1016/0020-0190(75)90011-3.

[6] J. Díaz, O. Pottonen, M. Serna, and E. J. van Leeuwen. On the complexity of metric dimension. In L. Epstein and P. Ferragina, editors, *Algorithms – ESA 2012: 20th Annual European Symposium*, pages 419–430. Springer, 2012. doi:10.1007/978-3-642-33090-2_37.

[7] I. Dinur and D. Steurer. Analytical approach to parallel repetition. In *Proceedings of the 46th Annual ACM Symposium on Theory of Computing*, STOC '14, pages 624–633. ACM, 2014. doi:10.1145/2591796.2591884.

[8] R. G. Downey and M. R. Fellows. *Fundamentals of Parameterized Complexity*. Springer, 2013. doi:10.1007/978-1-4471-5559-1.

[9] D. Eppstein. Metric dimension parameterized by max leaf number. *Journal of Graph Algorithms and Applications*, 19(1):313–323, 2015. doi:10.7155/jgaa.00360.

[10] L. Epstein, A. Levin, and G. J. Woeginger. The (weighted) metric dimension of graphs: Hard and easy cases. *Algorithmica*, 72(4):1130–1171, 2015. doi:10.1007/s00453-014-9896-2.

[11] H. Fernau, P. Heggernes, P. van't Hof, D. Meister, and R. Saei. Computing the metric dimension for chain graphs. *Information Processing Letters*, 115(9):671–676, 2015. doi:10.1016/j.ipl.2015.04.006.

[12] A. S. Finbow, B. L. Hartnell, and J. R. Young. The complexity of monitoring a network with both watchers and listeners. *Networks*, accepted.
[13] F. Foucaud, G. B. Mertzios, R. Naserasr, A. Parreau, and P. Valicov. Identification, location-domination and metric dimension on interval and permutation graphs. ii. algorithms and complexity. *Algorithmica*, 78(3):914–944, 2017. doi:10.1007/s00453-016-0184-1.

[14] M. R. Garey and D. S. Johnson. *Computers and intractability: a guide to the theory of NP-completeness*. W. H. Freeman, 1979.

[15] F. Harary and R. A. Melter. On the metric dimension of a graph. *Ars Combinatoria*, 2:191–195, 1976.

[16] S. Hartung. *Exploring parameter spaces in coping with computational intractability*. PhD thesis, Technische Universität Berlin, Germany, 2014. doi:10.14279/depositonce-3922.

[17] S. Hartung and A. Nichterlein. On the parameterized and approximation hardness of metric dimension. In *2013 IEEE Conference on Computational Complexity (CCC)*, pages 266–276, 2013. doi:10.1109/CCC.2013.36.

[18] M. Hauptmann, R. Schmied, and C. Viehmann. Approximation complexity of metric dimension problem. *Journal of Discrete Algorithms*, 14(Supplement C):214 – 222, 2012. doi:10.1016/j.jda.2011.12.010.

[19] T. W. Haynes, S. T. Hedetniemi, and P. J. Slater, editors. *Domination in graphs: advanced topics*. Marcel Dekker, 1998.

[20] T. W. Haynes, S. T. Hedetniemi, and P. J. Slater. *Fundamentals of Domination in Graphs*. Marcel Dekker, 1998.

[21] D. S. Johnson. Approximation algorithms for combinatorial problems. *Journal of Computer and System Sciences*, 9(3):256 – 278, 1974. doi:10.1016/S0022-0000(74)80044-9.

[22] S. Khuller, B. Raghavachari, and A. Rosenfeld. Landmarks in graphs. *Discrete Applied Mathematics*, 70(3):217 – 229, 1996. doi:10.1016/0166-218X(95)00106-2.

[23] R. Niedermeier. *Invitation to fixed-parameter algorithms*. Oxford University Press, 2006.

[24] P. J. Slater. Leaves of trees. *Congressus Numerantium*, 14:549–559, 1975.