The complexity of computing optimum labelings for temporal connectivity

A graph is temporally connected if there exists a strict temporal path, i.e. a path whose edges have strictly increasing labels, from every vertex $u$ to every other vertex $v$. In this paper we study temporal design problems for undirected temporally connected graphs. The basic setting of these optimization problems is as follows: given a connected undirected graph $G$, what is the smallest number $|\lambda|$ of time-labels that we need to add to the edges of $G$ such that the resulting temporal graph $(G,\lambda)$ is temporally connected? As it turns out, this basic problem, called MINIMUM LABELING (ML), can be optimally solved in polynomial time. However, exploiting the temporal dimension, the problem becomes more interesting and meaningful in its following variations, which we investigate in this paper. First we consider the problem MIN. AGED LABELING (MAL) of temporally connecting the graph when we are given an upper-bound on the allowed age (i.e. maximum label) of the obtained temporal graph $(G,\lambda)$. Second we consider the problem MIN. STEINER LABELING (MSL), where the aim is now to have a temporal path between any pair of"terminals"vertices which lie in a subset $R\subseteq V$. This relaxed problem resembles STEINER TREE in static graphs. However, due to the requirement of strictly increasing labels in a temporal path, STEINER TREE is not a special case of MSL. Finally we consider the age-restricted version of MSL, namely MIN. AGED STEINER LABELING (MASL). Our main results are threefold: we prove that (i) MAL becomes NP-complete on undirected graphs, while (ii) MASL becomes W[1]-hard with respect to the number $|R|$ of terminals. On the other hand we prove that (iii) although the age-unrestricted problem MSL is NP-hard, it is in FPT with respect to the number $|R|$ of terminals. That is, adding the age restriction, makes the above problems strictly harder.


Introduction
A temporal (or dynamic) graph is a graph whose underlying topology is subject to discrete changes over time.This paradigm reflects the structure and operation of a great variety of modern networks; social networks, wired or wireless networks whose links change dynamically, transportation networks, and several physical systems are only a few examples of networks that change over time [24,33,35].Inspired by the foundational work of Kempe et al. [26], we adopt here a simple model for temporal graphs, in which the vertex set remains unchanged while each edge is equipped with a set of integer time-labels.
Definition 1 (temporal graph [26]) 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.
Here, whenever t ∈ λ(e), we say that the edge e is active or available at time t.Throughout the paper we may refer to "time-labels" simply as "labels" for brevity.Furthermore, the age (or lifetime) α(G, λ) of the temporal graph (G, λ) is the largest time-label used in it, i.e., α(G, λ) = max{t ∈ λ(e) : e ∈ E}.One of the most central notions in temporal graphs is that of a temporal path (or time-respecting path) which is motivated by the fact that, due to causality, entities and information in temporal graphs can "flow" only along sequences of edges whose time-labels are strictly increasing, or at least non-decreasing.
A vertex v is temporally reachable (or reachable) from vertex u in (G, λ) if there exists a temporal path from u to v. If every vertex v is reachable by every other vertex u in (G, λ), then (G, λ) is called temporally connected.Note that, for every temporally connected temporal graph (G, λ), we have that its age is at least as large as the diameter d G of the underlying graph G. Indeed, the largest label used in any temporal path between two anti-diametrical vertices cannot be smaller than d G .Temporal paths have been introduced by Kempe et al. [26] for temporal graphs which have only one label per edge, i.e., |λ(e)| = 1 for every edge e ∈ E, and this notion has later been extended by Mertzios et al. [28] to temporal graphs with multiple labels per edge.Furthermore, depending on the particular application, both variations of temporal paths with non-decreasing [6,26,27] and with strictly increasing [15,28] labels have been studied.In this paper we focus on temporal paths with strictly increasing labels.Due to the very natural use of temporal paths in various contexts, several path-related notions, such as temporal analogues of distance, diameter, reachability, exploration, and centrality have also been studied [1-3, 6, 8, 10, 11, 13, 15-18, 21, 27, 28, 32, 34, 36].
Furthermore, some non-path temporal graph problems have been recently introduced too, including for example temporal variations of maximal cliques [7,37], vertex cover [4,22], vertex coloring [31], matching [29], and transitive orientation [30].Motivated by the need of restricting the spread of epidemic, Enright et al. [15] studied the problem of removing the smallest number of time-labels from a given temporal graph such that every vertex can only temporally reach a limited number of other vertices.Deligkas et al. [12] studied the problem of accelerating the spread of information for a set of sources to all vertices in a temporal graph, by only using delaying operations, i.e., by shifting specific time-labels to a later time slot.The problems studied in [12] are related but orthogonal to our temporal connectivity problems.Various other temporal graph modification problems have been also studied, see for example [6,11,13,16,34].
The time-labels of an edge e in a temporal graph indicate the discrete units of time (e.g., days, hours, or even seconds) in which e is active.However, in many real dynamic systems, e.g., in synchronous mobile distributed systems that operate in discrete rounds, or in unstable chemical or physical structures, maintaining an edge over time requires energy and thus comes at a cost.One natural way to define the cost of the whole temporal graph (G, λ) is the total number of time-labels used in it, i.e., the total cost of (G, λ) is |λ| = e∈E |λ e |.
In this paper we study temporal design problems of undirected temporally connected graphs.The basic setting of these optimization problems is as follows: given an undirected graph G, what is the smallest number |λ| of time-labels that we need to add to the edges of G such that (G, λ) is temporally connected?As it turns out, this basic problem can be optimally solved in polynomial time, thus answering to a conjecture made in [2].However, exploiting the temporal dimension, the problem becomes more interesting and meaningful in its following variations, which we investigate in this paper.First we consider the problem variation where we are given along with the input also an upper bound of the allowed age (i.e., maximum label) of the obtained temporal graph (G, λ).This age restriction is sensible in more pragmatic cases, where delaying the latest arrival time of any temporal path incurs further costs, e.g., when we demand that all agents in a safety-critical distributed network are synchronized as quickly as possible, and with the smallest possible number of communications among them.Second we consider problem variations where the aim is to have a temporal path between any pair of "important" vertices which lie in a subset R ⊆ V , which we call the terminals.For a detailed definition of our problems we refer to Section 2.
Here it is worth noting that the latter relaxation of temporal connectivity resembles the problem Steiner Tree in static (i.e., non-temporal) graphs.Given a connected graph G = (V, E) and a set R ⊆ V of terminals, Steiner Tree asks for a smallest-sized subgraph of G which connects all terminals in R. Clearly, the smallest subgraph sought by Steiner Tree is a tree.As it turns out, this property does not carry over to the temporal case.Consider for example an arbitrary graph G and a terminal set R = {a, b, c, d} such that G contains an induced cycle on four vertices a, b, c, d; that is, G contains the edges ab, bc, cd, da but not the edges ac or bd.Then, it is not hard to check that only way to add the smallest number of timelabels such that all vertices of R are temporally connected is to assign one label to each edge of the cycle on a, b, c, d, e.g., λ(ab) = λ(cd) = 1 and λ(bc) = λ(cd) = 2.The main underlying reason for this difference with the static problem Steiner Tree is that temporal connectivity is not transitive and not symmetric: if there exists temporal paths from u to v, and from v to w, it is not a priori guaranteed that a temporal path from v to u, or from u to w exists.
Temporal network design problems have already been considered in previous works.Mertzios et al. [28] proved that it is APX-hard to compute a minimum-cost labeling for temporally connecting an input directed graph G, where the age of the graph is upper-bounded by the diameter of G.This hardness reduction was strongly facilitated by the careful placement of the edge directions in the constructed instance, in which every vertex was reachable in the static graph by only constantly many vertices.Unfortunately this cannot happen in an undirected connected graph, where every vertex is reachable by all other vertices.Later, Akrida et al. [2] proved that it is also APX-hard to remove the largest number of time-labels from a given temporally connected (undirected) graph (G, λ), while still maintaining temporal connectivity.In this case, although there are no edge directions, the hardness reduction was strongly facilitated by the careful placement of the initial time-labels of λ in the input temporal graph, in which every pair of vertices could be connected by only a few different temporal paths, among which the solution had to choose.Unfortunately this cannot happen when the goal is to add time-labels to an undirected connected graph, where there are potentially multiple ways to temporally connect a pair of vertices (even if we upper-bound the largest time-label by the diameter).
Summarizing, the above technical difficulties seem to be the reason why the problem of adding the minimum number of time-labels with an age-restriction to an undirected graph to achieve temporal connectivity remained open until now for the last decade.In this paper we overcome these difficulties by developing a hardness reduction from a variation of the problem Max XOR SAT (see Theorem 6 in Section 3) where we manage to add the appropriate (undirected) edges among the variable-gadgets such that simultaneously (i) the distance between any two vertices from different variable gadgets remains small (constant) and (ii) there is no shortest path between two vertices of the same variable gadget that leaves this gadget.
Our contribution and road-map.In the first part of our paper, in Section 3, we present our results on Min.Aged Labeling (MAL).This problem is the same as ML, with the additional restriction that we are given along with the input an upper bound on the allowed age of the resulting temporal graph (G, λ).Using a technically involved reduction from a variation of Max XOR SAT, we prove that MAL is NP-complete on undirected graphs, even when the required maximum age is equal to the diameter d G of the input static graph G.
In the second part of our paper, in Section 4, we present our results on the Steiner-tree versions of the problem, namely on Min.Steiner Labeling (MSL) and Min.Aged Steiner Labeling (MASL).The difference of MSL from ML is that, here, the goal is to have a temporal path between any pair of "important" vertices which lie in a given subset R ⊆ V (the terminals).In Section 4.1 we prove that MSL is NP-complete by a reduction from Vertex Cover, the correctness of which requires showing structural properties of MSL.Here it is worth recalling that, as explained above, the classical problem Steiner Tree on static graphs is not a special case of MSL, due to the requirement of strictly increasing labels in a temporal path.Furthermore, we would like to emphasize here that, as temporal connectivity is neither transitive nor symmetric, a straightforward NP-hardness reduction from Steiner Tree to MSL does not seem to exist.For example, as explained above, in a graph that contains a C 4 with its four vertices as terminals, labeling a Steiner tree is sub-optimal for MSL.
In Section 4.2 we provide a fixed-parameter tractable (FPT) algorithm for MSL with respect to the number |R| of terminal vertices, by providing a parameterized reduction to Steiner Tree.The proof of correctness of our reduction, which is technically quite involved, is of independent interest, as it proves crucial graph-theoretical properties of minimum temporal Steiner labelings.In particular, for our algorithm we prove (see Lemma 6) that, for any undirected graph G with a set R of terminals, there always exists at least one minimum temporal Steiner labeling (G, λ) which labels edges either from (i) a tree or from (ii) a tree with one extra edge that builds a C 4 .
In Section 4.3 we prove that MASL is W [1]-hard with respect to the number |R| of terminals.Our results actually imply the stronger statement that MASL is W [1]-hard even with respect to the number of time-labels of the solution (which is a larger parameter than the number |R| of terminals).
Finally, we complete the picture by providing some auxiliary results in our preliminary Section 2.More specifically, in Section 2.1 we prove that ML can be solved in polynomial time, and in Section 2.2 we prove that the analogue minimization versions of ML and MAL on directed acyclic graphs are solvable in polynomial time.

Preliminaries and notation
Given a (static) undirected graph G = (V, E), an edge between two vertices u, v ∈ V is denoted by uv, and in this case the vertices u, v are said to be adjacent in G.If the graph is directed, we will use the ordered pair (u, v) (resp.(v, u)) to denote the oriented edge from u to v (resp.from v to u).The age of a temporal graph (G, λ) is denoted by α(G, λ) = max{t ∈ λ(e) : e ∈ E}.A temporal path (e 1 , t 1 ), (e 2 , t 2 ), . . ., (e k , t k ) from vertex u to vertex v is called foremost, if it has the smallest arrival time t k among all temporal paths from u to v. Note that there might be another temporal path from u to v that uses fewer edges than a foremost path.A temporal graph (G, λ) is temporally connected if, for every pair of vertices u, v ∈ V , there exists a temporal path (see Definition 2) P 1 from u to v and a temporal path P 2 from v to u.Furthermore, given a set of terminals R ⊆ V , the temporal graph (G, λ) is R-temporally connected if, for every pair of vertices u, v ∈ R, there exists a temporal path from u to v and a temporal path from v to u; note that P 1 and P 2 can also contain vertices from V \ R. Now we provide our formal definitions of our four decision problems.Note that, for both problems MAL and MASL, whenever the input age bound a is strictly smaller than the diameter d of G, the answer is always NO. Thus, we always assume in the remainder of the paper that a ≥ d, where d is the diameter of the input graph G.For simplicity of the presentation, we denote next by κ(G, d) the smallest number k for which (G, k, d) is a YES instance for MAL.

