Skip to main content
Springer logoLink to Springer
. 2025 Feb 25;87(5):736–782. doi: 10.1007/s00453-025-01301-3

Counting Temporal Paths

Jessica Enright 1,, Kitty Meeks 1,, Hendrik Molter 2,
PMCID: PMC12062201  PMID: 40352583

Abstract

This work investigates the parameterised complexity of counting temporal paths. The problem of counting temporal paths is mainly motivated by temporal betweenness computation. The betweenness centrality of a vertex v is an important centrality measure that quantifies how many optimal paths between pairs of other vertices visit v. Computing betweenness centrality in a temporal graph, in which the edge set may change over discrete timesteps, requires us to count temporal paths that are optimal with respect to some criterion. For several natural notions of optimality, including foremost or fastest temporal paths, this counting problem reduces to #Temporal Path, the problem of counting all temporal paths between a fixed pair of vertices; like the problems of counting foremost and fastest temporal paths, #Temporal Path is #P-hard in general. Motivated by the many applications of this intractable problem, we initiate a systematic study of the parameterised and approximation complexity of #Temporal Path. We show that the problem presumably does not admit an FPT-algorithm for the feedback vertex number of the static underlying graph, and that it is hard to approximate in general. On the positive side, we prove several exact and approximate FPT-algorithms for special cases.

Keywords: Temporal paths, Temporal graphs, Parameterised counting, Approximate counting, #P-hard counting problems, Temporal betweenness centrality

Introduction

Computing a (shortest) path between two vertices in a graph is one of the most important tasks in algorithmic graph theory and serves as a subroutine in a wide variety of algorithms for connectivity-related graph problems. The betweenness centrality measure for vertices in a graph was introduced by Freeman [1] and is one of the most important motivations for the task of counting shortest paths in a graph. Intuitively, betweenness centrality measures the importance of a vertex for information flow under the assumption that information travels along optimal (i.e. shortest) paths. More formally, the betweenness of a vertex v is based on the ratio of the number of shortest paths between vertex pairs that visit v as an intermediate vertex and the total number of shortest paths, thus its computation is closely related to shortest path counting. The betweenness centrality is a commonly used tool in network analysis and it can be computed in polynomial time; e.g. Brandes’ algorithm [2] serves as a blueprint for all modern betweenness computation algorithms and implicitly also counts shortest paths.

In contrast to the tractability of counting shortest paths, the problem of counting all paths between two vertices in a graph is one of the classic problems discussed in the seminal paper by Valiant [3] that is complete for the complexity class #P (the counting analogue of NP) and hence is presumably not doable in polynomial time.

Temporal graphs are a natural generalisation of graphs that capture dynamic changes over time in the edge set. They have a fixed vertex set and a set of time-edges which have integer time labels indicating at which time(s) they are active. In recent years, the research field of studying algorithmic problems on temporal graphs has steadily grown [47]. In particular, an additional layer of complexity is added to connectivity-related problems in the temporal setting. Paths in temporal graphs have to respect time, that is, a temporal path has to traverse time-edges with non-decreasing time labels [8].1 This implies that temporal connectivity is generally not symmetric and not transitive, a major difference from the non-temporal case. Furthermore, there are several natural optimality concepts for temporal paths, the most important being shortest, foremost, and fastest temporal paths [9]. Intuitively speaking, shortest temporal paths use a minimum number of time-edges, foremost temporal paths arrive as early as possible, and fastest temporal paths have a minimum difference between start and arrival times. We remark that an optimal path with respect to any of these three criteria can be found in polynomial time [9, 10]. The existence of multiple natural optimality concepts for temporal paths implies several natural definitions of temporal betweenness, one for each path optimality concept [6, 11, 12].

Similar to the non-temporal case, the ability to count optimal temporal paths is a key ingredient for the corresponding temporal betweenness computation. However, the picture is more complex in the temporal setting. Shortest temporal paths can be counted in polynomial time and the corresponding temporal betweenness can be computed in polynomial time [1114]. In contrast, counting foremost or fastest temporal paths is #P-hard [11, 15, 16], which implies that computing the corresponding temporal betweenness is #P-hard as well [11]. Indeed, Buß et al. [11] show that there is a polynomial time reduction from the problem of counting foremost or fastest temporal paths to the problem of the corresponding temporal betweenness computation. Note that a reduction in the other direction is straightforward.

In this work, we study the (parameterised) computational complexity of (approximately) counting foremost or fastest temporal paths. In fact, we study the simpler and arguably more natural problem of counting all temporal paths from a start vertex s to a destination vertex z in a temporal graph.

Let G=(V,E,T) denote a temporal graph with vertex set V, time-edge set E, and maximum time label (or lifetime) T (formal definitions are given in Sect. 2). We are then concerned with the following computational problem:graphic file with name 453_2025_1301_Figa_HTML.jpg

It is easy to see that #Temporal Path generalises the problem of counting paths in a non-temporal graph (all time-edges have the same time label), hence we deduce that #Temporal Path is #P-hard. Furthermore, observe that using an algorithm for #Temporal Path, it is possible to count foremost or fastest temporal paths with only polynomial overhead in the running time; we discuss this reduction in more detail in Sect. 2.3. Hence, all exact algorithms we develop for #Temporal Path can be used to compute the temporal betweenness based on foremost or fastest temporal paths with polynomial overhead in the running time. To the best of our knowledge, this is the first attempt to systematically study the parameterised complexity and approximability of #Temporal Path.

Related Work

As discussed above, the temporal setting adds a new dimension to connectivity-related problems. The problems of computing shortest, foremost, and fastest temporal paths have been studied thoroughly [9, 10, 17]. The temporal setting also offers room for new natural temporal path variants that do not have an analogue in the non-temporal setting. Casteigts et al. [18] study the problem of finding restless temporal paths that dwell an upper-bounded number of time steps in each vertex, while Füchsle et al. [19] study the problem of finding delay-robust routes in a temporal graph (intuitively, temporal paths that are robust with respect to edge delays). Klobas et al. [20] and Kunz et al. [21] study the problem of finding temporally disjoint paths, which are temporal paths that do not visit the same vertex at the same time. All mentioned problems turn out to be NP-hard.

The problem of counting (optimal) temporal paths has mostly been studied indirectly in the context of temporal betweenness computation, which has received much attention [1114, 16, 2227]. Most of the mentioned work considers temporal betweenness variants that are polynomial-time computable. The corresponding optimal temporal paths are mostly shortest temporal paths or variations thereof. There are at least three notable exceptions: Buß et al. [11] also consider prefix-foremost temporal paths and the corresponding temporal betweenness and show that the latter is computable in polynomial time. Furthermore, they show #P-hardness for several temporal betweenness variants based on strict optimal temporal paths. Rad et al. [16] consider temporal betweenness based on foremost temporal paths and show that its computation is #P-hard. They further give an FPT-algorithm to compute temporal betweenness based on foremost temporal paths for the number of vertices as a parameter (note that the size of a temporal graph generally cannot be bounded by a function of the number of its vertices). Rymar et al. [12] give a quite general sufficient condition called prefix-compatibility for optimality concepts for temporal paths that makes it possible to compute the corresponding temporal betweenness in polynomial time.

Generally, connectivity related problems have received a lot of attention in the temporal setting, ranging from the mentioned temporal path and betweenness computation to finding temporally connected subgraphs [28, 29], temporal separation [8, 3033], temporal graph modification to decrease or increase its connectivity [3437], temporal graph exploration [3843], temporal network design [4446], and others [20, 21, 47, 48].

In the static setting the general problem of counting (sz)-paths in static graphs is known to be #P-complete [3]. In the parameterised setting, the problem of counting length-k paths (with parameter k) was one of the first problems shown to be #W[1]-complete [49], but the problem does admit an efficient parameterised approximation algorithm [50]. It is also generally considered folklore that the problem of counting paths (of any length) admits an FPT-algorithm parameterised by the treewidth of the input graph.

Our Contribution

Our goal is to initiate the systematic study of the parameterised and approximation complexity of #Temporal Path. We provide an argument that #Temporal Path is essentially equivalent to counting foremost or fastest paths or computing the respective temporal betweenness centrality in Sect. 2.3.

Hardness results (Sect.3). The main technical contribution of this paper is a reduction showing that #Temporal Path is intractable even when very strong restrictions are placed on the underlying graph; specifically the problem is hard for W[1] when parameterised by the feedback vertex number of the underlying graph, which rules out the existence of FPT algorithms with respect to several common parameters.

Exact algorithms for special cases (Sect. 4). We show that the problem is polynomial-time solvable if the underlying graph is a forest, and then use a wide range of algorithmic techniques to generalise this result in different ways. We show that the problem is fixed-parameter tractable with respect to two “distance to forest” parameterisations that are larger than the feedback vertex number of the underlying graph (timed feedback vertex number and underlying feedback edge number). We further show that #Temporal Path is in FPT parameterised by the treewidth of the underlying graph and the lifetime combined, or parameterised by the recently introduced parameter “vertex-interval-membership-width”.

Approximation algorithms (Sect. 5). We show that, although the general problem remains hard to approximate, there is an FPTRAS for #Temporal Path parameterised by the maximum permitted length of a temporal (sz)-path. We then turn our attention to the problem of approximating betweenness centrality, as the relationship between path counting and computing betweenness is not so straightforward in the approximate setting: we demonstrate that, whenever there exists an FPRAS (respectively FPTRAS) for #Temporal Path, we can efficiently approximate the maximum betweenness centrality of any vertex in the temporal graph. These two results together give an FPTRAS to estimate the maximum betweenness centrality of any vertex in a temporal graph (with respect to either foremost or fastest temporal paths) parameterised by the vertex cover number or treedepth of the underlying input graph.

Preliminaries and Basic Observations

In this section we provide all basic notations, definitions, and terminology used in this work. We discuss the relation between temporal path counting and temporal betweenness computation in more detail in Sect. 2.3. Additional background on parameterised and approximate counting complexity are given in Sects. 2.4 and 2.5, respectively. Given a static graph G=(V,E), we say that a sequence P={vi-1,vi}i=1k of edges in E forms a path in G if vivj for all 0i<jk.

Temporal Graphs and Paths

There are several different definitions and notations used in the context of temporal graphs [47] which are mostly equivalent. Here, we use the following definitions and notations:

An (undirected, simple) temporal graph with lifetime TN is a tuple G=(V,E,T), with time-edge set EV2×[T]. We assume all temporal graphs in this paper to be undirected and simple. The underlying graph of G is defined as the static graph G=(V,{{u,v}t[T]s.t.\ ({u,v},t)E}). We denote by Et the set of edges of G that are active at time t, that is, Et={{u,v}({u,v},t)E}.

For every vV and every time step t[T], we denote the appearance of vertex v at time t by the pair (vt). For a time-edge ({v,w},t) we call the vertex appearances (vt) and (wt) its endpoints and we call {v,w} its underlying edge.

We assume that every number in [T] appears at least once as a label for an edge in E. In other words, we ignore labels that are not used for any edges since they are irrelevant for the problems we consider in this work. It follows that we assume T|E| and hence TO(|G|)=O(|V|+|E|).

A temporal (sz)-path (or temporal path) of length k from vertex s=v0 to vertex z=vk in a temporal graph G=(V,E,T) is a sequence P=({vi-1,vi},ti)i=1k of time-edges in E such that the corresponding sequence of underlying edges forms a path in the underlying graph of G and, for all i[k-1], we have that titi+1. Given a temporal path P=({vi-1,vi},ti)i=1k, we denote the set of vertices of P by V(P)={v0,v1,,vk} and we say that P visits the vertex vi if viV(P). Moreover, we call vertex appearances (vi-1,ti) outgoing for P and we call the vertex appearances (vi,ti) incoming for P. Note that, if ti=ti+1, then (vi,ti) is both incoming and outgoing for P. We define (v0,1) to be incoming for P and (vk,T) to be outgoing for P. We say that a vertex appearance is visited by P if it is outgoing or incoming for P (so a vertex is visited by P if and only if at least one of its appearances is visited by P). We say that P starts at v0 at time t1 and arrives at vk at time tk. We say that P is a temporal subpath of P if P is a subsequence of P. Furthermore, we define the following optimality concepts for temporal (sz)-paths P.

  • P is a shortest temporal (sz)-path if there is no temporal path P from s to z such that the length of P is strictly less than the length of P.

  • P is a foremost temporal (sz)-path if there is no temporal path P from s to z such that P arrives at z at a strictly smaller time than P.

  • P is a fastest temporal (sz)-path if there is no temporal path P from s to z such that the difference between the time at which P starts at s and the time at which P arrives at z is strictly smaller than the analogous difference of times for P.

Temporal Betweenness Centrality

We follow the notation and definition for temporal betweenness given by Buß et al. [11]. Let G=(V,E,T) be a temporal graph. For any s,zV, σsz() is the number of -optimal temporal paths from s to z. We define σvv():=1. For any vertex vV, we write σsz()(v) for the number of -optimal paths that pass through v. We set σsz()(s):=σsz() and σsz()(z):=σsz(). We do not assume that there is a temporal path from any vertex to any other vertex in the graph. To determine between which (ordered) pairs of vertices a temporal path exists, we use a connectivity matrix A of the temporal graph: let A be a |V|×|V| matrix, where for every v,wV we have that Av,w=1 if there is a temporal path from v to w, and Av,w=0 otherwise. Note that As,z=1 if and only if σsz()0. Formally, temporal betweenness based on -optimal temporal paths is defined as follows.

Definition 1

(Temporal Betweenness) The temporal betweenness of any vertex vV is given by:

CB()(v):=svzandAs,z=1σsz()(v)σsz().

Crucially for our work, it turns out that we can adapt any algorithm for #Temporal Path into one that computes temporal betweenness with only polynomial overhead; we explain this reduction in Sect. 2.3.

In the reverse direction, a reduction by Buß et al. [11] from #Temporal Path to the problem of computing temporal betweenness centrality (based on foremost or fastest temporal paths) implies that our parameterised hardness result (Theorem 1) also holds for temporal betweenness computation, as the reduction increases the feedback vertex number of the underlying graph by at most three.

If we can only count temporal paths approximately, however, the relationship between temporal path counting and temporal betweenness computation is not so straightforward: approximating the number of temporal (sz)-paths that use a specific vertex can, in general, be much harder than approximating the total number of temporal (sz)-paths. This issue is discussed in more detail in Sect. 2.3.

Temporal Betweenness vs. Temporal Path Counting

In this subsection, we discuss the relationship between the problems of computing temporal betweenness and counting temporal paths. We show that we can compute temporal betweenness based on foremost and fastest temporal paths using an algorithm for #Temporal Path with only polynomial overhead in the running time. Let G=(V,E,T) be a temporal graph. We start with the following easy observation.

Observation 1

Given an algorithm to count all -optimal temporal (sz)-paths in G in time t(G), we can compute the temporal betweenness based on -optimal temporal paths of any vertex of G in t(G)·|G|O(1) time.

This follows by observing that we can count the number of temporal (sz)-paths in G that visit a vertex v by first counting all temporal (sz)-paths in G and then subtracting the number of temporal (sz)-paths in G-{v}.

Next, we observe that we can count foremost and fastest temporal (sz)-paths using an algorithm for #Temporal Path, with only polynomial overhead.

Observation 2

