Deleting edges to restrict the size of an epidemic in temporal networks

A variety of potentially disease-spreading contact networks can be naturally modeled with graphs whose structure is subject to discrete changes over time, i.e. with temporal graphs. In such a temporal graph, vertices represent meaningful entities (such as animals or farms) and edges represent potentially infectious contacts between those entities. Furthermore the `availability' of an edge $e$ at time $t$ means that, at time $t$, the entities at the endpoints of $e$ are in contact. In this paper, motivated by network epidemiology applications in the dynamics of disease spreading on a data-derived network, we study the problem of deleting edges and/or edge availabilities from a given temporal graph in order to reduce its (temporal) connectivity. In particular, our aim is to find a temporal subgraph, in which the potential disease of any vertex $u$ can be transferred to only a limited number of other vertices $v$ using a temporal path (i.e. a path from $u$ to $v$, along which the times of the edge availabilities increase). We introduce two natural deletion problems for temporal graphs (for deletion of edges and of edge availabilities, respectively) and we provide positive and negative results on their computational complexity, both in the traditional and the parameterized sense, subject to various natural parameters.


Introduction and motivation
Network epidemiology tries to understand the dynamics of disease spreading over a network, and has become an increasingly popular method for modeling real-world diseases. The rise of network epidemiology is supported by the plethora of contact network datasets which can naturally be encoded as networks (or graphs), with vertices and edges: typically, a vertex represents some entity that infects or can be infected (such as individual humans and animals, or groups of these such as cities and farms) and an edge represents potentially infectious contacts between those entities. However, in most of the real-life scenarios, from which these contact network datasets are generated, the notion of time plays a crucial role that has been, so far, mostly neglected in theoretical studies. In fact, some contacts between entities may occur more often than others, and thus equally modeling every contact with one static edge may obscure the effect that a disease may have in a real-world contact network. Such situations are better captured by graphs that are subject to discrete changes over time, in the sense that their "contacts" (i.e. edge availabilities) vary over time.
In this paper we adopt a simple and natural model for such time-varying networks which is given with time-labels on the edges of a graph, while the vertex set remains unchanged. This formalism originates in the foundational work of Kempe et al. [27].
Definition (temporal graph). A temporal graph is a pair (G, λ), where G = (V, E) is an underlying (static) graph and λ : E → 2 N is a time-labeling function which assigns to every edge of G a set of discrete-time labels.
A temporal graph is, loosely speaking, a graph that changes with time. For every edge e ∈ E in the underlying graph G of a temporal graph (G, λ), λ(e) denotes the set of time slots at which e is active in (G, λ). A great variety of modern and traditional networks can be modeled as temporal graphs; social networks, wired or wireless networks which may change dynamically, transportation networks, and several physical systems are only a few examples of networks that change over time [26,31]. Due to its vast applicability in many areas, this notion of temporal graphs has been studied from different perspectives under various names such as time-varying [1,20,34], evolving [9,13,19], dynamic [12,23], and graphs over time [28]; for a recent attempt to integrate existing models, concepts, and results from the distributed computing perspective see the survey papers [10][11][12] and the references therein. Mainly motivated by the fact that, due to causality, information in temporal graphs can "flow" only along sequences of edges whose time-labels are increasing, most temporal graph parameters and optimization problems that have been studied so far are based on the notion of temporal paths (see Definition 1 below) and other "path-related" notions, such as temporal analogues of distance, diameter, reachability, exploration, and centrality [2,3,18,29,30]. In addition, recently also non-path temporal graph problems have been theoretically studied, such as temporal variations of vertex cover [4] and maximal cliques [25,38,39].
Our paper is mainly motivated by the need to control infectious diseases that may spread over contact networks. Data specifying timed contacts that could spread an infectious disease are recorded in a variety of settings, including movements of humans via commuter patterns and airline flights [14], and fine-grained recording of livestock movements between farms in most European nations [32]. There is very strong evidence that these networks play a critical role in large and damaging epidemics, including the 2009 H1N1 influenza pandemic [8] and the 2001 British foot-and-mouth disease epidemic [24]. Because of the key importance of timing in these networks to their capacity to spread disease, methods to assess the susceptibility of temporal graphs and networks to disease incursion have recently become an active area of work within network epidemiology in general, and within livestock network epidemiology in particular [7,33,36,37].
The leading role of livestock epidemiology in the development of temporal graph methods for disease control is partially explainable by the wealth of data available in this area: it is required by European law that individual cattle movements between agricultural holdings be recorded, including the timings of those movements. In Great Britain, these are in the British Cattle Movement Service (BCMS) [32] dataset, which contained almost 300M trades between over 133K agricultural holdings in 2014. The set of all farms (vertices) together with the set of all possible animal trades (edges) form a static graph G; there already exists evidence that many such real-world animal trade networks are likely to have small treewidth [17]. When we consider each animal trade (i.e. edge) e together with the recorded times at which this trade is realized, we obtain a temporal graph (G, λ).
In this paper, we are interested in controlling the disease spread on this sort of temporal graphs (G, λ) which arise in such animal trade networks. Therefore, similarly to [17], we focus our attention on deleting edges and/or edge availabilities from (G, λ) in order to limit the temporal connectivity of the remaining temporal subgraph. To this end, the following temporal extension of the notion of a path in a static graph is fundamental [27,29].
Definition (Temporal path). A temporal path from u to v in a temporal graph (G, λ) is a path from u to v in G, composed of edges e 0 , e 1 , . . . , e k such that each edge e i is assigned a time t(e i ) ∈ λ, where t(e i ) < t(e i+1 ) for 0 ≤ i < k.
Our contribution We consider two natural deletion problems for temporal graphs and we study their computational complexity, both in the traditional and the parameterized sense, subject to natural parameters. In the first problem, namely Temporal Reachability Edge Deletion (for short, TR Edge Deletion), given a temporal graph (G, λ) and two natural numbers k, h, the goal is to delete at most k edges from (G, λ) such that, for every vertex v of G, there exists a temporal path to at most h − 1 other vertices. The second problem, namely Temporal Reachability Time-Edge Deletion (for short, TR Time-Edge Deletion), is similar, with the only difference that now we delete up to k time labels on edges (or "time-edges"), instead of k edges. Here, a time-edge is a pair (e, t), where t ∈ λ(e), i.e. the appearance of edge e at time t.
In Section 3, we prove our hardness results for TR Edge Deletion and TR Time-Edge Deletion. Namely we show that they are both NP-complete, even on a very restricted class of temporal graphs. In particular, this NP-hardness reduction implies that both problems are para-NP-hard (i.e. NP-hard even for constant-valued parameters) with respect to each one of the parameters h, or maximum temporal total degree ∆ G,λ (i.e. the maximum number of time-edges incident to a vertex in (G, λ)), or lifetime of (G, λ) (i.e. the maximum label assigned by λ to any edge of G). Moreover we show that both these problems are also W[1]-hard, when parameterized by the number k of deleted edges/time-edges.
On the positive side, we prove in Section 4 that TR Edge Deletion and TR Time-Edge Deletion both admit an FPT algorithm, when simultaneously parameterized by h, by the treewidth tw(G) of the underlying (static) graph G, and by the maximum temporal total degree ∆ G,λ . Our FPT algorithm exploits a celebrated result by Courcelle, concerning relational structures with bounded treewidth (see Theorem 4.2).
Finally, in Section 5 we consider a natural generalization of the above two problems by restricting the notion of a temporal path, as follows. Given two numbers α, β ∈ N, where α ≤ β, we require that the time between arriving at and leaving any vertex on a temporal path is between α and β; we refer to such a path as an (α, β)-temporal path. The resulting problems, incorporating this restricted version of a temporal path, are called (α, β)-TR Edge Deletion and (α, β)-TR Time-Edge Deletion, respectively. These (α, β)-extensions of the deletion problems are well motivated in cases where a disease needs to follow a "clocked" transmission in order to propagate. For example, an upper bound β on the permitted time between entering and leaving a vertex might represent the time within which an infection would be detected and eliminated (thus ensuring no further transmission). On the other hand, a lower bound α might represent the minimum time individuals must spend together (i.e. in the same vertex) for there to be a non-trivial probability of disease transmission. In these generalized "clocked" settings, it turns out that both our (positive and negative) results from Sections 3 and 4 carry over. In fact, we prove the stronger result that, for any α ≤ β, (α, β)-TR Time-Edge Deletion is NP-complete and W[1]-hard, parameterized by the number k of time-edges that can be removed, even if the underlying graph is a tree with vertex cover number two. This implies that (α, β)-TR Time-Edge Deletion is para-NP-hard with respect to the treewidth and with respect to the vertex cover number of the underlying (static) graph G.

Preliminaries
Given a (static) graph G, we denote by V (G) and E(G) the sets of its vertices and edges, respectively. An edge between two vertices u and v of G is denoted by uv, and in this case u and v are said to be adjacent in G. Given a temporal graph (G, λ), where G = (V, E), the maximum label assigned by λ to an edge of G, called the lifetime of (G, λ), is denoted by T (G, λ), or simply by T when no confusion arises. That is, T (G, λ) = max{t ∈ λ(e) : e ∈ E}. Throughout the paper we consider temporal graphs with finite lifetime T . Furthermore, we assume that the given labeling λ is arbitrary, i.e. (G, λ) is given with an explicit list of labels for every edge. That is, the size of the input temporal graph (G, λ) is O |V | + T t=1 |E t | = O(n + mT ). We say that an edge e ∈ E appears at time t if t ∈ λ(e), and in this case we call the pair (e, t) a time-edge in (G, λ). Given a subset E ⊆ E, we denote by (G, λ) \ E the temporal graph (G , λ ), where G = (V, E \ E ) and λ is the restriction of λ to E \ E . Similarly, given a subset X ⊆ {(e, t) : e ∈ E, t ∈ λ(e)} of time edges, we denote by (G, λ) \ X the temporal graph (G, λ ), where λ (e) = λ(e) \ X for every edge e ∈ E.
We define the temporal total degree d G,λ (v) of a vertex v in the temporal graph (G, λ) to be the number of time-edges (e, t), where e is incident to v in G. The maximum temporal total degree ∆ G,λ of (G, λ) is the maximum temporal total degree of any vertex in (G, λ). We say that a vertex v is temporally reachable from u in (G, λ) if there exists a temporal path from u to v. Furthermore we adopt the convention that every vertex v is temporally reachable from itself. The temporal reachability set of a vertex u, denoted by reach G,λ (u), is the set of vertices which are temporally reachable from vertex u. The temporal reachability of u is the number of vertices in reach G,λ (u). Furthermore, the maximum temporal reachability of a temporal graph is the maximum of the temporal reachabilities of its vertices.
In this paper we mainly consider the following two problems.
Output: Is there a set E ⊆ E(G), with |E | ≤ k, such that the maximum temporal reachability of (G, λ) \ E is at most h?
Temporal Reachability Time-Edge Deletion (TR Time-Edge Deletion) Input: A temporal graph (G, λ), and k, h ∈ N. Output: Is there a set X of time-edges, with |X| ≤ k, such that the maximum temporal reachability of (G, λ) \ X is at most h?
Note that, in the setting where each edge is assigned a unique time step by λ, these two problems are equivalent. Moreover, both problems clearly belong to NP as a set of edges or time-edges acts as a certificate (the reachability set of any vertex in a given temporal graph can be computed in polynomial time [2,27,29]). It is worth noting here that the (similarly-flavored) deletion problem for finding small separators in temporal graphs was studied recently; namely the problem of removing a small number of vertices from a given temporal graph such that two fixed vertices become temporally disconnected [22,40].

Computational hardness
In this section we show that both TR Edge Deletion and TR Time-Edge Deletion are NPcomplete and, more specifically, they are W[1]-hard when parameterized by the number k of deleted edges (resp. time-edges). First we show in the next theorem that both problems are W[1]-hard with respect to k; note that both problems are trivially in XP with respect to this parameter.
-hard when parameterized by the maximum number k of edges (resp. time-edges) that can be removed, even when the input temporal graph has the lifetime 2.
Proof. We provide a standard parameterized m-reduction from the following W[1]-complete problem.
Question: Does G contain a clique on at least r vertices?
We describe our hardness reduction for TR Edge Deletion. However, as the constructed temporal graph has exactly one label per edge, this reduction also implies W[1]-hardness for TR Time-Edge Deletion. First note that, without loss of generality, we may assume that r ≥ 3, as otherwise the problem is trivial. Let (G = (V G , E G ), r) be the input to an instance of Clique; we denote n = |V G | and m = |E G |. We will construct an instance ((H, λ), k, h) of TR Edge Deletion, which is a yes-instance if and only if (G, r) is a yes-instance for Clique. Note that, without loss of generality we may assume that m > r + r 2 ; otherwise there cannot be more than r + 3 vertices of degree at least r − 1 in G, and thus we can check all possible sets of r vertices with degree at least r − 1 in time O(r 3 ).
We begin by defining We complete the construction of the temporal graph H, λ) by setting Finally, we set k = r and h = 1 + (n − r) + (m − r 2 ). We begin by observing that s is the only vertex in (H, λ) whose temporal reachability is more than h. Note that | reach H,λ (e)| = 3 for all e ∈ E G , and | reach H,λ (v)| ≤ n + 1 for all v ∈ V G . Thus, as the temporal reachability of any vertex other than s is less than h. Hence, we see that for any E ⊆ E H the maximum temporal reachability of (H, λ) \ E is at most h if and only if the temporal reachability of s in the modified graph is at most h.
so no element of U belongs to reach H ,λ (s). Moreover, for any e ∈ E G , any temporal path from s to e in (H, λ) must contain precisely two edges, and so must include an endpoint of e; thus, for any edge e with both endpoints in U , we have e / ∈ reach H ,λ (s). Since U induces a clique, there are precisely r 2 such edges. It follows that We begin by arguing that we may assume, without loss of generality, that every element of E is incident to s. Let W ⊂ V G be the set of vertices in V G which are incident to some element of E ; we claim that deleting the set of edges E = {sw : w ∈ W } instead of E would also reduce the maximum temporal reachability of (H, λ) to at most h. To see this, consider a vertex x / ∈ reach H ,λ (s). If x ∈ V G , then we must have sx ∈ E , and so sx ∈ E implying that there is no temporal path from s to x when E is deleted. If, on the other hand, x = u 1 u 2 ∈ E G , then E must contain at least one edge from each of the two temporal paths from s to x in (H, λ), namely su 1 x and su 2 x. Hence E contains at least one edge incident to each of u 1 and u 2 , so su 1 , su 2 ∈ E and deleting all edges in E destroys all temporal paths from s to x.
Thus we may assume that E ⊆ {sv : v ∈ V G }. We define U ⊆ V G to be the set of vertices in V G incident to some element of E , and claim that U induces a clique of cardinality r in G. First note that |U | ≤ r. Now observe that the only vertices in V G that are not temporally reachable from s in (H , λ ) are the elements of U , and the only elements of E G that are not temporally reachable from s are those corresponding to edges with both endpoints in U . Thus, if m denotes the number of edges in By our assumption that this quantity is at most h, we see that Since |U | ≤ r, we have that m ≤ r 2 , with equality if and only if G[U ] is a clique. Thus, in order to satisfy the inequality above, we must have that |U | = r and that U induces a clique in G, as required.
The W[1]-hardness reduction of Theorem 3.1 also implies that the problems TR Edge Deletion and TR Time-Edge Deletion are NP-complete. In the next theorem we strengthen this result by proving that these problems remain NP-complete even on a very restricted class of temporal graphs.
Theorem 3.2. TR Edge Deletion and TR Time-Edge Deletion are NP-complete, even when the maximum temporal reachability h is at most 7 and the input temporal graph (G, λ) has: 1. maximum temporal total degree ∆ G,λ at most 5, and 2. lifetime at most 2.
Therefore both TR Edge Deletion and TR Time-Edge Deletion are para-NP-hard with respect to each of the parameters h, ∆ G,λ , and lifetime T (G, λ).
Proof. As we mentioned in Section 2, both problems trivially belong to NP. Now we give a reduction from the following well-known NP-complete problem [35].

3,4-SAT
Input: A CNF formula Φ with exactly 3 variables per clause, such that each variable appears in at most 4 clauses. Output: Does there exists a truth assignment satisfying Φ?
Let Φ be an instance of 3, 4-SAT with variables x 1 , . . . , x n , and clauses C 1 , . . . , C m . We may assume without loss of generality that every variable x i appears at least once negated and at least once unnegated in Φ. Indeed, if a variable x i appears only negated (resp. unnegated) in Φ, then we can trivially set x i = 0 (resp. x i = 1) and then remove from Φ all clauses where x i appears; this process would provide an equivalent instance of 3,4-SAT of smaller size. Now we construct an instance The gadget corresponding to variable xi. The number beside an edge is the time step at which that edge appears. The bold edges are the ones we refer to as literal edges.
We construct (G, λ) as follows. For each variable x i we introduce in G a copy of the subgraph shown in Figure 2, which we call an x i -gadget. There are three special vertices in an x i -gadget: x i and x i , which we call literal vertices, and v xi which we call the head vertex of x i -gadget. All the edges incident to v xi appear in time step 1, the other two edges of x i -gadget, which we call literal edges, appear in time step 2. Additionally, for every clause C s we introduce in G: 1) a clause vertex C s that is adjacent to the three literal vertices corresponding to the literals of C s , and 2) one more vertex adjacent only to C i , which we call the satellite vertex of C s . All the new edges incident to C s appear in time step 1. See Figure 3 for illustration. Finally, we set k = n and h = 7.
First recall that, in Φ, every variable x i appears at least once negated and at least once unnegated. Therefore, since every variable x i appears in at most four clauses in Φ, it follows that each of the two vertices corresponding to the literals x i , x i is connected with at most three clause gadgets. Therefore the temporal total degree of each vertex corresponding to a literal in the constructed temporal graph (G, λ) (see Figure 3) is at most five. Moreover, it can be easily checked that the same also holds for every other vertex of (G, λ), and thus ∆ G,λ ≤ 5.
We continue by observing temporal reachabilities of the vertices of (G, λ). A literal vertex can temporally reach only the corresponding clause vertices, and the two neighbors in its gadget. Since every literal belongs to at most 4 clauses in Φ, the temporal reachability of the literal vertex in (G, λ) is at most 7 (including the vertex itself). The head vertex of a gadget temporally reaches only the vertices of the gadget, hence the temporal reachability of any head vertex in (G, λ) is 8. Any other vertex belonging to a gadget can temporally reach only its unique neighbor in G. Every clause vertex can reach only the corresponding literal vertices and their neighbors incident to the literal edges and its satellite vertex. Hence the temporal reachability of every clause vertex in (G, λ) is 8. Finally, every satellite vertex reaches only its neighbor, and thus its temporal reachability is 2. Therefore in our instance of TR Edge Deletion we only need to care about temporal reachabilities of the clause and head vertices.
Now we show that, if there is a set E of n edges such that the maximum temporal reachability of the modified graph (G, λ) \ E is at most 7, then Φ is satisfiable. First, notice that since the temporal reachability of every head vertex is decreased in the modified graph and the number of gadgets is n, the set E contains exactly one edge from every gadget. Hence, as the temporal reachability of every clause vertex C s is also decreased, set E must contain at least one literal edge that is incident to a literal neighbor of C s . We now construct a truth assignment as follows: for every literal edge in E we set the corresponding literal to TRUE. If there are unassigned variables left we set them arbitrarily, say, to TRUE.
Since E has one edge in every gadget, every variable was assigned exactly once. Moreover, by the above discussion, every clause has a literal that is set to TRUE by the assignment. Hence the assignment is well-defined and satisfies Φ.
To show the converse, given a truth assignment (α 1 , . . . , α n ) satisfying Φ we construct a set E of n edges such that the maximum temporal reachability of (G, λ) \ E is at most 7. For every i ∈ [n] we add to E the literal edge incident to x i if α i = 1, and the literal edge incident to x i otherwise. By the construction, E has exactly one edge from every gadget. Moreover, since the assignment satisfies Φ, for every clause C s set E contains at least one literal edge corresponding to one of the literals of C s . Hence, by removing E from (G, λ), we strictly decrease temporal reachability of every head and clause vertex. Figure 3: A subgraph of a temporal graph corresponding to an instance of 3,4-SAT.

An FPT algorithm
In this section we show that both TR Edge Deletion and TR Time-Edge Deletion admit an FPT algorithm, when simultaneously parameterized by h, the maximum temporal total degree ∆ G,λ of (G, λ), and the treewidth tw(G) of the underlying graph G. The proof of our main result of this section (see Theorem 4.4) uses a celebrated theorem by Courcelle (see Theorem 4.2). Before we present this result in Section 4.2, we first present in Section 4.1 some necessary background on logic and on tree decompositions of graphs and relational structures. For any undefined notion in Section 4.1, we refer the reader to [21].

Treewidth of graphs
Given any tree T , we will assume that it contains some distinguished vertex r(T ), which we will call the root of T . For any vertex v ∈ V (T ) \ {r(T )}, the parent of v is the neighbor of v on the unique path from v to r(T ); the set of children of v is the set of all vertices u ∈ V (T ) such that v is the parent of u. The leaves of T are the vertices of T whose set of children is empty. We say that a vertex u is a descendant of the vertex v if v lies somewhere on the unique path from u to r(T ). In particular, a vertex is a descendant of itself, and every vertex is a descendant of the root. Additionally, for any vertex v, we will denote by T v the subtree induced by the descendants of v.
We say that (T, B) is a tree decomposition of G if T is a tree and B = {B s : s ∈ V (T )} is a collection of non-empty subsets of V (G) (or bags), indexed by the nodes of T , satisfying: (1) for all v ∈ V (G), the set {s ∈ T : v ∈ B s } is nonempty and induces a connected subgraph in T , (2) for every e = uv ∈ E(G), there exists s ∈ V (T ) such that u, v ∈ B s .
The width of the tree decomposition (T, B) is defined to be max{|B s | : s ∈ V (T )} − 1, and the treewidth of G is the minimum width over all tree decompositions of G.
Although it is NP-hard to determine the treewidth of an arbitrary graph [5], the problem of determining whether a graph has treewidth at most w (and constructing such a tree decomposition if it exists) can be solved in linear time for any constant w [6]; note that this running time depends exponentially on w.
Theorem 4.1 (Bodlaender [6]). For each w ∈ N , there exists a linear-time algorithm, that tests whether a given graph G = (V, E) has treewidth at most w, and if so, outputs a tree decomposition of G with treewidth at most w.

Relational structures and monadic second order logic
A relational vocabulary τ is a set of relation symbols. Each relation symbol R has an arity, denoted arity(R) ≥ 1. A structure A of vocabulary τ , or τ -structure, consists of a set A, called the universe, and an interpretation R A ⊆ A arity(R) of each relation symbol R ∈ τ . We write a ∈ R A or R A (a) to denote that the tuple a ∈ A arity(R) belongs to the relation R A .
We briefly recall the syntax and semantics of first-order logic. We fix a countably infinite set of (individual ) variables, for which we use small letters. Atomic formulas of vocabulary τ are of the form: where R ∈ τ is r-ary and x 1 , . . . , x r , x, y are variables. First-order formulas of vocabulary τ are built from the atomic formulas using the Boolean connectives ¬, ∧, ∨ and existential and universal quantifiers ∃, ∀.
The difference between first-order and second-order logic is that the latter allows quantification not only over elements of the universe of a structure, but also over subsets of the universe, and even over relations on the universe. In addition to the individual variables of first-order logic, formulas of second-order logic may also contain relation variables, each of which has a prescribed arity. Unary relation variables are also called set variables. We use capital letters to denote relation variables. To obtain second-order logic, the syntax of first-order logic is enhanced by new atomic formulas of the form X(x 1 . . . x k ), where X is k-ary relation variable. Quantification is allowed over both individual and relation variables. A second-order formula is monadic if it only contains unary relation variables. Monadic second-order logic is the restriction of second-order logic to monadic formulas. The class of all monadic second-order formulas is denoted by MSO.
A free variable of a formula φ is a variable x with an occurrence in φ that is not in the scope of a quantifier binding x. A sentence is a formula without free variables. Informally, we say that a structure A satisfies a formula φ if there exists an assignment of the free variables under which φ becomes a true statement about A. In this case we will write A |= φ.

Treewidth of relational structures
The definition of tree decompositions and treewidth generalizes from graphs to arbitrary relational structures in a straightforward way. A tree decomposition of a τ -structure A is a pair (T, B), where T is a tree and B a family of subsets of the universe A of A such that: (1) for all a ∈ A, the set {s ∈ V (T ) : a ∈ B s } is nonempty and induces a connected subgraph (i.e. subtree) in T , (2) for every relation symbol R ∈ τ and every tuple (a 1 , . . . , a r ) ∈ R A , where r := arity(R), there is a s ∈ V (T ) such that a 1 , . . . , a r ∈ B s .
The width of the tree decomposition (T, B) is the number max{|B s | : s ∈ V (T )} − 1. The treewidth tw(A) of A is the minimum width over all tree decompositions of A.
We will make use of the version of Courcelle's celebrated theorem for relational structures of bounded treewidth, which, informally, says that the optimization problem definable by an MSO formula can be solved in FPT time with respect to the treewidth of a relational structure. The formal statement is an adaptation of an analogous theorem (see Theorem 9.21 in [16]) for the model-checking problem [15].
Theorem 4.2. Let φ be an M SO formula with a free set variable E. Assume we are given a relational structure A together with a width-t tree decomposition of A. Then the problem of finding a set E ⊆ A of minimum cardinality such that A satisfies φ(E) can be solved in time where f is a computable function, is the length of φ, and ||A|| is the size of A.

The FPT algorithm
In this section we present an FPT algorithm for TR Edge Deletion when parameterized simultaneously by three parameters: h, tw(G) and ∆ G,λ . Our strategy is first, given an input temporal graph (G, λ), to construct a relational structure A G,λ whose treewidth is bounded in terms of the three parameters. Then we construct an MSO formula φ h with a unique free set variable E, such that A G,λ satisfies φ h (E) for some E ⊆ A if and only if the maximum reachability of (G, λ) \ E is at most h. Finally, we apply Theorem 4.2 to find the minimum cardinality of such a set E ⊆ A. If the minimum cardinality is at most k, then ((G, λ), k, h) is a yes-instance of the problem, otherwise it is a no-instance.
Given a temporal graph (G, λ), we define a relational structure A G,λ as follows. The ground set A G,λ consists of • the set V (G) of vertices in G, • the set E(G) of edges in G, and • the set of all time-edges of (G, λ), i.e. the set Λ(G, λ) = {(e, t) | e ∈ E(G), t ∈ λ(e)}.
First we show that the treewidth of A G,λ is bounded by a function of tw(G) and ∆ G,λ . Lemma 4.3. The treewidth of A G,λ is at most (2∆ G,λ + 1)(tw(G) + 1) − 1.
Proof. To prove the lemma we show how to modify an optimal tree decomposition of G into a desired tree decomposition of A G,λ . Suppose that (T, B) is a tree decomposition of G of width tw(G). The relational structure A G,λ then has a tree decomposition (T, B ) where, for every s ∈ V (T ), t) : (e, t) ∈ Λ(G, λ), e is incident to v}.

It is clear that
for all s ∈ V (T ), and it is easy to verify that (T, B ) is indeed a tree decomposition for A G,λ .
Using this, we prove the main result of this section. Proof. We describe our algorithm for both problems TR Edge Deletion and TR Time-Edge Deletion; in the description of the algorithm below we will distinguish between the two problems, wherever needed. Note that the input to each of the problems TR Edge Deletion and TR Time-Edge Deletion is a temporal graph (G, λ). Note also that, by Theorem 4.1, we can compute a minimum tree decomposition of any (static) graph G by an FPT algorithm, parameterised by treewidth. Furthermore, it follows from the proof of Lemma 4.3, a tree decomposition of the underlying (static) graph G can be transformed in linear time (in the size of the temporal graph (G, λ)) into the tree decomposition of A G,λ . Therefore, since such a tree decomposition of A G,λ can be computed in linear time overall, we assume here that such a decomposition is already computed. We start by defining an MSO formula which captures the property that the maximum temporal reachability is at most h. Given a tree S on h + 1 vertices and an arbitrary root vertex r ∈ V (S), we define ρ(S, r) to be the set {(e 1 , e 2 ) : ∃v ∈ V (S) such that e 1 lies on the path from v to r, and v is incident to e 1 , e 2 }.
This formula defines the property that there is some copy of S such that all vertices in S are temporally reachable from r. In our modified temporal graph, the maximum temporal reachability is at most h if and only if there is no copy S of a tree on h + 1 vertices in (G, λ) such that all vertices of S are temporally reachable from some r ∈ V (S). We therefore define another formula θ (S, r, E), which captures the property that in any copy of such a tree, at least one time-edge must belong to the set E of removed time-edges: We can now define an MSO formula which is true if and only if there exists a set of time-edge whose deletion ensures that there is no "bad" subtree. We write S h for the set of all rooted trees on h + 1 vertices. Then we define φ h (E) = Note that in either case, the length of the formula depends only on h. The result then follows from the application of Theorem 4.2 to the MSO formula φ h .

A "clocked" generalization of temporal reachability
In many applications, we might want to generalise our notion of temporal reachability: we might require that the time between arriving at and leaving any vertex on a temporal path falls within some fixed range. For example, in the context of disease transmission, an upper bound on the permitted time between entering and leaving a vertex might represent the time within which an infection would be detected and eliminated (thus ensuring no further transmission). On the other hand, a lower bound might represent the minimum time individuals must spend together for there to be a non-trivial probability of disease transmission. Motivated by this, we now define a generalized notion of temporal reachability which allows for such "clocked" restrictions.
Definition. Let (G, λ) be a temporal graph and let α ≤ β ∈ N. An (α, β)-temporal path from u to v in (G, λ) is a path from u to v in G, composed of edges e 0 , e 1 , . . . , e k , such that each edge e i , 0 ≤ i < k, is assigned a time t(e i ) from its image in λ, where α ≤ t(e i+1 ) − t(e i ) ≤ β.
Given Definition 5, we define (α, β)-temporal reachability, (α, β)-temporal reachability set of a vertex u (denoted reach (α,β) G,λ (u)), and maximum (α, β)-temporal reachability of a temporal graph in the obvious way, similarly to the classical temporal reachability, as defined in Section 2. Note that the notion of temporal reachability we have used thus far is (1, T )-temporal reachability, where T is the lifetime of the temporal graph (G, λ). Now, similarly to the problems TR Edge Deletion and TR Time-Edge Deletion, we define their corresponding (α, β)-extensions. Furthermore, clearly both these problems belong to NP.
First we show that the results of Theorems 3.1, 3.2, and 4.4 (from Sections 3 and 4) easily extend to the problems (α, β)-TR Edge Deletion and (α, β)-TR Time-Edge Deletion, by just slightly adapting the proofs.
Proof. With a slight modification, the reduction of Theorem 3.1 works also for (α, β)-TR Edge Deletion and (α, β)-TR Time-Edge Deletion. Indeed, given an instance of (α, β)-TR Edge Deletion, the reduced graph (G, λ) is constructed exactly as one in the proof of Theorem 3.1, with the only difference that every time label "2" needs to be replaced by the time label "α + 1". The proof then works verbatim for the generalized problems (α, β)-TR Edge Deletion and (α, β)-TR Time-Edge Deletion.
Exactly the same arguments as in the proof of Theorem 5.1 show that the following analog of Theorem 3.2 holds.
In the next theorem, we obtain a stronger hardness result for (α, β)-TR Time-Edge Deletion than the one for TR Time-Edge Deletion. In particular, we prove that for (α, β)-TR Time-Edge Deletion, hardness (i.e. both NP-hardness and W[1]-hardness) holds even when the underlying graph belongs to a very restricted family of trees.
Theorem 5.4. For any α ≤ β, (α, β)-TR Time-Edge Deletion is NP-complete and W[1]-hard, when parameterized by the maximum number k of time-edges that can be removed, even if the underlying graph is a tree with vertex cover number two. Therefore (α, β)-TR Time-Edge Deletion is para-NP-hard with respect to the treewidth and with respect to the vertex cover number of the underlying (static) graph G.
Proof. To prove the theorem we provide a reduction from Clique. Let (G = (V, E), r) be the input to an instance of Clique, and suppose that V = {v 1 , . . . , v n } and E = {e 1 , . . . , e m }. We may assume without loss of generality that r < n and r 2 < m, as otherwise our instance of Clique is trivially solvable (by checking whether there is a clique that uses all vertices or edges respectively). We construct an instance ((G , λ), k, h) of (α, β)-TR Time-Edge Deletion which is a yes-instance if and only if (G, r) is a yes-instance for Clique.
We begin by describing the construction of G . G consists of a single edge xy, together with m leaf vertices u 1 , . . . , u m adjacent to x and another m leaf vertices w 1 , . . . , w m adjacent to y. We now define λ. For 1 ≤ i ≤ m, we set λ(xu i ) = {1}, and λ(xy) = {jβ + 2 : 1 ≤ j ≤ n}. For 1 ≤ i ≤ m, suppose that e i = v i1 v i2 ; we then set λ(yw i ) = {i 1 β + α + 2, i 2 β + α + 2}. We complete the construction of our instance of (α, β)-TR Time-Edge Deletion by setting k = r and h = 2m + 2 − r 2 . Note that, as we are assuming r 2 < m, this gives h > m + 2. We now claim that the only vertex whose (α, β)-temporal reachability in (G , λ) exceeds h is x, and so we have a yes-instance if and only if it is possible to delete at most k edge-labels so that the (α, β)reachability set of x has size at most h. Suppose, for a contradiction, that there is some vertex v = x such that | reach (α,β) G ,λ (v)| ≥ h. We begin by observing we cannot have v ∈ {u 1 , . . . , u m }: since every timestep in λ(xy) exceeds the unique time step in λ(xv) by more than β, it follows that reach G ,λ (v)| < h. Next, suppose that v ∈ {y} ∪ {w 1 , . . . , w m }: it is clear that no element of {u 1 , . . . , u m } is in the reachability set of v, so we have | reach (α,β) G ,λ (v)| ≤ m + 2 < h. This completes the proof of the claim; note also that reach (α,β) G ,λ (x) = V (G ). Now we suppose that (G, r) is a yes-instance, and demonstrate that it is possible to delete k = r time-edges from (G , λ) so that the (α, β)-reachability set of x has cardinality at most h. Suppose that U = {v i1 , . . . , v ir } induces a clique in G. We claim that deleting the set of time-edges {i j β + 2 : 1 ≤ j ≤ r} from λ(xy) has the desired result. Note that, if e s = v ij v i with 1 ≤ j < ≤ r, then w s will not be in the (α, β)-reachability set of x: since we have removed both i j β + 2 and i β + 2 from λ(xy), there is no time step t remaining for xy such that t + α ≤ i j β + α + 2 ≤ t + β or t + α ≤ i β + α + 2 ≤ t + β. Thus we see that the reachability set of x misses w i whenever e i has both endpoints in U , and so has cardinality at most 2m + 2 − r 2 as required. Conversely, suppose that we can delete r edge-labels from (G , λ) so that the reachability set of x has cardinality at most h. We write L 1 for the set of pairs (xy, t) such that we delete t from λ(xy), L 2 for the set of pairs (e, t) such that e = xu i for some i and we delete t from λ(xu i ), and L 3 for the set of pairs (e, t) such that e = yw i for some i and we delete t from λ(yw i ); we set r i = |L i | for i ∈ {1, 2, 3} (so r = r 1 + r 2 + r 3 ). We further define the set of vertices U = {v i : iβ + 2 ∈ L 1 }. Now suppose that some vertex v is not in the reachability set of x. Then we can conclude at least one of the following statements must hold: 2. v = w i for some i, and (yw i , t) ∈ L 3 for some t, or 3. v = w i for some i, and both endpoints of e i belong to U , or 4. v = y, and L 1 = λ(xy).
Note that we can exclude case (4), as this would imply that r ≥ n. We see that there are at most r 2 vertices that satisfy condition (1), at most r 3 vertices that satisfy condition (2), and at most |U | 2 = r1 2 vertices that satisfy condition (3). Thus the number of vertices removed from the reachability set of x is at most with equality if and only if r 1 = r and r 2 = r 3 = 0. Thus, in order to reduce the reachability set of x to at most h, we must only remove time-edges from xy; moreover, we must have r 2 edges with both endpoints in the set U . Since |U | = r, this implies that U induces a clique in G, as required.
The above reduction is a standard parameterized m-reduction with respect to k. Hence the proof shows W[1]-hardness of (α, β)-TR Time-Edge Deletion (resp. (α, β)-TR Time-Edge Deletion), when parameterized by the maximum number k of edges (resp. time-edges) that can be removed, even if the underlying graph is a tree with vertex cover number two.

Conclusions and open problems
In this paper we studied the problem of removing a small number of edges (or edge availabilities) from a given temporal graph (i.e. a graph that changes over time) to ensure that every vertex has a temporal path to at most h other vertices. The main motivation for this problem comes from the need of limiting the spread of real-world disease over a network; for example over the livestock trading network of the cattle movements in Great Britain, where farms are represented by vertices, and cattle trades between farms are encoded by edges [17,32]. Further motivation for the problem of removing temporal edge availabilities to limit the temporal connectivity of a temporal graph comes from scenarios of sensitive information propagation through rumor-spreading. In practical applications, removing an edge would correspond to completely prohibiting any contact between two entities, while removing an edge availability at time t would correspond to just temporally restricting their contact at that time point.
We formulated four natural problem variations and we showed that all our problems are W[1]-hard when parametrized by the maximum number k of edges (or edge availabilities) that can be removed. On the positive side, we proved that these problems admit fixed-parameter tractable (FPT) algorithms with respect to the combination of three parameters: the treewidth tw(G) of the underlying graph G, the maximum allowed temporal reachability h, and the maximum temporal total degree ∆ G,λ of (G, λ). Moreover, we showed that the latter two parameters combined (i.e. without the treewidth tw(G)) are not enough for deriving an FPT algorithm as they become para-NP-complete. On the other hand, it remains open whether any of these problems becomes FPT, when parametrized by treewidth tw(G), combined with only one of the other two parameters h and ∆ G,λ . In particular, the answer to these questions is not completely clear even for the special case where the underlying graph G is a tree (i.e. tw(G) = 1). For simplicity we formulate here these two (initial) open questions for our problem TR Time-Edge Deletion; similar questions can be asked also for the other three problem variations that we defined: Problem 1. Is TR Time-Edge Deletion fixed-parameter tractable on trees, when parametrized by the maximum temporal reachability h? Problem 2. Is TR Time-Edge Deletion fixed-parameter tractable on trees, when parametrized by the maximum temporal total degree ∆ G,λ of the input temporal graph?