Min. Labeling (ML)
Observation 1 For every graph G with n vertices and diameter d, we have that κ(G, d) ≤ n(n − 1).
Proof.For every vertex v of G = (V, E), consider a BFS tree T v rooted at v, while every edge from a vertex u = v to its parent in T v is assigned the time-label dist(v, u), i.e., the length of the shortest path from v to u in G.Note that each of these time-labels is smaller than or equal to the diameter d of G. Clearly, each BFS tree T v assigns in total n − 1 time-labels to the edges of G, and thus the union of all BFS trees T v , where v ∈ V , assign in total at most n(n − 1) labels to the edges of G.
The next lemma shows that the upper bound of Observation 1 is asymptotically tight as, for cycle graphs C n with diameter d, we have that κ(C n , d) = Θ(n 2 ).
Lemma 1 Let C n be a cycle on n vertices, where n = 4, and let d be its diameter.Then . ., v n } be the vertices of C n .In the following, if not specified otherwise, all subscripts are considered modulo n.We distinguish two cases, depending on the parity of n.
First, when n is odd, i.e., n = 2d + 1.In this case one can observe that for each vertex v i ∈ V (C n ) there are exactly two vertices on the distance d from it, namely v i+d (on the right side of v i ) and v i−d (on the left side of v i ).Therefore, the (v i , v i+d /v i−d ) and (v i+d /v i−d , v i )temporal paths must be labeled using all labels from 1 to d, one per each edge.Note also that each edge v i v i+1 lies on the d temporal paths when the starting vertex v j is on the left side of it (j ∈ {i, i − 1, i − 2, . . ., i − d}) and on d temporal paths, when the starting vertex v j is on the right side of it (j ∈ {i, i + 1, i + 2, . . ., i + d}).This results in edge v i v i+1 admitting all labels.As this is true for any edge of C n , each edge is labeled with all labels.Therefore we need n • d = 2d 2 + 1 labels to ensure the existence of temporal paths among any two vertices in C 2d+1 .Now let us continue with the case when n is even, i.e., n = 2d.In this case each vertex v i ∈ V (C n ) has exactly one vertex, v i−d = v i+d , on the distance d from it and two on the distance d − 1 from it (v i−d+1 and v i+d−1 ).Therefore we have to label two disjoint paths starting in v i , one of length d and the other of length d − 1. Suppose that we chose the following labeling to label the edges of C n .Let i ∈ {1, 2, . . ., d}, if the edge is of form v 2i v 2i+1 then it is labeled with all even labels, {2, 4, 6, . . ., j}, where j ≤ d, and if the edge is of form v 2i+1 , v 2i then it is labeled with all odd labels, {1, 3, 5, . . ., j }, where j ≤ d.Now vertices v 2i−1 and v 2i use the same labels (i.e., the same temporal paths), to reach all other vertices from the cycle.Namely, the (v 2i−1 , v 2i+d−1 )-temporal path is of length d, uses all labels from 1 to d and visits vertices This implies that that v 2i and v 2i−1 reach all other vertices in the graph.This holds for any two endpoints of an edge in C n .Therefore we need d • n 2 = d 2 labels to ensure the existence of temporal paths among any two vertices in C 2d .

A polynomial-time algorithm for ML
As a first warm-up, we study the problem ML, where no restriction is imposed on the maximum allowed age of the output temporal graph.It is already known by Akrida et al. [2] that any undirected graph can be made temporally connected by adding at most 2n − 3 time-labels, while for trees 2n − 3 labels are also necessary.Moreover, it was conjectured that every graph needs at least 2n − 4 time-labels [2].Here we prove their conjecture true by proving that, if G contains (resp.does not contain) the cycle C 4 on four vertices as a subgraph, then (G, k) is a YES instance of ML if and only if k ≥ 2n − 4 (resp.k ≥ 2n − 3).The proof is done via a reduction to the gossip problem [9] (for a survey on gossiping see also [23]).
The related problem of achieving temporal connectivity by assigning to every edge of the graph at most one time-label, has been studied by Göbel et al. [20], where the relationship with the gossip problem has also been drawn.Contrary to ML, this problem is NP-hard [20].That is, the possibility of assigning two or more labels to an edge makes the problem computationally much easier.Indeed, in a C 4 -free graph with n vertices, an optimal solution to ML consists in assigning in total 2n − 3 time-labels to the n − 1 edges of a spanning tree.In such a solution, one of these n − 1 edges receives one time-label, while each of the remaining n − 2 edges receives two time-labels.Similarly, when the graph contains a C 4 , it suffices to span the graph with four trees tooted at the vertices of the C 4 , where each of the edges of the C 4 receives one time-label and each edge of the four trees receives two labels.That is, a graph containing a C 4 can be temporally connected using 2n − 4 time-labels.
In the gossip problem we have n agents from a set A. At the beginning, every agent x ∈ A holds its own secret.The goal is that each agent eventually learns the secret of every other agent.This is done by producing a sequence of unordered pairs (x, y), where x, y ∈ A and each such pair represents one phone call between the agents involved, during which the two agents exchange all the secrets they currently know.
The above gossip problem is naturally connected to ML.The only difference between the two problems is that, in gossip, all calls are non-concurrent, while in ML we allow concurrent temporal edges, i.e., two or more edges can appear at the same time slot t.Therefore, in order to transfer the known results from gossip to ML, it suffices to prove that in ML we can equivalently consider solutions with non-concurrent edges (see Lemma 2).
From the set of agents A and a sequence of calls C = c(1), c(2), . . ., c(m) we build a temporal graph G C = (G, λ) by the following procedure.For every agent x ∈ A we create a vertex v x ∈ V (G).Every phone call c(i) between two agents x, y gives rise to a time edge (v x v y , i) of G C .Therefore the labeling λ is defined by the sequence of phone calls.Since no two calls are concurrent, we can order them linearly: for every 1 ≤ i ≤ m, the phone call c(i) gives the label i to the edge between the two agents involved.
Observation 2 If the sequence c(1), c(2), . . ., c(m) of m phone calls results in all agents knowing all secrets, then the above construction produces a temporally connected temporal graph Now note that the temporal graph G C produced by the above procedure has the special property that, for every time-label t = 1, 2, . . ., m, there exists exactly one edge labeled with t.
In the next lemma we prove the reverse statement of Observation 2.
Lemma 2 Let (G, λ) be an arbitrary temporally connected temporal graph with |λ| = m timelabels in total.Then there exists a sequence c(1), c(2), . . ., c(m) of m phone calls that results in all agents knowing all secrets.
Proof.Let (G, λ) be an arbitrary temporally connected temporal graph.W.l.o.g.we may assume that, for every t = 1, 2, . . ., α(G, λ), there exists at least one edge e such that t ∈ λ(e).Indeed, if such an edge does not exist in (G, λ), we can replace in (G, λ) every label t > t by t − 1, thus obtaining another temporally connected graph with a smaller age.Now we proceed as follows.Let t ∈ {1, 2, . . ., α(G, λ)} be an arbitrary time step within the lifetime of (G, λ), and let {e i k } t k=1 be the edges of G such that t ∈ λ(e i k ).Let ε = 1 2t .For every k = 1, . . ., t, we replace the label t of the edge e i k by the label t + kε.Finally, we normalize the new time-labels of the edges of G such that they become the distinct consecutive natural numbers from 1 to m (since |λ| = m by the assumption of the lemma).Denote the resulting temporal graph by (G, λ ).Note that every temporal path in (G, λ) corresponds to a temporal path in (G, λ ) with the same sequence of edges, and vice versa.
Finally we create the required sequence of phone calls as follows: for every i = 1, 2, . . ., m, if (G, λ ) contains the edge e with time-label i, we add a phone call c(i) between the two endpoints of the edge e.Since both (G, λ) aqnd (G, λ ) are temporally connected, it follows that after the sequence c(1), c(2), . . ., c(m) of calls results in every agent knowing every secret.This completes the proof.Now denote with f (n) the minimum number of calls needed to complete gossiping among a set A of n agents, where a specific set of pairs of vertices B ⊆ A × A are allowed to make a direct call between each other.Let G 0 = (A, B) be the (static) graph having the agents in A as vertices and the pairs of B among them as edges.Then it is known by [9] that, if G 0 contains a C 4 as a subgraph then f (n) = 2n − 4, while otherwise f (n) = 2n − 3. Therefore the next theorem follows by Observation 2 and Lemma 2 and by the results of [9].

A polynomial-time algorithm for directed acyclic graphs
As a second warm-up, we show that the minimization analogues of ML and MAL on directed acyclic graphs (DAGs) are solvable in polynomial time.More specifically, for the minimization analogue of ML we provide an algorithm which, given a DAG G = (V, A) with diameter d G , computes a temporal labeling function λ which assigns the smallest possible number of timelabels on the arcs of G with the following property: for every two vertices u, v ∈ V , there exists a directed temporal path from u to v in (G, λ) if and only if there exists a directed path from u to v in G.Moreover, the age α(G, λ) of the resulting temporal graph is equal to d G .Therefore, this immediately implies a polynomial-time algorithm for the minimization analogue of MAL on DAGs.For notation uniformity, we call these minimization problems ML directed and MAL directed , respectively.First we define a canonical layering of a DAG, which is useful for our algorithm.
An example of a canonical layering of a DAG G is illustrated in Figure 1.Proof.First we initialize an auxiliary vertex subset S = ∅ and a counter s v = 0 for every vertex v.We start by computing the vertices of L 0 in O(n + m) time by just visiting all vertices and arcs of G; L 0 contains all vertices u such that N − (u) = ∅.Now, for every i ≥ 0 we proceed as follows.First we set S = ∅.Then, for every arc (u, v), where u ∈ L i , we add v to S and we increase the counter s v by 1. Then we set L i+1 = {v ∈ S : Before we continue to the next iteration i + 1, we reset the set S to be ∅, and we iterate until we reach all vertices of G, i.e., until we add every vertex u to one of the sets L 0 , L 1 , . . ., L d .It is easy to check that the above procedure is correct, as at every iteration i + 1 (where i ≥ 0) we include to L i all vertices v which have zero in-degree in the graph induced by the vertices in V \ i k=1 L k .Furthermore, the running time is clearly O(n + m) as we visit each vertex and arc a constant number of times.
The following observations will be useful when considering the canonical layering.Observation 3 Each layer L i is an independent set in G.
Observation 5 For every arc (u, v) ∈ A, where u ∈ L i and v ∈ L i+1 for some i ∈ {0, 1, . . ., d− 1}, there is no directed path of length two or more from u to v in G.
We use the canonical layering to prove the following result.
Theorem 2 Let G = (V, E) be a DAG with n vertices and m arcs.Then ML directed (G) and MAL directed (G) can be both computed in O(n(n + m)) time.
Proof.For the purposes of simplicity of the proof, we denote by κ(G) the optimum value of ML directed with the DAG G as its input.First we calculate the canonical layering L 0 , L 1 , . . ., L d of G in O(n+m) time by Lemma 3.For simplicity of the presentation, denote by G v the induced subgraph of G that contains v and all vertices that are reachable by v in G with a directed path.Let d v be the diameter of G v ; note that d v is the length of the longest shortest directed path in G that starts at v. For every vertex u ∈ V , we define the set L u 0 = {u} and we initialize the set S u = N + (u).Then, similarly to the proof of Lemma 3, we iterate over all vertices v ∈ S u = N + (u) and over all vertices w ∈ N + (v).Whenever we encounter a vertex w ∈ N + (v) ∩ N + (u), we remove v from S u .At the end of this procedure, the set S u contains exactly those vertices of v ∈ N + (u), for which there is no directed path of length two or more from u to v in G.The above procedure can be completed in O(n(n + m)) time, as for every vertex u, we iterate at most over all arcs in G a constant number of times.Now we define the labeling λ of G as follows: Every arc (u, v) ∈ A, where u ∈ L i , v ∈ L j , and v ∈ S u , gets the label λ((u, v)) = j.Note here that 1 ≤ λ((u, v)) ≤ d for every arc of G, and thus the age α(G, λ) of the resulting temporal graph is equal to the diameter d of G.We will prove that |λ| = κ(G).To prove that |λ| ≤ κ(G), it suffices to show that every label of λ must participate in every temporal labeling of G which preserves temporal reachability.In fact, this is true as the only arcs of G, which have a label in λ, are those arcs (u, v) such that there is no other directed path from u to v.That is, in order to preserve temporal reachability, we need to assign at least one label to all these arcs.
Conversely, to prove that |λ| ≥ κ(G), it suffices to show that λ preserves all temporal reachabilities.For this, observe first that, every directed path P = (a, . . ., b) in G can be transformed to a directed path P = (a, . . ., b) such that, for every arc (u, v) in P , there is no other directed path from u to v in G apart from the arc (u, v) (i.e., there is no "shortcut" from u to v in G).Therefore, since every arc in P is assigned a label in λ and these labels are increasing along P , it follows that λ preserves all temporal reachabilities, and thus |λ| ≥ κ(G).Summarizing, |λ| = κ(G) and the labeling λ can be computed in O(n(n + m)) time.
Finally, since α(G, λ) = d, the obtained optimum labeling for ML is also an optimum labeling for MAL (provided that the upper bound a in the input of MAL is at least d).

MAL is NP-complete
In this section we prove that it is NP-hard to determine the number of labels in an optimal labeling of a static, undirected graph G, where the age, i.e., the maximum label used, is not larger than the diameter of the input graph.
To prove this we provide a reduction from the NP-hard problem Monotone Max XOR(3) (or MonMaxXOR(3) for short).This is a special case of the classical Boolean satisfiability problem, where the input formula φ consists of the conjunction of monotone XOR clauses of the form (x i ⊕ x j ), i.e., variables x i , x j are non-negated.If each variable appears in exactly r clauses, then φ is called a monotone Max XOR(r) formula.A clause (x i ⊕ x j ) is XOR-satisfied (or simply satisfied ) if and only if x i = x j .In Monotone Max XOR(r) we are trying to find a truth assignment τ of φ which satisfies the maximum number of clauses.As it can be easily checked, MonMaxXOR(3) encodes the problem Max-Cut on cubic graphs, which is known to be NP-hard [5].Therefore we conclude the following.2 n, since each variable appears in exactly 3 clauses.From φ we construct a static undirected graph G φ with diameter d = 10, and prove that there exists a truth assignment τ which satisfies at least k clauses in φ, if and only if there exists a labeling λ φ of G φ , with |λ φ | ≤ 13  2 n 2 + 99 2 n − 8k labels and with age α(G, λ) ≤ 10.
High-level construction For each variable x i , 1 ≤ i ≤ n, we construct a variable gadget X i that consists of a "starting" vertex s i and three "ending" vertices t i (for ∈ {1, 2, 3}); these ending vertices correspond to the appearances of x i in three clauses of φ.In an optimum labeling λ(φ), in each variable gadget there are exactly two labelings that temporally connect starting and ending vertices, which correspond to the True or False truth assignment of the variable in the input formula φ.For every clause (x i ⊕ x j ) we identifying corresponding ending vertices of X i and X j (as well as some other auxiliary vertices and edges).Whenever (x i ⊕ x j ) is satisfied by a truth assignment of φ, the labels of the common edges of X i and X j in an optimum labeling coincide (thus using few labels); otherwise we need additional labels for the common edges of X i and X j .
Detailed construction of G φ For each variable x i from φ we create a variable gadget X i , that consists of a base BX i on 11 vertices, where ∈ {1, 2, 3}.Vertices in the base BX i are connected in the following way: there are two paths of length 5: s i a i b i c i d i e i and s i a i b i c i d i e i , and 5 extra edges of form y i y i , where y ∈ {a, b, c, d, e}.Vertices in each fork F X i (where ∈ {1, 2, 3}) are connected in the following way: there are two paths of length 4: t i m i h i g i f i and t i m i h i g i f i , and 4 extra edges of form y i y i , where y ∈ {m, h, g, f }.The base BX i of the variable gadget X i is connected to each of the three forks F X i via two edges e i f i and e i f i , where ∈ {1, 2, 3}.For an illustration see Figure 2.
For an easier analysis we fix the following notation.The vertex The left (resp.right) s i , t i -path is a disjoint union of the left (resp.right) path on vertices of the base BX i of X i , an edge of form e i f i (resp.e i f i ) called the left (resp.right) bridge edge and the left (resp.right) path on vertices of the -th fork F X i of X i .The edges y i y i , where y ∈ {a, b, c, d, e, f , g , h , m }, ∈ {1, 2, 3}, are called connecting edges.
Connecting variable gadgets There are two ways in which we connect two variable gadgets, depending whether they appear in the same clause in φ or not. 1.Two variables x i , x j do not appear in any clause together.In this case we add the following edges between the variable gadgets X i and X j : Figure 2: An example of a variable gadget X i in G φ , corresponding to the variable x i from φ.
• from e i (resp.e i ) to f j and f j , where ∈ {1, 2, 3}, • from e j (resp.e j ) to f i and f i , where ∈ {1, 2, 3}, • from d i (resp.d i ) to d j and d j .
We call these edges the variable edges.For an illustration see Figure 3.
2. Let C = (x i ⊕ x j ) be a clause of φ, that contains the r-th appearance of the variable x i and r -th appearance of the variable x j .In this case we identify the r-th fork F r X i of X i with the r -th fork F r X j of X j in the following way: } respectively, and Besides that we add the following edges between the variable gadgets X i and X j : • from e i (resp.e i ) to f j and f j , where ∈ {1, 2, 3} \ {r }, • from e j (resp.e j ) to f i and f i , where ∈ {1, 2, 3} \ {r}, • from d i (resp.d i ) to d j and d j .
For an illustration see Figure 4. Figure 4: An example of two intersecting variable gadgets X i , X j corresponding to variables x i , x j , that appear together in some clause in φ, where it is the third appearance of x i and the first appearance of x j .
This finishes the construction of G φ .Before continuing with the reduction, we prove the following structural property of G φ .

