1 Introduction

In this paper, we refer to digraphs in the classical sense as static digraphs. A temporal digraph is a digraph that exists and changes in a time interval \(\mathcal {T}\). That is, given a static digraph G, a temporal digraph \(\mathcal {G}\) with base static digraph G and lifetime \(\mathcal {T}\) changes as follows: at each time stamp \(t \in \mathcal {T}\), only a subdigraph of G is active, and edges might have a delay, leaving a vertex at some time stamp but arriving only later. If a vertex \(v \in V(G)\) is active at every \(t \in \mathcal {T}\), we say that v is permanent.

In this paper we deal with disjoint spanning branchings in temporal digraphs, which are well-understood structures in digraphs. Given a digraph G, and a subset \(R\subseteq V(G)\), we say that \(H\subseteq G\) is a spanning branching of G with root R if \(V(H) = V(G)\), and H contains exactly one path between some \(r\in R\) and u, for each \(u\in V(G)\). Given subsets \(R_1,\cdots ,R_k\), a classical result by Edmonds [9] gives a necessary and sufficient condition for the existence of k edge-disjoint branchings with roots \(R_1,\cdots ,R_k\), respectively. His result also gives a polynomial algorithm that constructs these branchings.

When translating concepts to temporal graphs, it is often the case that theorems coming from graph theory, in the classical sense, can hold or not depending on the adopted definition. Indeed, in [14] the authors give an example where Edmonds’ result on branchings does not hold on the temporal context. However, as we will see later, their concept is just one of many possible definitions, and in fact there is even one case where polynomiality holds.

Another example of such behavior is the validity of Menger’s Theorem. It has been shown that the edge version of Menger’s Theorem holds [3], even if one considers weights on the edges [2]. However, the vertex version of Menger’s Theorem holds or not, depending on how one interprets what a cut should be. If a cut is understood as a subset of V(G), then Menger’s Theorem does not hold [3, 14]; and if it is understood as a subset of the appearances of vertices in time (alternatively, a cut can be seen as deactivating vertices at some time stamps), then Menger’s Theorem holds [18].

Our Contribution. Given a temporal digraph \(\mathcal{G}\) with base digraph G, and subsets of vertices in time \(R_1,\cdots ,R_k\), i.e. sets of pairs (ut) where u is a vertex of G and t a time stamp, here we investigate the many variations of finding (pairwise) disjoint spanning branchings with roots \(R_1,\cdots ,R_k\). Spanning can mean that one wants to pass by at least one appearance of each \(u\in V(G)\) (called vertex spanning), or by all appearances of each \(u\in V(G)\) (called temporal spanning). Similarly, edge-disjoint can have different interpretations, as it can refer to edges of G or to the appearances of these edges in \(\mathcal{G}\). We say that two branchings are edge-disjoint if they do not share any edge of G, and that they are temporal-edge-disjoint (or t-edge-disjoint for short) if they do not share any appearance of an edge of G in \(\mathcal{G}\). We found that the only case in which this problem is polynomial (as its static counterpart) is when we want t-edge-disjoint temporal-spanning branchings. We also found that if vertices are permanent (this is the more popular case where vertices are always active), the problem is polynomial for temporal-spanning branchings and \(\mathsf {NP}\)-complete otherwise. Our results are summarized in Table 1 and detailed in the following main theorem. A digraph G is a in-star if there exists \(u\in V(G)\) such that all the edges in G are incoming edges to u.

Theorem 1

Let \(\mathcal{G}\) be a temporal digraph with base digraph G, and consider subsets of vertices in time, \(R_1,\cdots ,R_k\). The problem of finding k branchings rooted at \(R_1,\cdots ,R_k\) is:

  1. 1.

    Polynomial for t-edge-disjoint temporal-spanning,

  2. 2.

    \(\mathsf {NP}\)-complete for edge-disjoint temporal-spanning even if G is a in-star, and each snapshot has constant size, or if \(\mathcal{G}\) has lifetime 3. And if vertices are permanent or \(\mathcal{G}\) has lifetime 2, then edge-disjoint temporal-spanning becomes polynomial.

  3. 3.

    \(\mathsf {NP}\)-complete for edge-disjoint vertex-spanning even if G is a DAG, the lifetime of \(\mathcal{G}\) is 2, and vertices are permanent.

  4. 4.

    \(\mathsf {NP}\)-complete for t-edge-disjoint vertex-spanning even if G is a DAG, the lifetime of \(\mathcal{G}\) is 2, and vertices are permanent.

As said before, Edmonds’ condition is the characterization behind the polynomial algorithm for finding k edge disjoint spanning branchings in digraphs. Because of our \(\mathsf {NP}\)-completeness results, it is worth remarking that, unless \(\mathsf {P}\)=\(\mathsf {NP}\), any such characterization for the \(\mathsf {NP}\)-complete cases in temporal digraphs should be checkable in superpolynomial time, unlike the one provided by Edmonds.

Finally, our reductions further imply that, in the case of edge-disjoint temporal-spanning, even if the base digraph G is a in-star, the problem cannot be solved by an algorithm running in time \(O^*(2^{o({{\,\mathrm{\mathcal {T}}\,}})})\) unless ETH fails, where \({{\,\mathrm{\mathcal {T}}\,}}\) is the lifetime of \(\mathcal{G}\). Moreover, in the vertex-spanning variations, the problem also cannot be solved in \(O^*(2^{o(n+m)})\) under the same assumption, where n and m are respectively the number of nodes and edges of the base digraph of \(\mathcal{G}\).

