Temporal Network Optimization Subject to Connectivity Constraints

In this work we consider \emph{temporal networks}, i.e. networks defined by a \emph{labeling} $\lambda$ assigning to each edge of an \emph{underlying graph} $G$ a set of \emph{discrete} time-labels. The labels of an edge, which are natural numbers, indicate the discrete time moments at which the edge is available. We focus on \emph{path problems} of temporal networks. In particular, we consider \emph{time-respecting} paths, i.e. paths whose edges are assigned by $\lambda$ a strictly increasing sequence of labels. We begin by giving two efficient algorithms for computing shortest time-respecting paths on a temporal network. We then prove that there is a \emph{natural analogue of Menger's theorem} holding for arbitrary temporal networks. Finally, we propose two \emph{cost minimization parameters} for temporal network design. One is the \emph{temporality} of $G$, in which the goal is to minimize the maximum number of labels of an edge, and the other is the \emph{temporal cost} of $G$, in which the goal is to minimize the total number of labels used. Optimization of these parameters is performed subject to some \emph{connectivity constraint}. We prove several lower and upper bounds for the temporality and the temporal cost of some very basic graph families such as rings, directed acyclic graphs, and trees.


Introduction
A temporal (or dynamic) network is, loosely speaking, a network that changes with time. This notion encloses a great variety of both modern and traditional networks such as information and communication networks, social networks, transportation networks, and several physical systems. In the literature of traditional communication networks, the network topology is rather static, i.e. topology modifications are rare and they are mainly due to link failures and congestion. However, most modern communication networks such as mobile ad hoc, sensor, peer-to-peer, opportunistic, and delay-tolerant networks are inherently dynamic and it is often the case that this dynamicity is of a very high rate. In social networks, the topology usually represents the social connections between a group of individuals and it changes as the social relationships between the individuals are updated, or as existing individuals leave, or new individuals enter the group. In a transportation network, there is usually some fixed network of routes and a set of transportation units moving over these routes and dynamicity refers to the change of the positions of the transportation units in the network as time passes. Physical systems of interest may include several systems of interacting particles.
In this work, embarking from the foundational work of Kempe et al. [15], we consider discrete time, that is, we consider networks in which changes occur at discrete moments in time, e.g. days. This choice is not only a very natural abstraction of many real systems but also gives to the resulting models a purely combinatorial flavor. In particular, we consider those networks that can be described via an underlying graph G and a labeling λ assigning to each edge of G a (possibly empty) set of discrete labels. Note that this is a generalization of the single-label-per-edge model used in [15], as we allow many time-labels to appear on an edge. These labels are drawn from the natural numbers and indicate the discrete moments in time at which the corresponding connection is available. For example, in the case of a communication network, availability of a communication link at some time t may mean that a communication protocol is allowed to transmit a data packet over that link at time t.
In this work, we initiate the study of the following fundamental network design problem: "Given an underlying (di)graph G, assign labels to the edges of G so that the resulting temporal graph λ(G) minimizes some parameter while satisfying some connectivity property". In particular, we consider two cost optimization parameters for a given graph G. The first one, called temporality of G, measures the maximum number of labels that an edge of G has been assigned. The second one, called temporal cost of G, measures the total number of labels that have been assigned to all edges of G (i.e. if |λ(e)| denotes the number of labels assigned to edge e, we are interested in e∈E |λ(e)|). That is, if we interpret the number of assigned labels as a measure of cost, the temporality (resp. the temporal cost) of G is a measure of the decentralized (resp. centralized) cost of the network, where only the cost of individual edges (resp. the total cost over all edges) is considered. Each of these two cost measures can be minimized subject to some particular connectivity property P that the temporal graph λ(G) has to satisfy. In this work, we consider two very basic connectivity properties. The first one, that we call the all paths property, requires the temporal graph to preserve every simple path of its underlying graph, where by "preserve a path of G" 123 Fig. 1 Path P 2 forces a second label to appear on either (u n−1 , u n ) or (u 1 , u 2 ) we mean in this work that the labeling should provide at least one strictly increasing sequence of labels on the edges of that path, in which case we also say that the path is time-respecting.
Before describing our second connectivity property let us give a simple illustration of temporality minimization. We are given a directed ring u 1 , u 2 , . . . , u n and we want to determine the temporality of the ring subject to the all paths property. That is, we want to find a labeling λ that preserves every simple path of the ring and at the same time minimizes the maximum number of labels of an edge. Looking at Fig. 1, it is immediate to observe that an increasing sequence of labels on the edges of path P 1 implies a decreasing pair of labels on edges (u n−1 , u n ) and (u 1 , u 2 ). On the other hand, path P 2 uses first (u n−1 , u n ) and then (u 1 , u 2 ) thus it requires an increasing pair of labels on these edges. It follows that in order to preserve both P 1 and P 2 we have to use a second label on at least one of these two edges, thus the temporality is at least 2. Next, consider the labeling that assigns to each edge (u i , u i+1 ) the labels {i, n + i}, where 1 ≤ i ≤ n and u n+1 = u 1 . It is not hard to see that this labeling preserves all simple paths of the ring. Since the maximum number of labels that it assigns to an edge is 2, we conclude that the temporality is also at most 2. In summary, the temporality of preserving all simple paths of a directed ring is 2.
The other connectivity property that we define, called the reach property, requires the temporal graph to preserve a path from node u to node v whenever v is reachable from u in the underlying graph. Furthermore, the minimization of each of our two cost measures can be affected by some problem-specific constraints on the labels that we are allowed to use. We consider here one of the most natural constraints, namely an upper bound of the age of the constructed labeling λ, where the age of a labeling λ is defined to be equal to the maximum label of λ minus its minimum label plus 1. Now the goal is to minimize the cost parameter, e.g. the temporality, satisfy the connectivity property, e.g. all paths, and additionally guarantee that the age does not exceed some given natural k. Returning to the ring example, it is not hard to see, that if we additionally restrict the age to be at most n − 1 then we can no longer preserve all paths of a ring using at most 2 labels per edge. In fact, we must now necessarily use the worst possible number of labels, i.e. n − 1 on every edge.
Minimizing such parameters may be crucial as, in most real networks, making a connection available and maintaining its availability does not come for free. For example, in wireless sensor networks the cost of making edges available is directly related to the power consumption of keeping nodes awake, of broadcasting, of listening to the wireless channel, and of resolving the resulting communication collisions. The same holds for transportation networks where the goal is to achieve good connectivity properties with as few transportation units as possible. At the same time, such a study is important from a purely graph-theoretic perspective as it gives some first insight into the structure of specific families of temporal graphs. To make this clear, consider again the ring example. Proving that the temporality of preserving all paths of a ring is 2 at the same time proves the following. If a temporal ring is defined as a ring in which all nodes can communicate clockwise to all other nodes via time-respecting paths then no temporal ring exists with fewer than n + 1 labels. This, though an easy one, is a structural result for temporal graphs. Finally, we believe that our results are a first step towards answering the following fundamental question: "To what extent can algorithmic and structural results of graph theory be carried over to temporal graphs?". For example, is there an analogue of Menger's theorem for temporal graphs? One of the results of the present work is an affirmative answer to the latter question.

Related Work
Labeled Graphs Labeled graphs have been widely used in Computer Science and Mathematics, e.g. in Graph Coloring [23]. In our work, labels correspond to moments in time and the properties of labeled graphs that we consider are naturally temporal properties. Note, however, that any property of a graph labeled from a discrete set of labels corresponds to some temporal property if interpreted appropriately. For example, a proper edge-coloring, i.e. a coloring of the edges in which no two adjacent edges share a common color, corresponds to a temporal graph in which no two adjacent edges share a common label, i.e. no two adjacent edges ever appear at the same time. Though we focus on properties with natural temporal meaning, our definitions are generic and do not exclude other, yet to be defined, properties that may prove important in future applications.

Single-label Temporal Graphs and Menger's Theorem
The model of temporal graphs that we consider in this work is a direct extension of the single-label model studied in [4] and [15] to allow for many labels per edge. The main result of [4] was that in single-label networks the max-flow min-cut theorem holds with unit capacities for time-respecting paths. In [15], Kempe et al., among other things, proved that a fundamental property of classical graphs does not carry over to their temporal counterparts. In particular, they proved that there is no analogue of Menger's theorem, at least in its original formulation, for arbitrary single-label temporal networks and that the computation of the number of node-disjoint s-t time-respecting paths is NP-complete. Menger's theorem states that the maximum number of node-disjoint s-t paths is equal to the minimum number of nodes needed to separate s from t (see [5]). In this work, we go a step ahead showing that if one reformulates Menger's theorem in a way that takes time into account then a very natural temporal analogue of Menger's theorem 123 is obtained. Both of the above papers, consider a path as time-respecting if its edges have non-decreasing labels. In the present work, we depart from this assumption and consider a path as time-respecting if its edges have strictly increasing labels. Our choice is very well motivated by recent work in dynamic communication networks. If it takes one time unit to transmit a data packet over a link then a packet can only be transmitted over paths with strictly increasing availability times.
Continuous Availabilities (Intervals) Some authors have assumed that an edge may be available for a whole time-interval [t 1 , t 2 ] or several such intervals and not just for discrete moments as we assume here. This is a clearly natural assumption but the techniques used in those works are quite different from those needed in the discrete case [11,28].

Dynamic Distributed Networks
In recent years, there is a growing interest in distributed computing systems that are inherently dynamic. This has been mainly driven by the advent of low-cost wireless communication devices and the development of efficient wireless communication protocols. Apart from the huge amount of work that has been devoted to applications, there is also a steadily growing concrete set of foundational work. A notable set of works has studied (distributed) computation in worst-case dynamic networks in which the topology may change arbitrarily from round to round subject to some constraints that allow for bounded end-to-end communication [10,17,22,25]. Population protocols [2] and variants [20] are collections of finite-state agents that move arbitrarily like a soup of particles and interact in pairs when they come close to each other. The goal is there for the population to compute (i.e. agree on) something useful in the limit in such an adversarial setting. Another interesting direction assumes that the dynamicity of the network is a result of randomness. Here the interest is on determining "good" properties of the dynamic network that hold with high probability, such as small (temporal) diameter, and on designing protocols for distributed tasks [3,7]. For introductory texts on the above lines of research in dynamic distributed networks the reader is referred to [6,21,26].
Distance Labeling A distance labeling of a graph G is an assignment of unique labels to the vertices of G so that the distance between any two vertices can be inferred from their labels alone. The goal is to minimize some parameter of the labeling and to provide a (hopefully fast) decoder algorithm for extracting a distance from two labels [13,14]. There are several differences between a distance labeling and the time-labelings that we consider in this work. First of all, a distance labeling is being assigned on the vertices and not on the edges. Moreover, in distance labeling, one usually seeks the most compact set of labels (in binary length) that still guarantees efficient decoding. That is, the labeling parameter to be minimized is the binary length of an appropriate encoding, which is quite different from our cost parameters. Finally, the optimization constraint there is efficient decoding while in our case the constraints have to do with connectivity properties of the labeled graph.
Also, we encourage the interested reader to see [19] for a recent introductory text on the recent algorithmic progress on temporal graphs.

Contribution
In Sect. 2, we formally define the model of temporal graphs under consideration and provide all further necessary definitions. The rest of the paper is partitioned into two parts. Part I focuses on journey problems for temporal graphs. In particular, in Sect. 3, we give two efficient algorithms for computing shortest time-respecting paths. Then in Sect. 4 we present an analogue of Menger's theorem which we prove valid for arbitrary temporal graphs. We apply our Menger's analogue to simplify the proof of a recent result on distributed token gathering. Part II studies the problem of designing a temporal graph optimizing some parameters while satisfying some connectivity constraints. Specifically, in Sect. 5 we formally define the temporality and temporal cost optimization metrics for temporal graphs. In Sect. 5.1, we provide several upper and lower bounds for the temporality of some fundamental graph families such as rings, directed acyclic graphs (DAGs), and trees, as well as an interesting trade-off between the temporality and the age of rings. Furthermore, we provide in Sect. 5.2 a generic method for computing a lower bound of the temporality of an arbitrary graph w.r.t. the all paths property, and we illustrate its usefulness in cliques, closeto-complete bipartite subgraphs, and planar graphs. In Sect. 5.3, we consider the temporal cost of a digraph G w.r.t. the reach property, when additionally the age of the resulting labeling λ(G) is restricted to be the smallest possible. We prove that this problem is hard to approximate, i.e. there exists no PTAS unless P=NP. To prove our claim, we first prove (which may be of interest in its own right) that the Max-XOR(3) problem is APX-hard via a PTAS reduction from Max-XOR. In the Max-XOR(3) problem, we are given a 2-CNF formula φ, every literal of which appears in at most 3 clauses, and we want to compute the greatest number of clauses of φ that can be simultaneously XOR-satisfied. Then we provide a PTAS reduction from Max-XOR(3) to our temporal cost minimization problem. On the positive side, we provide an (r (G)/n)-factor approximation algorithm for the latter problem, where r (G) denotes the total number of reachabilities in G. Finally, in Sect. 6 we conclude and give further research directions that are opened by our work.

A Model of Temporal Graphs
Given a (di)graph G = (V , E), 1 a labeling of G is a mapping λ : E → 2 N , that is, a labeling assigns to each edge of G a (possibly empty) 2 set of natural numbers, called labels.
Definition 1 Let G = (V , E) be a (di)graph and λ be a labeling of G. Then λ(G) is the temporal graph (or dynamic graph 3 ) of G with respect to λ. Furthermore, G is the underlying graph of λ(G).
We denote by λ(E) the multiset of all labels assigned to the underlying graph by the labeling λ and by |λ| = |λ(E)| their cardinality (i.e. |λ| = e∈E |λ(e)|). We also denote by λ min = min{l ∈ λ(E)} the minimum label and by λ max = max{l ∈ λ(E)} the maximum label assigned by λ. We define the age of a temporal graph λ(G) as α(λ) = λ max − λ min + 1. Note that in case λ min = 1 then we have α(λ) = λ max . For every graph G we denote by L G the set of all possible labelings λ of G. Furthermore, for every k ∈ N, we define L G,k = {λ ∈ L G : α(λ) ≤ k}.

Further Definitions
For every time r ∈ N, we define the r th instance of a temporal graph λ(G) as the static graph λ(G, r ) = (V , E(r )), where E(r ) = {e ∈ E : r ∈ λ(e)} is the (possibly empty) set of all edges of the underlying graph G that are assigned label r by labeling λ. A temporal graph λ(G) may be also viewed as a sequence of static Another, often convenient, representation of a temporal graph is the following.

Definition 2
The static expansion 4 of a temporal graph λ(G) is a static digraph H = (S, A), and in particular a DAG, defined as follows.
In words, we create α(λ) + 1 copies of V representing the nodes over time (time-nodes) and add outgoing edges from time-nodes of one level only to time-nodes of the next level. In particular, we connect a time-node u (i−1) j to its own subsequent copy u i j and to every time node u i j s.t. (u j , u j ) is an edge of λ(G) at time i.
A journey (or time-respecting path) J of a temporal graph λ(G) is a path (e 1 , e 2 , . . . , e k ) of the underlying graph G = (V , E), where e i ∈ E, together with labels l 1 < l 2 < · · · < l k such that l i ∈ λ(e i ) for all 1 ≤ i ≤ k. In words, a journey is a path that uses strictly increasing edge-labels. If labeling λ defines a journey on some path P of G then we also say that λ preserves P. A natural notation for a journey is (e 1 , l 1 ), (e 2 , l 2 ), . . . , (e k , l k ). We call each (e i , l i ) a time-edge as it corresponds to the availability of edge e i at some time l i . We call l 1 the departure time and l k Footnote 2 continued on an underlying graph. In the latter case, it is the algorithm's task to decide whether some of the provided edges need not be ever made available. 3 Even though both names are almost equally used in the literature, in this paper we have chosen to use the term "temporal" in order to avoid confusion of readers that are more familiar with the use of the term "dynamic" to refer to dynamically updated instances, with which usually an algorithm has to deal in an online way (including the rich literature of problems in which the algorithm has to maintain a graph property that is being disturbed by adversarial graph modifications). 4 The notion of static expansion is related to the notion of time-expanded graphs of temporal graphs such as periodic, or resulting from public transportation networks (cf. [24,27] We call a(J ) − d(J ) + 1 the duration of the journey. A journey J is called shortest if k is minimized, that is it minimizes the number of nodes visited (also called number of hops).
We say that a journey J leaves from node u (arrives at node u, resp.) at time t if (u, v, t) ((v, u, t), resp.) is a time-edge of J . Two journeys are called out-disjoint (in-disjoint, respectively) if they never leave from (arrive at, resp.) the same node at the same time.
Given a set J of (s, v)-journeys we define their arrival time as a(J ) = max J ∈J {a(J )}. We say that a set J of (s, v)-journeys satisfying some constraint c (e.g. containing at least k journeys and/or containing only out-disjoint journeys) is foremost if a(J ) is minimized over all sets of journeys satisfying the constraint.
If, in addition to the labeling λ, a positive weight w(e) > 0 is assigned to every edge e ∈ E, then we call a temporal graph a weighted temporal graph. In case of a weighted temporal graph, by "shortest journey" we mean a journey that minimizes the sum of the weights of its edges.
Throughout the text we denote by n the number of nodes and by m and m t the number of edges of graphs and temporal graphs, respectively. In case of a temporal graph, by "number of edges" we mean "number of time-edges", i.e. m t = |λ|. By d(G) we denote the diameter of a (di)graph G, that is the length of the longest shortest path between any two nodes of G. By δ u we denote the degree of a node u ∈ V (G) (in case of an undirected graph G).

Foremost Journeys
We are given (in its full "offline" description) a temporal graph λ(G), where G = (V , E), a distinguished source node s ∈ V , and a time λ min ≤ t start ≤ λ max and we are asked for all w ∈ V \{s} to compute a foremost (s, w)-journey from time t start . Theorem 1 Algorithm 1 correctly computes for all w ∈ V \{s} a foremost (s, w)journey from time t start . The running time of the algorithm is O(nλ max + m t ).
Proof Assume that at the end of round t − 1 all nodes in R have been reached by foremost journeys from s. Let (u, v, t) be a time-edge s.t. u ∈ R and v / ∈ R and let f (s, u) denote the foremost journey from s to u. We claim that J = f (s, u), (u, v, t) is a foremost journey from s to v. Recall that we denote the arrival time of J by a(J ). To see that our claim holds assume that there is some other journey J s.t. a(J ) < a(J ). So there must be some time-edge (w, z, t ) for w ∈ R, z / ∈ R and t < t. However, this contradicts the fact that z / ∈ R as the algorithm should have added it in R at time t .

Algorithm 1 FJ
Require: Temporal graph λ(G) (full "offline" description), source node s ∈ V , and time t start , where λ min ≤ t start ≤ λ max . The input is represented by an array A v with λ max − λ min + 1 entries for every node v, where the entry A v [t] stores a pointer to the linked list of the adjacent nodes of v at time step t. Ensure: For all v ∈ V \{s} a foremost (s, v)-journey from time t start . In particular, outputs for every v a pair ( is the predecessor node of v on the journey and a[v] is the arrival time of the journey at v (the pair as a whole may be viewed as the predecessor time-node of v on the journey).
The proof follows by induction on t beginning from t = t start at which time R = {s} (s has trivially been reached by a foremost journey from itself so the claim holds for the base case).
We now prove that the time complexity of the algorithm is O(nλ max + m t ). In the worst-case, the last node may be inserted at step λ max , so the while loop is executed O(λ max ) times. In each execution of the while loop, the algorithm visits the O(n) nodes of the current set R in the worst-case (e.g. when all nodes but one have been added into R from the first step). For each such node v and for each time λ min ≤ t ≤ λ max the algorithm first locates the entry A v [t] in the array A v in constant time and then it visits the whole linked list of the adjacent nodes of v at time step t. All these operations can be performed in O(nλ max + m t ) time in total.

Shortest Journeys with Weights
, be a weighted temporal graph with n vertices and m edges. Assume also that |λ(e)| = 1 for all e ∈ E, i.e. there is a single label on each edge (this implies also that m t = m). Let s, t ∈ V . Then, we can compute a shortest journey J between s and t in λ(G) (or report that no such journey exists) Proof First, we may assume without loss of generality that λ(G) is a connected graph, and thus m ≥ n − 1. For the purposes of the proof we construct from λ(G) a weighted directed graph H with two specific vertices s , t , such that there exists a journey J in λ(G) between s and t if and only if there is a directed path P in H from s to t . Furthermore, if such paths exist, then the weight of the shortest journey J of λ(G) between s and t equals the weight of the shortest directed path P of H from s to t .
First consider the (undirected) graph G that we obtain when we add two vertices s 0 and t 0 to λ(G) and the edges s 0 s and tt 0 . Assign to these two new edges the weight zero and assign to them the time labels λ(s 0 s) = 0 and λ(tt 0 ) = λ max + 1. Then, clearly there exists a time-respecting path between s and t in λ(G) if and only if there exists a time-respecting path between s 0 and t 0 in G , while the weights of these two paths coincide. For simplicity of the presentation, denote in the following by V and E the vertex and edge sets of G , respectively. Then we construct In this case, we assign to the arc e 1 e 2 of E H the weight w H ( e 1 e 2 ) = w(e 2 ).
Suppose first that G has a journey between s 0 and t 0 . Let J = (u 0 , u 1 , . . . , u k ), where u 0 = s 0 and u k = t 0 , be the shortest among them with respect to the weight function w of G . Then, by the definition of G , s 0 s and tt 0 are the first and the last edges of J . Furthermore, by the definition of a time-respecting path, Let now s H = s 0 s and t H = tt 0 . Suppose now that H has a path between s H and t H . Let Q = (e 0 , e 1 , . . . , e k ), where e 0 = s H and e k = t H , be the shortest among them with respect to the weight function w H of H . Since Q is a directed path between s H and t H , λ(e i ) < λ(e i+1 ) for every i = 0, 1, . . . , k − 1 by the construction of H . Furthermore, the edges e i and e i+1 of G are incident for every i = 0, 1, . . . , k − 1. Denote now by p i the common vertex of the edges e i and e i+1 in G for every i = 0, 1, . . . , k − 1. We will prove that p i = p i+1 for every i = 0, 1, . . . , k − 2. Suppose otherwise that p i = p i+1 for some 0 ≤ i ≤ k − 2. Then the edges e i , e i+1 , and e i+2 of G are as it is shown in Fig. 2, where e i = ad, e i+1 = bd, e i+2 = cd, and d = p i = p i+1 is the common point of the edges e i , e i+1 , and e i+2 . However, since λ(e i ) < λ(e i+1 ) and λ(e i+1 ) < λ(e i+2 ), it follows that λ(e i ) < λ(e i+2 ), and thus there exists the arc e i e i+2 in the directed graph H . Furthermore w H ( e i e i+2 ) = w H ( e i+1 e i+2 ) = w(e i+2 ), and thus w H ( e i e i+1 ) + w H ( e i+1 e i+2 ) > w H ( e i e i+2 ). Therefore there exists in H the strictly shorter directed path Q = (e 0 , e 1 , . . . , e i , e i+2 . . . , e k ) between e 0 = s H and e k = t H . This is a contradiction, since Q is the shortest directed path between s H and t H . Therefore Since Q is a simple directed path, it follows that every edge of J appears exactly once in J , and thus J is a path of G . Now we will prove that J is actually a simple path of G . Suppose otherwise that p i = p j for some 0 ≤ i < j ≤ k + 1. If p j = p k , i.e. p j = t 0 , then the subpath ( p 0 , p 1 , . . . , p i ) of J implies a strictly shorter directed path Q than Q between s H and t H in H , which is a contradiction. Therefore p j = p k . Then, since λ( p i−1 p i ) < λ(p i p i+1 ) for every i = 0, 1, . . . , k − 1 by the construction of the directed graph H , it follows in particular that λ( p i−1 p i ) < λ(p j p j+1 ), and thus is an arc in the directed graph H . Thus the path ( p 0 , p 1 , . . . , p i , p j+1 , . . . , p k ) of G implies a strictly shorter directed path Q than Q between s H and t H in H , which is again a contradiction. Therefore p i = p j for every 0 ≤ i < j ≤ k + 1 in J , and thus J is a simple path in G between p 0 = s 0 and p k = t 0 . Finally, it is easy to check Summarizing, there exists a journey J in G between s 0 and t 0 if and only if there is a directed path Q in H from s H to t H . Furthermore, if such paths exist, then the weight of the shortest journey J of G between s 0 and t 0 equals the weight of the shortest directed path Q of H from s H to t H .
Moreover, the above proof immediately implies an efficient algorithm for computing the graph H from λ(G) (by first constructing the auxiliary graph G from After we construct H , we can compute a shortest directed path between s H and t H in O(|E H | + |V H | log |V H |) time using Dijkstra's algorithm with Fibonacci heaps [12]. That is, we can compute a shortest directed path Q in H between s H and t H in O(m log m + v∈V δ 2 v ) time. Once we have computed the path Q, we can easily construct the shortest undirected journey J in λ(G) between s and t in O(m + n) time. This completes the proof of the theorem.

A Menger's Analogue for Temporal Graphs
In [15], Kempe et al. proved that Menger's theorem, at least in its original formulation, does not hold for single-label temporal networks in which journeys must have non-decreasing labels (and not necessarily strictly increasing as in our case). For a counterexample, it is not hard to see in Fig. 3 that there are no two disjoint timerespecting paths from v 1 to v 4 but after deleting any one node (other than v 1 or v 4 ) there still remains a time-respecting v 1 -v 4 path. Moreover, they proved that the violation of Menger's theorem in such temporal networks renders the computation of the number of disjoint s-t paths NP-complete.
We prove in this section that, in contrast to the above important negative result, there is a natural analogue of Menger's theorem that is valid for all temporal networks. In Theorem 3, we define this analogue and prove its validity. Then as an illustration (Sect. 4.1), we show how using our theorem can simplify the proof of a recent token dissemination result.
When we say that we remove node departure time (u, t) we mean that we remove all time-edges leaving u at time t, i.e. we remove label t from all (u, v) edges (for all v ∈ V ). In case of an undirected graph, we replace each edge by two antiparallel edges and remove label t only from the outgoing edges of u. So, when we ask how many node departure times are needed to separate two nodes s and v we mean how many node departure times must be selected so that after the removal of all the corresponding time-edges the resulting temporal graph has no (s, v)-journey. 5 Proof Assume, in order to simplify notation, that λ min = 1. Take the static expansion H = (S, A) of λ(G). Let {u i1 } and {u in } represent s and v over time, respectively (first and last columns, respectively), where 0 ≤ i ≤ λ max . We extend H as follows. For each u i j , 0 ≤ i ≤ λ max − 1, with at least 2 outgoing edges to nodes different than u (i+1) j , e.g. to nodes u (i+1) j 1 , u (i+1) j 2 , . . . , u (i+1) j k , we add a new node w i j and the edges ( We also define an edge capacity function c : A → {1, λ max } as follows. All edges of the form (u i j , u (i+1) j ) take capacity λ max and all other edges take capacity 1. We are interested in the maximum flow from u 01 to u λ max n . As this is simply a usual static flow network, the max-flow min-cut theorem applies stating that the maximum flow from u 01 to u λ max n is equal to the minimum of the capacity of a cut separating u 01 from u λ max n . So it suffices to show that (i) the maximum number of out-disjoint journeys from s to v is equal to the maximum flow from u 01 to u λ max n and (ii) the minimum number of node departure times needed to separate s from v is equal to the minimum of the capacity of a cut separating u 01 from u λ max n .
For (i) observe that any set of h out-disjoint journeys from s to v corresponds to a set of h disjoint paths from u 01 to u λ max n w.r.t. diagonal edges (edges in E\{(u i j , u (i+1) j )}) and inversely, so their maximums are equal. Next observe that any set of h disjoint paths from u 01 to u λ max n w.r.t. diagonal edges corresponds to an integral u 01 -u λ max n flow on H of value h and inversely. As the maximum integral u 01 -u λ max n flow is equal to the maximum u 01 -u λ max n flow (the capacities are integral and thus the integrality theorem of maximum flows applies) we conclude that the maximum u 01 -u λ max n flow is equal to the maximum number of out-disjoint journeys from s to v.
For (ii) observe that any set of r node departure times that separate s from v corresponds to a set of r diagonal edges leaving u i j nodes (ending either in w i j or in u (i+1) j nodes) that separate u 01 from u λ max n and inversely. Finally, observe that there is a minimum u 01 -u λ max n cut on H that only uses such edges: for if a minimum cut uses vertical edges we can replace them by diagonal edges and we can replace all edges leaving a w i j node by the edge (u i j , w i j ) without increasing the total capacity. The following version is though violated: "the maximum number of out-disjoint (or in-disjoint) journeys from s to v is equal to the minimum number of time-edges needed to separate s from v" (see Fig. 4). The same holds for the original statement of Menger's theorem as discussed in the beginning of this section (see [15]).

An Application: Foremost Dissemination (Journey Packing)
Consider the following problem. We are given a temporal graph λ(G), where G = (V , E), a source node s, a sink node v and an integer q. We are asked to find the minimum arrival time of a set of q out-disjoint (s, v)-journeys or even the minimizing set itself.
By exploiting the Menger's analogue proved in Theorem 3 (and in order to provide an example application of it), we give an alternative (and probably simpler to appreciate) proof of the following Lemma from [10] (stated as Lemma 1 below) holding for a special case of temporal networks, namely those that have connected instances. Formally, a temporal network λ(G) is said to have connected instances if λ(G, t) is connected at all times t ∈ N. The problem under consideration is distributed k-token dissemination: there are k tokens assigned to some given source nodes. In each round (i.e. discrete moment in the temporal network), each node selects a single token to be sent to all of its current neighbors (i.e. broadcast). The current neighbors at round i are those defined by E(i). The goal of a distributed protocol (or of a centralized strategy for the same problem) is to deliver all tokens to a given sink node v as fast as possible.
We assume that the algorithms know the temporal network in advance.

Lemma 1 Let there be k ≤ n tokens at given source nodes and let v be an arbitrary node. Then, all the tokens can be sent to v using broadcasts in O(n) rounds.
Let S = {s 1 , s 2 , . . . , s h } be the set of source nodes and let k(s i ) be the number of tokens of source node s i , so that 1≤i≤h k(s i ) = k. Clearly, it suffices to prove the following lemma.

Lemma 2
We are given a temporal graph λ(G) with connected instances and age α(λ) = n +k. We are also given a set of source nodes S ⊆ V , a mapping k : S → N ≥1 so that s∈S k(s) = k, and a sink node v. Then there are at least k out-disjoint journeys from S to v such that k(s i ) journeys leave from each source node s i .

Proof
We conceive k(s) as the number of tokens of source s. Number the tokens arbitrarily. Create a supersource node s and connect it to the source node with token i by an edge labeled i. Increase all other edge labels by k. Clearly the new temporal graph D = λ (G ) has asymptotically the same age as the original and all properties have been preserved (we just shifted the original temporal graph in the time dimension). Moreover, if there are k out-disjoint journeys from s to v in D then by construction of the edges leaving s we have that precisely k(s) of these journeys must be leaving from each source s ∈ S. So it suffices to show that there are k out-disjoint journeys from s to v. By Theorem 3 it is equivalent to show that the minimum number of departure times that must be removed from D to separate s from v is k. Assume that we remove y < k departure times. Then for more than n rounds all departure times are available (as we have n + 2k rounds and we just have y < k removals). As every instance of G is connected, we have that there is always an edge in the cut between the nodes that have been reached by s already and those that have not, unless we remove some departure times. As for more than n rounds all departure times are available it is immediate to observe that s reaches v implying that we cannot separate s from v with less that k removals and this completes the proof.

123
Part II

Minimum Cost Temporal Connectivity
In this section, we introduce some cost measures for maintaining different types of temporal connectivity. According to these temporal connectivity types, individuals are required to be capable to communicate with other individuals over the dynamic network, possibly with further restrictions on the timing of these connections. We initiate this study by considering the following fundamental problem: Given a (di)graph G, assign labels to the edges of G so that the resulting temporal graph λ(G) minimizes some parameter and at the same time preserves some connectivity property of G in the time dimension. For a simple illustration of this, consider the case in which λ(G) should contain a journey from u to v if and only if there exists a path from u to v in G. In this example, the reachabilities of G completely define the temporal reachabilities that λ(G) is required to have.
We consider two cost optimization criteria for a (di)graph G. The first one, called temporality of G, measures the maximum number of labels that an edge of G has been assigned. The second one, called temporal cost of G, measures the total number of labels that have been assigned to all edges of G. That is, if we interpret the number of assigned labels as a measure of cost, the temporality (resp. the temporal cost) of G is a measure of the decentralized (resp. centralized) cost of the network, where only the cost of individual edges (resp. the total cost over all edges) is considered. We introduce these cost parameters in Definition 3. Each of these two cost measures can be minimized subject to some particular connectivity property P that the labeled graph λ(G) has to satisfy. For simplicity of notation, we consider in Definition 3 the connectivity property P as a subset of the set L G of all possible labelings λ on the (di)graph G. Furthermore, the minimization of each of these two cost measures can be affected by some problem-specific constraints on the labels that we are allowed to use. We consider here one of the most natural constraints, namely an upper bound on the age of the constructed labeling λ. Definition 3 Let G = (V , E) be a (di)graph, α max ∈ N, and P be a connectivity property. Then the temporality of (G, P, α max ) is and the temporal cost of (G, P, α max ) is Furthermore τ (G, P) = τ (G, P, ∞) and κ(G, P) = κ(G, P, ∞).
Note that Definition 3 can be stated for an arbitrary property P of the labeled graph λ(G) (e.g. some proper coloring-preserving property). Nevertheless, we only consider here P to be a connectivity property of λ(G). In particular, we investigate the following two connectivity properties P: • all-paths (G) = {λ ∈ L G : for all simple paths P of G, λ preserves P}, preserves at least one simple path from u to v}.

Preserving All Paths
We begin with some simple observations on τ (G, all paths). Recall that given a (di)graph G our goal is to label G so that all simple paths of G are preserved by using as few labels per edge as possible. From now on, when we say "graph" we will mean a directed one and we will state it explicitly when our focus is on undirected graphs.
Another interesting observation is that if p(G) is the length of the longest path in G then we can trivially preserve all paths of G by using p(G) labels per edge. Give to every edge the labels {1, 2, . . . , p(G)} and observe that for every path e 1 , e 2 , . . . , e k of G we can use the increasing sequence of labels 1, 2, . . . , k due to the fact that k ≤ p(G). Thus, we conclude that the upper bound τ (G, all paths) ≤ p(G) holds for all graphs G. Of course, note that equality is easily violated. For example, a directed line has p(G) = n but τ (G, all paths) = 1.

Directed Rings
The following proposition states that if G is a directed ring then the temporality of preserving all paths is 2. This means that the minimum number of labels per edge that preserve all simple paths of a ring is 2. As the proof was already sketched in Sect. 1, we don't provide a proof here.

Proposition 1 τ (G, all paths) = 2 when G is a ring and τ (G, all paths) ≥ 2 when G contains a ring.
Directed Acyclic Graphs A topological sort of a digraph G is a linear ordering of its nodes such that if G contains an edge (u, v) then u appears before v in the ordering. It is well known that a digraph G can be topologically sorted iff it has no directed cycles that is iff it is a DAG. A topological sort of a graph can be seen as placing the nodes on a horizontal line in such a way that all edges go from left to right; see e.g. [8, page 549].

Proposition 2 If G is a DAG then τ (G, all paths) = 1.
Proof Take a topological sort u 1 , u 2 , . . . , u n of G. Clearly, every edge is of the form (u i , u j ) where i < j. Give to every edge (u i , u j ) label i, that is λ(u i , u j ) = i for all (u i , u j ) ∈ E. Now take any node u l . Each of its incoming edges has some label l < l and all its outgoing edges have label l. Now take any simple path p = v 1 , v 2 , . . . , v k of G. Clearly, v i appears before v i+1 in the topological sort for all 1 This proves that p is preserved. As we have preserved all simple paths with a single label on every edge, we conclude that τ (G, all paths) = 1 as required.

Preserving All Reachabilities
Now, instead of preserving all paths, we impose the apparently simpler requirement of preserving just a single path between every reachability pair u, v ∈ V . We claim that it is sufficient to understand how τ (G, reach), behaves on strongly connected digraphs. Let C(G) be the set of all strongly connected components of a digraph G.
The following lemma proves that, w.r.t. the reach property, the temporality of any digraph G is equal to the maximum temporality of its components. Lemma 3 τ (G, reach) = max{1, max C∈C(G) τ (C, reach)} for every digraph G with at least one edge. In the case of no edge, τ (G, reach) = 0 trivially.
Proof Take any digraph G. Now take the DAG D of the strongly connected components of G. The nodes of D are the components of G and there is an edge from component C to component C if there is an edge in G from some node of C to some node of C . As D is a DAG, we can obtain a topological sort of it which is a labeling C 1 , C 2 , . . . , C t of the t components so that all edges between components go only from left to right.
In the case where at least one component has at least 2 nodes (in which case max C∈C(G) τ (C, reach) ≥ 1), we have to prove that we can label G by using at most max 1≤i≤t τ (C i , reach) labels per edge and that we cannot do better than this. Consider the following labeling process. For each component C i define d i = min λ∈C i (λ max (λ)− λ min (λ)), where C i is the set of all labelings of C i that preserve all of its reachabilities using at most τ (C i , reach) labels per edge. Note that any C i can be labeled beginning from any desirable λ min with at most τ (C i , reach) labels per edge and with λ max equal to λ min + d i . Now, label component C 1 with λ min = 1 and λ max = 1 + d 1 . Label all edges leaving C 1 with label d 1 + 2. Label component C 2 with λ min = d 1 + 3 and λ max = (d 1 + 3) + d 2 and all its outgoing edges with label (d 1 + 3) + d 2 + 1. In general, label component C i with λ min = 1+ 1≤ j≤i−1 (d j +2) and λ max = λ min +d i and label all edges leaving C i with label λ max + 1. It is not hard to see that this labeling scheme preserves all reachabilities of G using just one label on each edge of G corresponding to an edge of D and at most τ (C i , reach) labels per edge inside each component C i . Thus, it uses at most max 1≤i≤t τ (C i , reach) labels on every edge. By observing that for each strongly connected component C i , τ (C i , reach) must be paid by any labeling of G that preserves all reachabilities in that component, the equality τ (G, reach) = max C∈C(G) τ (C, reach) follows.
In the extreme case where all components are just single nodes (in which case max C∈C(G) τ (C, reach) = 0), it holds that D = G, therefore G itself is a DAG and we only need 1 label per edge (as in Proposition 2) and, thus, τ (G, reach) = 1.
Lemma 3 implies that any upper bound on the temporality of preserving the reachabilities of strongly connected digraphs can be used as an upper bound on the temporality of preserving the reachabilities of general digraphs. In view of this, we focus on strongly connected digraphs G.
We begin with a few simple but helpful observations. Obviously, τ (G, reach) ≤ τ (G, all paths) as any labeling that preserves all paths trivially preserves all reachabilities as well. If G is a clique then τ (G, reach) = 1 as giving to each edge a single arbitrary label (e.g. label 1 to all) preserves all direct connections (one-step reachabilities) which are all present. If G is a directed ring (which is again strongly connected) then it is easy to see that τ (G, reach) = 2. An interesting question is whether there is some bound on τ (G, reach) either for all digraphs or for specific families of digraphs. The following lemma proves that indeed there is a very satisfactory generic upper bound.

Lemma 4 τ (G, reach) ≤ 2 for all strongly connected digraphs G.
Proof As G is strongly connected, if we pick any node u then for all v there is a (v, u) and a (u, v)-path. As for any v there is a (v, u)-path, then we may form an in-tree T in rooted at u (that is a tree with all directions going upwards to u). Now beginning from the leaves give any direction preserving labeling (just begin from labels 1 at the leaves and increase them as you move upwards). Say that the depth is k which means that you have increased up to label k. Now consider an out-tree T out rooted at u that has all edge directions going from u to the leaves. To make things simpler create second copies of all nodes but u so that the two trees are disjoint (w.r.t. to all nodes but u). In fact, one tree passes through all the first copies and arrives at u and the other tree begins from u and goes to all the second copies. Now we can begin the labeling of T out from k + 1 increasing labels as we move away from u on T out . This completes the construction. Now take any two nodes w and v. Clearly, there is a time-respecting path from w to u and then a time-respecting path from u to v using greater labels so there is a time-respecting path from w to v. Finally, notice that for any edge on T in there is at most one copy of that edge on T out thus clearly we use at most 2 labels per edge.

Restricting the Age
Now notice that for all G we have τ (G, reach, d(G)) ≤ d(G); recall that d(G) denotes the diameter of (di)graph G. Indeed it suffices to label each edge by {1, 2, . . . , d(G)}. Since every shortest path between two nodes has length at most d(G), in this manner we preserve all shortest paths and thus all reachabilitities arriving always at most by time d(G), thus we also preserve the diameter. Thus, a clique G has trivially τ (G, reach, d(G)) = 1 as d(G) = 1 and we can only have large τ (G, reach, d(G)) in graphs with large diameter. For example, a directed ring G of size n has τ (G, reach, d(G)) = n − 1 (note that on a ring it always holds that τ (G, reach, k) = τ (G, all paths, k), as on a ring it happens that satisfying all reachabilities also satisfies all paths while the inverse is true for all graphs). Indeed, assume that from some edge e, label 1 ≤ i ≤ n − 1 is missing. It is easy to see that there is some shortest path between two nodes of the ring that in order to arrive by time n − 1 must use edge e at time i. As this label is missing, it uses label i + 1, thus it arrives by time n which is greater than the diameter. In this particular example we can preserve the diameter only if all edges have the labels {1, 2, . . . , n − 1}.
On the other hand, there are graphs with large diameter in which τ (G, reach, d(G)) is small. This may also be the case even if G is strongly connected. For example, consider the graph with nodes u 1 , u 2 , . . . , u n and edges (u i , u i+1 ) and (u i+1 , u i ) for all 1 ≤ i ≤ n − 1. In words, we have a directed line from u 1 to u n and an inverse one from u n to u 1 . The diameter here is n − 1 (e.g. the shortest path from u 1 to u n ). On the other hand, we have τ (G, reach, d(G)) = 1: simply label one path 1, 2, ..., n − 1 and label the inverse one 1, 2, ..., n − 1 again, i.e. give to edges (u i , u i+1 ) and (u n−i+1 , u n−i+2 ) label i. The reason here is that there are only two pairs of nodes that must necessarily use the long paths (u 1 , u n ) and (u n , u 1 ) and preserve the diameter n − 1. All other smaller shortest paths between other pairs of nodes have now a big gap of n − 1 to exploit.
We will now demonstrate what makes τ (G, reach, d(G)) grow. It happens when many maximum shortest paths (those that determine the diameter of G) between different pairs of nodes that are additionally unique (the paths), in the sense that we must necessarily take them in order to preserve the reachabilities (it may hold even if they are not unique but this simplifies the argument), all pass through the same edge e but use e at many different times. It will be helpful to look at Fig. 5. Each (u i , v i )-path is a unique shortest path between u i and v i and has additionally length equal to the diameter (i.e. it is also a maximum one), so we must necessarily preserve all 5 (u i , v i )-paths. Note now that each (u i , v i )-path passes through e = (u 1 , v 5 ) via its i-th edge. Each of these paths can only be preserved without violating d(G) by assigning the labels 1, 2, . . . , d(G), however note that then edge e must necessarily have all labels 1, 2, . . . , d(G). To see this, notice simply that if any label i is missing from e then there is some maximum shortest path that goes through e at step i. As i is missing it cannot arrive sooner than time d(G) + 1 which violates the preservation of the diameter.
Undirected Tree Now consider an undirected tree T . τ (G, reach, d(G)) = d(G). All paths longer than length 5 that are formed are not shortest paths, e.g. there is a path (the dashed one) of length at most 5 from u 2 to v 1 and the same for all other such pairs

Corollary 3 If T is an undirected tree then τ (T , all paths, d(T )) ≤ 2.
Proof This follows as a simple corollary of Lemma 4. If we replace each undirected edge by two antiparallel edges, then T is a strongly connected digraph and, additionally, for every ordered pair of nodes (u, v) there is precisely one simple path from u to v. The latter implies that preserving all paths of T is equivalent to preserving all reachabilities of T . So, all assumptions of Lemma 4 are satisfied and therefore τ (T , all paths) ≤ 2. Finally, recall that the labeling of the construction in the proof of Lemma 4 starts increasing labels level-by-level from the leaves to the root and then from the root to the leaves, therefore the number of increments (i.e., the maximum label used) is upper bounded by the diameter of T , thus, τ (T , all paths, d(T )) ≤ 2 as required.

Trade-off on a Ring
We shall now prove that there is a trade-off between the temporality and the age. In particular, we consider a directed ring G = (e 1 , e 2 , . . . , e n ), where the e i are edges oriented clockwise. As we have already discussed, if α = n − 1 then τ (G, all paths, α) = n − 1 (which is the worst possible) and if α = 2(n − 1) then τ (G, all paths, α) = 2 (which is the best possible). We now formalize the behavior of τ as α moves from n − 1 to 2(n − 1).

Theorem 5 If G is a directed ring and α
then τ (G, all paths, α) = (n/k) and in particular n−1 k+1 ≤ τ (G, all paths, α) ≤ n k+1 + 1. Moreover, τ (G, all paths, n − 1) = n − 1 (i.e. when k = 0). Proof The proof of the upper bound is constructive. In particular, we present a labeling that preserves all paths of the ring G using at most n k+1 + 1 labels on every edge and maximum label (n − 1) + k. Let the ring be e 1 , e 2 , . . . , e n and clockwise. We say that an edge e i is satisfied if there is a journey of length n − 1 beginning from e i (clearly, considering only those journeys that do not use a label greater than α = (n − 1) + k). Consider the following labeling procedure.
Note that in each iteration i we satisfy edges e i(k+1)+1 , e i(k+1)+2 , . . . , e (i+1)(k+1) , i.e. k + 1 new edges, without leaving gaps. It follows that in n k+1 iterations all edges have been satisfied. The first iteration assigns at most two labels on edge e 1 and every other iteration, apart from the last one, assigns one label on e 1 (and clearly at most one on every other edge), thus e 1 gets a total of at most n k+1 + 1 labels (and all other edges get at most this). Now, for the lower bound, take an arbitrary edge, e.g. e 1 . Given an edge e i and a journey J from e i to e 1 that uses label l 1 on e 1 , define the delay of J as l 1 − l(J ), where l(J ) is the length of journey J i.e. n − i + 2. In words, the delay of a (e i , e 1 )journey is the difference between the time at which the journey visits e 1 minus the fastest time that it could have visited e 1 . Now, beginning from e n count k + 1 times 123 counterclockwise, i.e. consider edge e n−k . We show that in order to satisfy e n−k we must necessarily use one of the labels {k + 2, k + 3, . . . , 2k + 2} on e 1 . To this end, notice that the delay of any journey that satisfies some edge can be at most k, the reason being that a delay of k + 1 or greater implies that the journey cannot visit n − 1 edges in less than (n − 1) + (k + 1) time, thus it will have to use some label greater than α = (n − 1) + k, which is the maximum allowed. Thus, the maximum label by which a journey that satisfies e n−k can go through e 1 is l(e n−k ) + k = 2k + 2, where l(e i ) denotes the length of the path beginning from the tail of e i and ending at the head of e 1 . Moreover, the minimum label by which any journey from e n−k can go through e 1 is l(e n−k ) = k + 2. Thus, we conclude that any journey that satisfies e n−k has to use one of the labels {k + 2, k + 3, . . . , 2k + 2} on e 1 .

A Generic Method for Computing Lower Bounds for Temporality
Proposition 1 showed that graphs with directed cycles need at least 2 labels on some edge(s) in order for all paths to be preserved. Now a natural question to ask is whether we can preserve all paths of any graph by using at most 2 labels (i.e. whether τ (G, all paths) ≤ 2 holds for all graphs). We shall prove that there are graphs G for which τ (G, all paths) = ( p(G)) (recall that p(G) denotes the length of the longest path in G), that is graphs in which the optimum labeling, w.r.t. temporality, is very close to the trivial labeling λ(e) = {1, 2, . . . , p(G)}, for all e ∈ E, that always preserves all paths.
Definition 4 Call a set K = {e 1 , e 2 , . . . , e k } ⊆ E(G) of edges of a digraph G an edge-kernel if for every permutation π = (e i 1 , e i 2 , . . . , e i k ) of the elements of K there is a simple path P of G that visits all edges of K in the ordering defined by the permutation π .
We will now prove that an edge-kernel of size k needs at least k labels on some edges. Our proof is constructive. In particular, given any labeling using k − 1 labels on an edge-kernel of size k, we present a specific path that forces a kth label to appear. Theorem 6 (Edge-kernel Lower Bound) If a digraph G contains an edge-kernel of size k then τ (G, all paths) ≥ k.
Proof Let K = {e 1 , e 2 , . . . , e k } be such an edge-kernel of size k. Assume for contradiction that there is a path-preserving labeling using on every edge at most k − 1 labels. Then there is a path-preserving labeling that uses precisely k − 1 labels on every edge (just extend the previous labeling by arbitrary labels). On every edge e i , 1 ≤ i ≤ k, sort the labels in an ascending order and denote by λ l (e) the lth smallest label of edge e; e.g. if an edge e has labels {1, 3, 7}, then λ 1 (e) = 1, λ 2 (e) = 3, and λ 3 (e) = 7. Note that, by definition of an edge-kernel, all possible permutations of the edges in K appear in paths of G that should be preserved. We construct a permutation π = (e j 1 , e j 2 , . . . , e j k ) of the edges in K which cannot be time-respecting without using a kth label on some edge. As e j 1 use the edge with the maximum λ 1 , that is arg max e∈K λ 1 (e). Then as e j 2 use the edge with the maximum λ 2 between the remaining edges, that is arg max e∈K \{e j 1 } λ 2 (e), and define e j 3 , e j 4 , . . . analogously. It is not hard to see that π satisfies λ i (e j i ) ≥ λ i (e j i+1 ) for all 1 ≤ i ≤ k − 1. This, in turn, implies that for π to be time-respecting it cannot use the labels λ 1 , . . . , λ i−1 at edge e j i , for all i ≥ 2, which shows that at edge e j k it can use none of the k − 1 available labels, thus a kth label is necessarily needed and the theorem follows.

Lemma 5 If G is a complete digraph of order n then it has an edge-kernel of size n/2 .
Proof Note that n/2 is the size of a maximum matching M of G. As all possible edges that connect the endpoints of the edges in M are available, M is an edge-kernel of size n/2 . Now, Theorem 6 implies that a complete digraph of order n requires at least n/2 labels on some edge in order for all paths to be preserved, that is n/2 ≤ τ (G, all paths). At the same time we have the trivial upper bound τ (G, all paths) ≤ n − 1 which follows from the fact that the longest path of a clique is hamiltonian, thus has n − 1 edges, and for any graph G the length of its longest path is an upper bound on τ (G, all paths).
The above, clearly remain true for the following (close to complete) bipartite digraph. There are two partitions A = {u i : 1 ≤ i ≤ k} and B = {v i : 1 ≤ i ≤ k} both of size k. The edge set consists of (u i , v i ) for all i and (v i , u j ) for all i, j. In words, from A to B we have only horizontal connections while from B to A we have all possible connections.

Lemma 6
There exist planar graphs G with n vertices having edge-kernels of size (n 1 3 ).
Proof The proof is done by construction. Consider the grid graph G = G 2n 2 ,2n , i.e. G is formed as a part of the infinite grid having width of 2n 2 vertices and height of 2n vertices. Note that G is a planar graph. For simplicity of the presentation, we consider the grid graph G on the Euclidean plane, where the vertices have integer coordinates and the lower left vertex has coordinates (1, 1). Furthermore denote by v i, j the vertex of G that is placed on the point (i, j), where 1 ≤ i ≤ 2n 2 and 1 ≤ j ≤ 2n. For every i ∈ {1, 2, . . . , n} denote p i = v (2i−1)n,n and q i = v (2i−1)n+1,n . We define the edge subset S = {e i = p i q i : 1 ≤ i ≤ n}. We now prove that S is an edge-kernel of G. Let π = (e i 1 , e i 2 , . . . , e i n ) be an arbitrary permutation of the edges of S = {e 1 , e 2 , . . . , e n }. We construct a simple path P in G that visits all the edges of S in the order of the permutation π . That is, we construct a path P = ( p i 1 , q i 1 , P 1 , p i 2 , q i 2 , P 2 , . . . p i n−1 , q i n−1 , P n−1 , p i n , q i n ). In order to do so, it suffices to define iteratively the simple paths P 1 , P 2 , . . . , P n−1 such that no two of these paths share a common vertex. The path P 1 starts at q i 1 and continues upwards on the column of q i 1 in the grid, until it reaches the top 2nth row of the grid. Then, if i 2 > i 1 (resp. if i 2 < i 1 ), the path P 1 continues on this top row to the right (resp. to the left), until it reaches the column of vertex p i 2 of the grid. Finally it continues downwards on this column until it reaches p i 2 , where P 1 ends. Consider now an index t ∈ {2, 3, . . . , n − 1}. In a similar manner as P 1 , the path P t starts at vertex q i t . Then it continues upwards on the column of q i t in the grid as much as possible, such that it does not reach any vertex of a path P k , where k ≤ t − 1. Note that, if no path P k , k ≤ t − 1, passes through any vertex of the column of q i t in the grid, then the path P t reaches the top 2n th row of the grid in this column. On the other hand, note that, since q i t = v (2i t −1)n+1,n and t ≤ n − 1, at most the upper t − 1 ≤ n − 2 vertices of the column of q i t in the grid can possibly belong to a path P k , where k ≤ t − 1. Thus the path P t can always continue upwards from q i t by at least one edge. Let a t be the uppermost vertex of P t on the column of q i t of the grid (cf. Fig. 6 for t = 5 and e i 5 = e 1 ).
Assume that i t+1 > i t , i.e. vertex p i t+1 lies to the right of vertex q i t on the nth row of the grid. Then, the path P t continues from vertex a t to the right, as follows. If P t can reach the column of p i t without passing through a vertex of a path P k , k ≤ t − 1, then it does so; in this case the path P t continues downwards until it reaches vertex p i t , where it ends (cf. Fig. 6 for t = 3 and e i 3 = e 3 ). Suppose now that P t can not reach the column of P t without passing through a vertex of a path P k , k ≤ t − 1 (cf. Fig. 6 for t = 5 and e i 5 = e 1 ). Then, P t continues on the row of vertex a t to the right as much as possible (say, until vertex b t ), such that it does not reach any vertex of a path P k , k ≤ t − 1. In this case the path P t continues from vertex b t downwards as much as possible until it reaches a vertex c t that is not neighbored to its right to any vertex of a path P k , k ≤ t − 1 (cf. Fig. 6 for t = 5 and e i 5 = e 1 ). Furthermore P t continues from vertex c t to the right as much as possible until it reaches a vertex d t that is not neighbored from above to any vertex of a path P k , k ≤ t − 1. Then, P t continues from d t in a similar way until it reaches the column of vertex p i t+1 (cf. Fig. 6 for t = 5, e i 5 = e 1 , and e i 6 = e 6 ), and then it continues downwards until it reaches p i t+1 , where P t ends. Note that, by definition of the edge set S, there exist at least 2n columns of the grid between any two edges of the set S. Furthermore there exist n − 1 rows of the grid below every edge of S. Thus, since there exist at most t − 1 ≤ n − 2 previous paths P k , k ≤ t − 1, it follows that there exists always enough space for the path P t in the grid to (a) reach vertex d t and (b) continue from d t until it reaches vertex p i t+1 , where P t ends.
Assume now that i t+1 < i t , i.e. vertex p i t+1 lies to the left of vertex q i t on the nth row of the grid. In this case, when we start the path P t at vertex q i t , we first move one edge downwards and then two edges to the left (cf. Fig. 6 for t = 2 and e i 2 = e 5 , as well as for t = 4 and e i 4 = e 4 ). After that point we continue constructing the path P t similarly to the case where i t+1 > i t (cf. Fig. 6).
Therefore, we can construct in this way all the paths P 1 , P 2 , . . . , P n−1 , such that no two of these paths share a common vertex, and thus the path P = ( p i 1 , q i 1 , P 1 , p i 2 , q i 2 , P 2 , . . . p i n−1 , q i n−1 , P n−1 , p i n , q i n ) is a simple path of G that visits all the edges of S in the order of the permutation π . An example of the construction of such a path P is given in Fig. 6. In this example S = (e 1 , e 2 , . . . , e 6 ) and π = (e 2 , e 5 , e 3 , e 4 , e 1 , e 6 ). That is, using the above notation, i 1 = 2, i 2 = 5, i 3 = 3, i 4 = 4, i 5 = 1, and i 6 = 6. In this figure we also depict for t = 5 the vertices a t , b t , c t that we defined in the above construction of the path P i t .
Since such a path P exists for every permutation π of the edges of the set S, it follows by Definition 4 that S is an edge-kernel of G, where G is a planar graph. Finally, since G = (V , E) has by construction |V | = 4n 3 vertices and |S| = n, it follows that the size of the edge-kernel S is (|V | 1 3 ). This completes the proof of the lemma.

Hardness of Approximation
Consider a boolean formula φ in conjunctive normal form with two literals in every clause (2-CNF). Let τ be a truth assignment of the variables of φ and α = ( 1 ∨ 2 ) be a clause of φ. Then α is XOR-satisfied (or NAE-satisfied) in τ , if one of the literals { 1 , 2 } of the clause α is true in τ and the other one is false in τ . The number of clauses of φ that are XOR-satisfied in τ is denoted by |τ (φ)|. The formula φ is XOR-satisfiable (or NAE-satisfiable) if there exists a truth assignment τ of φ such that every clause of φ is XOR-satisfied in τ . The Max-XOR problem (also known as the Max-NAE-2-SAT problem) is the following maximization problem: given a 2-CNF formula φ, compute the greatest number of clauses of φ that can be simultaneously XOR-satisfied in a truth assignment τ , i.e. compute the greatest value for |τ (φ)|. The Max-XOR(k) problem is the special case of the Max-XOR problem, where every variable of the input formula φ appears in at most k clauses of φ. It is known that a special case of Max-XOR(3), namely the monotone Max-XOR(3) problem, is APX-hard (i.e. it does not admit a PTAS unless P=NP [9,16]), as the next lemma states [1]. In this special case of the problem, the input formula φ is monotone, i.e. every variable appears not negated in the formula. The monotone Max-XOR(3) problem essentially encodes the Max-Cut problem on 3-regular (i.e. cubic) graphs, which is known to be APX-hard [1].  Fig. 7 The gadget G φ,i for the variable x i variables x 1 , x 2 , . . . , x n and m clauses. Since every variable x i appears in φ (either as x i or as x i ) in at most 3 clauses, it follows that m ≤ 3 2 n. We will construct from φ a graph G φ having length of a directed cycle at most 2. Then, as we prove in Theorem 7, κ(G φ , reach, d(G φ )) ≤ 39n −4m −2k if and only if there exists a truth assignment τ of φ with |τ (φ)| ≥ k, i.e. τ XOR-satisfies at least k clauses of φ. Since φ is an instance of Max-XOR(3), we can replace every clause ( Thus, we can assume without loss of generality that every clause of φ is either of the form ( For every i = 1, 2, . . . , n we construct the graph G φ,i of Fig. 7. Note that the diameter of G φ,i is d(G φ,i ) = 9 and the maximum length of a directed cycle in G φ,i is 2. In this figure, we call the induced subgraph of G φ,i on the 13 vertices {s x i , u x i 1 , . . . , u x i 6 , v x i 1 , . . . , v x i 6 } the trunk of G φ,i . Furthermore, for every p ∈ {1, 2, 3}, we call the induced subgraph of G φ,i on the 5 vertices and v x i 6 v x i 7, p the transition edges of the pth branch of G φ,i . Furthermore, for every i = 1, 2, . . . , n, let r i ≤ 3 be the number of clauses in which variable x i appears in φ. For every 1 ≤ p ≤ r i , we assign the pth appearance of the variable x i (either as x i or as x i ) in a clause of φ to the pth branch of G φ,i .
Consider now a clause α = ( i ∨ j ) of φ, where i < j. Then, by our assumptions on φ, it follows that i = x i and j ∈ {x j , x j }. Assume that the literal i (resp. j ) of the clause α corresponds to the pth (resp. to the qth) appearance of the variable x i (resp. x j ) in φ. Then we identify the vertices of the pth branch of G φ,i with the vertices of the qth branch of G φ, j as follows. If  Fig. 9a). Otherwise, if j = x j then we iden- 1   1  2   2  3  4  5  6   2  3  3  4  4  5  5  6  6 7 q , respectively (cf. Fig. 9b). This completes the construction of the graph G φ . Note that, similarly to the graphs G φ,i , 1 ≤ i ≤ n, the diameter of G φ is d(G φ ) = 9 and the maximum length of a directed cycle in G φ is 2. Furthermore, note that for each of the m clauses of φ, one branch of a gadget G φ,i coincides with one branch of a gadget G φ, j , where 1 ≤ i < j ≤ n, while every G φ,i has three branches. Therefore G φ has exactly 3n − 2m branches which belong to only one gadget G φ,i , and m branches that belong to two gadgets G φ,i , G φ, j .
Proof (⇒) Assume that there is a truth assignment τ that XOR-satisfies k clauses of φ. We construct a labeling λ of G φ with cost 39n − 4m − 2k as follows. Let i = 1, 2, . . . , n. If x i = 0 in τ , we assign labels to the edges of the trunk of G φ,i as in Fig. 8a. Otherwise, if x i = 1 in τ , we assign labels to the edges of the trunk of G φ,i as in Fig. 8b. We now continue the labeling λ as follows. Consider an arbitrary clause Assume that the literal i (resp. j ) of the clause α corresponds to the pth (resp. to the qth) appearance of variable x i (resp. x j ) in φ. Then, by the construction of G φ , the pth branch of G φ,i coincides with the qth branch of G φ, j .
Assume that j = x j (cf. Fig. 9a). Then by our construction u x i 7, p = v Fig. 9a). Let α be XOR-satisfied in τ , i.e. x i = x j . If x i = x j = 0 then we label the edges of the pth branch of G φ,i (equivalently, the edges of the qth branch of G φ, j ), the transition edges of the pth branch of G φ,i , and the transition edges of the qth branch of G φ, j , as illustrated in Fig. 10a. In the symmetric case where x i = x j = 1 we label these edges in the same Fig. 9 The gadgets for a the clause (x i ∨ x j ) and b the clause (x i ∨ x j ), where x i appears in the pth branch of G φ,i and x j (resp. x j ) appears in the qth branch of G φ, j  Fig. 10a, with the only difference that we exchange the role of u's and v's. Let now α be XOR-unsatisfied in τ , i.e. x i = x j . If x i = x j = 0 then we label the edges of the pth branch of G φ,i (equivalently, the edges of the qth branch of G φ, j ), the transition edges of the pth branch of G φ,i , and the transition edges of the qth branch of G φ, j , as illustrated in Fig. 10b. In the symmetric case where x i = x j = 1 we label these edges in the same way as in Fig. 10b, with the only difference that we exchange the role of u 's and v's. For the case where j = x j we label the edges of Fig. 9b similarly to the case where j = x j (cf. Fig. 10).
Finally consider any of the 3n − 2m branches that belong to only one gadget G φ,i , where 1 ≤ i ≤ n. Let this be the pth branch of G φ,i . If x i = 0 then we label the edges of this branch and its transition edges as illustrated in Fig. 10a (by ignoring in this figure the vertices u x j 6 , v x j 6 ). In the symmetric case where x i = 1, we label these edges in the same way, with the only difference that we exchange the role of u's and v's. This finalizes the labeling λ of G φ . It is easy to check that λ preserves all reachabilities of G φ and its greatest label is d.
Summarizing, for every i ∈ {1, 2, . . . , n}, the edges of the trunk of G φ,i are labeled with 18 labels (cf. Fig. 8), and thus λ uses in total 18n labels for the trunks of all G φ,i , i ∈ {1, 2, . . . , n}. Furthermore, for every i ∈ {1, 2, . . . , n} and every p ∈ {1, 2, 3}, λ fore, we may assume without loss of generality that for every i ∈ {1, 2, . . . , n}, it is are different from the last two edges of Q( j, q), while the last two edges of Q(i, p) are different from the last two edges of P( j, q). Therefore, since each of the edges u x i z, p v x i z, p and v x i z, p u x i z, p , where z ∈ {7, 8}, receives at least one label in λ, it follows that λ uses for the pth branch of G φ,i (equivalently for the qth branch of G φ, j ) at least 8 labels, if j = x j .
Using Theorem 7, we are now ready to prove the main theorem of this section.

Theorem 8 (Hardness of Approximating the Temporal Cost)
The problem of computing κ(G, reach, d(G)) is APX-hard, even when the maximum length of a directed cycle in G is 2.
Proof Denote now by OPT Max-XOR(3) (φ) the greatest number of clauses that can be simultaneously XOR-satisfied by a truth assignment of φ. Then Theorem 7 implies that Note that a random assignment XOR-satisfies each clause of φ with probability 1 2 , and thus we can easily compute (even deterministically) an assignment τ that XORsatisfies m 2 clauses of φ. Therefore OPT Max-XOR(3) (φ) ≥ m 2 , and thus, since every variable x i appears in at least one clause of φ, it follows that Assume that there is a PTAS for computing κ(G, reach, d(G)). Then, for every ε > 0 we can compute in polynomial time a labeling λ for the graph G φ , such that Given such a labeling λ we can compute by the sufficiency part (⇐) of the proof of Theorem 7 a truth assignment τ of φ such that 39n − 4m − 2|τ (φ)| ≤ |λ|, i.e.
Therefore it follows by (1), (2), (3), and (4) that and thus That is, assuming a PTAS for computing κ (G, reach, d(G)), we obtain a PTAS for the Max-XOR(3) problem, which is a contradiction by Lemma 7. Therefore computing κ(G, reach, d(G)) is APX-hard. Finally, since the graph G φ that we constructed from the formula φ has maximum length of a directed cycle at most 2, it follows that computing κ(G, reach, d(G)) is APX-hard even if the given graph G has maximum length of a directed cycle at most 2.

Approximating the Cost
In this section, we provide an approximation algorithm for computing κ(G, reach, d(G)), which complements the hardness result of Theorem 8. Given a digraph G define, for every u ∈ V , u's reachability number r (u) = |{v ∈ V : v is reachable from u}| and r (G) = u∈V r (u), that is r (G) is the total number of reachabilities in G.

Theorem 9
There is an r (G) n−1 -factor approximation algorithm for computing κ(G, reach, d(G)) on any weakly connected digraph G.
Proof First of all, note that OPT ≥ n − 1, where OPT is the cost of the optimal solution. The reason is that if a labeling labels less than n − 1 edges then the subgraph of G induced by the labeled edges is disconnected (not even weakly connected) thus clearly fails to preserve some reachabilities. To see this, take any two components C 1 and C 2 . G either has an edge from C 1 to C 2 or from C 2 to C 1 (or both). The two cases are symmetric so just consider the first one. Clearly some node from C 1 can reach some node from C 2 but this reachability has not been preserved by the labeling. Now consider the following labeling algorithm.
that for all u we use (i.e. we label) precisely r (u) edges in T u , thus, in total, we use u∈V r (u) = r (G) edges by definition of r (G). We conclude that ALG OPT ≤ r (G) n − 1 ⇒ ALG ≤ r (G) n − 1 OPT

Conclusions and Further Research
There are many open problems related to the findings of the present work. We have considered several graph families in which the temporality of preserving all paths is very small (e.g. 2 for rings) and others in which it is very close to the worst possible (i.e. (n) for cliques and (n 1/3 ) for planar graphs). There are still many interesting graph families to be investigated like regular or bounded-degree graphs. Moreover, though it turned out to be a generic lower-bounding technique related to the existence of a large edge-kernel in the underlying graph G, we still do not know whether there are other structural properties of the underlying graph that could cause a growth of the temporality (i.e. the absence of a large edge-kernel does not necessarily imply small temporality). Similar things hold also for the reach property. There are also many other natural connectivity properties subject to which optimization is to be performed that we haven't yet considered, like preserving a shortest path from u to v whenever v is reachable from u in G, or even depart from paths and require the preservation of more complex subgraphs (for some appropriate definition of "preservation"). Another interesting direction which we didn't consider in this work is to set the optimization criterion to be the age of λ e.g. w.r.t. the all paths or the reach connectivity properties. In this case, computing α(G, all paths) is NP-hard, which can be proved by reduction from HAMPATH. On the positive side, it is easy to come up with a 2-factor approximation algorithm for α(G, reach, 2), where we have restricted the maximum number of labels of an edge (i.e. the temporality) to be at most 2. Additionally, there seems to be great room for approximation algorithms (or even randomized algorithms) for all combinations of optimization parameters and connectivity constraints that we have defined so far, or even polynomial-time algorithms for specific graph families. Finally, it would be valuable to consider other models of temporal graphs and in particular models with succinct representations, that is models in which the labels of every edge are provided by some short function associated to that edge (in contrast to a complete description of all labels). Such examples are several probabilistic models and several periodic models which are worth considering.