Given an algorithm for #Temporal Path that runs in time t(G), we can compute all foremost temporal (sz)-paths and all fastest temporal (sz)-paths in t(G)·|G|O(1) time.

First, note that we can compute a foremost temporal (sz)-path and a fastest temporal (sz)-path in polynomial time [9, 10]. In the case of foremost temporal (sz)-paths, we can in this way obtain the time at which a foremost temporal (sz)-path arrives at z and remove all time-edges with later time labels from G. After this modification, every temporal (sz)-path is foremost hence we can count them using an algorithm for #Temporal Path.

In the case of fastest temporal (sz)-paths, we can in the same way obtain the time difference tf between starting at s and arriving at z for any fastest temporal (sz)-path. We can now iterate over all intervals [t0,t0+tf] with 1t0T-tf and, for each one, create an instance of #Temporal Path by removing all time-edges from G that are either earlier than t0 or later than t0+tf. After this modification, every temporal (sz)-path in the instance corresponding to any interval is fastest, and every fastest temporal path survives in exactly one instance; hence we can count fastest temporal paths by calling an algorithm for #Temporal Path on each instance and summing the results.

Using Observations 1 and 2 we obtain the following lemma, which implies that our polynomial-time and FPT-algorithms for special cases of #Temporal Path yield polynomial-time solvability and fixed-parameter tractability results respectively for temporal betweenness based on foremost temporal paths or fastest temporal paths, under the same restrictions.

Lemma 1

Given an algorithm for #Temporal Path that runs in time t(G), we can compute the temporal betweenness based on foremost temporal paths or fastest temporal paths of any vertex of G in t(G)·|G|O(1) time.

If we can only count temporal paths approximately, however, the relationship between temporal path counting and temporal betweenness computation is not so straightforward. In the exact setting, we were able to determine the number of temporal (sz)-paths visiting v by calculating the difference between the number of temporal (sz)-paths in G and G-{v} respectively. However, in the approximate setting, we cannot use the same strategy: if there are N temporal paths in total and N-v is an ε-approximation to the number of temporal paths that do not contain v, it does not follow that N-N-v is an ε-approximation to the number of temporal paths that do contain v, as the relative error will potentially be much higher if the proportion of temporal paths containing v is very small. A similar issue arises if we aim to estimate the number of temporal paths through v by sampling a collection of temporal paths (from an approximately uniform distribution) and using the proportion that contains v as an estimate for the total proportion of temporal paths containing v: if the proportion that contain v is exponentially small, we would need exponentially many samples to have a non-trivial probability of finding at least one temporal path which does contain v; otherwise we deduce incorrectly that there are no temporal paths through v and output 0, which cannot be an ε-approximation of a non-zero number of temporal paths for any ε<1.

Lastly, we briefly shift our attention to computational hardness. Buß et al. [11] provide a reduction from #Temporal Path to the computation of temporal betweenness based on foremost temporal paths and to the computation of temporal betweenness based on fastest temporal paths. In both cases, three new vertices are added to the temporal graph and all newly added time-edges are incident with at least one of the newly added vertices. This implies that our parameterised hardness result in the next section (Theorem 1) also holds for temporal betweenness computation based on foremost temporal paths or fastest temporal paths, since the reductions by Buß et al. [11] increase the feedback vertex number of the underlying graph by at most three.

Summarizing, results for #Temporal Path have the following implications for temporal betweenness computation.

  • Every (exact) algorithm for #Temporal Path can be used to compute the temporal betweenness based on foremost temporal paths or fastest temporal paths with an additional polynomial factor in the running time (Lemma 1).

  • Every (classic) computational hardness result for #Temporal Path also holds for temporal betweenness computation based on foremost temporal paths or fastest temporal paths.

  • Every parameterised hardness result for #Temporal Path with respect to parameters of the underlying graph that are increased by at most a function of the original parameter value when three new vertices and an arbitrary number of new edges incident with those vertices are added to the underlying graph also holds for temporal betweenness computation based on foremost temporal paths or fastest temporal paths.

The results in this paper show that:

  • Computing temporal betweenness based on foremost or fastest temporal paths is unlikely to be in FPT parameterised by the feedback vertex number of the underlying graph (and hence also by the treewidth of the underlying graph).

  • Temporal betweenness based on foremost or fastest paths can be computed in polynomial time if the underlying graph is a forest, and is in FPT parameterised by any of
    • the timed feedback vertex number of the input temporal graph,
    • the feedback edge number of the underlying graph,
    • the treewidth of the underlying graph and lifetime of the temporal graph combined, or
    • the vertex-interval-membership-width of the temporal graph.
  • There is an FPTRAS to estimate the maximum betweenness centrality of any vertex in a temporal graph (with respect to either foremost or fastest temporal paths) parameterised by the vertex cover number or treedepth of the underlying input graph.

Parameterised Counting Complexity

We use standard definitions and terminology from parameterised complexity theory [5153]. A parameterised counting problem F,κ is in FPT (or fixed-parameter tractable) if there is an algorithm that solves any instance (Ik) of F,κ in f(k)·|I|O(1) time for some computable function f [49, 52]. A parameterised counting Turing reduction from F,κ to F,κ is an algorithm with oracle access to F,κ that solves any instance (Ik) of F,κ in f(k)·|I|O(1) time, where for all instances (I,k) of F,κ queried to the oracle of F,κ we have that kg(k), for some computable functions fg. A parameterised counting problem F,κ is hard for #W[1] if there is a parameterised counting Turing reduction from #Multicoloured Clique parameterised by the number of colours to F,κ [49, 52]; in #Multicoloured Clique we are given a k-partite graph and are asked to count the number of k-cliques. A parameterised counting problem F,κ is hard for W[1] (“parity-W[1]”) if there is a parameterised counting Turing reduction from Multicoloured Clique parameterised by the number of colours to F,κ [54]; in Multicoloured Clique we are given a k-partite graph and are asked to count the number of k-cliques modulo two, that is, decide whether the number of k-cliques is odd.

If a #W[1]-hard (resp. W[1]-hard) parameterised counting problem F,κ admits an FPT-algorithm, then #W[1]=FPT (resp. W[1]=FPT), which is generally not believed to be the case [49, 52, 54]. We remark that #W[1]=FPT clearly implies W[1]=FPT (and also W[1]=FPT), whereas at the time of writing it is unknown whether W[1]=FPT implies W[1]=FPT.

Approximate Counting and Sampling

Many computational problems can be associated with a relation RΣ×Σ, where Σ is some finite alphabet and R can be seen as assigning to each problem instance xΣ a set of solutions (namely the set SolR(x):={yΣ:xRy}). For a given relation RΣ×Σ and an instance xΣ, we might be interested in the associated decision problem (“is SolR(x) non-empty?”), counting problem (“determine |SolR(x)|”) or the uniform generation problem (“return a uniformly random element of SolR(x)”).

We begin by defining our notion of efficient approximation for counting problems (see, for example, [55, Chapter 11]).

Definition 2

Let F:ΣN{0} be a counting problem. A fully polynomial randomised approximation scheme (FPRAS) for F is a randomised approximation scheme that takes an instance I of F (with |I|=n), and real numbers ε>0 and 0<δ<1, and in time poly(n,1/ε,log(1/δ)) outputs a rational number z such that

P[(1-ε)F(I)z(1+ε)F(I)]1-δ.

We are also interested in the parameterised analogue of an FPRAS, a fixed parameter tractable randomised approximation scheme (FPTRAS) [50].

Definition 3

Let F:ΣN{0} be a counting problem with parameterisation κ:ΣN. An FPTRAS for (F,κ) is a randomised approximation scheme that takes an instance I of F (where |I|=n), and real numbers ε>0 and 0<δ<1, and in time f(κ(I))·poly(n,1/ε,log(1/δ)) (where f is an arbitrary fixed computable function) outputs a rational number z such that

P[(1-ε)F(I)z(1+ε)F(I)]1-δ.

For convenience, we often refer to a number z satisfying (1-ε)F(I)z(1+ε)F(I) as an ε-approximation to |F(I)|.

It is well-known that there is a close relationship between the algorithmic problems of approximately counting solutions and generating solutions almost uniformly [56]. We will make use of this relationship when considering approximating the temporal betweenness of a vertex in Sect. 5.2, and to do so need a notion of efficient almost uniform sampling [55, Chapter 11].

Definition 4

Let S be the uniform generation problem associated with the relation RΣ×Σ. A fully polynomial almost uniform sampler (FPAUS) for S is a randomised algorithm which takes as input an instance x of S (with |x|=n) together with an error parameter 0δ1, and in time poly(n,log(1/δ)) returns an element of SolR(x)={yΣ:xRy}; for any fixed y with xRy, the probability py that the algorithm returns y satisfies (1-δ)/|SolR(x)|py(1+δ)/|SolR(x)|.

One can naturally define the parameterised analogue of an FPAUS.

Definition 5

Let S be the uniform generation problem associated with the relation RΣ×Σ, and let κ:ΣN be a parameterisation of S. A fixed parameter tractable almost uniform sampler (FPTAUS) for S is a randomised algorithm which takes as input an instance x of S (with |x|=n) together with an error parameter 0δ1, and in time f(κ(x))·poly(n,log(1/δ)) (where f is any computable function) returns an element of SolR(x)={yΣ:xRy}; for any fixed y with xRy, the probability py that the algorithm returns y satisfies (1-δ)/|SolR(x)|py(1+δ)/|SolR(x)|.

Parameterised Intractability

In this section, we present our main hardness result, which provides strong evidence that #Temporal Path does not admit an FPT algorithm when parameterised by the feedback vertex number of the underlying graph. Note that this also rules out FPT algorithms for many other parameterizations, including the treewidth of the underlying graph. However, it is folklore that #Path admits an FPT algorithm parameterised by treewidth as a parameter (this is also implied by our result Theorem 6). The result here, therefore, means that #Temporal Path is strictly harder than #Path in terms of parameterised complexity for the parameterisations that are at most the feedback vertex number of the underlying graph and at least the treewidth of the underlying graph.

Theorem 1

#Temporal Path is W[1]-hard when parameterised by the feedback vertex number of the underlying graph.

Proof

We present a parameterised counting Turing reduction from Multicoloured Independent Set on 2-Track Interval Graphs parameterised by the number of colours k. In Multicoloured Independent Set on 2-Track Interval Graphs we are given a set I of interval pairs and a colouring function c:I[k] and asked whether there is an odd number of k-sized sets of interval pairs in I such that in each set, every two interval pairs have different colours and are non-intersecting. Two interval pairs ([xa,xb],[xa,xb]),([ya,yb],[ya,yb]) are considered non-intersecting if [xa,xb][ya,yb]= and [xa,xb][ya,yb]=.

Inspecting the W[1]-hardness proof by Jiang [57] for Independent Set on 2-Track Interval Graphs shows that the reduction used from Multicoloured Clique parameterised by the number of colours k is parsimonious2 and the reduction also shows W[1]-hardness for the multicoloured version of the problem. Since Multicoloured Clique is W[1]-hard when parameterised by the number of colours k [54], we can conclude that Multicoloured Independent Set on 2-Track Interval Graphs is W[1]-hard when parameterised by the number of colours k.

Description of the reduction. Given an instance (Ic) of Multicoloured Independent Set on 2-Track Interval Graphs, where I is a set of interval pairs and c:I[k] is a colouring function, we create O(2k) temporal graphs. We assume w.l.o.g. that for all ([xa,xb],[xa,xb]),([ya,yb],[ya,yb])I that |{xa,xb,ya,yb}|=4 and |{xa,xb,ya,yb}|=4 or ([xa,xb],[xa,xb])=([ya,yb],[ya,yb]), that is, if two interval pairs are different, we assume that all endpoints on each track are pairwise different. Furthermore, we assume w.l.o.g. that all intervals contained in pairs in I are integer subsets of [2|I|]. The main intuition of our construction follows:

  • We model track one with a path in the underlying graph and track two with time.

  • Through the feedback vertices of the underlying graph, a temporal path can “enter” and “leave” the path that models track one.

  • The number of feedback vertices corresponds to the number of colours.

  • We have to make sure that we can determine the parity of the number of temporal paths visiting all feedback vertices.

  • The number of temporal paths that do not correspond to independent sets should not be considered. It seems difficult to get an exact handle on the number of such paths, however, we will show that this number is even. Note that, intuitively, this is the main reason we show hardness for W[1] and not #W[1].

We construct a family of directed temporal graphs (GC=(V,AC,2|I|+1))C[k] with rational time labels (such that the maximum time label is at most 2|I|+1), where ACV×V×Q for all C[k]. Towards the end of the proof, we explain how to remove the need for directed edges which will also have the consequence that the temporal graphs only contain strict temporal paths. Note that we can scale up the lifetime to remove the need for rational time labels, however using rational time labels will be convenient in the construction and the correctness proof.

  • We set V:=VI{s,z,z}{w1,,wk}{uxxI}, where VI:={v1,,v2|I|}.

  • We set AC:=xIc(x)CAx{(s,wi,1)i[k]}{(z,z,2|I|+1)}, where
    Ax:={(wc(x),ux,a),(ux,va,b),(ux,va,b+1-aε),(vb,z,b)}{(vb,wi,b)i[k]ic(x)}{(vj,vj+1,b),(vj,vj+1,b+1-(j+1)ε)j{a,,b-1}}
    for x=([a,b],[a,b])I and ε=12|I|.

For all GC we use s as the starting vertex and z as the end vertex of the temporal paths we want to count. The temporal graphs GC can each clearly be constructed in polynomial time and it is easy to see that the vertex set {s,z,z,w1,,wk} constitutes a feedback vertex set of size O(k) for each of them (even if edge directions are removed). The construction is illustrated in Fig. 1.

Fig. 1.

Fig. 1

Illustration of GC with C={1,3} and two interval pairs x1,x2I where x1=([1,4],[2,5]) and x2=([3,6],[1,4]), and the corresponding colours are c(x1)=1 and c(x2)=3. The arcs added for x1 are depicted in red and the arcs added for x2 are depicted in blue

Correctness of the reduction. We now show some properties of the construction that will help to prove correctness of the reduction.

Claim 1

Let x=([a,b],[a,b])I, i[k]ic(x), and C[k] with c(x)C. Then there is exactly one temporal (wc(x),wi)-path P in GC such that V(P)VI={va,va+1,,vb}. Furthermore, there is exactly one temporal (wc(x),z)-path P in GC such that V(P)VI={va,va+1,,vb}.

Proof of Claim

Let x=([a,b],[a,b])I, i[k]ic(x), and C[k] with c(x)C. We first show that there is a temporal (wc(x),wi)-path P in GC such that V(P)VI={va,va+1,,vb}. Then we show that the path is unique. The case for a temporal (wc(x),z)-path works analogously.

Consider the path P=((wc(x),ux,a),(ux,va,b),(va,va+1,b),,(vb-1,vb,b),(vb,wi,b)). It is easy to verify that this path is contained in GC and that we have V(P)VI={va,va+1,,vb}. Now assume for contradiction that there is a temporal (wc(x),wi)-path P in GC such that V(P)VI={va,va+1,,vb} and PP. Recall that we assume that if two interval pairs x,yI are different, then all endpoints on each track are pairwise different. This means that, by construction of GC, the temporal path P has to visit the same vertices as P in the same order. This implies that P contains a transition (uvt) such that P contains the transition (u,v,t) with some tt. However, note that the only time step when we have a transition from vb to wi is b and also the earliest time step when we can arrive at va (via ux) is b. Hence we must have that t=b unless (u,v,t)=(wc(x),ux,a). In both cases, we obtain a contradiction to the assumption that PP.

