Foremost, Fastest, Shortest: Temporal Graph Realization Under Various Path Metrics
Abstract
In this work, we follow the current trend on temporal graph realization, where one is given a property and the goal is to determine whether there is a temporal graph, that is, a graph where the edge set changes over time, with property . We consider the problems where the given property is a prescribed matrix for the duration, length, or earliest arrival time of pairwise temporal paths. This means that we are given a matrix and ask whether there is a temporal graph such that for any ordered pair of vertices , equals the duration (length, or earliest arrival time, respectively) of any temporal path from to minimizing that specific temporal path metric. For shortest and earliest arrival temporal paths, we are the first to consider these problems as far as we know. We analyze these problems for many settings such as: strict and non-strict paths, periodic and non-periodic temporal graphs, and limited number of labels per edge (limited number of occurrences per edge over time). In contrast to all other path metrics, we show that for the earliest arrival times, we can achieve polynomial-time algorithms in periodic and non-periodic temporal graphs and for strict and and non-strict paths. However, the problem becomes NP-hard when the matrix does not contain a single integer but a set or range of possible allowed values. As we show, the problem can still be solved efficiently in this scenario, when the number of entries with more than one value is small, that is, we develop an FPT-algorithm for the number of such entries. For the setting of fastest paths, we achieve new hardness results that answers an open question by Klobas, Mertzios, Molter, and Spirakis [Theor. Comput. Sci. ’25] about the parameterized complexity of the problem with respect to the vertex cover number and significantly improves over a previous hardness result for the feedback vertex set number. When considering shortest paths, we show that the periodic versions are polynomial-time solvable whereas the non-periodic versions become NP-hard.
Keywords and phrases:
network design, temporal paths, foremost paths, fastest paths, shortest paths, non-strict paths, periodic temporal graphsCopyright and License:
2012 ACM Subject Classification:
Theory of computation Design and analysis of algorithmsFunding:
Supported by the French ANR, projects ANR-22-CE48-0001 (TEMPOGRAL) and ANR-24-CE48-4377 (GODASse).Editors:
Meena Mahajan, Florin Manea, Annabelle McIver, and Nguyễn Kim ThắngSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
Due to space constraints, proofs of results marked with are (partially) deferred to the full version accessible at https://arxiv.org/abs/2510.01702.
1 Introduction
Graph realization problems have been studied since the 1960s and consists of finding a static graph that satisfies a desired property or answering that no such graph exists. The earliest example of such a problem is the case of degree sequence realization, where one is given a non-decreasing sequence of natural numbers, and one asks whether there is an undirected graph with vertex set , such that vertex has degree exactly . This problem was introduced by Erdős and Gallai [9] and generalizations of it remain the object of active study (see, e.g., [2] when ranges are given for each degree). In another early graph realization problem by Hakimi and Yau [13], one is given an distance matrix and asks whether there is a static graph on vertices where, for each ordered pair of vertices, the shortest path from to has length exactly . Since the introduction of these early problems, graph realization problems were considered in many variations and for many other desirable properties to realize. Recently motivated by the realization problem for distance matrices on static graphs, Klobas, Mertzios, Molter and Spirakis [16] lifted graph realization problems to the realm of temporal graphs. Here, a temporal graph is a finite sequence of static graphs that are all defined over the same vertex set. Temporal graphs are a valuable tool to model and analyze the behavior of real world dynamic networks [4]. In the problem introduced by Klobas et al. [16], the goal is to decide whether a desired property is fulfilled by some temporal graph. They introduced the following problem:
Fastest-path TGR:
Input: An distance matrix .
Question: Is there a temporal graph with vertices such that for any ordered pair of vertices, the fastest temporal path from to has duration ?
Recall that a (strict) temporal path can start at any time step and is allowed to traverse at most one edge per time step, and its duration is the difference between the starting time and the arrival time, and that a fastest temporal path is a temporal path with minimum duration (see Section 2). More precisely, the authors considered this problem111They analyzed the problem under the name Simple (Periodic) Temporal Graph Realization. where only a single label per edge is allowed and where the temporal graph is periodic, that is, where the same edges repeat every time steps for some period . They showed that the this version of the problem is NP-hard and they exhibited an FPT algorithm parameterized by the feedback edge number of the underlying graph, that is, the uniquely defined graph that contains an edge if and only if . In contrast, they showed that this version of the problem is W[1]-hard when parameterized by the feedback vertex set number of the underlying graph. Erlebach, Morawietz and Wolf [11] generalized the problem by allowing each edge to appear up to times per period and proved that this remains NP-hard even on underlying graphs that are trees for . In [19], the authors studied the problem where upper bounds on the fastest paths are given and the underlying graph is a tree. This was further considered for directed graphs by Meusel, Müller-Hannemann and Reinhardt [21]. Further recent papers on temporal graph realization include: designing a temporal graph for which the fastest path should not have duration more than times the real distance [20], designing a temporal graph which should have a prescribed reachability relation between the vertices [10], and designing a temporal graph for which all pairs of agents can pairwise reach each other via strict temporal paths, with one label per edge, while the degree sequence of the underlying graph is prescribed [3]. It is worth mentioning that Göbel, Cerdeira and Veldman [12] considered a connectivity problem that can also be seen as a temporal graph realization problem. All these problems are motivated both from a design perspective, where we aim to design a network with a desired behavior, or from a verification perspective, where we want to verify that the behavior of our network is correct or at least plausible. From the perspective of temporal network design problems, the field is even more vibrant (see, e.g., [14, 17, 18, 8, 23, 7, 1, 15]).
Our Results.
In this work, we extend the previous work on Fastest-path TGR to the non-strict case (that is, where arbitrary many edges per time step can be traversed). Furthermore, we consider the other most frequently used temporal path metrics and (formally defined in Section 2). Roughly speaking, Foremost-path TGR requires that the earliest arrival time at , minimized over all temporal -paths, is equal to for each vertex pair , whereas Shortest-path TGR requires that the number of edges, minimized over all temporal -paths, is equal to for each vertex pair . Our main results are as follows:
-
1.
In Section 3 we show that all considered versions (strict/non-strict, periodic/non-periodic) of Foremost-path TGR are polynomial-time solvable if we are allowed to put an arbitrary number of labels on each edge. This is surprising, as almost all other previously mentioned temporal graph realization problems turn out to be NP-hard (with one exception [3]). In particular, we show that all our algorithms produce a labeling with at most time labels in total, if dealing with a realizable instance. This is asymptotically tight as some realizable matrices do require time labels.
-
2.
To show the limitations of the tractability, we also show in Section 3 that Foremost-path TGR becomes NP-hard if (i) we are only allowed to assign one label per edge or (ii) the matrix contains more than one entry for each vertex pair, and we are to choose which of these possible values we want to realize. For the latter problem version, we present a single exponential FPT-algorithm when parameterized by the number of entries in that have more than one possible value.
-
3.
In Section 4 we consider Fastest-path TGR. Among other results, we answer open questions by Klobas et al. [16] and Erlebach et al. [11] about the parameterized complexity of the problem for the vertex cover number. We show that the problem is W[1]-hard when parameterized by this parameter plus the largest entry in the matrix. This result improves significantly over the previous known parameterized hardness result for the feedback vertex set number; in terms of the parameter, the construction, and the length of the proof.
-
4.
In Section 5 we consider Shortest-path TGR and show that the problem is NP-hard for both the strict and the non-strict case, but becomes trivial when considering a periodic temporal graph.
Finally, in Section 6, we conclude with some open questions for future work.
2 Preliminaries
For natural numbers , we let and we define .
(Static) graphs.
An (undirected) graph is defined by its vertex set and its edge set . Any pair is called an edge between vertices and . We also say that and are neighbors when . For a vertex set , we define the subgraph of induced by as . A graph is a subgraph of if and . A -walk is a sequence of vertices such that is an edge for every . We then say that is a walk from to in . Such a walk is called a path if the vertices are pairwise distinct.
Temporal graphs.
A temporal graph is defined by a pair where is a graph, and is a labeling that associates to each edge the set of (positive) times when appears. The graph is called the underlying graph of and the labeling is called the time labeling of . When is clear from the context, we let denote the number of vertices of . A time-edge is a pair such that and . Its appearance time is . Given a time label , we define the set of edges appearing at time , and call the snapshot of at time . The size of a temporal graph can be measured by its number of time labels. A temporal graph is said to be -periodic if each edge appears periodically with period , that is if and only if . Such a temporal graph is represented by its list of time-edges up to time . In the following, we always assume that the vertices of a temporal graph are numbered from to . We assume without loss of generality that its vertex set is . We let denote the set of all such temporal graphs.
Temporal paths.
A strict (respectively non-strict) temporal -walk is a walk in with associated time labels such that for each and (respectively ). Equivalently, a temporal walk can be defined as the sequence of time-edges satisfying (respectively ). Moreover, has length , departure time , arrival time , and duration (number of time steps spanned). A temporal -walk is called a temporal -path if the vertices are pairwise distinct. Note that a strict (respectively non-strict) temporal walk can always be transformed into a strict (respectively non-strict) temporal path by removing loops, and this can only reduce length, arrival time and duration. By default, we consider strict temporal paths, and simply call them temporal paths. We specify non-strict for non-strict temporal paths.
Temporal path metrics.
Classically, a temporal -path is said to be shortest, foremost, or fastest if it has minimum number of edges, minimum arrival time, or minimum duration, respectively among all temporal -paths. These notions indeed define some kinds of metrics that we now formalize. A distance matrix is any matrix of size with values in and that satisfies the following very loose notion of metric: if and only if , for all . It is not assumed that satisfies any other specific properties. In particular, may violate the triangle inequality. A temporal path metric is defined as a function that associates a distance matrix to any temporal graph . Consider for example, a cost function that associates a positive cost in to any temporal path given as a sequence of time-edges (independently of any temporal graph). It defines a temporal path metric by associating to any temporal graph the matrix (respectively ) such that (respectively ) is the minimum cost of a strict (respectively non-strict) temporal -path in . We define (respectively ) if no strict (respectively non-strict) temporal -path exists and (respectively ) if . The foremost, fastest, and shortest notions are indeed associated to the following cost functions: arrival time, duration, and length, respectively. We let , , and denote the corresponding temporal path metrics, respectively. We also let , , and denote the respective variants for non-strict temporal paths. For example, given a temporal graph , and two vertices in , is the earliest arrival time of a strict temporal -path in .
Temporal graph realization.
Given an integer , the temporal graph realization problem consists of finding a temporal graph with vertices that satisfies a given property. We assume that this property can be expressed as an input sequence of bits, given that the vertices of the temporal graph are . More precisely, we define a predicate as a binary relation between the set of all temporal graphs and the set of all bit sequences, that is is a subset of . We then say that a temporal graph satisfies a sequence of bits for if . We equivalently say that is satisfied, or that is a realization of for . As a simple example, the lifetime of a temporal graph can be tested by the predicate where and encodes an integer (that we denote also by with a slight abuse of notation). That is is satisfied when is the last appearance time of a time-edge of . Given a predicate we thus define the following (very general) problem.
Temporal Graph Realization ( TGR):
Input: A number and a sequence of bits.
Question: Is there a temporal graph with vertices such that is satisfied?
This paper focuses on temporal path metric realization. More precisely, considering a temporal path metric , , we define the -temporal-path-metric predicate, or -path for short, as where the sequence of bits encodes an distance matrix where is the number of vertices of . For example, -path TGR is the following problem.
Foremost-path TGR:
Input: A number and an distance matrix .
Question: Is there a temporal graph with vertices such that ?
When considering an instance of TGR, we always let denote the associated number. Note that, in the case of an -path TGR instance, the input has size . For brevity, given an input sequence encoding a distance matrix , a realization of for -path is simply called an -realization of . If the metric is clear from the context, we simply say that is a realization of or that realizes .
We also combine -path predicates with additional requirements. In particular, when the input either encodes a (static) graph with nodes, or a period , we define the following additional predicates, respectively:
-
the underlying graph of is a subgraph of ,
-
is -periodic.
Given two predicates , the problem “ TGR” asks whether there exists a temporal graph satisfying both and for a given pair of inputs for and . For example, Periodic Foremost-path TGR asks, given an distance matrix and a period , whether there exists a -periodic temporal graph that is a -realization of . Similarly, Prescribed Foremost-path TGR supposes that, in addition to , the input includes a static graph called the prescribed graph, and asks whether there exists a -realization of whose underlying graph is a subgraph of . We also sometimes refer to “ TGR” as “ TGR where is required”, especially if is specified in plain text without defining a formal name for it.
3 Foremost paths
We first consider the -path TGR problem. Recall that, given an distance matrix , it consists of checking whether there exists a temporal graph whose foremost matrix is , i.e. . We also consider its non-strict variant (-path TGR), and combining both with Prescribed and Periodic additional requirements. Similar results can be obtained for latest departure using a time-reversal argument. We often implicitly assume that we are given an distance matrix .
We first show that these main variants of the problem can be solved in polynomial time.
3.1 Polynomial time algorithms
Strict Foremost paths
In the strict setting, we can indeed state the following.
Theorem 3.1.
Foremost-path TGR can be solved in time and space. Furthermore, if dealing with a realizable instance, a realization with at most time labels can be computed with the same complexity.
The proof mainly comes from an algorithm given hereafter. First note that the above complexity can be expressed as where is the size of the input. We also state that the above result is asymptotically tight in terms of the number of time labels as follows.
Proposition 3.2.
There exists a family of distance matrices that are -realizable where each realization requires time labels.
Proof.
Consider the temporal graph with vertices, whose underlying graph is a star rooted at , and where, for all , edge appears at times . Its foremost matrix then satisfies for , for , and for . These temporal graphs thus define a family of distance matrices that are foremost realizable and that have pairwise distinct entries. This implies that any foremost realization of such a matrix must have time labels. The reason is that any foremost realization of an distance matrix containing pairwise distinct entries must have at least time labels. Indeed, any entry must correspond to some foremost temporal -path in whose last edge appears at time .
Remark.
The above lower bound also applies to non-strict foremost realizations (using a similar proof with the same families of matrices and temporal graphs). It also holds if we restrict the problem to sparse prescribed graphs with edges, or even trees, as long as the star is a possible prescribed graph.
We now present a simple algorithm for computing a -realization that leads to time complexity; this bound will be improved subsequently. It is based on the observation that any realization of a distance matrix for -path must satisfy the following compatibility property.
Definition 3.3 (Edge compatibility).
Given an distance matrix , a time-edge is said to be -edge-compatible with if it satisfies: .
The intuition behind is the following. If an edge appears at time in a temporal graph , then any foremost temporal -path with arrival time less than can be extended by the time-edge , implying that the foremost arrival time at is at most . Moreover, if is a realization of , i.e. , and , then we must have . By symmetry of edges, we must also have . Note that, given an distance matrix and a time-edge , the property can easily be tested in time.
The algorithm behind Theorem 3.1 now consists of checking that for each entry of , there exists a vertex such that and the time-edge is -edge-compatible with . If this is the case, such a time-edge is added to the temporal graph we are constructing (see Algorithm 1). This condition is indeed necessary as a foremost temporal -path in a realization of must end with such an edge. We will show that this condition is also sufficient, and leads to a construction of a realization with at most time labels.
The correctness of the algorithm comes with defining how a temporal graph can partially realize a matrix as follows.
Definition 3.4.
A temporal graph is said to be -compatible with if , i.e. for all , and all time-edges of are -edge-compatible with .
First note that any -realization of must be -compatible with .
Lemma 3.5.
If is a -realization of , then is -compatible with .
Proof.
First, we clearly have since is a -realization of . Second, suppose for the sake of contradiction that some time-edge is not -edge-compatible with . That is, without loss of generality, there exists a vertex such that and . Any foremost temporal -path in must arrive in at time . However, this temporal path can be extended with , yielding a temporal -walk arriving at time , contradicting the fact that is a -realization of .
Note also that an -vertex empty temporal graph, i.e. without any time labels, is always -compatible with as it does not contain any time-edges. Moreover, -compatibility is preserved by addition of a -edge-compatible time-edge as stated below.
Lemma 3.6.
If a temporal graph is -compatible with and a time-edge is -edge-compatible with , then the temporal graph obtained from by adding label to edge is also -compatible with .
Proof.
We just need to prove . Suppose for the sake of contradiction that there exists such that , i.e., is greater than the arrival time of a foremost temporal -path in . Consider the first time-edge of such that arrives in at time but arrives in before , i.e. . Such an edge must exist since arrives in before and . The (strict) temporal path definition implies which thus yields . As , cannot be -edge-compatible with . This contradicts either the -edge-compatibility of if , or the -compatibility of otherwise.
Lemma 3.7.
If is a -realization of , then for any entry with , there exists a vertex such that and is -edge-compatible with .
Proof.
It suffices to consider the last time-edge of a foremost temporal -path in a -realization of . It must satisfy since is a realization of . Since it is a strict temporal path, it arrives in before , implying . Moreover, is -edge-compatible with by Lemma 3.5.
Proof of Theorem 3.1.
If there exists a -realization of , the algorithm must find a suitable time-edge for each pair by Lemma 3.7. It thus returns NO, only when no such realization exists. Let denote the complete graph with vertex set . Lemma 3.6 implies that Algorithm 1 preserves the invariant that is -compatible with . If the algorithm returns YES, the constructed temporal graph is thus -compatible with , implying . We now prove that we indeed must have . Suppose for the sake of contradiction that there are pairs satisfying . Consider such a pair such that is minimum. When this pair was considered, the algorithm added to a time-edge satisfying . By the choice of , we have . Now, if we extend a foremost temporal -path in with , we obtain a temporal -walk arriving at time in contradiction with . This concludes the proof of correctness of Algorithm 1.
Its time complexity is clearly as for each of the pairs , we consider at most vertices and the test for the -edge-compatibility of takes time. To obtain , we use an interval tree data-structure (see, e.g., [5]). It can store intervals and querying whether a value is in one of these intervals can be answered in time. It uses space and can be constructed in time. To benefit from such a data-structure, we consider all pairs with fixed consecutively. Before processing them, we compute for each vertex two interval trees and where (respectively ) contains the intervals (respectively ) for , ignoring empty intervals. The -edge-compatibility of a time-edge can then be tested in time by checking that neither nor has an interval containing . The reason is that any vertex violating satisfies in which case belongs to the interval of associated to . Analogously, any vertex violating is associated to an interval of that contains . Constructing the interval trees takes time while processing each pair now takes time as it mainly consists of -edge-compatibility tests. The overall complexity is thus time using space.
Note that the algorithm adds a time label to an edge at most once for each vertex , when considering either or , depending on whether or . The -realization computed by Algorithm 1 thus has at most time labels per edge, and at most time labels in total.
Non-strict foremost paths
We have a similar result for the non-strict case.
Theorem 3.8 ().
NS-Foremost-path TGR can be solved in time and space. Furthermore, if dealing with a realizable instance, a realization with at most time labels can be computed with the same complexity.
A slight modification of Algorithm 1 suffices, replacing with:
The change of for accounts for considering non-strict temporal paths rather than strict ones. This modification requires a different version of Lemma 3.7 with a significantly different proof where a non-strict temporal -path whose edges are traversed at same time in a realization is replaced by a single time-edge (see Lemma 3.12 in the full version).
Periodic temporal graph and prescribed graph
It is straightforward to generalize Theorem 3.1 to Periodic Foremost-path TGR and Prescribed Foremost-path TGR with appropriate definitions of edge compatibility (see Therems 3.13 and 3.14 in the full version).
Non-strict foremost paths with a prescribed graph
In this setting, a prescribed graph is additionally given as input, and the realization is required to have a subgraph of as underlying graph. We let denote the set of neighbors of any vertex in .
The main idea is again to add time-edges that satisfy and such that is present in the prescribed graph. But conversely to the non-strict setting considered in Theorem 3.8, it is not possible to replace an instantaneous temporal -path (whose edges are traversed at the same time) in a realization by a single appearance of as this edge might not be in the prescribed graph.
Indeed, the condition at Line 6 of Algorithm 1 now becomes problematic as the prescribed graph may impose the addition of a time-edge such that to fulfill an entry . Moreover, the order in which we can fulfill entries in this manner may depend on the prescribed graph. A naive solution would be to let each edge appear at all times appearing in that satisfy . It would then suffice to check if the resulting temporal graph is an -realization of . However, this would result in a poor complexity and possibly time labels overall. We can still solve the problem with a better complexity and a tight number of time labels as stated below.
Theorem 3.9 ().
Prescribed NS-Foremost-path TGR can be solved in time and space, where is the number of edges of the prescribed graph. Furthermore, if dealing with a realizable instance, a realization with at most time labels can be computed with the same complexity.
The result is a consequence of an algorithm that works as follows: It scans the set of entries of excluding and (in any order). For each , it checks the set of all pairs such that . If there exists a vertex such that and is satisfied, it adds label to , similarly to Algorithm 1. In addition, it starts a BFS like procedure to find other pairs that can be reached at time through . See Algorithm 2 in the full version for more details.
3.2 Limits of polynomial-time algorithms for Foremost-path TGR
In this section, we show several additional requirements on instances of Foremost-path TGR for which the problem becomes NP-hard.
Theorem 3.10 ().
Foremost-path TGR is NP-hard when allowing at most one label per edge.
Foremost paths in ranges
Given a temporal path metric , we define the following variant of -path TGR where the input sequence encodes a matrix of ranges. More precisely, each entry is supposed to represent a range of positive integers. The Ranged--path predicate is then defined as for all . For example, this leads to the following problem for .
Ranged-Foremost-path TGR:
Input: A number and an matrix of ranges.
Question: Is there a temporal graph such that for all ?
An entry is said to be undetermined if with . Note that when the number of undetermined entries is zero, this problem is equivalent to Foremost-path TGR, for which we presented a polynomial-time algorithm. We now analyze the complexity of Ranged-Foremost-path TGR and its non-strict variant Ranged-NS-Foremost-path TGR with a focus on the parameter .
Theorem 3.11 ().
Ranged-Foremost-path TGR and Ranged-NS-Foremost-path TGR are both NP-hard. Moreover, believing the ETH, neither Ranged-Foremost-path TGR nor Ranged-NS-Foremost-path TGR can be solved in time, where is the number of undetermined entries of .
For the strict setting, we obtain hardness even when each range has size at most 2.
Theorem 3.12 ().
Ranged-Foremost-path TGR is NP-hard even when each range has length at most two and the largest value of the matrix is .
FPT algorithm for Ranged-Foremost-path TGR
We now propose a dynamic programming algorithm solving Ranged-Foremost-path TGR which has running time . Note that this is tight in the sense that a significantly faster algorithm would contradict ETH by Theorem 3.11.
Theorem 3.13 ().
Ranged-Foremost-path TGR can be solved in time and space, where is the number of undetermined entries of .
In the following, we let (respectively ) denote the lower bound (respectively upper bound) of entry , i.e., . Recall that an entry is undetermined if . The set of such undetermined entries is denoted by and its size is denoted by .
This result relies on the fact that a realizable instance can always be realized by a temporal graph using time labels in the restricted set (as proven in the full version). We then propose an algorithm that processes all times in in increasing order and guesses which undetermined entries can be realized at the current time. More precisely, letting denote the times in , we maintain, for each , a table such that for is equal to True if and only if there exists a temporal graph with time labels in such that:
-
for each , the earliest arrival time of any foremost temporal -path in is in and is at most ,
-
for each with , the earliest arrival time of any foremost temporal -path in is ,
-
for all other entries , there is no temporal -path in .
We have that if and only if there exists a temporal graph that realizes for Ranged--path.
When processing time , we consider tri-partitions of the set where represents the set of undetermined entries that must be realized before time , represents the set of undetermined entries that must be realized at time and the set of undetermined entries that must be realized after time . Similarly to Algorithm 1, an appropriate definition of edge compatibility (with respect to , and ) allows to test if a temporal graph realizing can be completed in order to set . Importantly, we do not need explicit access to such a temporal graph as we probe it through .
Remark.
The algorithm proposed here can easily be generalized to a more general setting where a collection of ranges is given for each entry of with time complexity where denotes the total number of ranges in . In particular, this provides an FPT algorithm for Ranged-Foremost-path TGR when each entry of encodes a set of integers and at most of them are non-singletons. Note that the hardness result of Theorem 3.12 holds in that setting, even if each set has size at most 2.
4 Fastest paths
In this section we consider temporal graph realization for fastest paths analyzed by Klobas et al. [16] and Erlebach et al. [11]. We answer an open question by both papers about the parameterized complexity with respect to the vertex cover number.
So far, Fastest-path TGR has only been considered for strict temporal paths, and if we consider a periodic temporal graph or if we consider the non-periodic version with a limited number of labels per edge [16, 11]. Our parameterized hardness result holds even for non-periodic temporal graph with arbitrary many labels per edge and without limiting the lifetime of the sought temporal graph. We then show that this hardness is preserved in the periodic case with one label per edge per period to answer the open questions.
Theorem 4.1 ().
Fastest-path TGR is NP-hard and W[1]-hard when parameterized by the vertex cover number of the underlying graph plus the largest entry of . This holds even on a family of instances for which all yes-instances are realizable with only one label per edge.
Proof (sketch)..
We reduce from Multicolored Clique [6].
Multicolored Clique:
Input: An undirected graph , an integer , and a -partition of , such that is an independent set in for each .
Question: Is there a clique of size in ?
Let be an instance of Multicolored Clique where for each , is a disjoint union of bicliques. For each , we call a color class. Even under these restrictions, Multicolored Clique is NP-hard and W[1]-hard when parameterized by [22]. Let .
To obtain an instance of Fastest-path TGR as follows, we first describe the underlying graph, that is, the graph that contains an edge if and only if . The graph is defined over the vertex set , where is a vertex set of size and (see Figure 1). We add edges between these vertices, such that is a vertex cover of . That is, there are no edges between the vertices of in . We make into a clique and adjacent to all vertices of besides and . Similarly, we make the vertices and adjacent to all vertices of besides and make the vertices and adjacent to all vertices of besides . Additionally, we make adjacent to the vertices of , adjacent to the vertices of , and for each , we make adjacent to the vertices of . There are no edges between the vertices of . Finally, we make adjacent to , and , and we make adjacent to , and .
This completes the underlying graph and thus all entries of the matrix of value . Let denote the edges of . Next, we define the remaining entries. Note that each vertex of is adjacent to each other vertex of . Hence, for these vertices it remains to define the entries of the table from and to the vertices and . We set for each vertex . Similarly, we set for each vertex . For each non-edge of , we set . Finally, we set and . All other undefined entries are set to . This completes the construction. Note that is a vertex cover of size and that the largest entry in is .
Intuition.
The idea behind the reduction is that realizing all entries besides is possible, regardless of whether contains a (multicolored) clique of size . We will show that this is ensured by the fact that with is a disjoint union of bicliques. The difficulty to decide whether the matrix is realizable thus comes from the difficulty of deciding whether the entry can additionally be realized, which can only be done by using vertices of as intermediate vertices of the path. Let denote the vertices of on any path realizing the entry . Based on the structure of the underlying graph (see Figure 1), contains for each at least one vertex of . By definition of the entries between vertices of , these vertices need to form a clique in the original graph, as only adjacent vertices and in fulfill , which is the duration of .
Correctness.
We now show that is realizable if and only if admits a clique of size . More precisely, we show that if admits a clique of size , then there is a realization for with exactly one label per edge.
-
Let be an edge labeling, such that realizes . We show that has a clique of size . Consider the entry . Since is a realization of , this implies that the fastest temporal path from to has duration exactly . Let be an arbitrary fastest temporal path from to in . Since the duration of is , the duration of each (not necessarily proper) subpath of is at most . Hence, for any two distinct vertices of , where precedes in , the entry is at most , as is realized by . This immediately implies that does not visit any vertex of , since and for each vertex . That is, only uses vertices of . By definition, each path from to in traverses all vertices of and one vertex of each of the color classes of , that is, for each , the path contains one vertex of . This in particular holds for . Let be the vertices of that are visited by . By the above, has size at least . Moreover, for each two distinct vertices and of , , since the subpath between and of has duration at most and realizes . This implies that is an edge of , as otherwise, is defined as . Consequently, is a clique of size in .
-
Let be a clique of size in and for each , let denote the unique vertex of . We define a labeling , such that realizes . To this end, we describe several time blocks, that is, intervals with , such that only the described edges receive a label from this interval, and all other edges receive no label from . The reason behind this is that labeling edges in different time blocks do not create paths of duration less than , which is larger than the largest entry of . Hence, we can show that our labeling realizes by showing that for each two vertices and of (i) there is a time block in which there is a temporal path from to of duration exactly and (ii) for each time block, there is no temporal path from to of duration less than . Note that the order of time blocks does not matter. Hence, when describing the labeling, we simply describe a collection of time blocks which in total fulfill the above properties, while not explicitly defining the concrete start and end time of the time blocks. In the following, we mainly focus on realizing all entries of value at least in . Afterwards, we describe how to realize the entries of value .
-
Realizing all entries involving vertices of besides .
We show that we can realize all these entries by only labeling edges that have at least one endpoint in . This proof is deferred to the full version.
-
Realizing . Next, we define a time block that realizes the entry . Recall that is a clique in and that for each , denotes the vertex of . Consider the path and label the edges of this path with consecutive time labels starting with . Hence, this path has duration equal to its length, namely .
The argument that this creates no paths that are too fast is deferred to the full version. It mainly comes from the fact that for any two vertices and of that are both from , since is a clique, and we have .
So far, we have realized all entries of of value at least that involve at least one vertex of . In the following, we describe further time blocks to realize the entries of of value at least involving only vertices of . To this end, we will only use edges between and . Note that none of these edges has received a label in the previous time blocks, that is, the only edges incident with vertices of that received labels so far were the edges between and . Let the vertices of be called .
-
Realizing entries between vertices of of value and entries between vertices of and . We define a time block as follows: For each vertex , we set and . For each vertex , we set and . Finally, we set . Note that each vertex of has only two incident labels in this time block, namely, and . Hence, no temporal path in this time block between vertices of has duration less than . Moreover, since entries involving a vertex from and a vertex from are of value at most , we guarantee that we do not create paths that are too fast in this time block. We now show that this time block realizes (i) all entries of value at least between vertices of and and (ii) all entries between vertices of of value . For the first type, let and with . That is, . Then, there is a temporal path in this time block of duration 2. Similarly, the temporal path also has duration 2. Now consider the second type. For each two distinct vertices and of with , there is the temporal path with labels . This path has duration . This time block realizes the stated entries of .
-
Realizing entries between vertices of . For each , we define a time block in which we set and for each . For each , this realizes the entries with . Similarly, we add a time block in which we set and for each . These time blocks realize all entries of between vertices of .
-
Realizing entries between vertices of of value . Recall that we have to ensure that there is a path of duration 2 between the endpoints of each edge in our temporal graph. To define the necessary time blocks, we will highly rely on the fact that for each , is a vertex disjoint union of bicliques. This property will allow us to realize all edges between and via just two vertices of . We can do this for several combinations of color classes via the same two vertices of , as long as no color class occurs in more than one pair. We formalize this as follows. Let be a partition of , such that for each and each , there is at most one ordered pair in that contains . That is, is a matching in the directed graph with vertex set and edge set . Note that such a partition exists due to the fact that a clique on vertices has a proper edge coloring with colors. Let . We let denote all edges of between each pair of color classes in , that is, . Since is a matching and is a disjoint union of bicliques for each , is also a disjoint union of bicliques. That is, each connected component in is a biclique. We use the vertices and of to realize the entries of corresponding to the edges of . For each connected component of with bipartition , we add a new time block and set for each and for each . This realizes paths of duration from each vertex of to each vertex of and no other temporal paths of length more than 1. Since is a biclique, for all these vertex pairs, the entry in the matrix is also . In the same way, we also add a new time block and set for each and for each . This thus realizes also the entries of duration from each vertex of to each vertex of . Since , this implies that we realized the entries and of value by the above time blocks for each edge .
Hence, all entries of value at least 2 in are realized by . Let denote the edges of that have not received a label yet. We add one final time block from which all edges of receive the same label. This surely does not create new temporal paths of length more than 1 for which the duration is at most . This completes the definition of . Thus, also all entries of value 1 are realized. By definition of the time blocks, we showed that realizes the input matrix even with just a single label per edge.
Based on this reduction, we can now directly transfer the hardness result to Periodic Fastest-path TGR even when allowing at most one label per edge.
That is, we simply define the period to be an integer much larger than , which ensures that all fastest paths start and end within a window of consecutive time steps (see [11]).
Theorem 4.2.
Even when only allowed to put one label per edge and per period, Periodic Fastest-path TGR is W[1]-hard when parameterized by the vertex cover number of the underlying graph plus the largest entry of .
This answers an open question by Klobas et al. [16] and Erlebach et al. [11] about the parameterized complexity of the problem with respect to the vertex cover number. Furthermore, this reduction improves significantly over the known hardness result for parameter feedback vertex set number. It also shows that Periodic Fastest-path TGR can presumably not be solved in FPT time for the combined parameter of the vertex cover number plus (the number of allowed labels per edge and per period) plus the largest entry in . Thus, in the FPT algorithm by Erlebach et al. [11] for the vertex cover number plus the period (or lifetime), one cannot replace by plus the largest entry of .
A similar reduction also shows similar intractability results for Fastest-path TGR with non-strict paths. The following reduction however requires more than one label per edge.
Theorem 4.3 ().
NS-Fastest-path TGR is NP-hard and W[1]-hard when parameterized by the vertex cover number of the underlying graph plus the largest entry of .
5 Shortest paths
In this section, we consider the question for shortest temporal paths.
Shortest-path TGR:
Input: A distance matrix of size .
Question: Is there a temporal graph such that ?
Note that a realization of can only assign labels to edges where . Hence, with is the underlying graph of every realization of . We show the NP-hardness of both the strict and the non-strict variants.
Theorem 5.1 ().
Shortest-path TGR and NS-Shortest-path TGR are NP-hard.
Proof (sketch)..
We reduce from SAT.
Let be an instance of SAT where each variable occurs at least once positively and at least once negatively, and where no clause contains the same variable both positively and negatively.
Construction.
Let be the variable set of and let denote the clauses of . To obtain an instance of Shortest-path TGR or NS-Shortest-path TGR, we first define the underlying graph that contains an edge if and only if (see Figure 2). The graph contains for each variable the vertices and which are joined by an edge. For each clause , we also add a vertex , which we make adjacent to all vertices corresponding to literals that are contained in . Additionally, we add three more vertices to : a vertex which is adjacent to all vertices of , and two vertices and that are adjacent to all vertices representing literals, that is, to the vertices of .
Next, we describe the remaining entries of . Let be a clause of . We set and . For each other clause of , we set . For each positive literal that occurs in , we set . Similarly, for each negative literal that occurs in , we set . For each variable for which neither nor occurs in , we set . This defines all entries regarding vertices of .
Let and be distinct literals, such that they are not the negation of each other. We set . For each literal , we also set .
Finally, we set , , , and . This completes the definition of .
Note that nearly all defined entries are the exact distances between the vertices in the underlying graph . The only exceptions are the entry and the entry for each clause . Hence, only for the vertex pairs , one could possibly create a temporal path that has length less than the respective entry of . Based on this property, we can prove that a labeling realizes by showing the following two points:
-
For distinct vertices and of , there is a temporal path of length from to .
-
For each , there is no temporal path of length less than from to .
Intuition.
We have clause vertices that aim to reach . For each such clause vertex , we want that the shortest temporal path to has length exactly . By the structure of the implicit underlying graph, these paths must be of the form for some literal that occurs in clause . If two clauses try to use the same variable gadget from different sides to realize their entries, that is, if and are both temporal paths in our solution graph, then in fact at least one of or is also a temporal path, implying that for at least one of the clauses, the shortest temporal path has length , which is lower than the desired length of . Intuitively, this means that in each solution, each variable gadget can only be used in one direction for paths between clauses and , which then encodes a satisfying truth assignment.
The correctness is deferred to the full version.
Note that a realization question for shortest temporal paths in periodic temporal graphs is polynomial time solvable. Due to the periodicity, a shortest path in the underlying static graph will always be a shortest temporal path in the periodic temporal graph where each edge receives at least one label. Since the latter is mandatory, the resulting problem is answered with yes if and only if the given matrix is the distance matrix of the underlying graph.
6 Conclusion
Our work spawns several interesting future questions.
-
We showed that Foremost-path TGR is polynomial-time solvable if we are allowed to assign up to labels per edge but becomes NP-hard when allowing only a single label per edge. What is the smallest number of labels per edge for which this problem is still polynomial-time solvable? For example, is there an efficient algorithm when we are allowed to assign only labels per edge?
-
Our hardness results for Shortest-path TGR use multiple labels per edge. Does this problem become polynomial-time solvable, if we restrict the respective labeling? For example, what if we enforce that at most one label per edge is allowed or we require a proper labeling, that is, a labeling where no two adjacent edges share a label?
-
Are there structural parameters for which we can solve Shortest-path TGR in FPT-time. For example, can we solve the problem efficiently if the underlying graph has bounded treewidth?
-
One could consider approximation of the considered problems. For example under the measurement of fulfilling as many entries as possible, are there constant factor approximations for Shortest-path TGR or Fastest-path TGR?
References
- [1] Eleni C. Akrida, Leszek Gąsieniec, George B. Mertzios, and Paul G. Spirakis. The complexity of optimal design of temporally connected graphs. Theory Comput. Syst., 61(3):907–944, 2017. doi:10.1007/S00224-017-9757-X.
- [2] Amotz Bar-Noy, Keerti Choudhary, David Peleg, and Dror Rawitz. Efficiently realizing interval sequences. SIAM J. Discret. Math., 34(4):2318–2337, 2020. doi:10.1137/20M1326489.
- [3] Arnaud Casteigts, Michelle Döring, and Nils Morawietz. Realization of Temporally Connected Graphs Based on Degree Sequences. In Proceedings of the 36th International Symposium on Algorithms and Computation (ISAAC), 2025. doi:10.48550/arXiv.2504.17743.
- [4] Arnaud Casteigts, Paola Flocchini, Walter Quattrociocchi, and Nicola Santoro. Time-varying graphs and dynamic networks. Int. J. Parallel Emergent Distributed Syst., 27(5):387–408, 2012. doi:10.1080/17445760.2012.668546.
- [5] Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms, 3rd Edition, chapter 14.3. MIT Press, 2009. URL: http://mitpress.mit.edu/books/introduction-algorithms.
- [6] Marek Cygan, Fedor V. Fomin, Lukasz Kowalik, Daniel Lokshtanov, Dániel Marx, Marcin Pilipczuk, Michal Pilipczuk, and Saket Saurabh. Parameterized Algorithms. Springer, 2015. doi:10.1007/978-3-319-21275-3.
- [7] Argyrios Deligkas and Igor Potapov. Optimizing reachability sets in temporal graphs by delaying. Inf. Comput., 285(Part):104890, 2022. doi:10.1016/J.IC.2022.104890.
- [8] Jessica A. Enright, Kitty Meeks, George B. Mertzios, and Viktor Zamaraev. Deleting edges to restrict the size of an epidemic in temporal networks. J. Comput. Syst. Sci., 119:60–77, 2021. doi:10.1016/J.JCSS.2021.01.007.
- [9] Paul Erdős and Tibor Gallai. Graphs with prescribed degrees of vertices. Mat. Lapok, 11:264–274, 1960.
- [10] Thomas Erlebach, Othon Michail, and Nils Morawietz. Recognizing and Realizing Temporal Reachability Graphs. In Proceedings of the 33rd Annual European Symposium on Algorithms (ESA), 2025. doi:10.48550/arXiv.2503.15771.
- [11] Thomas Erlebach, Nils Morawietz, and Petra Wolf. Parameterized algorithms for multi-label periodic temporal graph realization. Theoretical Computer Science, 1051:115412, 2025. doi:10.1016/j.tcs.2025.115412.
- [12] F. Göbel, J. Orestes Cerdeira, and Henk Jan Veldman. Label-connected graphs and the gossip problem. Discret. Math., 87(1):29–40, 1991. doi:10.1016/0012-365X(91)90068-D.
- [13] S. Louis Hakimi and S. S. Yau. Distance matrix of a graph and its realizability. Quarterly of Applied Mathematics, 22:305–317, 1965. URL: https://api.semanticscholar.org/CorpusID:118924338.
- [14] David Kempe, Jon M. Kleinberg, and Amit Kumar. Connectivity and inference problems for temporal networks. In F. Frances Yao and Eugene M. Luks, editors, Proceedings of the Thirty-Second Annual ACM Symposium on Theory of Computing, May 21-23, 2000, Portland, OR, USA, pages 504–513. ACM, 2000. doi:10.1145/335305.335364.
- [15] Nina Klobas, George B. Mertzios, Hendrik Molter, and Paul G. Spirakis. The complexity of computing optimum labelings for temporal connectivity. J. Comput. Syst. Sci., 146:103564, 2024. doi:10.1016/J.JCSS.2024.103564.
- [16] Nina Klobas, George B. Mertzios, Hendrik Molter, and Paul G. Spirakis. Temporal graph realization from fastest paths. Theoretical Computer Science, 1056:115508, 2025. doi:10.1016/j.tcs.2025.115508.
- [17] George B. Mertzios, Othon Michail, Ioannis Chatzigiannakis, and Paul G. Spirakis. Temporal network optimization subject to connectivity constraints. In Fedor V. Fomin, Rusins Freivalds, Marta Z. Kwiatkowska, and David Peleg, editors, Automata, Languages, and Programming - 40th International Colloquium, ICALP 2013, Riga, Latvia, July 8-12, 2013, Proceedings, Part II, volume 7966 of Lecture Notes in Computer Science, pages 657–668. Springer, 2013. doi:10.1007/978-3-642-39212-2_57.
- [18] George B. Mertzios, Othon Michail, and Paul G. Spirakis. Temporal network optimization subject to connectivity constraints. Algorithmica, 81(4):1416–1449, 2019. doi:10.1007/S00453-018-0478-6.
- [19] George B. Mertzios, Hendrik Molter, Nils Morawietz, and Paul G. Spirakis. Realizing temporal transportation trees. In Proceedings of the 51st Workshop on Graph-Theoretic Concepts in Computer Science (WG), 2025. URL: https://arxiv.org/abs/2403.18513.
- [20] George B. Mertzios, Hendrik Molter, Nils Morawietz, and Paul G. Spirakis. Temporal Graph Realization With Bounded Stretch. In Proceedings of the 50th International Symposium on Mathematical Foundations of Computer Science (MFCS), 2025. doi:10.48550/arXiv.2504.14258.
- [21] Julia Meusel, Matthias Müller-Hannemann, and Klaus Reinhardt. Directed temporal tree realization for periodic public transport: Easy and hard cases. In Proceedings of the 25th Symposium on Algorithmic Approaches for Transportation Modelling, Optimization, and Systems (ATMOS), 2025. doi:10.48550/arXiv.2504.07920.
- [22] Nils Morawietz, Carolin Rehs, and Mathias Weller. A timecop’s work is harder than you think. In Javier Esparza and Daniel Král’, editors, 45th International Symposium on Mathematical Foundations of Computer Science, MFCS 2020, August 24-28, 2020, Prague, Czech Republic, volume 170 of LIPIcs, pages 71:1–71:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2020. doi:10.4230/LIPIcs.MFCS.2020.71.
- [23] Philipp Zschoche, Till Fluschnik, Hendrik Molter, and Rolf Niedermeier. The complexity of finding small separators in temporal graphs. J. Comput. Syst. Sci., 107:72–92, 2020. doi:10.1016/J.JCSS.2019.07.006.