Lemma 4
The diameter d φ of G φ is 10.
Proof.We prove this in two steps.First we show that the diameter of any variable gadget is 10 and then show that the diameter does not increase, when the variable edges are introduced, i.e., vertices in any two variable gadgets are at most 10 apart.Let us start with fixing a variable gadget X i .A path from the starting vertex s i to any ending vertex t i ( ∈ {1, 2, 3}) has to go through at least one of the vertices from {a i , a i }, then through at least one of the vertices from {b i , b i }, then through {c i , c i }, {d i , d i }, {e i , e i }, {f i , f i }, {g i , g i }, {h i , h i } and finally through {m i , m i }, before reaching the ending vertex.The shortest s i , t i path will go through exactly one vertex from each of the above sets.Therefore it is of length 10.Because of the construction of X i , there are exactly two s i , t i paths of length 10, which are edge and vertex disjoint, as they share only the starting and ending vertices.One of this paths uses the vertices a i , b i , c i , d i , e i , f i , g i , h i , m i (i.e., the left path) and the other uses vertices a i , b i , . . ., m i (i.e., the right path).A path between any two ending vertices t i , t i (where , ∈ {1, 2, 3} and = ), has to go through the following sets of vertices, Similarly as before, the shortest path uses exactly one vertex from each set and is of size 10.Even more, there are exactly two t i , t i paths of length 10.They are edge and vertex disjoint, as they share only the starting and ending vertices.One of this paths uses the vertices without the line in the label (i.e., the left path) and the other uses vertices with the line in the label (i.e., the right path).It is not hard to see that the distance between any other vertex in X i and starting or ending vertices is at most 9, as that vertex lies on one of the s i , t i or t i , t i -paths, but it is not an endpoint of it.By the similar reasoning there exists a path between any two vertices in X i (different than s i , t i ), of distance at most 9. Therefore the diameter of X i is 10.Now let us fix two variable gadgets X i , X j , that share no fork (i.e., x i and x j appear in no clause of φ).The shortest path from the starting vertex s i of X i to the starting vertex s j of X j has to reach vertex d i (resp.d i ), which is done in 4 steps, from where it connects to either d j or d j , using a variable edge, and continues toward s j , with 4 edges.Therefore, d(s i , s j ) = 9.The shortest path connecting vertex s i with t j , uses one of the vertices e i or e i , that are on the distance 5 from s i , then using one variable edge reaches f j or f j , which is on the distance 4 from the ending vertex t j .Therefore, d(s i , t j ) = 10, for all ∈ {1, 2, 3}.Lastly, the shortest path between an ending vertex t i of X i and an ending vertex t j uses 4 edges in the fork F X i to reach the vertex f i or f i , from where it uses a variable edge that connects it to the vertex e j or e j , that is on the distance 5 from the t j .Therefore, d(t i , t j ) = 10, for all , ∈ {1, 2, 3}.It is not hard to see that if two variable gadgets X i , X j share a fork the shortest path among any two vertices does not increase.
We proved that the distance among any two vertices in G φ is at most 10 and thus its diameter is 10.
where n is the number of variables in the formula φ.
Proof.Let τ be an optimum truth assignment of φ, i.e., a truth assignment that satisfies at least k clauses of φ.We will prove that there exists a temporal labeling λ φ of G φ which uses |λ φ | ≤ 13  2 n 2 + 99 2 n − 8k labels, such that (G, λ) is temporally connected and α(G, λ) = d φ = 10.Recall that, since φ is an instance of MonMaxXOR(3) with n variables, it has m = 3 2 n clauses.We build the labeling λ φ using the following rules.For an illustration see Figure 5.
1.If a variable x i from φ is set to be True by the truth assignment τ , we label the edges in X i in the following way: • all three left (s i , t i )-paths, for all ∈ {1, 2, 3}, get the labels 1, 2, 3, . . ., 10, one on each edge, • similarly, all left (t i , s i )-paths, get the labels 1, 2, 3, . . ., 10, one on each edge, • all connecting edges (i.e., edges of form y i y i , where y ∈ {a, b, c, d, e, f , g , h , m }) get the labels 1 and 10.
If a variable x i from φ is set to be False by the truth assignment τ , we label the edges in X i in the following way: • all three right (s i , t i )-paths, for all ∈ {1, 2, 3}, get the labels 1, 2, 3, . . ., 10, one on each edge, • similarly, all right (t i , s i )-paths, get the labels 1, 2, 3, . . ., 10, one on each edge, • all connecting edges get the labels 1 and 10.
Labeling λ φ uses 10 labels on the left (resp.right) path of the base BX i , 10 labels on the left (resp.right) path of each fork F X i , where ∈ {1, 2, 3} and 10 + 3 • 8 labels on the connecting edges.All in total λ φ uses 74 labels on the variable gadget X i .
We still need to prove that there exists a temporal path among any two vertices in X i .
There is a (unique) temporal path from the starting s i vertex to all three ending vertices t i , where ∈ {1, 2, 3}, using left (in case of x i being True) or right (in case of x i being False) paths of the base BX i and forks F X i .Similarly it holds for all temporal (t i , s i )paths.The temporal path connecting two ending vertices t 1 i , t 2 i , uses first the left (in case of x i being True) or right (in case of x i being False) path of the fork F 1 X i to reach e i (in case of x i being True) or e i (in case of x i being False), using the labels 1 to 5, and then continues on the left (in case of x i being True) or right (in case of x i being False) path of the F 2 X i from e i or e i to t 2 i , using labels 6 to 10.Any vertex not on the left (in case of x i being True) or right (in case of x i being False) path, can reach the starting vertex or any of the ending vertices, using a connecting edge at time 1.Similarly it hold for the paths in the opposite direction, where the connecting edges have the label 10.A temporal path among two vertices not on the left (in case of x i being True) or right (in case of x i being False) path uses first a connecting edge at time 1, then a portion of the left (in case of x i being True) or right (in case of x i being False) path and again the appropriate connecting edge at time 10.This proves that λ φ on X i admits a temporal path among any two vertices in X i .
2. If two variable gadgets X i and X j do not share a fork, i.e., variables x i and x j are not in the same clause in φ, and are both set to True by τ , then we label the following variable gadgets: • the edge d i d j , connecting the left path of BX i with the left path of BX j , gets the label 5, • three edges of the form e i f j ( ∈ {1, 2, 3}), that connect the left path of BX i to left paths of F X j , with the labels 4 and 6, • three edges of the form e j f i ( ∈ {1, 2, 3}), that connect the left path of BX j to left paths of F X i , with the labels 4 and 6.
The labeling λ φ uses 74 labels for each variable gadget and 13 labels on 7 variable edges that connect both variable gadgets.Note, the three other combinations (x i , x j are both False, one of x i , x j is True and the other False) give rise to the labeling λ φ that uses the same number of labels on both variable gadgets and variable edges, where the labeled variable edges are chosen appropriately.
Since labeling variable edges does not change the labeling on each variable gadget, we know that there is still a temporal path among any two vertices from the same variable gadget.We need to prove now that there is a temporal path among any two vertices from X i and X j .The edge d i d j , with the label 5, connects all the vertices from the BX i \{e i , e i } to the vertices from the BX j \ {e j , e j } and vice versa.To go from the starting vertex s i of X i to the ending vertex t j of X j we use the following route.From s i to e i we use the left labeled path on X i with labels from 1 to 5, then the edge e i f j at time 6 to reach the corresponding fork F ell X j of X j and from f j to the ending vertex t j we use the left labeled path of X j with labels 7 to 10.This temporal path connects all vertices in the base BX i to all vertices in the forks F X j , where ∈ {1, 2, 3}.Similar we obtain temporal paths from vertices in the base BX j to vertices in the forks F X i , where ∈ {1, 2, 3}.To go from any vertex in the fork F X i to any vertex of the X j we use the following route.First, we reach the vertex f i , by the time 4, using the left labeled path of X i .Then we use the edge f i e j at time 5. Now, by the construction of λ φ of X j , each vertex in X j can be reached from e j from time 5 to 10. Therefore all vertices from F X i can reach any vertex in X j .This is true for all ∈ {1, 2, 3}.Similarly it holds for temporal paths from any vertex in the fork F X j ( ∈ {1, 2, 3}) to vertices of the X i .The only thing left to show is that the vertices {e i , e i can reach all other vertices in BX j .This is true as there is a temporal path using the edge e i f j at time 5 and then, from f j to any vertex in the base BX j , the left labeled path of BX j , that is labeled by λ φ .This is true for all ∈ {1, 2, 3}.
Similarly it holds for the temporal paths from {e j , e j } to the vertices in BX i .Therefore λ φ admits a temporal path among any two vertices of variable gadgets, that do not share the fork.
3. If two variable gadgets X i and X j share a fork, i.e., variables x i and x j are in the same clause, are both set to True and F r X i = F r X j , then we label the following variable edges: • the edge d i d j , connecting the left path of BX i and BX j , gets the label 5, • two edges of the form e i f j ( ∈ {1, 2, 3} \ {r }), that connect the left path of BX i to left paths of F X j , with the labels 4 and 6, • two edges of the form e j f i ( ∈ {1, 2, 3} \ {r}), that connect the left path of BX j to left paths of F X i , with the labels 4 and 6.
The labeling λ φ uses 9 labels on 5 variable edges that connect both variable gadgets.Note, the three other combinations (x i , x j are both False, one of x i , x j is True and the other False) give rise to the labeling λ φ that uses the same number of labels on variable edges, where the labeled edges are chosen accordingly to the truth values of x i and x j .The only difference is in the labeling of the shared fork F r X i = F r X j .There are two possibilities, one when the truth value of x i and x j is the same and one when it is different, i.e., x i = x j or x i = x j .
a) Let us start with the case when x i = x j .Without loss of generality (w.l.o.g.) we can assume that x i is True and x j False.In the labeling λ φ we label all left paths in the variable gadget X i and all right paths in X j .By the construction of the graph G φ (and the rules of how to identify vertices of the two forks), the left labeling of F r X i coincides with the right labeling of F r X j .Therefore λ φ uses 2 • 74 − 16 = 132 labels on both variable gadgets.
b) Let us now observe the case when x i = x j .W.l.o.g.we can assume that both variables are True.In the labeling λ φ we label all left paths of both variable gadgets.By the construction of the graph G φ (and the rules of how to identify vertices of the two forks), the fork F r X i = F r X j gets labeled from both sides, i.e., all edges in the fork get 2 labels.Therefore λ φ uses 2 • 74 − 8 = 140 labels on both variable gadgets.
Identifying two forks F r X i = F r X j and labeling them using the union of both labelings on each fork, preserves temporal paths among all the vertices from X i and X j .This is true as the labeling in each variable is not changed by the labeling in the other variable.Among forks that are not in the intersection there are still the variable edges left, which assure that vertices from different variable gadgets can reach them or can be reached by them.Therefore the labeling λ φ admits a temporal path among any two vertices from the variable gadgets X i , X j , that have a fork in the intersection.
Summarizing all of the above we get that the labeling λ φ uses 74 labels on each variable gadget and 13 labels on variable edges among any two variables, from which we have to subtract the following: • 4 labels for each pairs of variable edges between two variables that appear in the same clause, • 16 labels for the shared fork between two variables, that appear in a satisfied clause, • 8 labels for the shared fork between two variables, that appear in a non-satisfied clause.
Altogether sums up to the 74n + 13 n(n−1) 2 − 4m − 16k − 8(m − k) labels.Therefore, if τ satisfies at least k clauses of φ, the labeling λ φ consists of at most 13  2 n 2 + 99 2 n − 8k labels.Before proving the statement in the other direction, we have to show some structural properties.Let us fix the following notation.If a labeling λ φ labels all left (resp.right) paths of the variable gadget X i (i.e., both bottom-up from s i to t 1 i , t 2 i , t 3 i and top-down from t 1 i , t 2 i , t 3 i to s i with labels 1, 2 . . ., 10 in this order), then we say that the variable gadget X i is left-aligned (resp.right-aligned ) in the labeling λ φ .Note, if at least one edge on any of these left (resp.right) paths of X i is not labeled with the appropriate label between 1 and 10, then the variable gadget is not left-aligned (resp.not right-aligned).Every temporal path from s i to t i (resp.from t i to s i ) of length 10 in X i is called an upward path (resp.a downward path) in X i .Any part of an upward (resp.downward) path is called a partial upward (resp.downward) path.Note that, for any , ∈ {1, 2, 3}, = , a temporal path from t i to t i of length 10 is the union of a partial downward path on the fork F i and a partial upward path on F i .Moreover, note that these two partial downward/upward paths must be either both parts of a left temporal path or both parts of a right temporal path between s i and t i , t i .The following technical lemma will allow us to prove the correctness of our reduction.
Lemma 5 Let λ φ be a minimum labeling of G φ .Then λ φ can be modified in polynomial time to a minimum labeling of G φ in which each variable gadget X i is either left-aligned or right-aligned.
Proof.Let λ φ be a minimum labeling of G φ that admits at least one variable gadget X i that is neither left-aligned nor right-aligned.
First we will prove that there exists a fork F X i of X i that admits at least three partial upward or downward paths, i.e., it either has two partial upward paths (one on each side of the fork) and at least one partial downward path, or two partial downward paths (one on each side of the fork) and at least one partial upward path.For the sake of contradiction, suppose that each of the forks F 1 X i , F 2 X i , F 3 X i contains at most two partial upward or downward paths.Then, since λ φ must have in X i at least one upward and at least one downward path between s i and t i , ∈ {1, 2, 3}, it follows that each fork F X i has exactly one partial upward and exactly one partial downward path.
Assume that each of the forks F 1 X i , F 2 X i , F 3 X i has both its partial upward and downward paths on the same side of X i (i.e., either both on the left or both on the right side of X i ).If (a) x i and x j do not appear together in any clause.
(b) x i and x j appear together in a clause, where x i appears with its third and x j with its first appearance.
Figure 5: Example of the labeling λ on variable gadgets X i , X j and variable edges between them, where x i is True and x j False in φ.Note, edges that are not labeled are omitted, all of them have their partial upward and downward paths on the left (resp.right) side of X i , then X i is left-aligned (resp.right-aligned), which is a contradiction.Therefore, at least one fork (say F 1 X i ) has its partial upward and downward paths on the left side of X i and at least one other fork (say F 2 X i ) has its partial upward and downward paths on the right side of X i .But then there is no temporal path from t 1 i to t 2 i of length 10 in λ φ , which is a contradiction.Therefore there exists at least one fork F X i (say, F 1 X i w.l.o.g.), in which (w.l.o.g.) the partial upward path is on the right side and the partial downward path is on the left side of X i .
Since the partial downward path of F 1 X i is on the left side of X i , it follows that the partial upward path of each of F 2 X i and F 2 X i is on the left side of X i .Indeed, otherwise there is no temporal path of length 10 from t 1 i to t 2 i or t 3 i in λ φ , a contradiction.Similarly, since the partial upward path of F 1 X i is on the right side of X i , it follows that the partial downward path of each of F 2 X i and F 2 X i is on the right side of X i .But then, there is no temporal path of length 10 from t 2 i to t 3 i , or from t 3 i to t 2 i in λ φ , which is also a contradiction.Therefore at least one fork F X i (say F 3 X i ) of X i admits at least three partial upward or downward paths.
W.l.o.g.we can assume that the fork F 3 X i has two partial downward paths and at least one partial upward path which is on the left side of X i .We distinguish now the following cases.Case A. The fork F 3 X i has no partial upward path on the right side of X i .Then the base BX i has a partial upward path on the left side of X i .Furthermore, each of the forks F 1 X i , F 2 X i has a partial downward path on the left side of X i .
Case A-1.The base BX i of X i has no partial downward path on the left side of X i ; that is, there is no temporal path from vertex e i to vertex s i with labels "6,7,8,9,10".Then the base BX i of X i has a partial downward path on the right side of X i , as otherwise there would be no temporal path of length 10 from any of t 1 i , t 2 i , t 3 i to s i .For the same reason, each of the forks F 1 X i , F 2 X i has a partial downward path on the right side of X i .Case A-1-i.None of the forks F 1 X i , F 2 X i has a partial upward path on the left side of X i .Then each of the forks F 1 X i , F 2 X i has a partial upward path on the right side of X i , as otherwise there would be no temporal path of length 10 from s i to t 1 i or t 2 i .For the same reason, the base BX i has a partial upward path on the right side of X i .Therefore we can remove the label "5" from the left bridge edge e i f 3 i of the fork F 3 X i , thus obtaining a labeling with fewer labels than λ φ , a contradiction.Case A-1-ii.Exactly one of the forks F 1 X i , F 2 X i (say F 1 X i ) has a partial upward path on the left side of X i .Then the fork F 2 X i has a partial upward path on the right side of X i .Furthermore the base BX i has a partial upward path on the right side of X i , since otherwise there would be no temporal path of length 10 from s i to t 2 i .In this case we can modify the solution as follows: remove the labels "1,2,3,4,5" from the partial right-upward path of BX i and add the labels "6,7,8,9,10" to the partial left-upward path of the fork F 2 X i .Finally we can remove the label "5" from the right bridge edge e i f i 3 of the fork F 3 X i , thus obtaining a labeling with fewer labels than λ φ , a contradiction.
Case A-1-iii.Each of the forks F 1 X i , F 2 X i has a partial upward path on the left side of X i .In this case we can modify the solution as follows: remove the labels "10,9,8,7,6" from the partial right-downward path of BX i and add the same labels "10,9,8,7,6" to the partial left-downward path of the base BX i .Finally we can remove the label "5" from the right bridge edge e i f i 3 of the fork F 3 X i , thus obtaining a labeling with fewer labels than λ φ , a contradiction.
Case A-2.The base BX i of X i has a partial downward path on the left side of X i ; that is, there is a temporal path from vertex e i to vertex s i with labels "6,7,8,9,10".Case A-2-i.None of the forks F 1 X i , F 2 X i has a partial upward path on the left side of X i .
Then the base BX i and each of the forks F 1 X i , F 2 X i have a partial upward path on the right side of X i , as otherwise there would be no temporal paths of length 10 from s i to t 1 i , t 2 i .Moreover, as none of F 1 X i , F 2 X i has a partial left-upward path, it follows that each of F 1 X i , F 2 X i has a partial downward path on the right side of X i .Indeed, otherwise there would be no temporal paths of length 10 between t 1 i and t 2 i .In this case we can modify the solution as follows: remove the labels "1,2,3,4,5" from the partial left-upward path of BX i and add the labels "6,7,8,9,10" to the partial right-upward path of the fork F 3 X i .Finally we can remove the label "6" from the left bridge edge e i f 3 i of the fork F 3 X i , thus obtaining a labeling with fewer labels than λ φ , a contradiction.Case A-2-ii.Exactly one of the forks F 1 X i , F 2 X i (say F 1 X i ) has a partial upward path on the right side of X i .Then the fork F 2 X i has a partial upward path on the left side of X i .Furthermore the base BX i must have a partial right-upward path, as otherwise there would be no temporal path from s i to t 2 i .In this case we can modify the solution as follows: remove the labels "1,2,3,4,5" from the partial right-upward path of BX i and add the labels "6,7,8,9,10" to the partial left-upward path of the fork F 2 X i .Finally we can remove the label "5" from the right bridge edge e i f i 3 of the fork F 3 X i , thus obtaining a labeling with fewer labels than λ φ , a contradiction.
Case A-2-iii.Each of the forks F 1 X i , F 2 X i has a partial upward path on the right side of X i .
Then we we can simply remove the label "5" from the right bridge edge e i f i 3 of the fork F 3 X i , thus obtaining a labeling with fewer labels than λ φ , a contradiction.
Case B. The fork F 3 X i has also a partial upward path on the right side of X i .That is, F 3 X i has partial upward-left, upward-right, downward-left, and downward-right paths.
Case B-1.The base BX i of X i has no partial downward path on the left side of X i .Then the base BX i of X i has a partial downward path on the right side of X i , as otherwise there would be no temporal path of length 10 from any of t 1 i , t 2 i , t 3 i to s i .For the same reason, each of the forks F 1 X i , F 2 X i has a partial downward path on the right side of X i .
Note that Case B-1 is symmetric to the case where the base BX i of X i has no partial right-downward (resp.left-upward, right upward) path.Case B-1-i.None of the forks F 1 X i , F 2 X i has a partial upward path on the left side of X i .This case is the same as Case A-1-i.Case B-1-ii.Exactly one of the forks F 1 X i , F 2 X i (say F 1 X i ) has a partial upward path on the left side of X i .Then both the base BX i and the fork F 2 X i has a partial right-upward path, as otherwise there would be no temporal path of length 10 from s i to t 2 i .In this case, we can always remove the label "6" from the left bridge edge e i f 3 i of the fork F 3 X i (without compromising the temporal connectivity), thus obtaining a labeling with fewer labels than λ φ , a contradiction.Case B-1-iii.Each of the forks F 1 X i , F 2 X i has a partial upward path on the left side of X i .That is, each of F 1 X i , F 2 X i has a partial left-upward and a partial right-downward path.The following subcases can occur: Case B-1-iii(a).None of the forks F 1 X i , F 2 X i has a partial right-upward path.Then each of the forks F 1 X i , F 2 X i has a partial left-downward path, since otherwise there would not exist temporal paths of length 10 between t 1 i and t 2 i .Furthermore, the base BX i has a partial leftupward path, since otherwise there would not exist a temporal path of length 10 from s i to t 1 i and t 2 i .In this case, we can remove the label "6" from the right bridge edge e i f i 3 of the fork F 3 X i , thus obtaining a labeling with fewer labels than λ φ , a contradiction.Case B-1-iii(b).Exactly one of the forks F 1 X i , F 2 X i (say F 1 X i ) has a partial right-upward path.Then the base BX i has a partial left-upward path, since otherwise there would not exist a temporal path of length 10 from s i to t 2 i .Similarly, the fork F 1 X i has a partial left-downward path, since otherwise there would not exist a temporal path of length 10 from t 1 i to t 2 i .In this case we can modify the solution as follows: First, remove the labels "10,9,8,7,6" from the partial right-downward path of BX i and add the labels "10,9,8,7,6" to the partial left-downward path of BX i .Second, remove the labels "5,6" from each of t two right bridge edges e i f i 1 and e i f i of the forks F 1 X i and F 3 X i , respectively.Third, remove the label "5" from the right bridge edge e i f i 1 of the fork F 2 X i .Finally, add the five labels "5,4,3,2,1" to the partial left-downward path of the fork F 2 X i .The resulting labeling λ * φ still preserves the temporal reachabilities and has the same number of labels as λ φ , while the variable gadget X i is aligned.Case B-1-iii(c).Each of the forks F 1 X i , F 2 X i has a partial right-upward path.In this case, we can always remove the label "5" from the left bridge edge e i f 3 i of the fork F 3 X i , thus obtaining a labeling with fewer labels than λ φ , a contradiction.
Case B-2.The base BX i of X i has partial left-downward, right-downward, left-upward, and right-upward paths.Then, due to symmetry, we may assume w.l.o.g. that the fork F 1 X i has a left-upward path.Suppose that F 1 X i has also a left-downward path.In this case we can modify the solution as follows: remove the labels "1,2,3,4,5" and "10,9,8,7,6" from the partial right-upward and right-downward paths of BX i and add the labels "6,7,8,9,10" and "5,4,3,2,1" to the partial left-upward and left-downward paths of the fork F 2 X i .Finally we can remove the label "6" from the right bridge edge e i f i 3 of the fork F 3 X i , thus obtaining a labeling with fewer labels than λ φ , a contradiction.Finally suppose that F 1 X i has no partial left-downward path.Then F 1 X i has a partial right-down path, since otherwise there would not exist any temporal path of length 10 from t 1 i to s i .Similarly, the fork F 2 X i has a partial right-upward path, since otherwise there would not exist any temporal path of length 10 from t 1 i to t 2 i .In this case we can modify the solution as follows: First remove the labels "1,2,3,4,5" and "10,9,8,7,6" from the partial left-upward and left-downward paths of BX i .Second add the labels "6,7,8,9,10" to the partial right-upward path of the fork F 1 X i and add the labels "5,4,3,2,1" to the partial right-downward path of the fork F 2 X i .Finally remove the label "6" from the left bridge edge e i f 3 i of the fork F 3 X i , thus obtaining a labeling with fewer labels than λ φ , a contradiction.Summarizing, starting from an optimum λ φ of G φ , in which at least one variable gadget is neither left-aligned nor right-aligned, we can modify λ φ to another labeling λ * φ , such that λ * φ has one more variable-gadget that is aligned and |λ φ | = |λ * φ |.Note that this modification can only happen in Case B-1-iii(b); in all other cases our case analysis arrived at a contradiction.Note here that, by making the above modifications of λ φ , we need to also appropriately modify the "connecting edges" (within the variable gadgets) and the "variable edges" (between different variable gadgets), without changing the total number of labels in each of these edges.Finally, it is straightforward that all modifications of λ φ can be done in polynomial time.This concludes the proof.
where n is the number of variables in the formula φ.
Proof.Recall by Lemma 4 that d φ = 10.Let λ φ be an optimum solution to MAL(G φ , 10), which uses OPT MAL (G φ , d φ ) ≤ 13  2 n 2 + 99 2 n − 8k labels by the assumption of the theorem.We will prove that there exists a truth assignment τ that satisfies at least k clauses of φ.Recall that, since φ is an instance of MonMaxXOR(3) with n variables, it has m = 3 2 n clauses.Let X i and X j be two variable gadgets in G φ .First we observe that the temporal path from a starting vertex s i of X i , to any of the ending vertices t i , where ∈ {1, 2, 3}, must only go through the vertices and edges of the variable gadget X i .This is true since in any other case the temporal path would use at least one variable edge and in this case the distance of the path would increase by at least one.Therefore, the path would be of length at least 11, but since the diameter of the graph is 10, the largest label that is allowed to be used is 10 and thus the longest temporal path can use at most 10 edges.Similarly it holds for temporal paths from the ending vertices t i ( ∈ {1, 2, 3}) to the starting vertex s i and the temporal paths among the ending vertices.Even more, these temporal paths must be either all on the left or all on the right side of X i , i.e., they have to use vertices and edges that are all on the left or the right side of the base BX i and each fork F X i .This holds as paths of any other form (i.e., containing vertices and edges of both sides) are of length at least 11.Consequently, to label a (s i , t 1 i )-path in both directions any labeling must use at least 2 • 10 labels.Now, to label (s i , t 2 i ) and (s i , t 3 i )-paths, the labels on the base BX i can be reused, which produces additional 10 labels on each fork F 2 X i and F 3 X i .In the case when all these labels were used on the same path of the variable gadget i.e., all labels were placed on the left or on the right side of BX i and F i X i , there are also temporal paths connecting all three ending vertices, without having to introduce any extra labels.The only missing part is to assure that also all the vertices from the opposite side (i.e., if the labeling used left paths, then the opposite vertices are on the right side, or vice versa) are able to reach and be reached by any other vertex.Therefore, we need at least 2 more labels (one for incoming and one for outgoing temporal paths) on the edges connecting them with the path (vertices) on the other side.Altogether, to ensure the existence of a temporal path between any two vertices from X i , a labeling must use at least 74 labels on a variable gadget X i .Now, let X i and X j be such variable gadgets that do not share the fork.As observed above, all vertices from each variable gadget can only be reached among each other, without using the variable edges.Therefore, the variable edges must be labeled in such a way, that they ensure a temporal path among vertices from different variable gadgets.W.l.o.g.we can assume that X i is left-aligned and X j is right-aligned by λ φ (all the other cases of aligned and non-aligned labelings of X i and X j by λ φ , are symmetric).Since the starting vertex s i is on the distance 10 from the ending vertices of t j ( ∈ {1, 2, 3}) of X j , there must be a temporal path using all labels, to connect them.This path must use the edge of the form e i f j , as any other path is longer than 10.Since the path must be traversed in both direction each edge e i f j ( ∈ {1, 2, 3}) must have at least 2 labels.Similarly it holds for the (s j , t i )-paths ( ∈ {1, 2, 3}) and the edges e j f i ( ∈ {1, 2, 3}).For a vertex s i to reach s j we must label the edge d i d j , as any other (s i , s j )-path is longer than 10.Therefore, we need at least one extra label for the edge d i d j .Altogether, to ensure the existence of a temporal path among two vertices from two variable gadgets that do not share a fork, a labeling must use at least 13 labels on the variable edges.
Lastly, let X i and X j be two variable gadgets that share a fork.W.l.o.g.we can suppose that X i is left-aligned by the optimum labeling λ φ and that F r X i = F r X j .By the construction of G φ , there exists a temporal path to and from all the vertices in the fork F r X i = F r X j to all vertices in X i and X j , as there is a temporal path among all vertices from X i and a temporal path among all vertices in X j .As observed above, these paths do not use the variable edges, but the variable edges must be labeled in such a way, that they ensure a temporal path among vertices from different variable gadgets.Now if we suppose that the variable gadget X j is rightaligned by the labeling λ φ , then a temporal path between s i and s j must use the edge d i d j and therefore at least one extra label is used for this edge.A temporal path between s i and t j , where ∈ {1, 2, 3} \ {r }, must use the edge e i f j .Since the edge of this form is traversed in both directions it must have at least two labels.Similarly it holds for the temporal paths between t i ( ∈ {1, 2, 3} \ {r}) and s j .Altogether, to ensure the existence of a temporal path among any two vertices from two variable gadgets that share a fork, a minimum labeling must use at least 9 labels on the variable edges.Similarly we can see that also all other combinations of aligned and non-aligned labelings of X i and X j by λ φ , require at least 9 labels on the variable edges.
The only thing left to study, in the case of two variable gadgets that share a fork, is what happens in the intersecting fork.By Lemma 5 we know that the variable gadgets X i and X j are aligned by the labeling λ φ .Suppose that F r X i = F r X j .W.l.o.g.we can assume that X i is left-aligned.We distinguish the following two cases.
• The variable gadget X j is right-aligned.Then, by the construction of G φ , the fork F 1 X i = F 1 X j is labeled using the same labeling, i.e., the left labeling of the variable gadget X i coincides with the right labeling of the variable gadget X j .This "saves" 16 labels from the total number of labels used on variable gadgets X i and X j .
• The variable gadget X j is left-aligned.In this case all edges in the fork F 1 X i = F 1 X j admit two labels.This "saves" 8 labels from the total number of labels used on variable gadgets X i and X j , since both labelings coincide on the connecting edges.
From the labeling λ φ of G φ we construct a truth assignment τ of φ in the following way.If a variable gadget X i is left-aligned, we set x i to True and if it is right-aligned, we set x i to False.Using the results from above we deduce that the truth assignment τ satisfies at most k clauses.
Since MAL is clearly in NP, the next theorem follows directly by Theorems 3 to 5.
Theorem 6 MAL is NP-complete on undirected graphs, even when the required maximum age is equal to the diameter of the input graph.