Claim 2

Let V={va,va+1,,vb} for some [ab] such that for all a,b we have that ([a,b],[a,b])I. Then for all i,j[k] and for all C[k] we have that GC contains an even number of temporal (wi,wj)-paths P such that V(P)VI=V. Furthermore, there is an even number of temporal (wi,z)-paths P in GC such that V(P)VI=V.

Proof of Claim

Let V={va,va+1,,vb} for some [ab] such that for all a,b we have that ([a,b],[a,b])I. We show that for all i,j[k] and for all C[k] we have that GC contains an even number of temporal (wi,wj)-paths P such that V(P)VI=V. The case for temporal (wi,z)-paths works analogously.

If there is no temporal path satisfying the conditions, then we are done. Hence, assume that there is a C[k] and i,j[k] such that GC contains a temporal (wi,wj)-path P with V(P)VI=V. Let Pi,jC denote the set of all temporal (wi,wj)-paths P in GC with V(P)VI=V. We will argue that |Pi,jC|0mod2.

Since Pi,jC we have an interval pair x=([a,b^],[a^,b^])I with c(x)=i, otherwise the first vertex from VI that is visited by each temporal path PPi,jC cannot be va. Now consider the vertex set V^={va,va+1,,vmin(b^,b)}V. By construction of GC, we have for any two vertices v,v+1V^ that (v,v+1,b^)AC and (v,v+1,b^+1-(+1)ε)AC. Furthermore, we have that the first time-arc of every temporal path in Pi,jC is (wi,ux,a^) and we have (ux,va,b^)AC and (ux,va,b^+1-aε)AC. We call the collection of these time-arcs the early lane A^i,jC of Pi,jC, formally A^i,jC={(ux,va,b^),(ux,va,b^+1-aε)}{(v,v+1,b^),(v,v+1,b^+1-(+1)ε)v,v+1V^}. Notice that every static arc that appears as a time-arc in A^i,jC appears exactly twice (i.e. with two different time labels).

We now distinguish temporal (wi,wj)-paths P with V(P)VI=V by the last vertex they visit using the early lane. Formally, given a temporal (wi,wj)-path P with V(P)VI=V, let v^PV^ be the last vertex of the longest prefix P^ of P such that P^ only consists of time-arcs in the early lane A^i,jC. For vVI, let Pi,jC(v) be the sets of all temporal (wi,wj)-paths P with V(P)VI=V and v^P=v; intuitively these are the temporal paths that ‘leave’ the early lane at v. Note that we have Pi,jC=vVIPi,jC(v), and since the sets Pi,jC(v) with vVI are by definition pairwise disjoint, we also have |Pi,jC|=vVI|Pi,jC(v)|.

Finally, we show that for all vVI we have |Pi,jC(v)|0mod2, from which the claim then follows. Let vVI. If Pi,jC(v)= we are done, hence assume that Pi,jC(v). Recall that all temporal paths in Pi,jC(v) use time-arcs from the early lane A^i,jC of Pi,jC until they reach v. We now partition Pi,jC(v) into Qi,jC(v) and Ri,jC(v). Assume that >a; the case that =a works analogously. The set Qi,jC(v) contains all temporal paths from Pi,jC(v) that use the time-arc (v-1,v,b^) and the set Ri,jC(v) contains all temporal paths from Pi,jC(v) that use the time-arc (v-1,v,b^+1-ε). In both cases, the mentioned time-arc is the last time-arc from the early lane used by the temporal paths.

We show that |Qi,jC(v)|=|Ri,jC(v)| by giving a bijection f:Qi,jC(v)Ri,jC(v) between the two sets. This then implies that |Pi,jC(v)|0mod2. Given a temporal path PQi,jC(v), the function f maps P to f(P)=P, where P is obtained from P by replacing time-arc (v-1,v,b^) with (v-1,v,b^+1-ε). We first show that P is indeed a temporal path which implies that it is contained in the set Ri,jC(v). Since the new time-arc (v-1,v,b^+1-ε) has a larger time label than the original one, the following time-arc in P cannot have a smaller time label in order for P to be a temporal path. However, note that the time-arc in P that directly follows (v-1,v,b^+1-ε) is not a time-arc from the early lane, hence its time label is at least b+1. It follows that P is a temporal path. We now have shown that f maps each element in Qi,jC(v) to exactly one element in Ri,jC(v), meaning that f is injective. To finish the proof, we consider the inverse function f-1:Ri,jC(v)Qi,jC(v) of f, which maps temporal paths QRi,jC(v) to f-1(Q)=Q, where Q is obtained from Q by replacing time-arc (v-1,v,b^+1-ε) with (v-1,v,b^). We show that f-1 is also injective by showing that Q is a temporal path and hence element of Qi,jC(v). Now the new time-arc in Q has a smaller time label than the original one, so the preceding time-arc cannot have a larger time label. Let e be the time-arc in Q that directly precedes (v-1,v,b^). We know that e is also a time-arc from the early lane, hence its label is either also b^ or b^+1-(-1)ε. However, if the label of e was b^+1-(-1)ε, then it would be larger than the label of the replaced original time-arc, which had label b^+1-ε, a contradiction to the assumption that Q is a temporal path. It follows that the label of e is b^ which implies that Q is a temporal path. This shows that also f-1 is injective which means that f is indeed a bijection.

We call an independent set colourful if every vertex of the independent set has a different colour.

Claim 3

Let C[k]. The number of temporal (sz)-paths in GC is even if and only if the number of colourful independent sets X in (Ic) with {c(x)xX}C is even.

Proof of Claim

Let C[k] and let PC be the set of all temporal (sz)-paths in GC. We partition the set PC into two parts, QC and RC. Intuitively, the set QC will contain “cheating” temporal (sz)-paths, that do not correspond to a colourful independent set in instance (Ic) that uses only colours in C. We show that |QC|0mod2. The set RC will contain temporal (sz)-paths that have a one-to-one correspondence with colourful independent sets in (Ic) that use colours in C. We show that |RC|=|{XXis a colourful independent set in(I,c)and each element inXhas a colour fromC}|. From this, the claim then follows.

Let PPC. If for some i,jC the temporal path P contains a temporal subpath P from wi to wj or from wi to z such that V(P)VI={va,va+1,,vb} for some [ab] and for all a,b we have that ([a,b],[a,b])I, then we define P to be contained in QC. Otherwise, P is contained in RC. By Claim 2 we have that |QC|0mod2. It follows that |PC||RC|mod2.

Let PRC. Then we can construct a colourful independent set in (Ic) that uses colours in C as follows. We identify the following temporal subpaths of P:

  • Pi,j is the subpath from wi to wj, where we assume that no other vertex in {w1,,wk} is visited by Pi,j, that is, V(Pi,j){w1,,wk}={wi,wj}.

  • Pi,z is the subpath from the “last” wi visited by P to z, that is, V(Pi,z){w1,,wk}={wi}.

For each of these subpaths Pi,j we know that there exists an x=([a,b],[a,b])I such that V(Pi,j)VI={va,va+1,,vb}, otherwise we would have PQC. By construction of GC we also know that c(x)=i. Analogously we can make the same observation for Pi,z. Hence, we can identify each of the above-defined subpaths with an element x of I. Let X denote the set of those elements. By construction we know that X is colourful and uses colours from C; what remains to show is that it is an independent set in (Ic). Assume for contradiction that X is not an independent set in (Ic). Then there are two distinct interval pairs x=([a,b],[a,b])X and x=([c,d],[c,d])X such that [a,b][c,d] or [a,b][c,d]. Let Pi,j and Pi,j be the two subpaths corresponding to x and x, respectively (here we allow j=z and j=z).

  • If [a,b][c,d], then V(Pi,j)V(Pi,j). This is a contradiction to the assumption that P is a temporal path, since vertices are visited multiple times.

  • If [a,b][c,d], then P contains the time-arcs (wc(x),ux,a),(ux,va,b) consecutively and also time-arcs (wc(x),ux,c),(ux,vc,d) consecutively (since P contains Pi,j and Pi,j). This is a contradiction to the assumption that P is a temporal path, since the time labels on the time-arcs are not non-decreasing.

Hence, we can conclude that X is a colourful independent set in (Ic) that uses colours from C. Furthermore, by Claim 1 we have that for different temporal paths P,PRC, we obtain different colourful independent sets X,X in (Ic) using colours from C, that is, we have described an injective mapping from the temporal paths in RC to the colourful independent sets in (Ic) that use colours from C.

Now let X be a colourful independent set in (Ic) that uses colours from C. Then we can construct a temporal (sz)-path P in GC with PRC as follows. Let X={x1,x2,,x|X|} such that for all xi=([a,b],[a,b])X and xj=([c,d],[c,d])X we have i<j if and only if b<c. Note that this indexing is well-defined since X is an independent set in (Ic). For each xi=([a,b],[a,b])X with i<|X| we define a path segment Pi as follows. The path segment Pi starts at wc(xi), ends at wc(xi+1), and visits vertices uxi and va,va+1,,vb in VI. It does so using the following time-arcs: (wc(xi),uxi,a),(uxi,va,b),(va,va+1,b),,(vb-1,vb,b),(vb,wc(xi+1),b). Note that all mentioned time-arcs are present in GC by construction and since ab we have that Pi is a temporal path segment. The path segment P|X| starts at wc(x|X|), ends at z, and is defined analogously. Now the temporal path P starts with the time-arc (s,wx1,1), then uses P1,P2,,P|X|, and finally ends with time-arc (z,z,2|I|+1). Assume for contradiction that P is not a temporal path.

  • Note that by construction, P visits each vertex from {ux1,ux2,,ux|X|} at most once. If P visits a vertex from {w1,,wk} multiple times, then we have a contradiction to X being colourful. If P visits a vertex from VI multiple times, then we have a contradiction to X being an independent set in (Ic), since the “first” intervals of two interval pairs in X are intersecting.

  • If P is not temporal, that is, the time-arcs in P are not non-decreasing, then we have a contradiction to X being an independent set in (Ic), since the “second” intervals of two interval pairs in X are intersecting.

Note that by construction we also have that PRC. Furthermore, since we assume all interval pairs in I have distinct endpoints, we have that for different colourful independent sets X,X in (Ic) using colours from C, we obtain different temporal paths P,PRC, that is, we have described an injective mapping from the colourful independent sets in (Ic) that use colours from C to the temporal paths in RC.

Overall, we now have shown that the set RC contains temporal (sz)-paths that have a one-to-one correspondence with colourful independent sets in (Ic) that use colours in C, which implies that |RC|=|{XXis a colourful independent set in(I,c)and each vertex inXhas a colour fromC}|. This finishes the proof of the claim.

Using an oracle A for #Temporal Path, we can solve the Multicoloured Independent Set on 2-Track Interval Graphs instance (Ic) as follows. We use a dynamic programming table F:2[k]{0,1} where F(C) for some C[k] equals the parity of independent sets in (Ic) that have exactly one vertex of each colour in C.

F()=0,F(C)=(A(GC)+CCF(C))mod2.

The correctness follows directly from Claim 3. Computing F([k]) requires O(2k) calls to the oracle A and O(4k)·|(I,c)|O(1) time overall (including computing the temporal graphs GC).

Replacing directed time-arcs with undirected time-edges. Lastly, we show how to replace the directed time-arcs in the constructed temporal graphs with undirected time-edges such that the correctness of our reduction is preserved. The main idea is to use appropriate edge subdivisions. We assume these replacements are done before scaling all time labels to obtain integer time labels.

  • For all x=([a,b],[a,b])I with c(x)C and all iC\{c(x)} we add a new vertex u(x,i) replace each time-arc (vb,wi,b) with the two time-edges ({vb,u(x,i)},b), ({u(x,i),wi},b+ε).

  • For all x=([a,b],[a,b])I we add a new vertex u(x,z) replace each time-arc (vb,z,b) with the two time-edges ({vb,u(x,z)},b), ({u(x,i),z},b+ε).

  • We replace all other time-arcs with undirected versions of themselves.

Consider the undirected temporal graph obtained from the modifications above, an illustration is given in Fig. 2. We can make the following observations.

  • Once a temporal (sz)-path arrives at a vertex wi for some iC, then it can only continue to a vertex ux for some xI with c(x)=i. It cannot continue to a vertex u(x,i), since from there it cannot continue without revisiting vertex wi. For the same reason, it cannot return to vertex s.

  • Once a temporal (sz)-path arrives at a vertex ux for some x=([a,b],[a,b])I, then it can only continue to vertex va, since otherwise it would revisit vertex wc(x).

  • Once a temporal (sz)-path arrives at a vertex u(x,i) for some x=([a,b],[a,b])I with c(x)i, then it can only continue to a vertex wi, since otherwise it would revisit vertex vb.

  • Once a temporal (sz)-path arrives at a vertex u(x,z) for some x=([a,b],[a,b])I, then it can only continue to a vertex z, since otherwise it would revisit vertex vb.

  • Once a temporal (sz)-path arrives at vertex z, then it can only continue to vertex z, since otherwise it would revisit vertex z.

Furthermore, we can observe that if a temporal (sz)-path arrives at a vertex va coming directly from a vertex va-1, it can only continue to va+1 or some vertex u(x,i) for some xI with c(x)i. It cannot continue to a vertex ux for some xI, since from there it cannot continue without revisiting vertices.

Fig. 2.

Fig. 2

Illustration of the modified undirected version of GC with C={1,3} and one interval pair x=([1,4],[2,5])I with c(x)=1. The edges added for x are depicted in red

In all so far mentioned cases, the temporal (sz)-paths follow edges along the directions they had in the directed temporal graph construction.

The only “problematic” case left is when a temporal (sz)-path arrives at a vertex va coming directly from vertex ux for x=([a,b],[a,b])I. Then it can continue in the “wrong direction” to va-1. However, since we assume all interval pairs in I have unique endpoint, the edge {va-1,va} does not have label b and the next larger label is at least b+1, whereas the edge {ux,va} has labels b and b+1-aε. It follows that this has the same effect as “leaving the early lane”, see proof of Claim 2, and hence we have that there is an even number of such temporal (sz)-paths. Formally, this can be shown by an analogous proof to the one of Claim 2.

Lastly, it is easy to verify that the modifications do not increase the feedback vertex number of the underlying graph, because we only subdivide edges.

Exact Algorithms for Temporal Path Counting

In this section, we present several exact algorithms for #Temporal Path. We start in Sect. 4.1 with a polynomial-time algorithm for temporal graphs that have a forest as underlying graph. In Sect. 4.2 we show that our polynomial-time algorithm can be generalised in two ways, obtaining FPT-algorithms for the so-called timed feedback vertex number and the feedback edge number of the underlying graph. In Sect. 4.3 we show that #Temporal Path is in FPT when parameterised by the treewidth of the underlying graph and the lifetime combined. Lastly, in Sect. 4.4, we give an FPT algorithm for #Temporal Path parameterised by the so-called vertex-interval-membership-width.

A Polynomial Time Algorithms for Forests

As a warm-up, we note that #Temporal Path can be solved in polynomial time with a simple dynamic program if the underlying graph is a forest. This is used as a subroutine for algorithms presented in Sect. 4.2.

Theorem 2