Table 1. Our results. Vertices are permanent if they are always active.

Related Work: While it is easy to imagine a variety of graph problems that can profit from considering changes in time, it is hard to pin-point when the study of temporal graphs and similar structures began. Nevertheless, in the last decade or so, it has attracted a lot of attention from the community, with a considerable number of papers being published in the field (we refer the reader to the surveys [15, 19]). We mention that temporal graphs (or other very similar structures) appear in the literature under a number of names, such as dynamic networks [4], time-varying graphs [8], evolving networks [5], and link streams [15]. Also, many works consider a temporal graph \(\mathcal{G}\) as having vertices that are always active, and edges have the same starting and ending time [2, 6, 14, 18, 20]. While models where edges that have a delay are more common [8, 25], models where nodes can be inactive have already been considered in [8, 15].

A path in temporal graphs is generally understood as a sequence of edges respecting time, i.e. the arrival time in each vertex of the path must be lower than the departing time of the next edge taken. In this context, a number of metrics can be related to a path, such as earliest arrival time, latest departure time, minimum number of temporal edges, and minimum traveling time [25]. When vertices can be inactive, we have to further ensure that, when waiting for the next edge on a certain vertex, it must remain active in the waiting period [8]. In this scenario, the definitions of reachability and connectivity change accordingly, and it is natural to ask how well-known structures and results from graph theory in the classical sense change taking into account the temporal constraint.

Temporal definitions of trees [6, 15] and (minimum) spanning trees [13], which are related to our definition of branching, have been proposed and investigated, and usually consist of ensuring that the root-to-node path in the tree is a valid temporal path. Analogously, temporal cuts from a vertex s to t aim to break any temporal path from s to t and can be related to extending the max-flow min-cut Theorem to temporal graphs [2]. And as we have already mentioned, different conclusions have been made about a temporal version of Menger’s Theorem depending on the adopted translation in terms of temporal graphs [3, 14, 18].

Edmonds’ Theorem on disjoint branchings is a classical theorem in graph theory, with many distinct existing proofs (e.g. Lovász [16], Tarjan [24], and Fulkerson and Harding [12]), and has many interesting consequences on digraph theory (e.g., one can derive Menger’s Theorem from it, characterize arc-connectivity [22], characterize branching cover [11], ensure integer decomposition of the polytope of branchings of size k [17], etc). As far as we know, the only other time that Edmonds’ Theorem has been investigated on the temporal context has been in [14], where the authors give an example where the theorem does not hold. The definition used by them falls into our category of edge-disjoint vertex-spanning branchings, which we prove to be \(\mathsf {NP}\)-complete even under very strict constraints.

Structure of the Paper. The paper is organized as follows. In Sect. 2, we formalize the definitions of spanning branchings and disjointness, also showing that having multiple roots in each of the k branchings is computationally equivalent to having a single root for all of the k branchings. In Sect. 3, we present the results about temporal-spanning branchings. In Sect. 4 we present our results concerning vertex-spanning branchings. Finally, in Sect. 5, we draw our conclusions and make some final remarks. The proofs of the results marked with ‘(\(\star \))’ can be found online in [7].

2 The Temporal Disjoint Branchings Problems