The Steiner-Tree variations of the problem
In this section we investigate the computational complexity of the Steiner-Tree variations of the problem, namely MSL and MASL.First, we prove in Section 4.1 that the age-unrestricted problem MSL remains NP-hard, using a reduction from Vertex Cover.In Section 4.2 we prove that this problem is in FPT, when parameterized by the number |R| of terminals.Finally, using a parameterized reduction from Multicolored Clique, we prove in Section 4.3 that the age-restricted version MASL is W [1]-hard with respect to |R|, even if the maximum allowed age is a constant.

MSL is NP-complete
Proof.MSL is clearly contained in NP.To prove that the MSL is NP-hard we provide a polynomial-time reduction from the NP-complete Vertex Cover problem [25].

Vertex Cover Input:
A static graph G = (V, E), a positive integer k.Question: Does there exist a subset of vertices S ⊆ V such that |S| = k and ∀e ∈ E, e ∩ S = ∅.
Let (G, k) be an input of the Vertex Cover problem and denote |V (G)| = n, |E(G)| = m.We assume w.l.o.g. that G does not admit a vertex cover of size k −1.We construct (G * , R * , k * ), the input of MSL using the following procedure.The vertex set V (G * ) consists of the following vertices: • two starting vertices N = {n 0 , n 1 }, • a "vertex-vertex" corresponding to every vertex of G: • an "edge-vertex" corresponding to every edge of G: The edge set E(G * ) consists of the following edges: • an edge between starting vertices, i.e., n 0 n 1 , • a path of length 3 between a starting vertex n 1 and every vertex-vertex u v ∈ U V using 2 dummy vertices, and • for every edge e = vw ∈ E(G) we connect the corresponding edge-vertex u e with the vertex-vertices u v and u w , each with a path of length 6k + 1 using 6k dummy vertices.
We set R * = {n 0 } ∪ U E and k * = 6k + 2m(6k + 1) + 1.This finishes the construction.It is not hard to see that this construction can be performed in polynomial time.For an illustration see Figure 6.Note that any two paths in G * can intersect only in vertices from N ∪ U V ∪ U E and not in any of the dummy vertices.At the end G * is a graph with 3n + m(12k + 1) + 2 vertices and 1 + 3n + 2m(6k + 1) edges.
We claim that (G, k) is a YES instance of the Vertex Cover if and only if (G * , R * , k * ) is a YES instance of the MSL.(⇒): Assume (G, k) is a YES instance of the Vertex Cover and let S ⊆ V (G) be a vertex cover for G of size k.We construct a labeling λ for G * that uses k * labels and admits a temporal path between all vertices from R * as follows.
For the sake of easier explanation we use the following terminology.A temporal path starting at n 0 and finishing at some u e is called a returning path.Contrarily, a temporal path from some u e to n 0 is called a forwarding path.
Let U S be the set of corresponding vertices to S in G * .From each edge vertex u e there exists a path of length 6k + 1 to at least one vertex u v ∈ U S , since S is a vertex cover in G.We label exactly one of these paths, using labels 1, 2, . . ., 6k + 1.Since S is of size k, this part uses k(6k + 1) labels.Now we label a path from each v ∈ U S to n 1 using labels 6k + 2, 6k + 3, 6k + 4. Each path uses 3 labels, and since S is of size k we used 3k labels for all of them.At the end we label the edge n 0 n 1 with the label * = 6k + 5. Using this procedure we have created a forwarding path from each edge vertex u e to the start vertex n 0 and we used 3k + m(6k + 1) + 1 labels.
To create the returning paths, we label paths from n 1 to each vertex in U S with labels * + 1, * + 2, * + 3. Now again, we label exactly one path from vertices in U S to each edgevertex u e , using labels * + 4, * + 5, . . ., * + 3 + 6k.We used extra 3k + m(6k + 1) labels and created a returning path from n 0 to each vertex in U E .
All together, the constructed labeling uses k * = 6k +2m(6k +1)+1 labels, the only thing left to show is that there exists a temporal path between any pair of edge-vertices u e , u f ∈ U E .It is not hard to see that this holds, as we can construct a temporal path between two edge-vertices as a union of a (sub)path of a temporal path from the first edge-vertex to the starting vertex n 0 and a (sub)path of a temporal path from the starting vertex to the other edge-vertex.
(⇐): Assume that (G * , R * , k * ) is a YES instance of the MSL.We construct a vertex cover of size at most k for G as follows.
Let us first observe the following, a forwarding and returning path between the starting vertex n 0 and the same edge-vertex u e , can intersect in at most one time edge.Even more, two temporal paths between the same pair of vertices, going in the opposite directions, intersect in at most one time edge.
By the construction of G * each (temporal) path between n 0 and a vertex in U E passes through the set U V .Since there are m vertices in U E and each path between a vertex u e ∈ U E and some u v ∈ U V is of length 6k + 1, we need at least m(6k + 1) labels to connect U E to U V in "one direction".Using the observation from above, we get that there can be at most 1 time edge in common between any two temporal paths among any pair of edge-vertices, therefore we need at least 2m(6k + 1) − 1 labels for paths in both directions.We call these the forwarding path F e (from u e to some u v ) and the returning path R e (from some u v to u e ) for u e .It is straightforward to check that every u e can have at most one forwarding path and one returning path, since every additional path would require at least an additional 6k labels and then no connection between n 0 and U V would be possible.
All labeled temporal paths between N and U V can be split into two sets, one containing all temporal paths that are a part of (or can be extended to) some returning path, denote them P + N and the others which are a part of (or can be extended to) some forwarding path, denote them P − N .It is not hard to see that each temporal path from P + N or P − N starts and ends in N ∪ U V , i.e., no temporal path starts/ends in one of the dummy vertices.Therefore each temporal path in P + N or P − N uses 3 labels.Again, using the above observation we get that temporal paths from P + N and P − N share at most one label.Since this part uses at most 6k + 1 labels, there are at most 2k temporal paths in P + N and P − N .Suppose that , U S consists of vertices that are endpoints of temporal paths in P + N .We claim that S = {v | u v ∈ U S } is a vertex cover of G and |S| ≤ k.It is not hard to see that |P + N | ≤ k and therefore |S| ≤ k.We first make the following observation.We define a partial order on the set P = {F e , R e | e ∈ E} of forwarding and returning paths as follows.For two paths P, Q ∈ P, we say that P < Q if all labels used in P are strictly smaller than the smallest label used in Q.We can assume w.l.o.g. that the defined ordering is a total ordering on P since we can order incomparable path pairs arbitrarily by modifying the labels in a way that does not change the size and the connectivity properties of the labeling.Furthermore, we can observe that for any two e, e ∈ E with e = e we have that F e < R e since in order for u e to reach u e , the path F e needs to be used before the path R e .It follows that there is at most one edge e ∈ E such that R e < F e , otherwise we would reach a contradiction to the above observation.Now assume for contradiction that S is not a vertex cover of G. Then there is an edge e = {v, w} ∈ E such that {v, w} ∩ S = ∅.To reach u e from n 0 there needs to be an edge e = {v, w } (or symmetrically {w, w }) such that we can reach u w from n 1 via some path P , then continue to u e using R e , then continue to u v using F e , finally reach u e using R e .Notice that this requires P < R e < F e < R e .This implies that the path from n 0 to u e cannot be longer since otherwise there would be two edges e , e with R e < F e and R e < F e , a contradiction.It also implies that edge e is the only edge in E with e ∩ S = ∅.
Now consider an edge e = {w , v } = e such that there is no direct path from n 0 to u v .If such an edge does not exist then w and all of its neighbors , different than v, are in S. Hence we can remove w from S and add v to S to obtain a vertex cover for G of size at most k.Assume that edge e with the described properties exists and consider the temporal path from u e to u e .This path must start with F e thus reaching u v .From there the path cannot continue to some u e since for all e = e we have that F e < R e hence the path cannot continue from u e .It follows that the path has to eventually reach n 1 continue to u w from there.However, recall that P < F e which means that we cannot use P to reach u w from n 1 .Hence, there is a second temporal path P (using the same edges as P with later labels) from n 1 to u w with F e < P .This implies that |S| < k and we can add v to S to obtain a vertex cover of size at most k for G.