#Temporal Path is solvable in O(|V|·T2) time if the underlying graph of the input temporal graph is a forest.

Proof

Let G=(V,E,T) together with two vertices s,zV be an instance of #Temporal Path. We argue that this instance can be solved in polynomial time if there is a unique path between s and z in the underlying graph of G. Note that this is the case if the underlying graph of G is a forest.

First, observe that when counting (sz)-paths starting at s and arriving at z, if there is a unique static path between s and z in the underlying graph then we need only consider time-edges between vertices of that unique static path in our temporal graph when counting, as our temporal path may not repeat vertices and so corresponds to a path in the underlying graph. Edges not lying on the unique static path between s and z can therefore be deleted without changing the result, so we may w.l.o.g. consider an instance in which the underlying graph consists only of a static path P=(v0,v1,,v|P|) with s=v0 and z=v|P| as the leaf vertices.

We will base our counting on a recording at each vertex vi in P of how many temporal (s,vi)-paths there are starting at s and arriving at vi at time t or earlier. Note that there are O(|P|·T)=O(|V|·T) such vertex-time pairs.

We argue by induction on i that we can correctly compute this number for every vertex-time pair by dynamic programming. As a base case, note that there is one path from s to s for any arrival time. Then we assume that we have these numbers computed correctly for some vi with i0 and show how we compute them for vi+1. Formally, our dynamic program is defined as follows.

F(v0=s,t)=1F(vi,t)=({vi-1,vi},t)EwithttF(vi-1,t)fori1.

It is straightforward to check that F(zT) can be computed in the claimed running time. We now formally prove correctness by induction on i. That is, we prove that F(vi,t) equals the number of temporal (s,vi)-paths that start at s and arrive at vi at time t or earlier; it will follow immediately that F(zT) is the number of (sz)-paths, so it suffices to compute F(vi,t) for all 0i|P|.

The base case i=0 is trivial. Assume that i>0. We sum over the last time-edge of the temporal (s,vi)-paths starting at s and arriving at vi at time t or earlier. Let P be the set of all temporal (s,vi)-paths starting at s and arriving at vi at time t or earlier that use ({vi-1,vi},t)E as the last time-edge. All these temporal paths need to arrive at vi-1 at time t or earlier, otherwise they cannot use time-edge ({vi-1,vi},t). Since all temporal paths in P do not differ in the last time-edge, the cardinality of P equals the number of temporal (s,vi-1)-paths starting at s and arriving at vi-1 at time t or earlier. By the induction hypothesis, this number equals F(vi-1,t). Clearly, if the last time-edge of two temporal (s,vi)-paths starting at s and arriving at vi at time t or earlier is different, then the two temporal paths are different, so we do not double count.

Hence, we have shown that F(vi,t) equals the number of temporal (s,vi)-paths that start at s and arrive at vi at time t or earlier.

Generalisations of the Forest Algorithm

In this subsection, we present two generalisations of Theorem 2. The first one results in an FPT-algorithm for the timed-feedback vertex number as a parameter and the second one in an FPT-algorithm for the feedback edge number of the underlying graph as a parameter. We remark that both parameters are larger than the feedback vertex number of the underlying graph, for which Theorem 1 refutes the existence of FPT-algorithms. Both algorithms are inspired by algorithms presented by Casteigts et al. [18] for the so-called Restless Temporal Path problem.

The timed feedback vertex number was introduced by Casteigts et al. [18] and, intuitively, counts the minimum number of vertex appearances that need to be removed from a temporal graph to make its underlying graph cycle-free. Formally, it is defined as follows.

Definition 6

([18]) Let G=(V,E,T) be a temporal graph. A timed feedback vertex set of G is a set XV×[T] of vertex appearances such that the underlying graph of G=(V,E,T) is a forest, where E:=E\{({v,w},t)E(v,t)X(w,t)X}. The timed feedback vertex number of a temporal graph G is the minimum cardinality of a timed feedback vertex set of G.

Roughly speaking, our FPT-algorithm for the timed feedback vertex number as a parameter performs the following steps.

  1. Compute a minimum cardinality timed feedback vertex set of the input temporal graph.

  2. Iterate over all possibilities for how a temporal path can traverse the vertex appearances in the timed feedback vertex set.

  3. For each possibility, create an instance of the so-called #Weighted Multicoloured Independent Set on Chordal Graphs problem to compute the number of possibilities for connecting the vertex appearances of the timed feedback vertex set that are supposed to be traversed.

  4. Using this, compute the total number of temporal (sz)-paths in the temporal input graph.

The intuition here is that the possibilities for connecting the vertex appearances of the timed feedback vertex set that are supposed to be traversed correspond to path segments in the underlying graph of the temporal graph without the timed feedback vertex set, which is a forest. It is well-known that chordal graphs are intersection graphs of subtrees in forest [58]. This means that an independent set in a chordal graph corresponds to a selection of non-intersecting subtrees (which here will all be paths). The colours can be used to make sure that, for each pair of vertex appearances of the timed feedback vertex set that are supposed to be traversed directly after one another, exactly one path segment connecting them can be in the independent set. The weights can be used to model how many temporal paths follow the corresponding path segment of the underlying graph

Our algorithm follows similar ideas as the one by Casteigts et al. [18] for the Restless Temporal Path problem. The main difference is that we have to solve #Weighted Multicoloured Independent Set on Chordal Graphs as a subroutine instead of the unweighted decision version of the problem. In the following, we give a formal definition. graphic file with name 453_2025_1301_Figb_HTML.jpg

We can observe that #Weighted Multicoloured Independent Set on Chordal Graphs presumably cannot be solved in polynomial time. This follows directly from the NP-hardness of Multicoloured Independent Set on Chordal Graphs [59, Lemma 2]. Hence, we have the following.

Observation 3

#Weighted Multicoloured Independent Set on Chordal Graphs cannot be solved in polynomial time unless P=NP.

However, we can obtain an FPT-algorithm for #Weighted Multicoloured Independent Set on Chordal Graphs parameterised by the number of colours. This will be sufficient for our purposes.

To show this result, we adapt an algorithm by Bentert et al. [60, Proposition 5.6] to solve Maximum Weight Multicoloured Independent Set on Chordal Graphs, where given a chordal graph G=(V,E), a colouring function c:V[k], and a weight function w:VN, one is asked to compute a multicoloured independent set of maximum weight in G. Here, the weight of an independent set is the sum of the weights of its vertices. Note that in our problem #Weighted Multicoloured Independent Set on Chordal Graphs the weight of an independent set is the product of the weights of its vertices.

Proposition 1

#Weighted Multicoloured Independent Set on Chordal Graphs is fixed-parameter tractable when parameterised by the number k of colours.

Proof

Bentert et al. [60] provide a dynamic program on a tree decomposition of the input graph. Chordal graphs are known to admit a tree decomposition, where every bag is a clique, that can be computed in linear time [61]. Let G=(V,E) be a chordal graph and (B,T) a rooted tree decomposition of G such that for each bag BB we have that G[B] is a complete graph; note that an independent set can therefore contain at most one vertex from each bag. Furthermore, we assume that each bag is either a leaf, has one descendant, or has exactly two descendants that contain exactly the same vertices. A tree decomposition with this property can be obtained in linear time [60]. Let R denote the root of T and for each BB let VB denote the set of all vertices in B and all descendants of B in T. Let c:V[k] be a colouring function and w:VN be a weight function where w.l.o.g. we have for all vV that w(v)>0 (since we may delete vertices with weight zero without changing the answer). We define the following dynamic programming table F:B×2[k]×V1{}N. Intuitively, we want that for each BB, each C[k], and each vB the table entry F[B,C,{v}] is the sum of weights of all independent sets X in G[VB] such that vX, |C|=|X|, and C={c(w)wX}. For table entries F[B,C,] we want that the independent set does not contain any vertex of B. We distinguish the following cases (where an empty sum equals 0):

  • Bag B is a leaf in T: For all vB and C[k] we set F[B,C,{v}]=w(v) if C={c(v)} and F[B,C,{v}]=0 otherwise. We set F[B,C,]=0.

  • Bag B has one descendant B in T: For all vB and C[k] if c(v)C, then set F[B,C,{v}]=0. If this is not the case, then for all vBB we set F[B,C,{v}]=F[B,C,{v}], otherwise we set F[B,C,{v}]=w(v)·(F[B,C\{c(v)},]+vB\BF[B,C\{c(v)},{v}]). We set F[B,C,]=F[B,C,]+vB\BF[B,C,{v}].

  • Bag B has two descendants B1 and B2 in T with B=B1=B2: We set
    F[B,C,{v}]=1w(v)·C1,C2C1C2=CC1C2={c(v)}F[B1,C1,{v}]·F[B2,C2,{v}],andF[B,C,]=C1,C2C1C2=CC1C2=F[B1,C1,]·F[B2,C2,].

The answer to our problem is F[R,[k],]+vRF[R,[k],{v}], where R denotes the root bag of the tree decomposition.

We show the following by induction, which then implies correctness of our algorithm. Here, we call an independent set C-multicoloured if it contains exactly one vertex of each colour in C. graphic file with name 453_2025_1301_Figc_HTML.jpg If B is a leaf in T, then Equation (*) is clearly fulfilled.

Assume that B has one descendant B in T. For vertices vB that are also contained in B, no vertex in B\B can be contained in a C-multicoloured independent set in G that contains v, since B is a clique. Hence, in this case we have that setting F[B,C,{v}]=F[B,C,{v}] fulfills Equation (*). If a vertex vB is not contained in B, then we can add it to any independent set containing vertices from VB\B (noting that the properties of a tree decomposition ensure that there cannot be any edge from a vertex in B\B to one in B\B). In order to obtain C-multicoloured independent sets, we sum up all weights of (C\{c(v)})-multicoloured independent sets, yielding F[B,C\{c(v)},]+vB\BF[B,C\{c(v)},{v}]. By distributivity of multiplication, we can multiply this sum with w(v) to obtain the weighted sum of C-multicoloured independent sets that additionally contain vertex v. It follows that in this case, Equation (*) is fulfilled. The correctness for F[B,C,] is analogous.

Lastly, assume that B has two descendants B1 and B2 in T with B=B1=B2. For vertices vB with c(v)C we sum up all possibilities of combining a C1-multicoloured independent set X1 in G[VB1] with a C2-multicoloured independent set X2 in G[VB2] such that we obtain a C-multicoloured independent set X=X1X2 in G[VB]. To this end, C1 and C2 must obey C1C2=C and C1C2={v}. The set X is clearly an independent set since VB1VB2=B1=B2=B and hence all edges between vertices in VB1 and VB2 have both their endpoints in B and X contains exactly one vertex from B, namely {v}=X1X2. Multiplying the weights of the independent sets results in having the weight of v appear twice in the product, hence we divide the sum of all products by w(v). It follows that in this case Equation (*) is fulfilled for all F[BCv]. The correctness for F[B,C,] is analogous.

To obtain the claimed running time bound, note that the size of the dynamic programming table F is in O(2k·|V|2) and each entry can be computed in O(2k+|V|) time.

Using Proposition 1, we are ready to give our FPT-algorithm for #Temporal Path parameterised by the timed feedback vertex number.

Theorem 3

#Temporal Path is fixed-parameter tractable when parameterised by the timed feedback vertex number of the input temporal graph.

Proof

Let (G,s,z) be an instance of #Temporal Path. We adapt an algorithm by Casteigts et al. [18, Theorem 8] for the so-called Restless Temporal Path problem.

Intuitively, the algorithm iterates over all possibilities for how a temporal (sz)-path can traverse the vertex appearances in the timed feedback vertex set. Then, to calculate the number of ways to select path segments to connect the timed feedback vertex set elements visited by the path, we create an instance of #Weighted Multicoloured Independent Set on Chordal Graphs. Note that, informally speaking, the path segments connecting the timed feedback vertex set elements are subpaths of the forest that remains after the timed feedback vertex set is removed from the input graph, hence they form an intersection model for a chordal graph. Since a temporal path cannot revisit vertices, the timed feedback vertex set elements cannot be connected by intersecting path segments, hence we are interested in independent sets in the chordal graph representing the path segments. Furthermore, for each pair of feedback vertex set elements visited consecutively by the temporal path, we need exactly one path segment to connect them; this is modelled by giving the path segments colours.

Description of the algorithm. We assume w.l.o.g. that in G there is only one time-edge incident to s and that time-edge has label 1, and there is only one time-edge incident to z and that time-edge has label T. If this is not the case, we can add two new vertices s,z to G and connect s to s at time 1 and z to z at time T and the switch the names of s,s and z,z, respectively. Formally, the algorithm performs the following steps, we give a visualization in Fig. 3.

  1. Compute a minimum timed feedback vertex set X of G. This can be done in 2O(|X|)·|G|O(1) time [18, Theorem 9].

  2. Iterate over all possibilities for sets O, I and U such that (OI)U=X{(s,1),(z,T)} (where O and I can intersect, but must both be disjoint from U). Slightly abusing terminology, we will refer to all triples O, I, U with the mentioned property as partitions of X{(s,1),(z,T)}.

    Intuitively, the sets O, I, and U contain elements of the timed feedback vertex set X that are outgoing, incoming, or “unused” (that is, neither incoming nor outgoing) vertex appearances, respectively, in the temporal paths currently under considerations. The ordering <OI specifies in which order the vertex appearances shall be visited by the temporal paths.

  3. For each partition and each ordering <OI over OI, create an instance of #Weighted Multicoloured Independent Set on Chordal Graphs and solve it using Proposition 1. Let W<OI denote the computed value.

  4. Output (OI)U=X,<OIW<OI.

Fig. 3.

Fig. 3

Illustration of one iteration of the algorithm described Theorem 3. The upper part shows OI from the current partition ordered by <OI. The lower part sketches the underlying graph of the input temporal graph G without the timed feedback vertex set, which is a forest. The coloured areas correspond to vertices in the constructed #Weighted Multicoloured Independent Set on Chordal Graphs instance with the respective colours. The red thick path illustrates a temporal (sz)-path which corresponds to a multicoloured independent set in the constructed #Weighted Multicoloured Independent Set on Chordal Graphs instance

Construction of the #Weighted Multicoloured Independent Set on Chordal Graphs instance. In the following, we describe how we construct an instance of #Weighted Multicoloured Independent Set on Chordal Graphs given a partition (OI)U of X{(s,1),(z,T)} and an ordering <OI over OI. If there are two vertex appearances (v1,t1),(v2,t2)OI with (v1,t1)<OI(v2,t2) and t1>t2, then we set W<OI=0. If there are two vertex appearances (v1,t1),(v2,t2)OI with v1=v2, then we set W<OI=0 unless (v1,t1)I\O and (v2,t2)O\I, t1t2, sv1z, and (v1,t1),(v2,t2) are adjacent in <OI. Let (v,t)OI be the smallest element in OI according to <OI. If vs or (v,t)O, then we set W<OI=0. Let (v,t)OI be the largest element in OI according to <OI. If vz or (v,t)I, then we set W<OI=0. Formally, whenever we set a weight W<OI to zero, we create a trivial instance of #Weighted Multicoloured Independent Set on Chordal Graphs containing only one vertex with weight zero. If none of the above is the case, let {(v1,t1),(v2,t2),,(vx,tx)}=OI such that (vi,ti)<OI(vj,tj) if and only if i<j and denote VOI={v1,,vx}.