This section is devoted to formally define the several concepts of temporal graphs and disjoint branchings we introduce in this paper. A temporal digraph \(\mathcal{G}\) is a triple \((G, \gamma , \lambda )\) where G is a digraph and \(\gamma \) and \(\lambda \) are functions on V(G) and E(G), respectively, that tell us when the vertices and the edges appear. More formally, for each \(v\in V(G)\) we have \(\gamma (v)\subseteq \mathbb {N}\), and for each edge \(e\in E(G)\) we have \(\lambda (e)\subseteq \mathbb {N}\times \mathbb {N}\). Also, if \((t, t') \in \lambda (uv)\), then \(t\le t'\), \(t\in \gamma (u)\) and \(t'\in \gamma (v)\). Here, we consider only finite temporal digraphs, i.e., \({{\,\mathrm{\mathcal {T}}\,}}=\max \bigcup _{v\in V(G)}\gamma (v)\) is defined and is called the lifetime of \(\mathcal G\). We call G the base digraph of \(\mathcal G\). In what follows, unless said otherwise, we work on general digraphs, i.e., directions, loops and multiple edges are allowed.

In particular, if \({{\,\mathrm{\mathcal {T}}\,}}\) is the lifetime of \(\mathcal{G}=(G,\gamma ,\lambda )\), \(\gamma (v)=[{{\,\mathrm{\mathcal {T}}\,}}]\) for each \(v\in V(G)\), and \(t=t'\) for every \((t,t')\in \lambda (E(G))\), then the above definition corresponds to the definition of temporal graph given in [14] and many other works. The above definition also generalizes the definition of stream graph given in [15], and of time-varying graphs given in [1].

The vertices and edges of \(\mathcal{G}\) are the vertices and edges of G. We say that a vertex v is active at time t if \(t\in \gamma (v)\), and that v is active from \(t_1\) to \(t_2\) if v is active for every time t with \(t_1 \le t \le t_2\). Also, if v is active throughout the lifetime of \(\mathcal{G}\), then we say that v is permanent. The set \(V_T\) of temporal vertices is the set \(\{(v,t)\mid v\in V(G)\ and\ t\in \gamma (v)\}\), and the set \(E_T\) of temporal edges is the set \(\{(u,t)(v,t')\mid e=uv\in E(G)\ and\ (t,t')\in \lambda (e)\}\). Observe that a temporal digraph \(\mathcal {G}=(G,\gamma ,\lambda )\) can be also seen as a pair of digraphs \((G,G_T)\) where \(G_T = (V_T,E_T)\). This is similar to what has been proposed in [1] and [2]. We call the digraph \(G_T\) the \((\gamma ,\lambda )\)-digraph of \(\mathcal{G}\).

Since in our more general case, also vertices appear and disappear, the definition of walk must take into account that it is possible to wait only on vertices which are active, as formally defined next. Given temporal vertices \(s_1,s_k\in V_T\), an \(s_1,s_k\)-temporal walk in \((G,G_T)\) is a sequence of temporal vertices and temporal edges, \((s_1, \ldots , s_k)\), that either goes through a temporal edge, or stays on different copies of the same vertex of G. More formally: if \(s_i\) is a temporal edge, then \(s_{i-1}\) and \(s_{i+1}\) are temporal vertices and \(s_i\) goes from \(s_{i-1}\) to \(s_{i+1}\); and if \(s_i\) and \(s_{i+1}\) are temporal vertices, then \(s_i = (v, t)\) and \(s_{i+1} = (v, t+1)\) for some vertex v and some time t. If such a walk exists, we say that \(s_1\) reaches \(s_k\).

A temporal digraph \(\mathcal{B}=(G',\gamma ',\lambda ')\) such that \(G'\subseteq G\), \(\gamma '\subseteq \gamma \) and \(\lambda '\subseteq \lambda \) is called a temporal subdigraph of \(\mathcal{G}\).Footnote 1 Let \(R\subseteq V_T\); a temporal subdigraph \(\mathcal{B}\) of \(\mathcal{G}\) is a temporal-spanning branching of \(\mathcal{G}\) with root R if \(\mathcal{B}\) has a unique temporal walk from R to every vertex in \(V_T\), i.e. for any \((u,i)\in V_T\) there is exactly one temporal walk in \(\mathcal{B}\) starting at some vertex \(r\in R\) and arriving at (ui). And \(\mathcal{B}\) is a vertex-spanning branching of \(\mathcal{G}\) with root R if \(\mathcal{B}\) has exactly one temporal walk from R to some vertex in \(\{(u,i)\in V_T\}\) for every \(u\in V(G)\).

Given two branchings \(\mathcal{B}_1 = (G_1,\gamma _1,\lambda _1)\) and \(\mathcal{B}_2 = (G_2,\gamma _2,\lambda _2)\) rooted at \(R_1,R_2\), respectively, either both temporal-spanning or both vertex-spanning, we say that \(\mathcal{B}_1\) and \(\mathcal{B}_2\) are temporal-edge-disjoint (or t-edge-disjoint for short) if they have no common temporal edges; more formally, if \(\lambda _1(e)\cap \lambda _2(e) = \emptyset \) for every \(e\in E(G)\). And we say that \(\mathcal{B}_1\) and \(\mathcal{B}_2\) are edge-disjoint if there is no edge \(uv\in E(G)\) that has copies in both \(\mathcal{B}_1\) and \(\mathcal{B}_2\); more formally, \(E(G_1)\cap E(G_2) = \emptyset \).

Problem 1 (k X-disjoint Y-spanning Branching)

Let \(X\in \{\text {edge}, \text {t-edge}\}\), \(Y\in \{\text {temporal}, \text {vertex}\}\), and k be a fixed positive integer. Given a temporal digraph \(\mathcal{G}\), and subsets of temporal vertices \(R_1,\ldots ,R_k\subseteq V_T\), find k X-disjoint Y-spanning branchings \(\mathcal{B}_1,\ldots , \mathcal{B}_k\) respectively with roots \(R_1,\ldots ,R_k\).

We introduce the following restriction of Problem 1, which corresponds to finding branchings that have a single root (also called out-arborescence).

Problem 2 (k Single Source X-disjoint Y-spanning Branching)

Let \(X\in \{\text {edge}, \text {t-edge}\}\), \(Y\in \{\text {temporal}, \text {vertex}\}\), and k be a fixed positive integer. Given a temporal digraph \(\mathcal{G}\), and a temporal vertex \(r\in V_T\), find k X-disjoint Y-spanning branchings \(\mathcal{B}_1,\ldots , \mathcal{B}_k\) each one with root r.

Lemma 1

Problem 1 is computationally equivalent to Problem 2.

Proof

Problem 2 is clearly a restriction of Problem 1. In the following we provide the reduction in the opposite direction, from the problem where each branching has a subset of \(V_T\) as roots to the problem where each branching has a single same root. For this, for each \(i\in [k]\) add a new vertex \(r_i\) to G adjacent to every \(u\in V(G)\) such that \((u,t)\in R_i\), for some \(t\in [{{\,\mathrm{\mathcal {T}}\,}}]\). Then, make \(\gamma (r_i)=\{0\}\), and for each \((u,t)\in R_i\), add (0, t) to \(\lambda (r_iu)\) (which is the same as adding the temporal edge \((r_i,0)(u,t)\) to \(\mathcal{G}\)). Moreover, add a vertex r and make it adjacent to \(\{r_1,\cdots ,r_k\}\); also make \(\gamma (r) = \{0\}\) and \(\lambda (rr_i) = \{(0,0)\}\) (which is the same as adding temporal edges \((r,0)(r_i,0)\) for every \(i\in [k]\)).

One can see that k vertex-spanning (resp. temporal-spanning) branchings rooted at r give k vertex-spanning (resp. temporal-spanning) branchings rooted at \(R_1,\cdots ,R_k\), and vice-versa. The edge-disjointness, both for t-edge or edge-disjoint versions, clearly are not altered by adding the new temporal edges.   \(\square \)

The next easy proposition tells us that if finding k disjoint spanning branchings is hard, for some fixed k, then so is finding \(k+1\) of them.

Proposition 1

Let \(X\in \{\text {edge}, \text {t-edge}\}\), \(Y\in \{\text {temporal}, \text {vertex}\}\) and k be a fixed positive integer. If Problem \(k\) \(X\)-disjoint \(Y\)-spanning Branching is \(\mathsf {NP}\)-complete, then the same holds for Problem \(k+1\) \(X\)-disjoint \(Y\)-spanning Branching.

Proof

To reduce from k to \(k+1\), it suffices to add \(R_{k+1} = V_T\) as entry. Surely the \((k+1)\)-th branching has no temporal edges, which means that the other ones form a solution to the initial problem.   \(\square \)

3 Temporal-Spanning Branchings

This section is devoted to study Problem 1 in the case where Y is temporal, i.e. we aim to find k X-disjoint temporal-spanning branchings, with \(X\in \{\text {edge},\text {t-edge}\}\). We will hence prove Item 1 and Item 2 of Theorem 1 respectively in Sect. 3.1 and in Sect. 3.2.

3.1 T-Edge-Disjoint Temporal-Spanning Branchings

Let \(\mathcal{G} = (G,\gamma ,\lambda )\), and let \(V_T,E_T\) be its set of temporal vertices and edges, respectively. Also, let \(R_1,\cdots ,R_k\subseteq V_T\), and \(H = (V_T,E_T\cup E')\), where \(E'\) contains k copies of the edge \((u,t)(u,t+1)\) whenever \(\{(u,t),(u,t+1)\}\subseteq V_T\). We prove that \(\mathcal{G}\) has the desired branchings iff H has k edge-disjoint spanning branchings with roots \(R_1,\cdots ,R_k\). Then, Item 1 of Theorem 1 follows by Edmonds’ result [9].

Lemma 2

Let \(\mathcal{G} = (G,\gamma ,\lambda )\) be a temporal digraph, \(R_1,\cdots ,R_k\subseteq V_T\), and H be constructed as above. Then, \(\mathcal{G}\) has k t-edge-disjoint temporal-spanning branchings rooted at \(R_1,\cdots ,R_k\) iff H has k edge-disjoint spanning branchings rooted at \(R_1,\cdots ,R_k\).

Proof

Let \(\mathcal{B}_1,\cdots ,\mathcal{B}_k\) be t-edge-disjoint temporal-spanning branchings rooted at \(R_1,\cdots ,R_k\), respectively. For each \(\mathcal{B}_i\), let \(B_i\) be a spanning subgraph of H initially containing the temporal edges of \(\mathcal{B}_i\); then for each \((u,t)\in V(B_i)\), if the only walk in \(\mathcal{B}_i\) from \(R_i\) to (ut) contains \((u,t)(u,t+1)\) as a subsequence, then add an unused copy of \((u,t)(u,t+1)\in \) to \(B_i\). Because this walk is unique and cannot pass twice from time stamp t to time stamp \(t+1\), we get that at most k copies are needed, and, hence, the produced branchings are edge-disjoint. The converse can be easily proved by deleting the edges in \(E'\) from the solution to obtain the temporal subgraphs.   \(\square \)

3.2 Edge-Disjoint Temporal-Spanning Branchings

In this section, we prove Item 2 of Theorem 1. For this, we first prove that the problem is \(\mathsf {NP}\)-complete, and then that it is polynomial when each vertex is active for a consecutive set of time stamps. This includes the popular case where vertices are assumed to be permanent, as well as the case where \(T=2\).

Theorem 2 and Theorem 3 below detail our \(\mathsf {NP}\)-completeness results. In the next proof, we make a reduction from the k-Weak Disjoint Paths problem (k-WDP), where we are given a digraph G and a set I of k pairs of vertices \(\{(s_1, t_1), \ldots , (s_k, t_k)\}\) (called the requests) of V(G) and the goal is to find a collection of pairwise edge-disjoint paths \(\{P_1, \ldots , P_k\}\) such that \(P_i\) is a path from \(s_i\) to \(t_i\) in G, for \(i \in \{1, \ldots , k\}\). The k-WDP problem is \(\mathsf {NP}\)-complete for \(k=2\) [10] and W[1]-hard with parameter k in DAGs [23].

Theorem 2

Let \(k\ge 2\) be a fixed integer, \(\mathcal{G} = (G,\gamma ,\lambda )\) be a temporal digraph, and \(R_1,\ldots ,R_k\subseteq V_T\). Deciding whether \(\mathcal{G}\) has k edge-disjoint temporal-spanning branchings rooted at \(R_1,\cdots ,R_k\) is \(\mathsf {NP}\)-complete even if \(\mathcal{G}\) has lifetime 3.

Proof

Let (GI) be an instance of 2-WDP with \(I = \{(s_1, t_1), (s_2, t_2)\}\), and define \(W = \{s_1, t_1, s_2, t_2\}\). Assume that \(s_1,s_2\) are sources, \(t_1,t_2\) are sinks, and all vertices in W are distinct. We construct the temporal graph \(\mathcal {G} = (G, \gamma , \lambda )\) with subsets \(R_1,R_2\) such that \(\mathcal{G}\) has 2 edge-disjoint temporal-spanning branchings rooted at \(R_1,R_2\) if and only if (GI) is a “yes” instance of 2-WDP. The \(\mathsf {NP}\)-completeness for higher values of k follows from Proposition 1.

In the constructed temporal graph, there are no temporal edges of the type \((u,t)(v,t')\) with \(t\ne t'\). For this reason, it is easier to describe our temporal graph by describing, for each timestamp, what are the vertices and edges that are active. These are called snapshots and consist of subgraphs of G formed at each timestamp.

We let the first snapshot of \(\mathcal{G}\) initially consist of \(G-\{s_2,t_2\}\), and the third snapshot initially consist of \(G-\{s_1,t_1\}\). Then, we add a new vertex x to snapshot 1, and add the edges: \(\{xv\mid v\in V(G)\setminus \{s_2,t_2\}\}\cup \{t_1v\mid v\in (V(G)\,\cup \, \{x\})\setminus \{s_1,s_2,t_2\}\}\). Similarly, we add a new vertex y to snapshot 3, and add the edges: \(\{yv\mid v\in V(G)\setminus \{s_1,t_1\}\}\,\cup \, \{t_2v\mid v\in (V(G)\,\cup \, \{y\})\setminus \{s_2,s_1,t_1\}\}\). Observe Fig. 1.

Fig. 1.
figure 1

Temporal graph constructed from an instance (GI) of 2-WDP, where \(I=\{(s_1,t_1),(s_2,t_2)\}\) and \(W=\{s_1,t_1,s_2,t_2\}\). Edges arriving in \(t_1\) and \(t_2\) originally from G are omitted.

Define \(R_1 = \{(s_1,1), (y,3)\}\) and \(R_2 = \{(s_2, 3), (x,1)\}\). Now, we prove that (GI) is a “yes” instance of 2-WDP if and only if \(\mathcal {G}\) contains two edge-disjoint temporal-spanning branchings rooted at \(R_1\) and \(R_2\), respectively. Notice that snapshot 2 of \(\mathcal {G}\) is empty, thus each path in G can be represented by either a temporal path on snapshot 1 or a temporal path on snapshot 2.

First, let \(P_1\) and \(P_2\) be two edge-disjoint paths from \(s_1\) to \(t_1\) and from \(s_2\) to \(t_2\) in G, respectively. Let \(T_1\) be initially the copy of \(P_1\) in snapshot 1, and \(T_2\) be initially the copy of \(P_2\) in snapshot 3. Note that the vertices not spanned by \(T_1\) are all the copies of \(v\notin V(P_1)\) in snapshot 1, together with all the vertices in snapshot 3, and vertices \(\{(x,1),(y,3)\}\). To span snapshot 3, add to \(T_1\) all edges between (y, 3) and (v, 3), for every \(v\in V(G)\setminus \{s_1,t_1\}\). To span the remainder of snapshot 1, add all edges between \((t_1,1)\) and (v, 1), for every \(v\in V(G)\setminus (V(P_1)\cup \{s_2,t_2\})\), and the edge from \((t_1,1)\) to (x, 1). A similar argument can be applied to span every temporal vertex also with \(T_2\). Because \(P_1\) and \(P_2\) are edge-disjoint, we get that \(T_1\) and \(T_2\) could only intersect in the added edges, which does not occur because all edges added to \(T_1\) are incident to \(t_1\) and y, all edges added to \(T_2\) are incident to \(t_2\) and x, and there is no intersection between these.

Now, let \(T_1\) and \(T_2\) be edge-disjoint temporal-spanning branchings in \(\mathcal {G}\) with roots \(R_1,R_2\). Denote snapshot 1 by \(G_1\). Since \(t_1\) appears only in \(G_1\), and the only root of \(R_1\) in \(G_1\) is \((s_1,1)\), we get that in \(T_1\) there exists a path of \(G_1\) going from \((s_1,1)\) to \((t_1,1)\). Because the only incoming edge to (x, 1) is \((t_1,1)(x,1)\), we get that (x, 1) cannot be an internal vertex in this path, and hence it corresponds to a path in G, \(P_1\). Applying a similar argument, we get a path \(P_2\) from \(s_2\) to \(t_2\) in G taken from \(T_2\), and since \(T_1\) and \(T_2\) are edge-disjoint, so are \(P_1\) and \(P_2\).   \(\square \)

The next result concludes the proof of Item 2 of Theorem 1.

Theorem 3

(\(\star \) ). Let \(k\ge 2\) be a fixed integer, \(\mathcal{G} = (G,\gamma ,\lambda )\) be a temporal digraph, and \(R_1,\ldots ,R_k\subseteq V_T\). Deciding whether \(\mathcal{G}\) has k edge-disjoint temporal-spanning branchings rooted at \(R_1,\cdots ,R_k\) is \(\mathsf {NP}\)-complete, even if G is a in-star, and each snapshot has constant size. Furthermore, in this case, there is no algorithm running in time \(O^*(2^{o({{\,\mathrm{\mathcal {T}}\,}})})\) to solve the problem, unless ETH fails.

The following theorem gives us a situation where the problem becomes easy. Note that this case includes the temporal graphs used in [2, 6, 14, 18, 20], where vertices are assumed to be permanent. It also implies that the problem is polynomial when the lifetime of \(\mathcal{G}\) is 2, which together with Theorem 2, gives a complete dichotomy in terms of the lifetime of \(\mathcal{G}\).

Theorem 4

Let \(\mathcal{G} = (G,\gamma ,\lambda )\) be a temporal digraph with temporal vertices \(V_T\), and let \(R_1,\cdots ,R_k\subseteq V_T\). If for every \(v\in V(G)\), \(\gamma (v)\) is exactly one interval of consecutive integers, then finding k edge-disjoint temporal-spanning branchings rooted at \(R_1,\cdots ,R_k\) can be done in polynomial time.

Proof

Let \({{\,\mathrm{\mathcal {T}}\,}}\) be the lifetime of \(\mathcal{G}\). We first construct digraphs \(G_0,\cdots ,G_{\mathcal {T}}\) and subsets \(R^j_1,\cdots ,R^j_k\) for each \(j\in \{0,\cdots ,{{\,\mathrm{\mathcal {T}}\,}}\}\), then we prove that \(\mathcal{G}\) has the desired branchings if and only if \(G_j\) has k edge-disjoint branchings rooted at \(R^j_1,\ldots ,R^j_k\) for each \(j\in \{0,\cdots ,{{\,\mathrm{\mathcal {T}}\,}}\}\), which can be checked in polynomial time, applying Edmonds’ result [9].

First, let \(G_0 = (V_0,E_0)\) be the digraph in time stamp 0, i.e, \(V_0 = \{u\in V(G)\mid 0\in \gamma (u)\}\) and \(E_0 = \{e\in E(G)\mid (0,0)\in \gamma (e)\}\). Also, for every \(i\in [k]\), let \(R^0_i\) be the roots at time stamp 0, i.e., the set \(\{u\in V(G)\mid (u,0)\in R_i\}\). Now, for each \(j\in [{{\,\mathrm{\mathcal {T}}\,}}]\), let \(G_j = (V_j,E_j)\) be the digraph containing the edges arriving at time stamp j together with their endpoints; more formally, \(E_j = \{e\in E(G)\mid (t,j)\in \lambda (e)\text{, } \text{ for } \text{ some } t\}\) and \(V_j = \{u\in V(G)\mid (u,j)\in V_T \text{ or } uv\in E_j\text{, } \text{ for } \text{ some } v\}\). Also, for each \(i\in [k]\), let \(R^j_i\) be the set of roots at time stamp j together with vertices still active from the previous time stamp, i.e., \(R^j_i=\{u\in V(G)\mid (u,j)\in R_i\}\cup \{u\in V(G)\mid \{j-1,j\}\subseteq \gamma (u)\}\).

Now, let \(\mathcal{B}_1,\cdots ,\mathcal{B}_k\) be edge-disjoint temporal-spanning branchings rooted at \(R_1,\cdots ,R_k\); denote by \(E_T(\mathcal{B}_i)\) the set of temporal edges of \(\mathcal{B}_i\). Consider \(j\in \{0,\cdots ,{{\,\mathrm{\mathcal {T}}\,}}\}\), and for each \(i\in [k]\), let \(B^j_i\) be the set of edges of \(\mathcal{B}_i\) that have a copy ending at time stamp j, i.e., \(B^j_i = \{uv\in E(G)\mid (u,h)(v,j)\in E_T(\mathcal{B}_i) \text{ for } \text{ some } h\}\). Because \(\mathcal{B}_1,\cdots ,\mathcal{B}_k\) are edge-disjoint, we get that \(B^j_1,\cdots ,B^j_k\) are also disjoint. It remains to prove that each \(B^j_i\) is the edge set of a spanning branching of \(G_j\) rooted at \(R^j_i\). So, consider any \(i\in [k]\). Because \(\mathcal{B}_i\) is a temporal-spanning branching of \(\mathcal{G}\), we know that each \(u\in V(G)\) is either the head of some edge in \(B^j_i\), in which case u is spanned by \(B^j_i\), or u is a root in \(B^j_i\). We prove that in the latter case we get that \(u\in R^j_i\). Because u is not the head of any edge in \(B^j_i\), this means that either \((u,j)\in R_i\) or (uj) is spanned by \(\mathcal{B}_i\) just by waiting, i.e., \(\{j-1,j\}\subseteq \gamma (u)\). In both cases, we get that \(u\in R^j_i\), as we wanted to prove.

Now, for each \(j\in \{0,\cdots ,{{\,\mathrm{\mathcal {T}}\,}}\}\), let \(B^j_1,\ldots ,B^j_k\) be the edge sets of k edge-disjoint spanning branchings of \(G_j\). First, we prove that if \(uv\in B^j_i\), then \(v\in R^{j'}_{i'}\) for every \(i'\in [k]\) and every \(j'\in \{j+1,\cdots ,{{\,\mathrm{\mathcal {T}}\,}}\}\cap \gamma (v)\); hence if \(B_i = \bigcup _{j=0}^{{{\,\mathrm{\mathcal {T}}\,}}} B^j_i\), then we get that \(B_1,\cdots ,B_k\) are disjoint (these will be used later to construct the desired temporal branchings). So let \(j'\in \{j+1,\cdots ,k\}\cap \gamma (v)\) and observe that if \(uv\in E(G_j)\) then \(j\in \gamma (v)\). Because \(\gamma (v)\) is an interval of consecutive integers and \(j<j'\in \gamma (v)\), we get that \(j'-1\in \gamma (v)\), which implies that \(v\in R^{j'}_{i'}\) for every \(i'\in [k]\), as we wanted to show. Now, for each \(i\in [k]\), let \(\mathcal{B}_i = (G,\gamma ,\lambda ^i)\) be a spanning temporal subdigraph of \(\mathcal{G}\) having as temporal edges the temporal copies of each \(e\in B_i\), i.e, \(\lambda ^i(e)=\lambda (e)\) if \(e\in B_i\), and \(\lambda ^i(e) = \emptyset \) otherwise. Because \(B_1,\cdots , B_k\) are disjoint, it follows that \(\mathcal{B}_1,\cdots ,\mathcal{B}_k\) are edge-disjoint, so it remains to prove that each \(\mathcal{B}_i\) is a temporal-spanning branching rooted at \(R_i\). Let \(u\in V(G)\), and recall that \(\gamma (u)\) is an interval of consecutive integers; denote by \(s_u\) the minimum value in \(\gamma (u)\). Note that we just need to prove that if \((u,s_u)\notin R_i\), then there exists a temporal edge in \(\mathcal{B}_i\) arriving in \((u,s_u)\); this is because the other copies can be spanned simply by waiting in the interval \(\gamma (u)\). Since \((u,s_u)\notin R_i\) and \(s_u-1\notin \gamma (u)\), we get that \(u\notin R^{s_u}_i\). So, let \(vu\in B^{s_u}_i\) (it exists since \(B^{s_u}_i\) is the edge set of a spanning branching of \(G_{s_u}\)), and recall that \(\lambda ^i(vu) = \lambda (vu)\). We know that \(vu\in E(G_{s_u})\) only if \((v,j)(u,s_u)\) is a temporal edge of \(\mathcal{G}\) for some \(j\le s_u\) (i.e. \((j,s_u)\in \lambda (vu)\)). This means that there is a temporal edge arriving in \((u,s_u)\) in \(\mathcal{B}_i\), completing the proof.   \(\square \)

4 Vertex-Spanning Branchings

In this section, we provide an \(\mathsf {NP}\)-completeness proof to prove both Item 3 and Item 4 of Theorem 1. We make a reduction from NAE-SAT, which consists of, given a CNF formula \(\phi \) such that each clause contains exactly 3 literals, deciding whether there is a truth assignment to \(\phi \) such that each clause has at least one true and one false literal. This is problem is \(\mathsf {NP}\)-complete [21], and in fact it is a well known standard procedure to make a reduction from 3-SAT to it that produces a formula of size linear on the size of the original 3-SAT formula. Therefore, applying ETH we get that NAE-SATalso cannot be solved in time \(O(2^{o(n+m)})\) where nm are the number of variables and clauses of an input, respectively.

Let \(\phi \) be a CNF formula on variables \(\{x_1,\ldots ,x_n\}\) and clauses \(\{c_1,\ldots ,c_m\}\). A variable gadget related to \(x_i\) is formed by the set of vertices

$$V_i = \{x_i,F_i,T_i,a_i\}$$

and the set of edges

$$E_i = \{x_iT_i,x_iF_i,T_ia_i,F_ia_i\}.$$

Now, consider a clause \(c_i = \{\ell _{i_1}, \ell _{i_2}, \ell _{i_3}\}\), and for each \(i\in [3]\) let \(x_{i_j}\) be the variable related to literal \(\ell _{i_j}\). For each \(i\in [3]\), if \(x_{i_j}\) appears positively in \(c_i\), then add edge \(T_{i_j}c_i\) to the clause gadget related to \(c_i\); otherwise, add edge \(F_{i_j}c_i\). See Fig. 2 for the digraph related to \(\phi = (x_1\vee x_2\vee x_3)\wedge (\overline{x}_2\vee x_3\vee \overline{x_4})\).

Denote by \(C_i\) the set of vertices in the clause gadget of \(c_i\), and by \(E'_i\), the set of edges. Now, let \(G_\phi \) be the digraph formed by the union of all variable and clause gadgets, i.e., \(V(G) = \bigcup _{i=1}^n V_i\cup \bigcup _{i=1}^mC_i\) and \(E(G) = \bigcup _{i=1}^n E_i\cup \bigcup _{i=1}^mE'_i\). Finally, add to \(G_{\phi }\) two new vertices, gr, and add edges \(\{gx_i,rx_i\}\) for every \(i\in \{1,\cdots ,n\}\).

Fig. 2.
figure 2

Snapshot 1 related to formula \(\phi = (x_1\vee x_2\vee x_3)\wedge (\overline{x}_2\vee x_3\vee \overline{x}_4)\), and branchings related to the assignment (TTFF) to \((x_1,x_2,x_3,x_4)\).

Finally, let \(G'\) be the graph having \(A\cup \{g,r\}\) as vertex set, where \(A = \{T_i,F_i\mid i\in [n]\}\), and having every edge going from \(\{g,r\}\) to A. Let \(\mathcal{G}\) be the temporal digraph with lifetime 2, having \(G_{\phi }\) as first snapshot and \(G'\) as second snapshot (therefore, the basic digraph of \(\mathcal{G}\) is given by \((V,E(G_\phi )\cup E(G'))\), where \(V=V(G_{\phi })\supset V(G')\)).

Theorem 5

For each \(k\ge 2\), given a temporal digraph \(\mathcal{G}=(G,\gamma ,\lambda )\) with lifetime \({{\,\mathrm{\mathcal {T}}\,}}\), and set of temporal vertices \(V_T\), and subsets \(R_1,\cdots ,R_k\subseteq V_T\), it is \(\mathsf {NP}\)-complete to decide whether \(\mathcal{G}\) has k (t-edge-disjoint or edge-disjoint) vertex-spanning branchings rooted at \(R_1,\cdots ,R_k\), even if \({{\,\mathrm{\mathcal {T}}\,}}=2\) and G is a DAG. Furthermore, letting \(n=|V(G)|\) and \(m=|E(G)|\), no algorithm running in time \(O^*(2^{o(n+m)})\) can exist for the problem, unless ETH fails.

Proof

The second part follows easily since the reduction is linear. We prove the theorem for \(k=2\), and \(\mathsf {NP}\)-completeness for bigger values of k follows by Lemma 1. Let \(\phi \) be an instance of NAE-SAT, and let \(\mathcal{G}\) be the temporal digraph constructed as before; denote by G the base digraph. We prove that \(\phi \) is a “yes” instance if and only if \(\mathcal{G}\) has k edge-disjoint vertex-spanning branchings rooted at \(\{(g,1),(r,1)\}\) (we will see that the branchings are also t-edge disjoint).

First, suppose that \(\phi \) is a “yes” instance of NAE-SAT. We construct a solid and a dotted branching that satisfy our conditions. For each true variable \(x_i\), add to the solid branching the following edges of snapshot 1: \(\{gx_i,x_iT_i,T_ia_i\}\), together with edge \(T_ic_j\) for each clause \(c_j\) containing \(x_i\) that is not reached by the solid branching yet; also add to the dotted branching edges \(\{rx_i,x_iF_i,F_ia_i\}\), , together with edge \(F_ic_j\) for each clause \(c_j\) containing \(\overline{x}_i\) that is not reached by the dotted branching yet. Do something similar to the false variables, but switching the branchings. Figure 2 gives the branchings related to the assignment (TTFF) to \((x_1,x_2,x_3,x_4)\), respectively.

Observe that every \(u\in V(G)\) is spanned by both branchings, with the exception of vertices in \(B=\{(T_i,2),(F_i,2)\mid i\in [n]\}\). However, these can easily be spanned in the second snapshot since \(\{(g,2),(r,2)\}\) is complete to B.

Now, let \(\mathcal{B}_1,\mathcal{B}_2\) be two edge-disjoint vertex-spanning branchings. Because each \(a_i\) can only be reached at the first snapshot, it is reached by exactly two paths from \(\{(g,1),(r,1)\}\), one of them going through \((x_i,1)(T_i,1)\) and the other through \((x_i,1)(F_i,1)\). We then put \(x_i\) as true if and only if \((x_i,1)(T_i,1)\) is in branching \(\mathcal{B}_1\). Now, consider clause \(c_i = (\ell _{i_1}\vee \ell _{i_2}\vee \ell _{i_3})\). One can verify that, because \(c_i\) is spanned by \(\mathcal{B}_1\) and \(\mathcal{B}_2\), we get that at least one of the edges in \(E'_i\) is in \(\mathcal{B}_1\), and at least one in \(\mathcal{B}_2\), which implies that at least one of \(\ell _{i_1},\ell _{i_2},\ell _{i_3}\) is true, and at least one is false, as desired.   \(\square \)

5 Conclusions and Open Problems

In this paper we have investigated the temporal version of Edmonds’ classical result about the problem of finding k edge-disjoint spanning branchings rooted at given \(R_1,\cdots ,R_k\). We have introduced different definitions of spanning branchings, and of edge-disjointness in temporal digraphs. We have proved that, unlike the static case, only one of the these can be computed in polynomial time, namely the temporal-edge-disjoint temporal-spanning branchings problem, while the other versions are \(\mathsf {NP}\)-complete under very strict constraints. Given a temporal digraph \(\mathcal{G}=(G,\gamma ,\lambda )\), in the particular case of edge-disjoint temporal-spanning, we give separate \(\mathsf {NP}\)-complete results for fixed lifetime, and for when G is a in-star. A good question then might be whether there exists a polynomial algorithm for fixed lifetime and treewidth (a in-star has treewidth 1). Another interesting question is whether the problem remains hard for fixed lifetime when the base digraph is a DAG. Also, as we have provided computational lower bounds under ETH in Theorem 3 and in Theorem 5, we wonder whether there exist algorithms matching these lower bounds.