An FPT-algorithm for MSL with respect to the number of terminals
In this section we provide an FPT-algorithm for MSL, parameterized by the number |R| of terminals.The algorithm is based on a crucial structural property of minimum solutions for MSL: there always exists a minimum labeling λ that labels the edges of a subtree of the input graph (where every leaf is a terminal vertex), and potentially one further edge that forms a C 4 with three edges of the subtree.
Intuitively speaking, we can use an FPT-algorithm for Steiner Tree parameterized by the number of terminals [14] to reveal a subgraph of the MSL instance that we can optimally label using Theorem 1.Since the number of terminals in the created Steiner Tree instance is larger than the number of terminals in the MSL instance by at most a constant, we obtain an FPT-algorithm for MSL parameterized by the number of terminals.
Lemma 6 Let G = (V, E) be a graph, R ⊆ V a set of terminals, and k be an integer such that (G, R, k) is a YES instance of MSL and (G, R, k − 1) is a NO instance of MSL.
• If k is odd, then there is a labeling λ of size k for G such that the edges labeled by λ form a tree, and every leaf of this tree is a vertex in R.
• If k is even, then there is a labeling λ of size k for G such that the edges labeled by λ form a graph that is a tree with one additional edge that forms a C 4 , and every leaf of the tree is a vertex in R.
The main idea for the proof of Lemma 6 is as follows.Given a solution labeling λ, we fix one terminal r * and then (i) we consider the minimum subtree in which r * can reach all other terminal vertices and (ii) we consider the minimum subtree in which all other terminal vertices can reach r * .Intuitively speaking, we want to label the smaller one of those subtrees using Theorem 1 and potentially adding an extra edge to form a C 4 ; we then argue that the obtained labeling does not use more labels than λ.To do that, and to detect whether it is possible to add an edge to create a C 4 , we make a number of modifications to the trees until we reach a point where we can show that our solution is correct.Proof.Assume there is a labeling λ for G that labels all edges in the subgraph H of G.We describe a procedure to transform H into a tree T by removing edges from H such that T can be labeled with k labels such that all vertices in R are pairwise temporally connected.
Consider a terminal vertex r * ∈ R. is not a tree.Then there is a vertex v ∈ V (H + r * ) such that v is temporally reachable from r * in (H + r * , λ + r * ) via two temporal paths P, P that visit different vertex sets, i.e.V (P ) = V (P ).Assume w.l.o.g. that both P and P are foremost among all temporal paths that visit the vertices in V (P ) and V (P ), respectively, in the same order.Let the arrival time of P be at most the arrival time of P .Then we can remove the last edge traversed by P with all its labels from (H + r * , λ + r * ) such that afterwards r * can still temporally reach all vertices in R \ {r * }, a contradiction to the minimality of H + r * .From now on, assume that H + r * is a tree.Assume that H + r * contains a leaf vertex v that is not contained in R. Then we can remove v from (H + r * , λ + r * ) such that afterwards r * can still temporally reach all vertices in R \ {r * }, a contradiction to the minimality of H + r * .Lastly, assume that there is an edge e = uv in H + r * such that λ + r * assigns more than one label to e. Let v be further away from r * than u in H + r * and let P be a foremost temporal path from r * to v in (H + r * , λ + r * ) with arrival time t.Then we can remove all labels except for t from e and afterwards r * can still temporally reach all vertices in R \ {r * }, a contradiction to the minimality of λ + r * .Let H − r * be a minimum subgraph of H and λ − r * a minimum sublabelling of λ for H − r * such that each vertex in R \ {r * } can temporally reach r * in (H − r * , λ − r * ).We can observe by analogous arguments as above that H − r * is a tree where all leafs are vertices from R and λ − r * assigns exactly one label to every edge in H − r * .We define the following sets of edges: • The set of edges only appearing in H + r * : • The set of edges only appearing in • The set of edges appearing in both H + r * and H − r * : • The set of edges appearing in both H + r * and H − r * that receive the same label from λ + r * and λ − r * : We claim that there exists a labelling λ of size k for G such that there are two trees with the above described properties and and there exist two edges e + , e − in H that each of them, when added to We first argue that the statement of the lemma follows from this claim.Afterwards we prove the claim.Assume that It follows that we can temporally label H + r * with at most k labels such that all vertices in H + r * can pairwise temporally reach each other, using the result that trees with m edges can be temporally labeled with 2m − 1 labels (see Theorem 1).Since we assume (G, R, k − 1) is a NO instance of MSL it follows that k = 2m − 1 and hence this can only happen if k is odd.
It follows that we can temporally label H + r * together with edge e + with at most k labels such that all vertices in H + r * with edge e + can pairwise temporally reach each other, using the result that graphs containing a C 4 with n vertices can be temporally labeled with 2n − 4 labels (see Theorem 1).Since we assume (G, R, k − 1) is a NO instance of MSL it follows that k = 2n − 4 and hence this can only happen if k is even.Now we prove that there exists a labeling λ of size k for G such that there are two trees H + r * , H − r * with the above described properties and r * be two trees with the above described properties and x for some x ≥ 0. We will argue that by slightly modifying the labeling λ (and with that λ + r * and λ − r * , that way ultimately obtaining λ ) and We will argue that in the former case we must have that k is odd, and in the latter case we must have that k is even.Note that if |E * r * | = 1 we are done, hence assume from now on that |E * r * | ≥ 2. We consider several cases.For the sake of presentation of the next cases, define the head of a temporal path as the last vertex visited by the path and the extended head of a temporal path as the last two vertices visited by the path.Furthermore, define the tail of a temporal path as the first vertex visited by the path and the extended tail of a temporal path as the first two vertices visited by the path.
Case A. Assume there is a temporal path P from r * to some r ∈ R \ {r * } in H + r * that traverses two edges in E * r * .Let e, e ∈ E * r * with e = e such that there is a temporal path P from r * to some r ∈ R \ {r * } in H + r * that traverses w.l.o.g.first e and then e and a maximum number α of edges lies between them in P and the distance β between r * and e is minimum.Note that this implies that λ + r * (e) < λ + r * (e ).In the following we analyse several cases.In some of them we can deduce that the labeling λ must use labels that are not present in λ + r * or λ − r * that are unique to that case.This implies that for each of these cases we can attribute one label outside of λ + r * and λ − r * to edge e or e .In some other cases we describe modifications that do not increase Whenever a modification satisfies the above requirements it is clear that it can only be applied a finite number of times.Whenever we describe a case that requires modifications that do not satisfy the above requirements, we explicitly show that these modifications can only be applied a finite number of times as well.Overall this then shows that after a finite number of modifications, none of the described cases will apply.
We partition the temporal path P into the part P 1 from r * to e, the part consisting of e itself, the part P 2 between e and e , the part consisting of e itself, and the part P 3 from e to r.Now in H − r * we can have two different scenarios.For illustrations of all variations of Case A see Figures 7 to 9   Case A-1.There is a temporal path P from some r ∈ R \ {r * } to r * in H − r * that traverses both e and e .Note that this implies that e is traversed before e .
We partition the temporal path P into the part P 1 from r to e, the part consisting of e itself, the part P 2 between e and e , the part consisting of e itself, and the part P 3 from e to r * .
The analysis of each one follows from the observation that the labels in P 3 are larger than the ones in P 1 .
Case A-1-i.Assume there is a path P1 in H + r * starting at a vertex that is visited by P 1 and ending at r1 ∈ R \ {r * } such that r1 = r or P1 and P 1 intersect in a vertex.For our analysis, we treat these two cases the same since in both cases we can assume that r can reach r1 , in the latter through the intersection point.If there is a path P2 in H − r * starting at some r2 ∈ R \ {r * , r } and ending at the extended tail of P 2 or P 3 , then the temporal path P * in (G, λ) from r2 to r1 either uses no labels from λ + r * or no from λ − r * .Case A-1-ii.Assume there is a path P1 in H − r * starting at r1 ∈ R \ {r * } and ending at a vertex that is visited by P 3 , such that r1 = r or P1 and P 3 intersect in a vertex.Again for our analysis, we treat these two cases the same since in both cases we can assume that r1 can reach r, in the latter through the intersection point.If there is a path P2 in H + r * starting at the extended tail of P 1 or P 2 and ending at some r2 ∈ R \ {r * , r}, then the temporal path P * in (G, λ) from r1 to r2 either uses no labels from λ + r * or no from λ − r * .Assume that one of the above two applies.We assume that there is no path P2 in H − r * starting at some r2 ∈ R \ {r * , r } and ending at the extended tail of P 2 or P 3 in Case A-1-i and that there is no path P2 in H + r * starting at the extended tail of P 1 or P 2 and ending at some r2 ∈ R \ {r * , r}, since in both cases we can directly deduce that we need labels outside of λ + r * and λ − r * .Then we modify λ in the following way without changing its connectivity properties.First, we scale all labels in λ by a factor of |V |.
The idea is first to essentially switch the roles of P 1 and P1 in Case A-1-i and switch the roles of P 3 and P1 in Case A-1-ii.Assume Case A-1-i applies.
• We remove P1 's edges and labels from H + r * and λ + r * , respectively, add P1 's edges to H − r * .Add the edges between the (original) tail of P1 to e to H − r * and add the respective labels for those edges from λ + r * also to λ − r * .Add new labels for the edges of P1 to λ − r * such that there is temporal paths from r to r * that does use edges from P 1 .
• We remove P 1 's edges and labels from H − r * and λ − r * , respectively, add P 1 's edges to H + r * , and add new labels for the edges of P 1 to λ + r * such that there is a temporal path from r * to r .Now assume Case A-1-ii applies.We make analogous modifications.
• We remove P1 's edges and labels from H − r * and λ − r * , respectively, add P1 's edges to H + r * .Add the edges from the head of P1 to e to H + r * and add the respective labels for those edges from λ − r * also to λ + r * .Add new labels for the edges of P1 to λ + r * such that there is temporal paths from r * to r that does use edges from P 3 .
• We remove P 3 's edges and labels from H + r * and λ + r * , respectively, add P 3 's edges to H − r * , and add new labels for the edges of P 3 to λ − r * such that there are temporal paths from r to r * .Note that after the modifications H + r * and H − r * are still trees, and λ + r * and λ − r * still assign at most one label per edge.Furthermore, we have that the modification do not increase the sum of edges in both trees |E(H + r * ) ∪ E(H − r * )|.Note that these modifications potentially increase |E * r * | and α.However, note that in both cases we strictly decrease β.From now on assume that Cases A-1-i and A-1-ii do not apply.
We start with three further subcases.The analysis of each one follows from the observation that the labels in P 3 are larger than the ones in P 1 .Case A-1-iii.Assume there is a path P in H + r * starting at a vertex that is visited by P 1 but is different from its tail and extended head and ending at some r ∈ R \ {r * , r}.Then the temporal path P * in (G, λ) from r to r needs at least one label that is not contained in λ + r * or λ − r * .More specifically, P * either uses no labels from λ + r * or no from λ − r * .Case A-1-iv.Assume there is a path P in H − r * starting at some r ∈ R \ {r * , r } and ending at a vertex that is visited by P 3 but is different from its extended tail and head.Then the temporal path P * in (G, λ) from r to r needs at least one label that is not contained in λ + r * or λ − r * .More specifically, P * either uses no labels from λ + r * or no from λ − r * .Case A-1-v.Assume there is a path P1 in H + r * starting at a vertex that is visited by P 2 but is different from its tail and extended head and ending at some r1 ∈ R \ {r * , r}.Furthermore, assume there is a path P2 in H − r * starting at some r2 ∈ R \ {r * , r } and ending at a vertex that is visited by P 2 but is different from its extended tail and head.Then, if r2 = r1 and P 2 = P 2 , or the starting vertex of P1 is by at least two edges closer to e than the starting vertex of P2 , the temporal path P * in (G, λ) from r2 to r1 needs at least one label that is not contained in λ + r * or λ − r * .More specifically, P * either uses no labels from λ + r * or no from λ − r * .In the above three Cases A-1-iii to A-1-v we do not make any modifications, since we can directly deduce that we need labels outside of λ + r * and λ − r * .For the remainder of this case distinction, we assume that Cases A-1-iii to A-1-v do not apply.
We can further observe the following using analogous arguments as above.Case A-1-vi.Assume there is a path P1 in H + r * starting at the extended head of P 1 and ending at some r1 ∈ R \ {r * , r, r }.If there is a path P2 in H − r * starting at some r2 ∈ R \ {r * , r } and ending at a vertex from P 2 that is not its tail or a vertex from P 3 , then, if r2 = r1 , the temporal path P * in (G, λ) from r2 to r1 either uses no labels from λ + r * or no from λ − r * .Case A-1-vii.Assume there is a path P1 in H − r * starting at some r1 ∈ R \ {r * , r, r } and ending at the extended tail of P 3 .If there is a P2 in H + r * starting at a vertex from P 1 or a vertex from P 2 that is not its head and ending at some r2 ∈ R \ {r * , r}, then, if r1 = r2 , the temporal path P * in (G, λ) from r1 to r2 either uses no labels from λ + r * or no from λ − r * .First, assume that Case A-1-vi or Case A-1-vii or none of them apply.Then we modify λ in the following way without changing its connectivity properties.First, we scale all labels in λ by a factor of |V |.
The idea is first to essentially switch the roles of P 1 and P 3 .
• We remove P 1 's edges and labels from H + r * and λ + r * , respectively, add P 1 's edges to H − r * , and add new labels for the edges of P 1 to λ − r * such that there are temporal paths from both endpoints of e to r * that only use the new labels.
• We remove P 3 's edges and labels from H − r * and λ − r * , respectively, add P 3 's edges to H + r * , and add new labels for the edges of P 3 to λ + r * such that there are temporal paths from r * to both endpoints of e that only use the new labels.
In both modification above, we assume w.l.o.g. that the smallest and the largest label assigned to an edge of P 1 by λ + r * before the modification are equal the smallest and the largest label, respectively, assigned to an edge of P 3 by λ + r * after the modification.Symmetrically, we assume w.l.o.g. that the smallest and the largest label assigned to an edge of P 3 by λ − r * before the modification are equal the smallest and the largest label, respectively, assigned to an edge of P 1 by λ − r * after the modification.Note that now there is a path from r * to r in (H + r * , λ + r * ) that does not use edges e and e .Furthermore, there is a path from r to r * in (H − r * , λ − r * ) that does not use edges e and e .Now we have to adjust labels on e, e , P 2 , and P 2 , depending on whether Case A-1-vi, Case A-1-vii or none of them apply.• If Case A-1-vi applies, then we remove e, e , and the edges of P 2 and their labels from H − r * and λ − r * , respectively.Furthermore, we exchange the labels of e and e and the edges of P 2 assigned by λ + r * in a way that there is a temporal path from r * to r1 (see Case A-1-vi) in (H + r * , λ + r * ).
• If Case A-1-vii applies, then we remove e, e , and the edges of P 2 and their labels from H + r * and λ + r * , respectively.Furthermore, we exchange the labels of e and e and the edges of P 2 assigned by λ − r * in a way that there is a temporal path from r1 (see Case A-1-vii) to r * in (H − r * , λ − r * ).
• If none of the Cases A-1-vi and A-1-vii apply, then we remove e its labels from H + r * and λ + r * , respectively, and we remove e its labels from H − r * and λ − r * , respectively.We modify the labels of P 2 assigned by λ + r * is a way that all terminals that were reachable from r * before the modifications can now be reached via e .We modify the labels of P 2 assigned by λ − r * is a way that all terminals that could reach r * before the modifications can now reach r * via e.It follows that after exhaustively performing the above modifications we have that if Case A-1 applies, then one of the Cases A-1-iii to A-1-v has to apply.
Case A-2.There are two temporal paths P , P from some r , r ∈ R \ {r * }, respectively, to r * in H − r * such that P traverses e and P traverses e .We consider several different subcases.Let e = uv and let u be the vertex that is closer to r * in H + r * .Partition P into P 1 from r to e, then e, and then P 2 from e to r * .Case A-2-i.Assume the head of P 1 is v.
We remove e and its labels from H − r * and λ − r * , respectively.To obtain a new path in (H − r * , λ − r * ), we traverse P 1 , then traverse P 2 (by modifying λ − r * on P 1 accordingly) which lets us reach P and then we traverse P to reach r * .
Note that after the modifications H − r * is still a tree and λ − r * still assign at most one label per edge.However, the size of E * r * changes, in particular it can increase, but the maximal number α of edges between two edges from E * r * in P decreases by one.Case A-2-ii.Assume the head of P 1 is u.Assume there is a path P in H + r * starting at a vertex that is visited by P 1 but is different from its tail and extended head and ending at some r ∈ R \ {r * , r}, such that r = r or P and P 1 intersect in a vertex.For our analysis, we treat these two cases the same since in both cases we can assume that r can reach r, in the latter through the intersection point.Case A-2-ii(a).Furthermore, assume there is a path P in H − r * starting at some r ∈ R\{r * , r } and ending at a vertex that is visited by P 2 .Then the temporal path P * in (G, λ) from r to r either uses no labels from λ + r * or no from λ − r * .Case A-2-ii(b).Furthermore, assume there is a path P in H − r * starting at some r ∈ R \ {r * , r } and ending at a vertex that is visited by P 2 .Then the temporal path P * in (G, λ) from r to r either uses no labels from λ + r * or no from λ − r * .Assume that Cases A-2-ii(a) and (b) do not apply.Then we modify λ in the following way without changing its connectivity properties.First, we scale all labels in λ by a factor of |V |.
The idea is to essentially switch the roles of P and P 2 .r * starting at a vertex that is visited by P 1 but is different from its tail and extended head and ending at some r ∈ R\{r * , r, r }.Then the temporal path P * in (G, λ) from r to r either uses no labels from λ + r * or no from λ − r * .Furthermore, assume there is a path P in H − r * starting at some r ∈ R \ {r * , r } and ending at a vertex that is visited by P 2 but is different from its extended tail and head.Then the temporal path P * in (G, λ) from r to r either uses no labels from λ + r * or no from λ − r * .We again modify λ in a way that does not change its connectivity properties.First, we scale all labels in λ by a factor of |V |.We essentially switch the roles of P 1 and P 2 .
We remove P 1 's edges and labels from H + r * and λ + r * , respectively, add P 1 's edges to H − r * , and add new labels for the edges of P 1 to λ − r * such that there are temporal paths from both endpoints of e to r * that only use the new labels.We remove P 2 's edges and labels from H − r * and λ − r * , respectively, add P 2 's edges to H + r * , and add new labels for the edges of P 2 to λ + r * such that there are temporal paths from r * to both endpoints of e that only use the new labels.
Note that now there is a path from r to r * in (H Now consider the case where we have a temporal path P from some r ∈ R \ {r * } to r * in H − r * that traverses both e and e and two temporal paths P 1 , P 2 from r * to some r 1 , r 2 ∈ R \ {r * }, respectively, in H + r * such that P 1 traverses e and P 2 traverses e .This case is analogous to the previously discussed case.
From now on we assume that Case A-2 does not apply.
Case B. From now on we assume that none of the above described cases apply.This means that there is no path from r * to some r ∈ R \ {r * } in H + r * that traverses both e and e and there is no path from some r ∈ R \ {r * } to r * in H − r * that traverses both e and e .It follows that for every e ∈ E * r * we have a path in H + r * from r * to some r ∈ R \ {r * } that only traverses e from the edges in E * r * and we have a path in H − r * from some r ∈ R \ {r * } to r * that only traverses e from the edges in E * r * .All the following cases are illustrated in Figure 10.Case B-1.Let e, e ∈ E * r * and let P 1 be a path in H + r * from r * to some r 1 ∈ R \ {r * } that only traverses e from the edges in E * r * and let P 2 be a path in H − r * from some r 2 ∈ R \ {r * } to r * that only traverses e from the edges in E * r * .Let P 1 be a path in H + r * from r * to some r 1 ∈ R \ {r * } that only traverses e from the edges in E * r * and let P 2 be a path in H − r * from some r 2 ∈ R \ {r * } to r * that only traverses e from the edges in E * r * .Consider the case where all choices of P 1 , P 2 , P 1 , P 2 with the above properties we have r 1 = r 2 or P 1 and P 2 intersect in a vertex after they traversed e and e , respectively.Again for our analysis, we treat these two cases the same since in both cases we can assume that r 2 can  reach r 1 , in the latter through the intersection point.The case where all choices of P 1 , P 2 , P 1 , P 2 with the above properties we have r 1 = r 2 or P 1 and P 2 intersect in a vertex after they traversed e and e, respectively, is symmetric.Fix temporal paths P 1 , P 2 , P 1 , P 2 with the above properties and r 1 = r 2 or P 1 and P 2 intersect in a vertex after they traversed e and e , respectively.Let P1 be the path segment from e to the first vertex included in P 2 (excluding e) and let P 2 be the path segment from the last vertex included in P 1 to e (excluding e ).Case B-1-ii(a).The edges e, e , ê1 , and ê2 form a C 4 .Then we are in the case that k is even.In this case we set ê1 to be e + and we set ê2 to be e − .One of these two edges will be used to close the C 4 , depending on whether which of H + r * and H − r * has fewer edges.The edges e and e stay in E * r * and will be the only two edges for which we cannot account a label in λ that is not present in λ + r * or λ − r * .In this case we have that |E * r * | ≤ x + 2 is fulfilled.If Case B-1-ii(a) never applies, then we are in the case that k is odd and we have to be able to account a label in λ that is not present in λ + r * or λ − r * for all but one edge in E * r * .Case B-1-ii(b).The edges e, e , ê1 , and ê2 do not form a C 4 .Let e = uv and e = u v and let u and u be the vertices closer to r * in P 1 and P 2 , respectively.Then this means there is either at least one edge e * between r * and u or between r * and u .Consider the case where e * is between r * and u and let e * = uu * for some vertex u * .In this case e * is contained in H + r * .The other case is symmetric.Let e * * be the edge between r * and u in H − r * , that is incident with u.
Note that λ + r * (e * ) < λ + r * (e) < λ − r * (e * * ).We now make the following modification.We remove label λ + r * (e * ) and add a new label to ê2 in λ + r * that is chosen in a way that allows for a temporal path from r * to r 1 via e and then ê2 .
Case B-2.Fix some e ∈ E * r * and let P + be a path in H + r * from r * to some r + ∈ R \ {r * } that only traverses e from the edges in E * r * and let P − be a path in H − r * from some r − ∈ R \ {r * } to r * that only traverses e from the edges in E * r * .For all e i ∈ E * r * \ {e} let P + i be a path in H + r * from r * to some r + i ∈ R \ {r * } that only traverses e i from the edges in E * r * and let P − i be a path in H − r * from some r − i ∈ R \ {r * } to r * that only traverses e i from the edges in E * r * .Note that for all i = i we have that r + i = r + i and r − i = r − i .Now consider edge e i .If λ + r * (e) ≤ λ + r * (e i ), then the temporal path in (G, λ) from r − i to r + needs at least one label that is not contained in λ + Having Lemma 6, we can now give our algorithm for MSL.As mentioned before, it uses an FPT-algorithm for Steiner Tree parameterized by the number of terminals [14] as a subroutine.Recall the definition of Steiner Tree.

Steiner Tree Input:
A static graph G = (V, E), a subset of vertices R ⊆ V and a positive integer k.Question: Is there a subtree of G that includes all the vertices of R and that contains at most k edges.
Let (G, R, k) be an instance of MSL.Note that if G is C 4 -free, then Lemma 6 immediately implies that we can use an algorithm for Steiner Tree on the same input graph G with the same terminal vertices R and check whether the resulting solution subtree has at most k * = (k + 1)/2 edges.In the case where G contains C 4 s, we have to determine first whether there is a C 4 in G that can be labeled in an optimal labeling.Formally, we show the following.Theorem 9 MASL is W [1]-hard when parameterized by the number |R| of the terminals, even if the restriction a on the age is a constant.
Proof.To prove that the MASL is W [1]-hard when parameterized by the combination of the number |R| of the terminals and the number k of labels, even if the restriction a on the age is a constant, we provide a parameterized polynomial-time reduction from Multicolored Clique parameterized by the number of colors, which is W [1]-hard [19].• a "color-vertex" corresponding to every color of V (G): C = {c i |i ∈ {1, 2, . . ., k} a color of V (G)},

Multicolored Clique
• a "vertex-vertex" corresponding to every vertex of G: U V = {u v |v ∈ V (G)}, • an "edge-vertex" corresponding to every edge of G: U E = {u e |e ∈ E(G)}, • a "color-combination-vertex" corresponding to a pair of two colors of V (G): W = {c i,j |i, j ∈ {1, 2, . . ., k}, i < j, colors of V (G)}, and • 2n + 4m + 5m + 11 8 (k 4 − 2k 3 − k 2 + 2k) + 11 2 (k 3 − 3k 2 + 2k) "dummy" vertices.The edge set E(G * ) consists of the following edges: • a path of length 3 (using 2 dummy vertices) between a color-vertex c i , corresponding to the color i, and every vertex-vertex u v ∈ U V , where v is of color i in V (G), i.e., c(v) = i, • for every edge e = vw ∈ E(G), where c(v) = i and c(w) = j, we connect the corresponding edge-vertex u e with -the vertex-vertices u v and u w , each with a path of length 3 (using 2 dummy vertices), -the color-combination-vertex c i,j , with a path of length 6 (using 5 dummy vertices), • a path of length 12 (using 11 dummy vertices), between each pair of color-combinationvertices, and • a path of length 12 (using 11 dummy vertices), between all pairs of color-vertices c i and color-combination-vertices c jk , where i / ∈ {j, k}, i.e., we connect the color-vertex of color i with all color-combination vertices of pairs of color that do not include i.  (⇒): Assume (G, k, c) is a YES instance of the Multicolored Clique.Let S ⊆ V (G) be the set of vertices that form a multicolored clique in G.We construct a labeling λ for G * that uses k * labels, which are not larger than a * = 12, and admits a temporal path between all vertices from R * as follows.
Let U S be the set of corresponding vertices to S in G * .For each v ∈ S of color i we label the three edges connecting c i to u v with labels 1, 2, 3, one per each edge, in order to create temporal paths starting in c i and with labels 12, 11, 10, one per each edge, in order to create temporal paths that finish in c i .For every edge vw = e ∈ E with endpoints in S we label the path from both of its endpoint vertex-vertices u v , u w to the edge-vertex u e with labels 4, 5, 6, one per each edge, and with labels 9, 8, 7, one per each edge.This ensures the existence of both temporal paths between c i and c j .More precisely, (c i , c j )-temporal path (resp.(c j , c i )-temporal path) uses labels 1, 2, 3 to reach u v (resp.u w ), from where it continues with 4, 5, 6 to u e , then with 7, 8, 9 reaches u w (resp.u v ) and finally with 10, 11, 12 it finishes in c j (resp.c i ).Note, since S is a multicolored clique then each vertex v ∈ S is of a unique color i and all vertices in S are connected.Therefore, using the above construction for all vertices in S, vertex c i reaches and is reached by every other color vertex c j through the vertex-vertex u v .Even more, since there is an edge e connecting any two vertices v, w ∈ S, there is a unique edge vertex u e (and consequently a unique path), that is used for both temporal paths between vertexvertices u v , u w and their corresponding color-vertices.The above construction clearly produces a temporal path (of length 12) between any two color-vertices.This construction uses 2•3 labels between every color-vertex c i and its unique vertex-vertex u v , where v ∈ S and c(c) = i, and 2•6 labels from each edge vertex u e to both of its endpoint vertex-vertices, where e is an edge of the multicolored clique formed by the vertices in S. All in total we used 6k + 12 k 2 = 6k + 6(k 2 − k) labels, to connect all edge-vertices corresponding to edges formed by S with their endpoints vertex-vertices.Now, let c ij and c i j be two arbitrary color-combination-vertices.By the construction of G * there is a unique path of length 12 connecting them, which we label with labels 1, 2, . . ., 12 in both directions.This labeling uses 2•12 labels for each pair of color-combination-vertices, hence more it must use the edge vertex u e and consequently the vertex-vertex u v , from where it would reach c i .But this is in the contradiction with the assumption that the path from c i to u v uses only labels 1, 2, 3. Therefore, every color-vertex c i admits a unique vertex-vertex u v that lies on all (c i , c j ) and (c j , c i )-temporal paths.For the conclusion of the proof we claim that all vertices v corresponding to these unique vertex-vertices u v of color-vertices c i , form a multicolored clique in G.This is true as, by construction, a temporal path between two vertex-vertices u v , u w corresponds to the edge vw = e ∈ E(G).Since every vertex-vertex is connected to exactly one color-vertex, this corresponds to the vertex coloring of V (G).In G * there is a temporal path among any two color vertices, therefore the vertex-vertices used in these temporal paths can be reached among each other, which means that they really do form a multicolored clique.
Note here that, in the constructed instance of MASL in the proof of Theorem 9, the number of labels is also upper-bounded by a function of the number of colors in the instance of Multicolored Clique.Therefore the proof of Theorem 9 implies also the next result, which is even stronger (since in every solution of MASL the number of time-labels is lower-bounded by a function of the number |R| of terminals).
Corollary 1 MASL is W [1]-hard when parameterized by the number k of time-labels, even if the restriction a on the age is a constant.As we proved in Theorem 6, MAL is NP-complete when the upper age bound is equal to the diameter d of the input graph G.In other words, it is NP-hard to compute κ(G, d).On the other hand, κ(G, 2r) can be easily computed in polynomial time, where r is the radius of G. Indeed, using the results of Section 2.1, it easily follows that, if G contains (resp.does not contain) a C 4 then κ(G, 2r) = 2n − 4 (resp.κ(G, 2r) = 2n − 3).For which values of an upper age bound a, where d ≤ a ≤ 2r, can κ(G, a) computed efficiently?In particular, can κ(G, d + 1) or κ(G, 2r − 1) be computed in polynomial time for every undirected graph G?

Concluding remarks
With respect to parameterized algorithmics, is MAL FPT with respect to the number k of time-labels?

Theorem 3 (
[5]) MonMaxXOR(3) is NP-hard.Now we explain our reduction from MonMaxXOR(3) to the problem Minimum Aged Labeling (MAL), where the input static graph G is undirected and the desired age of the output temporal graph is the diameter d of G .Let φ be a monotone Max XOR(3) formula with n variables x 1 , x 2 , . . ., x n and m clauses C 1 , C 2 , . . ., C m .Note that m = 3

Figure 3 :
Figure 3: An example of two non-intersecting variable gadgets and variable edges among them.

Figure 6 :
Figure 6: Example of a canonical layering of a directed acyclic graph (DAG).
and either • strictly decrease β, or • strictly decrease α and not increase β, or • strictly decrease |E * r * | and not increase α and β, while preserving that • H + r * and H + r * are trees with leafs in R, and • λ + r * and λ − r * assign at most one label per edge. .
(a) Case A: an example of a path P from r * in H + r * , that traverses e, e ∈ E * r * .(b) Case A-1: an example of P in H + r * and P in H − r * , that share e, e ∈ E * r * .(c) Case A-1-i: P * from r2 to r1 either uses no labels from λ + r * or no from λ − r * .(d) Modification of Case A-1-i.(e) Case A-1-ii: P * from r1 to r2 either uses no labels from λ + r * or no from λ − r * .(f) Modification of Case A-1-ii.
(a) Case A-1-iii: P * from r to r either uses no labels from λ + r * or no from λ − r * .(b) Case A-1-iv: P * from r to r either uses no labels from λ + r * or no from λ − r * .(c) Case A-1-v: P * from r2 to r1 either uses no labels from λ + r * or no from λ − r * .(d) Case A-1-vi: P * from r2 to r1 either uses no labels from λ + r * or no from λ − r * .(e) Case A-1-vii: P * from r1 to r2 either uses no labels from λ + r * or no from λ − r * .(f) Modification of Case A-1-vi.(g) Modification of Case A-1-vii.(h)Modification when none of the cases A-1-vi nor A-1-vii apply.

Figure 8 :
Figure 8: Cases A-1-iii -A-1-vii, where blue color corresponds to the labeling λ + r * and red to λ − r * .31 (a) Example of Case A-2-i.(b) Modification of Case A-2-i.(c) Example of Case A-2-ii.(d) Case A-2-ii(a): P * from r to r either uses no labels from λ + r * or no from λ − r * .(e) Case A-2-ii(b): P * from r to r either uses no labels from λ + r * or no from λ − r * .(f) Modification of Case A-2-ii when A-2-ii(a) and A-2-ii(b) do not apply.(g) Case A-2-iii: P * from r to r either uses no labels from λ + r * or no from λ − r * .(h) Modification of Case A-2-iii.
Case B-1-i.Assume | P1 | ≤ | P 2 | (the opposite case is symmetric) and | P1 | + | P 2 | ≥ 3 (not both paths are only a single edge r * or λ − r * .If λ + r * (e) > λ + r * (e i ), then the temporal path in (G, λ) from r − to r + i needs at least one label that is not contained in λ + r * or λ − r * .This implies, if Case B-1-ii(a) does not apply, that λ contains at least |E * r * | − 1 labels that are not contained in λ + r * or λ − r * and hence |E * r * | ≤ x + 1.If Case B-1-ii(a) applies, then λ contains at least |E * r * | − 2 labels that are not contained in λ + r * or λ − r * and hence |E * r * | ≤ x + 2. This finishes the proof.

Figure 11 :
Figure 11: An example of the construction of the input graph for MASL.For better readability, some paths among the vertices in W and paths among c i ∈ C and c jk ∈ W (i = j = k), are not depicted.
Several open questions arise from our results.As we pointed out in Lemma 1,κ(C n , d) = Θ(n 2 ), while κ(G, d) = O(n 2 ) for every graph G by Observation 1.For which graph classes G do we have κ(G, d) = o(n 2 ) (resp.κ(G, d) = O(n)) for every G ∈ G?
A) be a DAG with n vertices, m arcs, and diameter d.A partition L 0 , L 1 , L 2 , . .., L d of V into d + 1 sets is a canonical layering of G if,for every 0 ≤ i ≤ d, the set L i contains all the source vertices in the induced subgraph , λ + r * ).Let us first observe that H + r * is a tree where all leafs are vertices from R and λ + r * assigns exactly one label to every edge in H + r * .First note that all vertices in (H + r * , λ + r * ) are temporally reachable from r * .If a vertex is not reachable, we can remove it, a contradiction to the minimality of H + r * .Now assume that H + Let H + r * be a minimum subgraph of H and λ + r * a minimum sublabeling of λ for H + r * such that r * can temporally reach all vertices in R \ {r * } in (H + r * Assume that |E * r * | ≤ x + 2 and there exist two edges e + , e − in H that each of them, when added to H + r * , H − r * , respectively, creates a C 4 in H + r * , H − r * , respectively.. Then we clearly have 2|E Note that after the modifications H + r * and H − r * are still trees, and λ + r * and λ − r * still assign at most one label per edge.Furthermore, we have that the modification do not increase the sum of edges in both trees |E(H + r * ) ∪ E(H − r * )|.Lastly, and most importantly, we have that at least one of H + r * and H − r * does contain both edges e and e .It follows that we strictly decrease |E * r * | without increasing α.

•
We remove P 1 's and P 's edges and labels from H + r * and λ + r * , respectively, add P 's edges to H − r * .Add the edges from the tail of P to r * to H − r * and add labels for those edges to λ − r * such that there is a path from r to r * in (H − r * , λ − r * ) that uses the newly added labels.•Weremove P 1 's and P 2 's edges and labels from H − r * and λ − r * , respectively, add P 1 's and P 2 's edges to H + r * , and add new labels for the edges of P 1 and P 2 to λ + r * such that there is temporal path from r * to r in (H + r * , λ + r * ).Note that after the modifications H + r * and H − r * are still trees, and λ + r * and λ − r * still assign at most one label per edge.Furthermore, we have that the modification do not increase the sum of edges in both trees |E(H + r * ) ∪ E(H − r * )|.Lastly, and most importantly, we have that the path from r * to r in H + r * does not contain both edges e and e .It follows that we decreased α.Case A-2-iii.Assume the head of P 1 is u.Assume there is a path P in H + Further note that after the modifications H + r * and H − r * are still trees, and λ + r * and λ − r * still assign at most one label per edge.Furthermore, we have that the modification do not increase the sum of edges in both trees |E(H + r − r * , λ − r * ) that does not use edge e. * ) ∪ E(H − r * )|.It follows that we strictly decrease |E * r * | without increasing α.
).We remove P 2 's edges and e and the corresponding labels from H − r Furthermore, we have that the modification do not increase the sum of edges in both trees |E(H + r * ) ∪ E(H − r * )|.Lastly, and most importantly, we have that at least one of H + r * and H − r * does contain both edges e and e .Case B-1-ii.Assume | P1 | = | P 2 | = 1, that is, both paths are only a single edge ê1 and ê2 , respectively.
* and λ − r * , respectively, such that there is a temporal path from r 2 to e that uses the new labels.Note that after the modifications H + r * and H − r * are still trees, and λ + r * and λ − r * still assign at most one label per edge.