Let F be the underlying (static) graph of the temporal graph G, where G is obtained from G by removing the timed feedback vertex set X. In particular, this means that F is a forest. We now define a chordal graph G<OI using an intersection model of paths in F. We also define a colouring function c<OI and a weight function w<OI for the vertices in G<OI. Let (vi,ti),(vi+1,ti+1)OI. We create the following collection POI(i) of paths in F.

  • If (vi,ti)O and (vi+1,ti+1)I, then for each ({vi,w1},ti)E with (w1,ti)X and each ({vi+1,w2},ti+1)E with (w2,ti+1)X, let P be the (w1,w2)-path in F (if it exists). If P visits no vertex in VOI, we add P to POI(i). We count the number of temporal (w1,w2)-path in G which start at w1 at time ti or later and arrive at w2 at time ti+1 or earlier using Theorem 2 and use this number as the weight for the vertex in G<OI corresponding to P. If ({vi,vi+1},ti)E and ti=ti+1, then we add an empty path to POI(i) (corresponding to an isolated vertex in G<OI) with weight one for the corresponding vertex in G<OI.

  • If (vi,ti)O and (vi+1,ti+1)O\I, then for each ({vi,w1},ti)E with (w1,ti)X, let P be the (w1,vi+1)-path in F (if it exists). If P visits no vertex in VOI\{vi+1}, we add P to POI(i). We count the number of temporal (w1,vi+1)-paths in G which start at w1 at time ti or later and arrive at vi+1 at time ti+1 or earlier using Theorem 2 and use this number as the weight for the vertex in G<OI corresponding to P. If ({vi,vi+1},ti)E, then we add an empty path to POI(i) (corresponding to an isolated vertex in G<OI) with weight one for the corresponding vertex in G<OI.

  • If (vi,ti)I\O and (vi+1,ti+1)I, then for each ({vi+1,w2},ti+1)E with (w2,ti+1)X, let P be the (vi,w2)-path in F (if it exists). If P visits no vertex in VOI\{vi}, we add P to POI(i). We count the number of temporal (vi,w2)-path in G which start at vi at time ti or later and arrive at w2 at time ti+1 or earlier using Theorem 2 and use this number as the weight for the vertex in G<OI corresponding to P. If ({vi,vi+1},ti+1)E, then we add an empty path to POI(i) (corresponding to an isolated vertex in G<OI) with weight one for the corresponding vertex in G<OI.

  • If (vi,ti)I\O and (vi+1,ti+1)O\I, then let P be the (vi,vi+1)-path in F (if it exists). If P visits no vertex in VOI\{vi,vi+1}, we add P to POI(i). We count the number of temporal (vi,vi+1)-path in G which start at vi at time ti or later and arrive at vi+1 at time ti+1 or earlier using Theorem 2 and use this number as the weight for the vertex in G<OI corresponding to P. If vi=vi+1, then we add an empty path to POI(i) (corresponding to an isolated vertex in G<OI) with weight one for the corresponding vertex in G<OI.

We give all vertices in G<OI corresponding to paths in POI(i) colour i. This completes the description of the #Weighted Multicoloured Independent Set on Chordal Graphs instance for partition (OI)U of X and ordering <OI over OI.

Running time of the algorithm. Note that given a partition (OI)U of X{(s,1),(z,T)} and an ordering <OI over OI, the #Weighted Multicoloured Independent Set on Chordal Graphs instance can be constructed in polynomial time and that the number of colours is in O(|X|). By Proposition 1, the instance can therefore be solved in FPT-time with respect to |X|. Since the number of instances is in O(4|X|·(|X|+2)!), we overall obtain fixed-parameter tractability for parameter |X|, the timed feedback vertex number.

Correctness of the algorithm. In the remainder, we prove correctness of our algorithm. The correctness proof is similar to the correctness proof of [18, Theorem 8]. We first prove that every temporal (sz)-path in G is counted at least once. Then we prove that every temporal (sz)-path in G is counted at most once.

Let P be a temporal (sz)-path in G. For each vertex appearance in the timed feedback vertex set X, we have that it is incoming, outgoing, both, or neither for P. Hence there is exactly one partition (OI)U of X{(s,1),(z,T)} that correctly distributes the timed vertex appearances into the sets OIU for P. Furthermore, there is exactly one ordering <OI over OI that correctly reflects in which order the vertex appearances in OI are visited by P. It is straightforward to check that when constructing the #Weighted Multicoloured Independent Set on Chordal Graphs, every possibility to connect two adjacent (with respect to <OI) vertex appearances in OI is considered and accounts to one weight unit of a vertex in the constructed chordal graph. In particular, the connections used in P are considered and account for one weight unit of exactly one multicoloured independent set in the constructed chordal graph. It follows that P accounts for one weight unit in the output of the constructed #Weighted Multicoloured Independent Set on Chordal Graphs instances and hence is counted at least once.

Furthermore, it is easy to see that every temporal (sz)-path in G is counted at most once. Changing the partition (OI)U of X{(s,1),(z,T)} or the ordering <OI over OI clearly results in considering different temporal paths. For a fixed partition (OI)U of X{(s,1),(z,T)} and ordering <OI over OI, connecting two adjacent (with respect to <OI) vertex appearances in OI differently also clearly results in considering different temporal paths. Lastly, no non-path temporal walks (that visit vertices multiple times) are counted. This follows by the same reasoning given in the correctness proof of [18, Theorem 8]. The main idea is that if a temporal (sz)-walk visits a vertex v multiple times, then this vertex either is in VOI, then these temporal (sz)-walks are explicitly excluded when constructing the #Weighted Multicoloured Independent Set on Chordal Graphs instances. If v is in V\VOI, then the vertices in the constructed #Weighted Multicoloured Independent Set on Chordal Graphs instance corresponding any two path segments that contain v are connected by an edge. It follows that no temporal (sz)-walk visiting v multiple times is considered which implies that only temporal (sz)-paths are considered. Hence, every temporal (sz)-path in G is counted at most once and the correctness follows.

Now we consider the feedback edge number of the input temporal graph as our parameter, and show the following fixed-parameter tractability result. It is very similar to an algorithm by Casteigts et al. [18] for the so-called Restless Temporal Path problem parameterised by the feedback edge number.

Theorem 4

#Temporal Path is fixed-parameter tractable when parameterised by the feedback edge number of the underlying graph of the input temporal graph.

Proof

Let (G,s,z) be an instance of #Temporal Path. We adapt an algorithm by Casteigts et al. [18, Theorem 7] for the so-called Restless Temporal Path problem. The algorithm consists of four steps (only the last step needs adaptation to our problem):

  1. Exhaustively remove vertices with degree 1 from the underlying graph of G (except s and z). Let G be the resulting (static) graph.

  2. Compute a minimum feedback edge set F of G. Let f:=|F|.

  3. Let V3 denote all vertices of G with degree at least three. Partition the forest G-F into a set of maximal paths P with endpoints in eFeV3{s,z}, and intermediate vertices all of degree 2. It holds that |P|O(f) [62, Lemma 2].

  4. Any temporal (sz)-path in G can be formed with time-edges whose underlying edges are feedback edges from F or form paths from P. Enumerate all 2O(f) sequences of underlying edges that a temporal (sz)-path in G can follow and for each one count the temporal (sz)-paths following these underlying edges using Theorem 2. Add up all path counts.

The described algorithm clearly runs in 2O(f)·|G|O(1) time. The correctness follows from the correctness of [18, Theorem 7] and the observation that due to the exhaustive search, all temporal (sz)-paths in G are considered and correctly counted. For completeness, we provide a self-contained proof here.

First, notice that Step 1 of the algorithm is correct, since no temporal (sz)-path visits a vertex that has degree 1 in the underlying graph of G. Consider a temporal (sz)-path P in G and consider the path P in the underlying graph of G that is formed by the edges corresponding to the time-edges used by P. We have that the path P is composed out of a unique sequence of maximal paths in P. This sequence is enumerated exactly once by the algorithm in Step 4 and hence the temporal (sz)-path P is accounted for exactly once when Theorem 2 is used to count all temporal (sz)-paths following that sequence of underlying edges.

Parameterisation by Treewidth and Lifetime

Our goal in this subsection is to demonstrate that #Temporal Path is in FPT when parameterised simultaneously by the treewidth of the underlying graph and the lifetime; to do this we give an MSO-encoding of the problem and make use of the counting version of Courcelle’s theorem for model-checking on relational structures [63].

We begin by recalling some basic notation and terminology for relational structures. A relational vocabulary is a finite set τ of relation symbols, each of which is associated with a natural number, known as its arity. Given any relational vocabulary τ, a τ-structure is a pair A=(A,{RARτ}); A is said to be the universe of A while, for each Rτ, the interpretation RA of R in A is a subset of Ar, where r is the arity of R. Here we are interested only in relational structures with finite universes, and where the maximum arity of any relation is two.

For any vocabulary τ, the set of first-order formulas is built up from a countably infinite set of individual variables x1,x2,, the relation symbols Rτ, the connectives ,,¬ and the quantifiers x,x ranging over elements of the universe of the structure (for notational convenience we will also use standard shorthand such as and ). Monadic second-order logic additionally allows quantification over subsets of the universe via unary relation variables (which we will call set variables); we call a formula in monadic second-order logic an MSO-formula. Given an MSO-formula ψ, an individual variable x (respectively a unary relation variable X) appearing in ϕ is said to be a free variable if x (respectively X) is not in the scope of a quantifier x or x (respectively X or X). We write ψ(X1,,Xj,x1,,x) for a formula ψ with with free relation variables X1,,Xj and individual variables x1,,x. Given subsets A1,,AjA (formally these define interpretations of unary relation variables over A) and elements a1,,aA, we write Aψ(A1,,Aj,a1,,a) to mean that A satisfies ψ if the variables X1,,Xj,x1,,x are interpreted as A1,,Aj,a1,,a respectively. We further define the set of satisfying assignments of a formula ψ by

ψ(A):={(A1,,Aj,a1,,a):A1,,AjA,a1,,aA,Aψ(A1,,Aj,a1,,a)}.

This definition can also be extended to formulas with no free variables: in this case ϕ(A) is a set containing only the empty tuple if Aϕ, and the empty set otherwise.

A tree decomposition of a τ-structure A with universe A is a pair (T,B), where T=(VT,ET) is a tree and B=(Bv)vVT is a collection of subsets of A such that:

  1. for all aA, the set {vVT:aBv} is non-empty and induces a connected subtree in T, and

  2. for every relation symbol Rτ and every tuple (a1,,ar)RA, there exists BvB such that a1,,arBV.

As for graphs, the width of the tree decomposition (T,B) is maxBvB|Bv|-1, and the treewidth of A is the minimum width over all tree decompositions of A.

We can now define the monadic second-order counting problem.graphic file with name 453_2025_1301_Figd_HTML.jpg

Our strategy is to demonstrate that #Temporal Path is a special case of this general problem. To prove our main result we will then apply the following meta-theorem, which can be deduced immediately from [63, Theorems 6.56 and 9.21], together with the discussion immediately after [63, Theorem 9.21].

Theorem 5

([63]) Let ψ(X1,,Xj,x1,,x) be an MSO-formula with free set variables X1,,Xj and free individual variables x1,,x, and let A be a relational structure on universe A. Given a width-w tree decomposition of A, the cardinality of the set ψ(A) can be computed in time f(w,k)·A, where k is the length of the formula ψ and A denotes the size of the structure A.

We now have all the ingredients to prove the main result of this section. We remark that Theorem 1 implies that we cannot hope to obtain fixed-parameter tractability by the treewidth of the underlying graph as the only parameter. The observation that #Temporal Path is #P-hard for lifetime one implies that we also cannot remove the treewidth from this parameterisation.

Theorem 6

#Temporal Path is in FPT when parameterised by the combination of the treewidth of the underlying graph and the lifetime.

Proof

It suffices to demonstrate that, given an arbitrary instance (G,s,z) of #Temporal Path, where G=(V,E,T), we can efficiently construct a relational structure A and a collection of at most T MSO-formulas ψ1,,ψT such that the number of temporal (sz)-paths in G that use exactly edges active at exactly distinct timesteps is equal to |ψ(A)|; it follows that the total number of temporal (sz)-paths in G is 1T|ψ(A)|. Provided that both the treewidth of A and the length of each formula ψ can be bounded by functions of the treewidth of the underlying input graph and the lifetime of G, the result will then follow immediately from Theorem 5.

Definition of the relational structure. We begin by defining the relational structure A that will encode our instance of #Temporal Path. Suppose that E=(E1,,ET) and the underlying graph of G is G=(V,E) (so E=i[T]Ei). The universe of A is

A=VE[T].

The structure A has four relation symbols, with the following interpretations:

  • appears: for eE and i[T], we have appears(e,i) if and only if eEi;

  • inc: for vV and eE, we have inc(v,e) if and only if v is an endpoint of e;

  • equal: for x,yVE, we have equal(x,y) if and only if x and y are the same element of the universe;

  • lessthan: for t1,t2[T], we have lessthan(t1,t2) if and only if t1t2.

We now bound the treewidth of A. Let (T,B) be a tree decomposition for G of width w; we will describe a strategy for constructing a tree decomposition (T,B) for A, indexed by the same tree T=(VT,ET). Fix a vertex vVT, and let Bv be the corresponding element of B. We define the corresponding element of B to be

Bv:=Bv{e=vwE:v,wBv}[T].

It is straightforward to verify that, with this definition, (T,B) is indeed a tree decomposition for A; moreover, it is immediate that |Bv||Bv|+|Bv|2+Tw+1+w+12+T<(w+1)2+T and hence that the treewidth of A is at most (w+1)2+T.

Definition of the MSO formula. We now proceed to define the formula ψ. We require a subformula that is true if and only if a specified set of edges forms a path in G with endpoints x and y. It is well-known that such a subformula can be expressed in MSO2 in constant length, e.g. as explained in Section 5.2.2 of [63].

However, for full exposition, we work through the construction of such a subformula. We first define two formulas which encode the fact that a vertex is incident with exactly one or two edges from a given set respectively:

degone(v,E):=(e(eEinc(v,e)))(e1e2((e1Ee2Einc(v,e1)inc(v,e2)equal(e1,e2)))

is true if and only if vertex v is incident with exactly one edge in E, whereas

degtwo(v,E):=(e1e2(e1Ee2Einc(v,e1)inc(v,e2)¬(equal(e1,e2))))(e3e4e5((e3Ee4Ee5Einc(v,e3)inc(v,e4)inc(v,e5))(equal(e3,e4)equal(e4,e5)equal(e3,e5))))

is true if and only if vertex v is incident with exactly two edges in E. Our next subformula is true if and only if the edges in the set E form a connected subgraph:

conn(E):=F((e1e2(e1Ee1Fe2E¬(e2F)))(e3e4v(e3Ee3Fe4E¬(e4F)inc(v,e3)inc(v,e4)))).

For our final subformula, we use degone, degtwo and conn to define a formula that is true if and only if the set E of edges forms a path in G with endpoints x and y:

ispath(x,y,E):=conn(E)degone(x,E)degone(y,E)(vV(¬(equal(v,x)equal(v,y))((eE¬inc(v,e))degtwo(v,E)))).

We can now define the formula ψ as

ψ(E0,,E,t0,,t):=v0v+1((v0=s)(v+1=z)0iispath(vi,vi+1,Ei)0i-1lessthan(ti,ti+1)0ieEiappears(e,ti)E((eE0ieEi)ispath(s,z,E))).

In this formula, the times t0,,t are the times at which at least one edge in the temporal path is active; each set Ei is the set of edges in the temporal walk active at time ti, and vi is the vertex at which the path segment active at time ti joins the path segment active at time ti+1. The first part of the formula,

(v0=s)(v+1=z)0iispath(vi,vi+1,Ei),

ensures that the first and last vertices on our path are s and z respectively, and that the edges in each set Ei do indeed form a path in the underlying graph from vi to vi+1 for each i. The second part of the formula enforces temporal constraints: we verify that the times at which consecutive path segments are traversed are weakly increasing, and that every edge in Ei is active at the appropriate time ti.

The parts of the formula described so far describe a temporal walk from s to z (with appropriate departure and arrival times), but it is possible that this walk revisits vertices. The purpose of the final part of the formula,

E((eE0ieEi)ispath(s,z,E)),

is to avoid this: E is the union of all edges used in the temporal walk, and this part of the formula verifies that this set of edges does indeed form a path from s to z in the underlying graph.

It is clear, therefore, that (E0,,E,t0,,t)ψ(A) if and only if there is a temporal path from s to z in G in which, for 0i, the edges of Ei are traversed at time ti.

Correctness. Observe that there is a one-to-one correspondence between tuples (E0,,E,t0,,t) and (sz)-paths in which each set of edges Ei is traversed at time ti. It follows that |ψ(A)| is the number of temporal (sz)-paths in G which use edges active at precisely distinct timesteps. Summing over all permitted choices of , we see that the number of temporal (sz)-paths in G that start at time ts or later and arrive at time tz or earlier is precisely equal to

0tz-ts|ψ(A)|,

as required. It remains only to bound the length of each formula ψ. Note first that each of the subformulas degone, degtwo, conn and ispath has constant length. It follows that the length of ψ is O()=O(tz-ts)=O(T), as required.

Parameterisation by Vertex-Interval-Membership-Width

In this subsection, we present an FPT algorithm for #Temporal Path parameterised by the so-called vertex-interval-membership-width of the input temporal graph. The vertex-interval-membership-width is a temporal graph parameter recently introduced by Bumpus and Meeks [40] which, like the timed feedback vertex number, depends not only on the structure of the underlying graph but also on the assignment of times to edges. Intuitively, the vertex-interval-membership-width bounds the maximum number of vertices that are “relevant” at any timestep, where a vertex is considered relevant if it has an incident edge both (weakly) before and after the current timestep (so, for example, a vertex v will be relevant at every time when a temporal path could have entered but not yet left v). We remark that the vertex-interval-membership-width is incomparable to the feedback vertex number of the underlying graph.

Definition 7

([40]) The vertex interval membership sequence of a temporal graph (G,E,T) is the sequence (Ft)t[T] of vertex-subsets of G where

Ft:={vV(G)itjandu,wV(G)such that{u,v}Eiand{w,v}Ej}.

Note that we allow u=w. The vertex-interval-membership-width of (G,E,T) is the integer vimw(G,E,T):=maxt[T]|Ft|.

Note that every vertex incident with an edge in Ei must belong to Fi, and so |Ei||Fi|2|Fi|2. The vertex interval membership sequence gives us a structure we can use for dynamic programming, which we exploit to obtain the following result.

Theorem 7

#Temporal Path can be solved in time O(w2w2+w·T) where T and w are the lifetime and vertex-interval-membership-width respectively of the input graph.

In our dynamic programming algorithm, a state of the bag Ft is a pair (vX), where vFt and XFt\{v}. For any state (vX) of Ft, we compute the number Pt(v,X) of temporal paths Q from s to v, arriving by time t, such that V(Q)(Ft\{v})=X. Computing all such values Pt(v,X) is clearly sufficient, since the total number of temporal (sz)-paths is YFT\{z}PT(z,Y). We compute the values for each bag Ft in turn, assuming for t1 that we have already computed all counts corresponding to Ft-1.

Proof

Note first that we may assume w.l.o.g. that z is incident with at least one edge in ET: if not, we can discard all edges in ET and decrease the lifetime by one without changing the number of (sz)-paths. It follows that zFT.

We proceed by dynamic programming. For each t[T], define the set of states of Ft to be

St={(v,X):vFt,XFt\{v}}.

For any state (v,X)St, we define Pt(v,X) to be the number of temporal paths Q from s to v, arriving by time t, such that V(Q)(Ft\{v})=X; for notational convenience, we adopt the convention that Pt(v,X)=0 if (v,X)St. It is clear from this definition that the total number of paths from s to z is

YFT\{z}PT(z,Y).

It therefore suffices to compute PT(x,V) for every state (x,V)ST. We will in fact compute the path counts for every state of each bag Ft in turn, assuming that we have already computed these counts for Ft-1.

For F1, given (v,X)S1, the value of P1(v,X) is the number of paths from s to v using only edges of E1 and precisely the vertices X in F1. By definition of the vertex interval membership sequence, it is clear that every endpoint of an edge in E1 must belong to F1, so in fact P1(v,X) counts only (sv)-paths whose vertices are precisely X{v} and whose edges belong to E1. We can consider all possibilities for such a path, and hence compute P1(v,X) in time (|X|+1)!=O(ww).

Continuing inductively, suppose we have access to Pi-1(v,X) for all (v,X)Si-1. Fix (v,X)Si. We claim that

Pi(v,X)=YFi=XPi-1(v,Y)+Qis a path fromutovin(V,Ei)(YV(Q))Fi=XPi-1(u,Y). 1

Here, the first term counts the temporal paths from s to v which arrive at time at most i-1, and the second counts the temporal paths from s to v arriving at time exactly i.

To see that the first term is correct, note that any vertex in Fi which belongs to a path P arriving at v by time i-1 must also belong to Fi-1 (since it must be incident with at least one edge active at time at most i-1), so every vertex of (Fi\{v})V(P) must belong to Fi-1; the path P may contain additional vertices of Fi-1\Fi. It follows that the number of temporal (s,v)-paths arriving at v by time i-1 and whose intersection with Fi is precisely X is exactly YFi=XPi-1(v,Y).

For the second term, note that any temporal path from s to v arriving at time exactly i consists of an initial segment that reaches some vertex u at time at most i followed by a terminal segment which must be a path from u to v consisting of edges in Ei. Moreover, observe that every vertex of Fi that is visited on such a path must either be visited by the terminal segment of edges active at time i or must belong to Fi-1: if it is not visited on the terminal segment, it must be incident with at least one edge active at a time less than or equal to i-1, and by assumption (by membership of Fi) it is also incident with at least one edge active at a time greater than or equal to i, and hence it must belong to Fi-1Fi. Finally, we observe that there is a one-to-one correspondence between pairs consisting of an initial and terminal path segment meeting the aforementioned conditions and temporal paths from s to v arriving at time exactly i. Correctness of (1) now follows immediately.

It remains to bound the time required to compute the path counts for every state of each bag. Note first that |Si|w2w-1 for each i. Recall that for S1, we can compute P1(v,X) for each state (v,X)S1 in time O(ww). For i>1, we consider the time needed to compute the two terms of (1) separately. For the first term, we sum at most 2w previously computed values, requiring time O(2w). For the second term, we need to find all paths Q that use only vertices in Fi (since all endpoints of edges in Ei belong to Fi by definition) and have v as an endpoint. Since |Fi|w, we find all such paths in time O(w!)=O(ww). Given each such path, the corresponding term in the sum can be computed in constant time. Overall, therefore, the time to compute P(vX) is again O(ww). Summing over all states in Si, we see that the time required to compute the path counts for all elements of Si is O(ww+1·2w-1)=O(w2w). Summing over all sets Ft, we obtain an overall running time of O(w2w·T), as required.

Approximation Algorithms for Temporal Path Counting

In this section, we consider the problems of approximating #Temporal Path and approximating the temporal betweenness centrality. Note that #Temporal Path generalises #Path, the problem of counting (sz)-paths in a static graph, to #Temporal Path: we set every edge to be active at time one only. It is known that the static problem #Path does not admit a fully polynomial randomised approximation scheme (FPRAS) unless randomised polynomial time (RP) equals NP (see, for example, [64]). It therefore follows that there is unlikely to be an FPRAS for #Temporal Path in general; however, in Sect. 5.1, we show that there is however an FPTRAS for #Temporal Path when the maximum permitted path length is taken as the parameter. This in turn implies the existence of an FPTRAS for #Temporal Path when restrictions are placed on the structure of the underlying graph that limit the length of the longest path. We remark that Theorem 1 does not rule out exact FPT-algorithms for these parameterisations. We leave open whether stronger hardness results or exact algorithms for this case can be obtained.

In Sect. 5.2 we apply this approximation result to the problem of approximating temporal betweenness: we demonstrate that, whenever we can efficiently approximate #Temporal Path, we can efficiently estimate the maximum temporal betweenness centrality over all vertices of the input graph.

Approximately Counting Short Temporal Paths

In this subsection, we consider the complexity of approximately counting (sz)-paths parameterised by the length of the path.graphic file with name 453_2025_1301_Fige_HTML.jpg

We prove the following result.

Theorem 8

There is a randomised algorithm which, given as input an instance (G,s,z) of #Short Temporal Path together with error parameters ε>0 and 0<δ<1, outputs an estimate N^ of the number of temporal (sz)-paths in G containing exactly k edges; with probability at least 1-δ, N^ is an ε-approximation to the number of (sz)-paths in G containing exactly k edges. The running time of the algorithm is O(k!eklog(1/δ)ε-2n2T2).

The key ingredient in the proof is an efficient algorithm for the multicoloured version of this problem, in which the input graph is equipped with a vertex-colouring (not necessarily proper) and we wish to count paths containing exactly one vertex of each colour.graphic file with name 453_2025_1301_Figf_HTML.jpg

Lemma 2

#Multicoloured Temporal Path is solvable in time O((+1)!n2T2).

Proof

Given a permutation π:[][], let paths(π) be the number of temporal (sz)-paths on vertices s,v1,,v,z such that viVπ(i) for each i. It is clear that the total number of multicolour (sz)-paths is πpaths(π). Intuitively, this permutation orders the parts and we consider paths that traverse the parts in order. Since the number of such permutations is !, it suffices to demonstrate that we can compute paths(π) for any fixed permutation π in time O(n2T2).

To compute paths(π), we use a dynamic programming strategy. For a vertex vVπ(i) and a time t[T], we define completionsi(v,t) to be the number of (vz)-paths on vertices v,wi+1,,w,z, starting at or later than time t, such that wjVπ(j) for i+1j. We claim that it suffices to compute completions1(v,t) for each vertex vVπ(1) and t[T] in time O(n2T2). To see this, observe that every (sz)-path respecting the partition and permutation consists of an edge from s to some vertex vVπ(1), followed by a temporal path counted in completions1(v,t). Specifically,

paths(π)=t[T]vVπ(1)svEtcompletions1(v,t).

To compute paths(π) it therefore suffices to sum at most Tn values of completions1(v,t), after checking the existence of a single edge corresponding to each value.

We will in fact calculate completionsi(u,t) for all uVπ(i) and t[T] for each i in turn, starting with . It is easy to verify that

completions(u,t)=|{t{t,,T}:uzEt}|,

and hence we can compute completions(u,t) for all pairs (ut) in time O(t[T]|Et|). Suppose now that we have computed all values completionsi+1(u,t) for uVπ(i+1) and t[T]; we explain how to compute completionsi(w,t) for wVπ(i) and t[T]. Again, it is clear that

completionsi(w,t)=trTuVπ(i+1)wuErcompletionsi+1(u,r).

Hence, given all values completionsi+1(u,t), we can compute completionsi(w,t) for any given pair (w,t) in time O(Tn), and for all such pairs in time O(T2n2). The total time to compute completionsi(u,t) for all 1i, uVπ(i) and tT is therefore

Ot[T]|Et|+(-1)n2T2=On2T2,

as required.

Equipped with this algorithm for #Multicoloured Temporal Path, we use a standard colour-coding technique to obtain an FPTRAS for #Short Temporal Path. This involves repeatedly generating random colourings (not necessarily proper) of the vertices of V\{s,z} using k-1 colours; note that a single colouring can clearly be generated in time O(nk). For each colouring, we solve the corresponding instance of #Multicoloured Temporal Path using the algorithm of Lemma 2. Setting N to be the sum of counts over all colourings, we return Nkk/k!. Following the argument by Alon et al. [65, Section 2.1], we see that the number of colourings we must generate to obtain an ε-approximation to #Short Temporal Path with probability at least 1-δ is O(eklog(1/δ)ε-2), giving the result. We note that this approach could be derandomised in a standard way by using so-called (ϵ,k)-balanced families of hash functions (see [66]): these are families of hash functions with the property not only that at least one member of the family is injective on every size k, but that the number of such functions is roughly the same for every size k subset. However, we note that colour coding is not the only use of randomness when we use this algorithm as a subroutine to approximate temporal betweenness in the next section.

As an immediate corollary of Theorem 8, we obtain an FPTRAS for #Temporal Path restricted to any class of temporal graphs in which the maximum possible path length is bounded. In particular, we note that the maximum length of any path in the underlying graph is bounded by a function of its vertex cover number; similarly, the maximum path length is bounded by a function of the underlying graph’s treedepth.3 These observations lead to the following result.

Corollary 1

#Temporal Path admits an FPTRAS parameterised by either vertex cover number or treedepth of the underlying input graph.

Approximating Temporal Betweenness

Observe that it is not clear how to use an approximation algorithm for #Temporal Path to approximate the temporal betweenness centrality for every vertex in the input graph (we give a detailed discussion in Sect. 2.3). In this section, we address the simpler problem of determining the maximal temporal betweenness centrality of any vertex in the graph: we show that we can efficiently approximate this quantity whenever there is an FPRAS (or FPTRAS) for #Temporal Path.

Theorem 9

Let C be a class of temporal graphs on which #Temporal Path admits an FPRAS. Then C admits an FPRAS to estimate, given an input temporal graph G=(V,E,T)C, maxvVCB()(v), for {fastest, foremost}. Similarly, if C is a class of graphs on which there exists an FPTRAS for #Temporal Path with respect to some parameterisation κ then, with respect to the same parameterisation, C admits an FPTRAS to estimate, given an input temporal graph G=(V,E,T)C, maxvVCB()(v), for {fastest, foremost}.

The proof relies on the fact that we may assume that at least one vertex has temporal betweenness centrality at least 1n(T+1), where n is the number of vertices; we begin by arguing that we can efficiently identify the inputs for which this lower bound does not hold, and that in these cases the correct answer is in fact 0. Using this assumption, we show that the following procedure is likely to produce a good approximation to maxvVCB()(v): for each vertex pair (sz), sample a large (polynomial) number of -optimal temporal (sz)-paths, and record the number that contain each vertex v as an internal vertex; after considering all pairs (sz), we assume that the vertex vmax we have seen most frequently has the maximum betweenness centrality, and return as our estimate the proportion of sampled paths that contain vmax.

For the proof of Theorem 9, we need not only to be able to approximately count -optimal temporal (sz)-paths, but to sample approximately uniformly at random from the set of all -optimal temporal (sz)-paths in the input graph. To see that we can do this, we make use of a general result of Jerrum et al. [56]: for problems that are downward self-reducible (see [56] for the formal definition of this property), the existence of an FPRAS implies the existence of an FPAUS (and vice versa). We note that an analogous argument implies the same relationship for the existence of an FPTRAS and FPTAUS. It is easy to verify that the problem #Temporal Path has this crucial property of downward self-reducibility, since the solution space can be partitioned according to the first time-edge on the path (with solutions including a fixed first time-edge ({s,v},t) corresponding to temporal (vz)-paths in the temporal graph obtained by deleting s and all time-edges appearing earlier than t). It follows (using the reasoning in Sect. 2.3) that, in this setting, we also have an FPAUS (or FPTAUS) to sample fastest or foremost temporal (sz)-paths.

Lemma 3

Let C be a class of temporal graphs on which #Temporal Path admits an FPRAS. Then C also admits FPAUS to sample almost uniformly from the set of all foremost or fastest temporal (sz)-paths. Similarly, if C admits an FPTRAS with respect to some parameterisation κ, then, with respect to the same parameterisation, C also admits an FPTAUS to sample almost uniformly from the set of all foremost or fastest temporal (sz)-paths.

We will also need two standard Chernoff bounds.

Lemma 4

([55, Theorem 4.4 and Corollary 4.6]) Suppose X is a binomial random variable with mean μ. Then:

  1. for all 0<ε1,
    P(|X-μ|εμ)2e-ε2μ/3;
  2. for all R6μ,
    P(XR)2-R.

We now have all the ingredients to prove Theorem 9.

Proof of Theorem 9

We only prove the result for an FPRAS, as the argument for the FPTRAS is identical (the only change is that we additionally allow the running times of all algorithms to be of the form f(k)nO(1)). We fix an optimality measure {fastest, foremost} on which the temporal betweenness will be based.

Assume that V={v1,,vn}, and fix values ε,δ>0; we may assume w.l.o.g. that our error parameter ε satisfies ε<1, and that n>12. We shall describe a randomised algorithm which, with probability at least 2/3, returns an ε-approximation to b:=maxvVCB()(v). Using standard probability amplification techniques (running the procedure O(log(δ-1)) times and returning the median output) we can increase the success probability to 1-δ without violating the running time bounds.

Description of the algorithm. We begin by describing one special case which we handle differently; this will allow us to assume a lower bound on maxvVCB()(v) for the rest of the proof. Our algorithm starts by considering each vertex pair (sz) in turn, and determining in polynomial time whether there is any -optimal temporal (sz)-path that contains at least one internal vertex: we do this by first using a polynomial-time algorithm to find a single -optimal temporal (sz)-path, then deleting all appearances of the edge {s,z} and running the algorithm again to determine whether there is an equally good path with at least one internal vertex. If we find that there is no pair (sz) such that some -optimal temporal (sz)-path contains at least one internal vertex, it is immediate from the definition of temporal betweenness centrality that maxvVCB()(v)=0, so in this case we return zero and terminate.

If we have not terminated at this point, we know that there exists some pair (s,z)V2 such that Nsz:=vVσsz()(v)1. Note that the number of -optimal temporal (sz)-paths with no internal vertex is at most the number of appearances of the edge {s,z} in the input graph, and thus is upper bounded by T. It follows that σsz()Nsz+T. Summing the temporal betweenness centrality over all vertices, we see that

vVCB()(v)NszNsz+T11+T.

It therefore follows by the pigeonhole principle that there exists some vertex v such that CB()(v)1n(T+1). We shall exploit this fact later in the proof.

The remainder of our algorithm proceeds as follows; note that, by Lemma 3, there exists an FPAUS to sample -optimal temporal (sz)-paths in elements of C, and we shall denote the output of a single run of this FPAUS on input graph G and vertices s and z with error parameter δ by Sample(G,s,z,δ).

  1. Initialise an n-element array C with zeros.

  2. For each pair (s,z)V2:
    • If there exists at least one temporal (sz)-path in G, repeat :=300000ε-3(T+1)n3lnn times:
      • PSample(G,s,z,ε/20);
      • For 1in, if vi{s,z} and vi belongs to P then increment C[i].
  3. Select i[n] such that C[i]=max1jnC[j]. Return C[i]/.

It is clear that this procedure runs in time polynomial in n and ε-1 (note that, in the interest of a simple proof, we have made no attempt to optimise constants in the running time).

Correctness of the algorithm. We claim that in fact, with probability at least 2/3, C[i]/ is an ε-approximation to b:=maxvVCB()(v).

We begin by introducing some notation. Given s,z,vV, we will write

b(s,z)(v)=σsz()(v)/σsz()ifsvzand there exists at least one temporal(s,z)-path;0otherwise;

thus CB()(v)=(s,z)V2b(s,z)(v). For any vertex viV, let the random variable Xi(s,z) be the number of temporal (sz)-paths we sample that contain vi as an internal vertex. Set Xi=(s,z)V2Xi(s,z) to be the total number of temporal paths we sample containing vi as an internal vertex.

We will consider the contribution to our path count Xi from each of the random variables Xi(s,z). If none of these random variables has an expectation that is too small, we can argue that it is unlikely that any of them will take a value far from its expectation, so when we take the sum we will obtain a good approximation to Xi. However, some of the random variables may have very low expectation, in which case they are likely to take values that differ from their expectations by a large multiplicative factor. We treat such random variables separately, arguing that they are unlikely to take a large absolute value, and therefore that the total contribution from all such random variables is likely to have a negligible impact on the overall sum.

We define two events that correspond to the random variables behaving well in this way. Let F1 be the event that, for every pair (s,z)V2 and i[n] with E(Xi(s,z))ε/60(T+1)n3, we have |Xi(s,z)-E(Xi(s,z))|(ε/20)E(Xi(s,z)), and let F2 be the event that, for every pair (s,z)V2 and i[n] with E(Xi(s,z))<ε/60(T+1)n3, we have Xi(s,z)ε/10(T+1)n3. Later, we will derive a lower bound on the probability that both F1 and F2 hold simultaneously. First, we show that, conditioned on this event F1F2, the value returned by the algorithm will be an ε-approximation to b.

Correctness assuming F1F2 holds. This argument proceeds in two stages. First, we show that the vertex vi such that we return C[i] at Step 3 of the algorithm satisfies CB()(vi)(1-ε/2)b. Second, we show that C[i]/ is an (ε/2)-approximation to CB()(vi). Together, these two facts imply that we do indeed return a ε-approximation to b, as required.

For both stages, we will make use of bounds on Xi. Before deriving these bounds, we note that the probability pi(s,z) that a single temporal (sz)-path sampled using our FPAUS contains vi as an internal vertex satisfies (1-ε/20)b(s,z)(vi)pi(s,z)(1+ε/20)b(s,z)(vi). Since each invocation of Sample(G,s,z,ε/20) uses independent randomness, we see that Xi(s,z) has binomial distribution Bin(,pi(s,z)).

Now, for an upper bound on Xi, note that (assuming F1F2 holds) we have

Xi=(s,v)V2E(Xi(s,z))ε/60(T+1)n3Xi(s,z)+(s,v)V2E(Xi(s,z))<ε/60(T+1)n3Xi(s,z)(s,v)V2(1+ε/20)E(Xi(s,z))+(s,v)V2ε10(T+1)n3(s,v)V2(1+ε/20)2b(s,z)(vi)+ε10(T+1)n(1+3ε/20)(s,v)V2b(s,z)(vi)+ε10(T+1)n=(1+3ε/20)CB()(vi)+ε10(T+1)n. 2

On the other hand, for a lower bound, we observe that

Xi(s,v)V2E(Xi(s,z))ε/60(T+1)n3Xi(s,z)(s,v)V2E(Xi(s,z))ε/60(T+1)n3(1-ε/20)E(Xi(s,z))=(s,z)V2(1-ε/20)E(Xi(s,z))-(s,v)V2E(Xi(s,z))<ε/60(T+1)n3(1-ε/20)E(Xi(s,z))(s,z)V2(1-ε/20)E(Xi(s,z))-(s,v)V2(1-ε/20)ε60(T+1)n3(s,v)V2(1-ε/20)2b(s,z)(vi)-ε60(T+1)n(1-ε/10)(s,v)V2b(s,z)(vi)-ε60(T+1)n=(1-ε/10)CB()(vi)-ε60(T+1)n. 3

We now prove that, conditioned on the event F1F2, the vertex vi such that we return C[i]/ at Step 3 of the algorithm satisfies CB()(vi)(1-ε/2)b. To see this, suppose that we have CB()(vi)<(1-ε/2)b, and fix a vertex vj such that CB()(vj)=b. It suffices to demonstrate that Xj>Xi, as in this case we will not return a value corresponding to vi. Using the bounds in (2) and (3), we see that

Xj-Xi(1-ε/10)CB()(vj)-ε60(T+1)n-(1+3ε/20)CB()(vi)-ε10(T+1)n(1-ε/10)b-(1+3ε/20)(1-ε/2)b-7ε60(T+1)n(1-ε/10)b-(1-7ε/20)b-7ε60(T+1)n=ε4b-7ε60(T+1)n.

Recall that we know b1(T+1)n; it follows that

Xj-Xiεb14-760>0,

as required.

We now proceed to the second stage of the argument, showing that, conditioned on F1F2, if vi is the vertex corresponding to the value C[i]/ returned in Step 3 of the algorithm, Xi/ is a ε/2-approximation to CB()(vi). From the bounds (2) and (3) on Xi, it follows immediately that

Xi-CB()(vi)3εCB()(vi)20+ε10(T+1)n.

Recall that, from the previous stage, we know that CB()(vi)(1-ε/2)bb/2, using the assumption that ε<1. Since we know that b1(T+1)n, it follows that CB()(vi)12(T+1)n, and so

Xi-CB()(vi)3εCB()(vi)20+εCB()(vi)5=720εCB()(vi)<12εCB()(vi).

We therefore see that |Xi/-CB()(vi)|<(ε/2)CB()(vi), and hence Xi/ is an (ε/2)-approximation to CB()(vi), as required.

We have therefore demonstrated that our algorithm returns an ε-approximation to b whenever the event F1F2 holds; it remains to prove that this event holds with probability at least 2/3.

Bounding the probability of F1F2. We shall in fact prove that each of F1 and F2 holds with probability at least 5/6, so that the claimed result follows immediately by a union bound.

We start by considering F1. Let Y be a binomial random variable whose expectation is at least ε/60(T+1)n3. By Lemma 4(i), we have

P|Y-E(Y)|(ε/20)E(Y)2exp-ε2400E(Y)32exp-ε372000(T+1)n3<2exp-4lnn<1/6n3.

Taking a union bound over all possible choices of s, z and i, we therefore see that the probability that any random variable Xi(s,z) whose expectation is at least ε/60(T+1)n3 takes a value that differs from its expectation by more than (ε/20)E(Xi(s,z)) is at most 1/6. It follows immediately that F1 holds with probability at least 5/6.

Finally, we consider F2. Let Y be any binomial random variable whose expectation is at most ε/60(T+1)n3. By Lemma 4(ii), we have

PYε10(T+1)n32-ε/10(T+1)n3=2-30000ε-2lnn<1/6n3.

Again taking a union bound over all possible choices of s, z and i, we therefore see that the probability that any random variable Xi(s,z) whose expectation is at most ε/60(T+1)n3 takes a value greater than ε/10(T+1)n3 is at most 1/6, so F2 holds with probability at least 5/6. This completes the proof.

Combining Theorem 9 with Corollary 1 gives the following immediate corollary.

Corollary 2

There is an FPTRAS which, given as input a temporal graph G=(V,E,T), computes an approximation to maxvVCB()(v) (for {fastest, foremost}), parameterised by either the vertex cover number or treedepth of the underlying input graph.

Conclusion

In this work, we initiate the systematic study of the parameterised and approximation complexity of #Temporal Path. We present parameterised and approximation hardness results and complement them with several parameterised exact and approximation algorithms.

In terms of improving our results, we conjecture that it is possible to prove #W[1]-hardness instead of W[1]-hardness for #Temporal Path parameterised by the feedback vertex number of the underlying graph. Furthermore, we leave open whether our parameterised approximation results for vertex cover number or treedepth of the underlying graph can be improved from a classification standpoint by obtaining exact algorithms, or whether we can also show parameterised hardness for those cases.

We leave open to what extent our results transfer to the problem of counting strict temporal (sz)-paths, where the labels on the time-edges have to be strictly increasing. We conjecture that most of our results hold for the strict case. In fact, we believe that the MSO formulation used to obtain fixed-parameter tractability for the treewidth of the underlying graph combined with the lifetime can be simplified: in the strict case, a first-order formula should suffice, which would lead to fixed-parameter tractability in terms of the lifetime on any class of nowhere-dense graphs [68], or for the combined parameter of cliquewidth and lifetime [69].

We conjecture that our polynomial-time algorithm for the case where the underlying graph is a forest (Sect. 4.1) can be extended to the case where the underlying graph is series–parallel [70]. Recall that a forest can be seen as a series–parallel graph where only series compositions are used. The idea would be to extend the dynamic program to parallel compositions, exploiting the observation that any temporal path can visit the terminal vertices of a series–parallel graph at most once.

Finally, we believe that our FPT-algorithms presented in Sect. 4.2 for the timed feedback vertex number and feedback edge number of the underlying graph, respectively, can be adapted to count other types of temporal (sz)-paths for which counting is in general #P-hard. This leads us to believe that the algorithms can be modified to count restless temporal (sz)-paths [18] and possibly also to count delay-robust (sz)-routes [19], since both of these path types can be found in polynomial time when the underlying graph of the input temporal graph is a forest.

Acknowledgements

This work was initiated at the Dagstuhl Seminar “Temporal Graphs: Structure, Algorithms, Applications” (Dagstuhl Seminar Nr. 21171). An extended abstract of this work appeared in the proceedings of the 40th International Symposium on Theoretical Aspects of Computer Science (STACS ’23) [71]. This version contains full proof details.

Author Contributions

All authors contributed equally to the manuscript.

Funding

Open access funding provided by Ben-Gurion University. J. Enright is supported by EPSRC grant EP/T004878/1. K. Meeks is supported by EPSRC grants EP/T004878/1 and EP/V032305/1. H. Molter is supported by the ISF, grants No. 1456/18 and No. 1070/20, and the European Union’s Horizon Europe research and innovation programme under grant agreement 949707.

Declarations

Conflict of interest

The authors declare no competing interests.

Footnotes

1

Temporal paths that traverse time-edge with non-decreasing time labels are often referred to as “non-strict”, in contrast to strict temporal paths, which traverse time-edges with increasing time labels. In this work, we focus on non-strict temporal paths.

2

Informally speaking, parsimonious reductions do not change the number of solutions.

3

We refer to the book of Nesetril and de Mendez [67] for the definition of treedepth, and a proof that the maximum length of a path in a graph is bounded by a function of its treedepth.

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Contributor Information

Jessica Enright, Email: jessica.enright@glasgow.ac.uk.

Kitty Meeks, Email: kitty.meeks@glasgow.ac.uk.

Hendrik Molter, Email: molterh@post.bgu.ac.il.

References

  • 1.Freeman, L.C.: A set of measures of centrality based on betweenness. Sociometry 40(1), 35–41 (1977) [Google Scholar]
  • 2.Brandes, U.: A faster algorithm for betweenness centrality. J. Math. Sociol. 25(2), 163–177 (2001) [Google Scholar]
  • 3.Valiant, L.G.: The complexity of enumeration and reliability problems. SIAM J. Comput. 8(3), 410–421 (1979) [Google Scholar]
  • 4.Holme, P.: Modern temporal network theory: a colloquium. Eur. Phys. J. B 88, 1–30 (2015) [Google Scholar]
  • 5.Holme, P., Saramäki, J.: Temporal Network Theory. Springer, New York (2019) [Google Scholar]
  • 6.Latapy, M., Viard, T., Magnien, C.: Stream graphs and link streams for the modeling of interactions over time. Soc. Netw. Anal. Min. 8, 1–29 (2018) [Google Scholar]
  • 7.Michail, O.: An introduction to temporal graphs: An algorithmic perspective. Internet Math. 12(4), 239–280 (2016) [Google Scholar]
  • 8.Kempe, D., Kleinberg, J., Kumar, A.: Connectivity and inference problems for temporal networks. J. Comput. Syst. Sci. 64(4), 820–842 (2002) [Google Scholar]
  • 9.Bui-Xuan, B.-M., Ferreira, A., Jarry, A.: Computing shortest, fastest, and foremost journeys in dynamic networks. Int. J. Found. Comput. Sci. 14(02), 267–285 (2003) [Google Scholar]
  • 10.Wu, H., Cheng, J., Ke, Y., Huang, S., Huang, Y., Wu, H.: Efficient algorithms for temporal path computation. IEEE Trans. Knowl. Data Eng. 28(11), 2927–2942 (2016) [Google Scholar]
  • 11.Buß, S., Molter, H., Niedermeier, R., Rymar, M.: Algorithmic aspects of temporal betweenness. Netw. Sci. 12(2), 160–188 (2024) [Google Scholar]
  • 12.Rymar, M., Molter, H., Nichterlein, A., Niedermeier, R.: Towards classifying the polynomial-time solvability of temporal betweenness centrality. J. Graph Algorithms Appl. 27(3), 173–194 (2023) [Google Scholar]
  • 13.Habiba, H., Tantipathananandh, C., Berger-Wolf, T.: Betweenness centrality measure in dynamic networks. Technical Report 19, Department of Computer Science, University of Illinois at Chicago, Chicago. DIMACS Technical Report (2007)
  • 14.Kim, H., Anderson, R.: Temporal node centrality in complex networks. Phys. Rev. E 85(2), 026107 (2012) [DOI] [PubMed] [Google Scholar]
  • 15.Mutzel, P., Oettershagen, L.: On the enumeration of bicriteria temporal paths. In: Proceedings of the 15th Annual Conference on Theory and Applications of Models of Computation (TAMC ’19). Lecture Notes in Computer Science, vol. 11436, pp. 518–535 (2019)
  • 16.Rad, A.A., Flocchini, P., Gaudet, J.: Computation and analysis of temporal betweenness in a knowledge mobilization network. Comput. Soc. Netw. 4(1), 5 (2017) [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 17.Bentert, M., Himmel, A.-S., Nichterlein, A., Niedermeier, R.: Efficient computation of optimal temporal walks under waiting-time constraints. Appl. Netw. Sci. 5(1), 73 (2020) [Google Scholar]
  • 18.Casteigts, A., Himmel, A.-S., Molter, H., Zschoche, P.: Finding temporal paths under waiting time constraints. Algorithmica 83(9), 2754–2802 (2021) [Google Scholar]
  • 19.Füchsle, E., Molter, H., Niedermeier, R., Renken, M.: Delay-robust routes in temporal graphs. In: Proceedings of the 39th International Symposium on Theoretical Aspects of Computer Science (STACS ’22). LIPIcs, vol. 219, pp. 30–13015 (2022)
  • 20.Klobas, N., Mertzios, G.B., Molter, H., Niedermeier, R., Zschoche, P.: Interference-free walks in time: temporally disjoint paths. Auton. Agent. Multi Agent Syst. 37(1), 1 (2023) [Google Scholar]
  • 21.Kunz, P., Molter, H., Zehavi, M.: In which graph structures can we efficiently find temporally disjoint paths and walks? In: Proceedings of the 32nd International Joint Conference on Artificial Intelligence (IJCAI), pp. 180–188 (2023)
  • 22.Alsayed, A., Higham, D.J.: Betweenness in time dependent networks. Chaos Solitons Fractals 72, 35–48 (2015) [Google Scholar]
  • 23.Nicosia, V., Tang, J., Mascolo, C., Musolesi, M., Russo, G., Latora, V.: Graph metrics for temporal networks. In: Temporal Networks, pp. 15–40. Springer, Berlin (2013) [Google Scholar]
  • 24.Simard, F., Magnien, C., Latapy, M.: Computing betweenness centrality in link streams. J. Graph Algorithms Appl. 27(3), 195–217 (2023) [Google Scholar]
  • 25.Tang, J., Leontiadis, I., Scellato, S., Nicosia, V., Mascolo, C., Musolesi, M., Latora, V.: Applications of temporal graph metrics to real-world networks. In: Temporal Networks, pp. 135–159. Springer, Berlin (2013) [Google Scholar]
  • 26.Tang, J., Musolesi, M., Mascolo, C., Latora, V., Nicosia, V.: Analysing information flows and key mediators through temporal centrality metrics. In: Proceedings of the 3rd ACM Workshop on Social Network Systems, pp. 3–136. ACM (2010)
  • 27.Tsalouchidou, I., Baeza-Yates, R., Bonchi, F., Liao, K., Sellis, T.: Temporal betweenness centrality in dynamic graphs. Int. J. Data Sci. Anal. 9(3), 257–272 (2020) [Google Scholar]
  • 28.Axiotis, K., Fotakis, D.: On the size and the approximability of minimum temporally connected subgraphs. In: Proceedings of the 43rd International Colloquium on Automata, Languages, and Programming (ICALP’16), pp. 149–114914 (2016)
  • 29.Casteigts, A., Peters, J.G., Schoeters, J.: Temporal cliques admit sparse spanners. J. Comput. Syst. Sci. 121, 1–17 (2021) [Google Scholar]
  • 30.Fluschnik, T., Molter, H., Niedermeier, R., Renken, M., Zschoche, P.: Temporal graph classes: A view through temporal separators. Theor. Comput. Sci. 806, 197–218 (2020) [Google Scholar]
  • 31.Maack, N., Molter, H., Niedermeier, R., Renken, M.: On finding separators in temporal split and permutation graphs. J. Comput. Syst. Sci. 135, 1–14 (2023) [Google Scholar]
  • 32.Molter, H.: The complexity of finding temporal separators under waiting time constraints. Inf. Process. Lett. 175, 106229 (2022) [Google Scholar]
  • 33.Zschoche, P., Fluschnik, T., Molter, H., Niedermeier, R.: The complexity of finding separators in temporal graphs. J. Comput. Syst. Sci. 107, 72–92 (2020) [Google Scholar]
  • 34.Deligkas, A., Potapov, I.: Optimizing reachability sets in temporal graphs by delaying. Inf. Comput. 285(Part B), 104890 (2022) [Google Scholar]
  • 35.Enright, J., Meeks, K., Mertzios, G.B., Zamaraev, V.: Deleting edges to restrict the size of an epidemic in temporal networks. J. Comput. Syst. Sci. 119, 60–77 (2021) [Google Scholar]
  • 36.Enright, J., Meeks, K., Skerman, F.: Assigning times to minimise reachability in temporal graphs. J. Comput. Syst. Sci. 115, 169–186 (2021) [Google Scholar]
  • 37.Molter, H., Renken, M., Zschoche, P.: Temporal reachability minimization: delaying vs. deleting. J. Comput. Syst. Sci. 144, 103549 (2024) [Google Scholar]
  • 38.Akrida, E.C., Mertzios, G.B., Spirakis, P.G., Raptopoulos, C.L.: The temporal explorer who returns to the base. J. Comput. Syst. Sci. 120, 179–193 (2021) [Google Scholar]
  • 39.Bodlaender, H.L., Zanden, T.C.: On exploring always-connected temporal graphs of small pathwidth. Inf. Process. Lett. 142, 68–71 (2019) [Google Scholar]
  • 40.Bumpus, B.M., Meeks, K.: Edge exploration of temporal graphs. Algorithmica 85(3), 688–716 (2023) [Google Scholar]
  • 41.Erlebach, T., Hoffmann, M., Kammer, F.: On temporal graph exploration. J. Comput. Syst. Sci. 119, 1–18 (2021) [Google Scholar]
  • 42.Erlebach, T., Kammer, F., Luo, K., Sajenko, A., Spooner, J.T.: Two moves per time step make a difference. In: Proceedings of the 46th International Colloquium on Automata, Languages, and Programming (ICALP ’19). LIPIcs, vol. 132, pp. 141–114114 (2019)
  • 43.Erlebach, T., Spooner, J.T.: Non-strict temporal exploration. In: Proceedings of the 27th International Colloquium on Structural Information and Communication Complexity (SIROCCO ’20). Lecture Notes in Computer Science, vol. 12156, pp. 129–145 (2020)
  • 44.Akrida, E.C., Gasieniec, L., Mertzios, G.B., Spirakis, P.G.: The complexity of optimal design of temporally connected graphs. Theory Comput. Syst. 61(3), 907–944 (2017) [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 45.Klobas, N., Mertzios, G.B., Molter, H., Spirakis, P.G.: The complexity of computing optimum labelings for temporal connectivity. J. Comput. Syst. Sci. 146, 103564 (2024) [Google Scholar]
  • 46.Mertzios, G.B., Michail, O., Spirakis, P.G.: Temporal network optimization subject to connectivity constraints. Algorithmica 81(4), 1416–1449 (2019) [Google Scholar]
  • 47.Füchsle, E., Molter, H., Niedermeier, R., Renken, M.: Temporal connectivity: coping with foreseen and unforeseen delays. In: Proceedings of the 1st Symposium on Algorithmic Foundations of Dynamic Networks (SAND ’22). LIPIcs, vol. 221, pp. 17–11717 (2022)
  • 48.Haag, R., Molter, H., Niedermeier, R., Renken, M.: Feedback edge sets in temporal graphs. Discrete Appl. Math. 307, 65–78 (2022) [Google Scholar]
  • 49.Flum, J., Grohe, M.: The parameterized complexity of counting problems. SIAM J. Comput. 33(4), 892–922 (2004) [Google Scholar]
  • 50.Arvind, V., Raman, V.: Approximation algorithms for some parameterized counting problems. In: Bose, P., Morin, P. (eds.) Proceedings of the 13th International Symposium on Algorithms and Computation (ISAAC’02). Lecture Notes in Computer Science, vol. 2518, pp. 453–464 (2002)
  • 51.Downey, R.G., Fellows, M.R.: Fundamentals of Parameterized Complexity. Springer, London (2013) [Google Scholar]
  • 52.Flum, J., Grohe, M.: Parameterized complexity theory. In: Texts in Theoretical Computer Science. An EATCS Series, vol. XIV (2006)
  • 53.Cygan, M., Fomin, F.V., Kowalik, Ł, Lokshtanov, D., Marx, D., Pilipczuk, M., Pilipczuk, M., Saurabh, S.: Parameterized Algorithms. Springer, Cham (2015) [Google Scholar]
  • 54.Björklund, A., Dell, H., Husfeldt, T.: The parity of set systems under random restrictions with applications to exponential time problems. In: Proceedings of the 42nd International Colloquium on Automata, Languages, and Programming (ICALP ’15), pp. 231–242 (2015). Springer
  • 55.Mitzenmacher, M., Upfal, E.: Probability and Computing: Randomization and Probabilistic Techniques in Algorithms and Data Analysis, 2nd edn. Cambridge University Press, Cambridge (2017) [Google Scholar]
  • 56.Jerrum, M.R., Valiant, L.G., Vazirani, V.V.: Random generation of combinatorial structures from a uniform distribution. Theor. Comput. Sci. 43, 169–188 (1986) [Google Scholar]
  • 57.Jiang, M.: On the parameterized complexity of some optimization problems related to multiple-interval graphs. Theor. Comput. Sci. 411(49), 4253–4262 (2010) [Google Scholar]
  • 58.Gavril, F.: The intersection graphs of subtrees in trees are exactly the chordal graphs. J. Comb. Theory Ser. B 16(1), 47–56 (1974) [Google Scholar]
  • 59.van Bevern, R., Mnich, M., Niedermeier, R., Weller, M.: Interval scheduling and colorful independent sets. J. Sched. 18(5), 449–469 (2015) [Google Scholar]
  • 60.Bentert, M., van Bevern, R., Niedermeier, R.: Inductive Inline graphic-independent graphs and Inline graphic-colorable subgraphs in scheduling: a review. J. Sched. 22(1), 3–20 (2019) [Google Scholar]
  • 61.Blair, J.R., Peyton, B.: An introduction to chordal graphs and clique trees. In: Graph Theory and Sparse Matrix Computation, pp. 1–29. Springer, New York (1993) [Google Scholar]
  • 62.Bentert, M., Dittmann, A., Kellerhals, L., Nichterlein, A., Niedermeier, R.: An adaptive version of Brandes’ algorithm for betweenness centrality. J. Graph Algorithms Appl. 24(3), 483–522 (2020) [Google Scholar]
  • 63.Courcelle, B., Engelfriet, J.: Graph Structure and Monadic Second-Order Logic: A Language-Theoretic Approach. Encyclopedia of Mathematics and its Applications, Cambridge University Press, Cambridge (2012) [Google Scholar]
  • 64.Yamamoto, M.: Approximately counting paths and cycles in a graph. Discrete Appl. Math. 217, 381–387 (2017) [Google Scholar]
  • 65.Alon, N., Dao, P., Hajirasouliha, I., Hormozdiari, F., Sahinalp, S.C.: Biomolecular network motif counting and discovery by color coding. In: Proceedings 16th International Conference on Intelligent Systems for Molecular Biology (ISMB ’08), pp. 241–249 (2008) [DOI] [PMC free article] [PubMed]
  • 66.Alon, N., Gutner, S.: Balanced families of perfect hash functions and their applications. ACM Trans. Algorithms 6(3), 1–12 (2010) [Google Scholar]
  • 67.Nesetril, J., Mendez, P.O.: Sparsity—Graphs, Structures, and Algorithms. Algorithms and Combinatorics, vol. 28. Springer, Berlin (2012) [Google Scholar]
  • 68.Grohe, M., Schweikardt, N.: First-order query evaluation with cardinality conditions. In: Proceedings of the 37th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems (SIGMOD/PODS ’18), pp. 253–266 (2018)
  • 69.Courcelle, B., Makowsky, J.A., Rotics, U.: On the fixed parameter complexity of graph enumeration problems definable in monadic second-order logic. Discrete Appl. Math. 108(1), 23–52 (2001) [Google Scholar]
  • 70.Eppstein, D.: Parallel recognition of series-parallel graphs. Inf. Comput. 98(1), 41–55 (1992) [Google Scholar]
  • 71.Enright, J.A., Meeks, K., Molter, H.: Counting temporal paths. In: Proceedings of the 40th International Symposium on Theoretical Aspects of Computer Science (STACS ’23). LIPIcs, vol. 254, pp. 30–13019 (2023)

Articles from Algorithmica are provided here courtesy of Springer

RESOURCES