# Efficient computation of optimal temporal walks under waiting-time constraints

## Abstract

Node connectivity plays a central role in temporal network analysis. We provide a broad study of various concepts of walks in temporal graphs, that is, graphs with fixed vertex sets but arc sets changing over time. Taking into account the temporal aspect leads to a rich set of optimization criteria for “shortest” walks. Extending and broadening state-of-the-art work of Wu et al. [IEEE TKDE 2016], we provide an algorithm for computing shortest walks that is capable to deal with various optimization criteria and any linear combination of these. It runs in O(|V|+|E|log|E|) time where |V| is the number of vertices and |E| is the number of time-arcs. A central distinguishing factor to Wu et al.’s work is that our model allows to, motivated by real-world applications, respect waiting-time constraints for vertices, that is, the minimum and maximum waiting time allowed in intermediate vertices of a walk. Moreover, other than Wu et al. our algorithm also allows to search for walks that pass multiple subsequent time-arcs in one time step, and it can deal with a richer set of optimization criteria. Our experimental studies indicate that our richer modeling can be achieved without significantly worsening the running time when compared to Wu et al.’s algorithms.

## Introduction

Computing shortest paths in networks is arguably among the most important graph algorithms. It is relevant in numerous application contexts and used as a subroutine in a highly diverse set of applications. While the respective problem has been studied for static graphs for decades, over the last years there has been an intensified interest in studying shortest path computations in temporal graphs—graphs where the vertex set remains static, but the arc set may change over time (in discrete time steps).

Two natural motivating examples for the relevance of path and walk (in the later one may visit a vertex multiple times) computations in temporal graphs are as follows. First, Wu et al. (2016) discussed applications in flight networks where every node represents an airport and each arc represents a flight connection with a departure time. Clearly, a “shortest” path may then relates to a most convenient flight connection between two cities. Second, understanding the spread of infectious diseases is a major challenge to global health. Herein, nodes represent persons and time-labeled arcs represent contacts between persons where a virus can be transmitted. “Shortest” path (walk) analysis here may help to find measures against disease spreading (Newman 2018, Chapter 17). Notably, in both examples one might need to also take into account issues such as different concepts of “shortest”—also called optimal—paths (walks) or waiting times in nodes; this will be an important aspect of our modeling.

Our main reference point is the work of Wu et al. (2016) on efficient algorithms for optimal temporal path computation. These algorithms are also implemented in the temporal graph library of Apache Flink (Lightenberg et al. 2018). We extend their model with respect to two aspects. First, we additionally consider waiting-time constraintsFootnote 1 for the network nodes, that is, a minimum time a walk must spend in a node before continuing and a maximum time a walk can stay in a node before it has to continue. Minimum waiting times can be used to model that passengers on an airport need some time to get from an arriving flight to the terminal for their next flight and maximum waiting times can be used to model recover times of patients after which they can no longer infect other people. Importantly, maximum-waiting-time constraints can enforce cycles from one node to another; refer to Fig. 1 for a simple example. Hence, we need to take into account optimal temporal walks from one node to another (in Wu et al.’s model without waiting-time constraints there is always an (optimal) temporal path visiting no node twice because no cycles are necessary).

Actually, if one insists on paths (without repeated nodes) instead of walks, then even deciding whether there exists a path between two nodes becomes NP-hard (Casteigts et al. 2019).

The second extension to Wu et al.’s work lies in an increased number of optimality criteria (different notions of optimal walks) and the fact that we do not only deal with optimizing one criterion but a linear combination of any of these, thus addressing potentially richer modeling needs in real-world applications. For example, in the above-mentioned flight network a traveling person might want to use our algorithm to optimize a linear combination of cost and travel duration. Note that trying to find walks under constraints (e.g., travel duration at most tand cost at most c for given c,t) leads to NP-hard computational problems, even in the static case (Ahuja et al. 1993).

Related Work. The theory of temporal graphs is a relatively young but active field of research (Holme 2015; Holme and Saramäki 2012; Holme and Saramäki 2013; Holme and Saramäki 2019). Many of the basic concepts of temporal graphs such as temporal connectivity (Kempe et al. 2002; Nicosia et al. 2012; Axiotis and Fotakis 2016; Mertzios et al. 2019) or s-z-separation (Zschoche et al. 2020; Fluschnik et al. 2020) are based on the notion of temporal paths and walks. The concept of optimal temporal walks plays a central role in the definition of temporal graph metrics such as eccentricity, diameter, betweenness and closeness centrality (Pan and Saramäki 2011; Santoro et al. 2011; Kim and Anderson 2012; Buß et al. 2020).

An early algorithm for computing optimal temporal walks is due to Xuan et al. (2003). They computed temporal walks under different optimization criteria, namely foremost, fastest, and minimum hop-count. Wu et al. (2016) followed up by introducing algorithms for computing optimal walks for the optimization criteria foremost, reverse-foremost, fastest, and shortest on temporal graphs with no waiting-time constraints. Their algorithms run in linear and quasi-linear time with respect to the number of time-arcs, provided that transmission times on time-arcs are greater than zero. Concerning time-dependent multicriteria optimal path computation, there has been research in the related field of route planning (Bast et al. 2016).

The study of minimum- and maximum-waiting-time constraints in vertices has not received much attention in the context of temporal walks even though they are considered as important extensions to the temporal walk model (Holme and Saramäki 2012; Pan and Saramäki 2011). One of the first papers to consider waiting-time constraints in the context of paths is due to Dean (Dean 2004). Dean showed that time-dependent shortest path problems with waiting constraints can be solved in polynomial time. Dean’s setting is closely related to waiting-time constraints for optimal temporal walks. In more recent work, Modiri et al. (2019) and Kivelä et al. (2018) studied the changes in reachability when introducing maximum-waiting time constraints for temporal walks using so-called event graphs. Lastly, Casteigts et al. (2019) have very recently shown that finding optimal temporal paths under maximum-waiting-time constraints is NP-hard.

In the so-called multistage setting, where multiple graphs over the same vertex set are considered without a (temporal) ordering, paths have been studied by Fluschnik et al. (2020).

Our Contributions. We analyze the running time complexity of computing optimal temporal walks under waiting-time constraints. To this end, we develop and (theoretically and empirically) analyze an algorithm for finding an optimal walk from a source vertex to each vertex in the temporal graph under waiting-time constraints. Our algorithm runs in quasi-linear time in the number of time-arcs. This implies that the additional consideration of waiting-time constraints on temporal walks does not increase the asymptotic computational complexity of finding optimal temporal walks. Moreover, our algorithm can compute optimal walks not only for single optimality criteria but also for any linear combination of these. In experiments on real-world social network data sets, we demonstrate that in terms of efficiency our algorithm can compete with state-of-the-art algorithms by Wu et al. (2016). Their algorithms only run on temporal graphs without waiting-time constraints, which do optimize only one criterion (and not a linear combination). Additionally, our algorithm allows transmission times being zero (hence, allowing to pass multiple arcs in one time step) while the algorithms of Wu et al. request transmission times on arcs to be greater than zero.

Organization of the Paper. In “Modeling of optimal temporal walks” section, we discuss temporal graphs, temporal walks, and the various corresponding optimality criteria, starting with an extensive motivating example in the context of disease spreading. In “Formal definitions” section, we introduce definitions and notations used throughout the paper. We continue in “Transformation” section by presenting two simple linear-time transformations to eliminate transmission times and minimum waiting times in the temporal graph without loosing any modeling power. In “Algorithm” section, we design and analyze an algorithm for computing optimal walks under maximum-waiting-time for any linear combination of these. Finally, in “Experimental results” section, we demonstrate the efficiency of our algorithm on real-world data sets. We compare our running times with the running times of the algorithms of Wu et al. (2016). We further examine the impact of different maximum-waiting-time values on the existence and structure of optimal temporal walks.

## Modeling of optimal temporal walks

Before we introduce our basic concepts relating to temporal graphs and walks, we start with a more extensive discussion of a motivating example from the disease spreading context.

Disease Spreading Motivating Example. Pandemic spread of an infectious disease is a great threat to global health, potentially associated with high mortality rates as well as economic fallout (Salathé et al. 2010). Understanding the dynamics of infectious disease spreading within human proximity networks could facilitate the development of mitigation strategies.

A large part of the study required to understand the dynamics of infectious diseases is the analysis of transmission routes through proximity networks (Salathé et al. 2010). Classical graph theory can be used to model the main structure of a network: Each person in the network is represented by a node and an arc between two nodes indicates the possibility of an infection from one person to the other. However, the time component plays a crucial role in the analysis of transmission routes of a potential disease as shown in the following example:

### Example 1

Studying a proximity network as shown in Fig. 2a, there are several transmission routes from A to D, e.g., ABD and ACD, by which a disease could have spread. If we extend our model by the points in time of proximity contacts in Fig. 2b to d, then we reach the conclusion that a disease could not have spread from A to D. The proximity contacts $$A\overset {3}{\rightarrow } B$$ and $$A \overset {3}{\rightarrow } C$$ occurred on day three whereas the contacts $$B \overset {1}{\rightarrow } D$$ and $$C \overset {2}{\rightarrow } D$$ occurred on days one and two, respectively. Thus, A could have only infected B and C after proximity contact with D. ■

In addition to what has been said so far, the infectious period of a disease also has to be taken into account when computing potential transmission routes through the network, implying the minimum time a person has to be infected before she becomes contagious herself and the maximum time a person can be infected before she is no longer contagious:

### Example 2

If person B was infected by person A on day four ($$A \overset {4}{\rightarrow } B$$) and the infectious period of the disease starts after one day and ends after the fourth day, then person B could not have infected person C she met on day ten ($$B \overset {10}{\rightarrow } C$$). Hence, person C could not have been infected by the disease via the transmission route $$A \overset {4}{\rightarrow } B \overset {10}{\rightarrow }C$$. ■

Temporal Graphs. These are capable of modeling both properties elaborated in the two examples above. Temporal graphs are already a frequently used model in the prediction and control of infectious diseases (Masuda and Holme 2013; Holme 2016). Temporal graphs—also referred to as temporal networks (Nicosia et al. 2013; Holme and Saramäki 2012), evolving graphs (Xuan et al. 2003), or time-varying graphs (Santoro et al. 2011; Casteigts et al. 2012)—are graphs where the arc set changes over time; thus, they can capture the dynamics within a proximity network.

In this paper, we will consider the following temporal graph model: A temporal graph consists of a set of vertices, a set of time-arcs, and a lifetime. A time-arc is a (directed) arc between two vertices that is associated with a time stamp at which the contact occurs and a transmission time that indicates the amount of time to traverse the arc. Furthermore, each vertex v is assigned an individual minimum waiting time α(v) and maximum waiting time β(v).

The application areas of temporal graphs are numerous: In addition to human and animal proximity networks, they are used in communication networks, traffic networks, and distributed computing, to name a few application areas (Holme and Saramäki 2012; Holme and Saramäki 2013; Holme and Saramäki 2019).

In our running disease spreading example, we are interested in transmission routes of an infectious disease. These transmission routes can revisit a person in the proximity network due to possible reinfection (Barabási 2016). Hence, the transmission routes can contain cycles which needs to be considered in the choice of concepts representing these routes.

Temporal Walks & Optimal Temporal Walks. Within the temporal graph model, temporal walks—also called journeys (Xuan et al. 2003; Nicosia et al. 2013)—are the fundamental concept that represents the transmission routes in our running example.

A temporal walk is a sequence of time-arcs which connects a sequence of vertices and which are non-decreasing in time. In our model, a temporal walk additionally ensures that it remains the minimum waiting time in each intermediate vertex and does not exceed the maximum waiting time in any intermediate vertex of the walk.

### Example 3

Continuing Example 2, a valid temporal walk (transmission route) from A to D could be the following: $$A \overset {4}{\rightarrow } B \overset {8}{\rightarrow } D$$. Person A could have infected B on day four. Due to the infectious period of four days, B was still contagious on day eight when she had contact with person C. This does not hold on a route $$A \overset {4}{\rightarrow } B \overset {10}{\rightarrow } C$$ as discussed in Example 2. If B was infected at time step 4, then she was not contagious anymore at time step 10. ■

A temporal path is a temporal walk where all vertices are pairwise distinct. Maximum-waiting-time constraints have significant impact on temporal walks. In a temporal graph with constraints on the maximum waiting time, one can be forced to make detours because the maximum waiting time in a vertex is exceeded. As a consequence, there can be two vertices A and C such that any temporal walk from A to C is not a path, as shown in Fig. 1.

### Observation 1

Let $$\mathcal {G} = (V,E,T, \beta)$$ be a temporal graph with maximum-waiting-time constraints. Then there can exist two vertices s,zV such that no s-z-walk is a temporal path.

We are interested in temporal walks within our proximity network in general, but wish to place emphasis on temporal walks that optimize certain properties. A plethora of criteria can be optimized as a consequence of the time aspect. Possible criteria (with the chosen names in brackets) include: arrival time (foremost), departure time (reverse-foremost), duration (fastest), transmission time (shortest), number of time-arcs (minimum hop-count), time-arc cost (cheapest), probability (most-likely), and waiting time (minimum waiting time). Next, we provide examples for all properties from their respective fields of application. Foremost. A foremost walk is a temporal walk that has the earliest arrival time. Computing a foremost walk from a source vertex to all vertices in the proximity network determines the speed with which an infectious disease could spread. Reverse-Foremost. A reverse-foremost walk is a temporal walk that exhibits the latest possible departure time. Computing a reverse-foremost walk from a source vertex to all vertices in the proximity network estimates the latest possible point in time at which an infectious disease could start spreading and still permeates the entire network. Fastest. A fastest walk is a temporal walk which exhibits the minimum travel duration, that is, the minimum difference between departure and arrival times. For an appropriate motivation, we leave proximity networks and consider the field of flight networks. Airports represent vertices, time-arcs represent flights from one airport to another. The time stamp of a time-arc indicates the departure time of a flight, the transmission time of the arc indicates the flight duration. The minimum waiting time in the vertices signifies the minimum time required to spend in an airport to catch a connecting flight. Within flight networks, the duration is often the criterion passengers aim to minimize in order to streamline their journeys. Shortest. A shortest walk is a temporal walk that minimizes the sum of transmission times on the time-arcs. In the context of flight networks, a shortest walk is a flight connection with the minimum time spent airborne. Minimum Hop-Count. A minimum-hop-count walk is a temporal walk which minimizes the number of time-arcs. Within a flight network, passengers also aim to minimize their number of connecting flights to avoid lengthy boarding procedures and the risk of missing connecting flights. Cheapest. For a given cost function on the time-arcs, a cheapest walk is a temporal walk with the minimum sum of costs over all time-arcs. The benefits of the minimization of this property within flight networks are obvious: Weighing long travel times and multiple connections against the cheapest fare is the oldest consideration in the book for many air travelers. Most-Likely. For given probabilities on the time-arcs, a most-likely walk is a temporal walk with the highest probability. One application lies in disease spreading: For every contact there is a certain likelihood for an infectious disease to be transmitted depending on the proximity of the persons or the body contact between them. Thus, a most-likely walk is a transmission route with the highest probability for the infectious disease to be spread under the simplifying assumption of stochastic independence. The respective probabilities of the time-arcs within the walk are multiplied. Minimum Waiting Time. The minimum-waiting-time walk is a temporal walk whose total sum of waiting times over all intermediate vertices is minimum. Routing packets through a router network prioritizes minimum waiting times of packages in the routers to improve the overall performance of the network.

## Formal definitions

In this section, we formally introduce the most important concepts related to temporal graphs, temporal walks, and formalize our optimality criteria. We start with some basic mathematical definitions. We refer to an interval [a,b] as a contiguous ordered set of discrete time steps: [a,b]:={nnanb}, where a,b. Further, [a]:=[1,a]. Given a function f:AB, we write fc if f(a)=c for all aA and cB.

Temporal Graphs. A temporal graph is a graph whose arc set changes over time.

### Definition 1

(Temporal Graph) A temporal graph $$\mathcal {G} = (V,E,T, \alpha, \beta)$$ is a five-tuple consisting of

• a vertex set V,

• a time-arc set EV×V×{1,…,T}×{0,…,T},

• a minimum waiting time α:V→{0,…,T}, and

• a maximum waiting time β:V→{0,…,T}.

We remark that the central modeling aspect in our work—the minimum and maximum waiting times—is so far not commonly part of the definition of temporal graphs. A time-arc (v,w,t,λ)E is a directed connection from v to w with time stamp t and transmission time λ, that is, a transmission from v to w starting at time step t and taking λ time steps to cross the arc. The departure time in vertex v is t; the arrival time in vertex w is then t+λ. The two waiting-time functions $$\alpha \colon V \rightarrow \mathbb{N}$$ and $$\beta \colon V \rightarrow \mathbb{N}$$ assign each vertex a minimum and maximum waiting time, respectively. The minimum waiting time α(v) is the minimum time a person has to stay in a vertex v before she can move on in the temporal graph. The maximum waiting time β(v) is the maximum time a person can stay in a vertex v before she is no longer allowed to move further in the graph. A temporal graph $$\mathcal {G} = (V,E,T, \alpha, \beta)$$ is called instantaneous if α(v)=0 for all vV and λ=0 for all (v,w,t,λ)E. Then, for the ease of presentation, we neglect α and we write arcs as triples (v,w,t)E for instantaneous graphs.

In Table 1, we introduce some notation for temporal graphs.

Temporal Walk. A temporal walk is a walk in a temporal graph such that the time stamps of the visited time-arcs of a temporal walk are non-decreasing in time. Additionally, the transmission time and the waiting-time constraints have to be taken into account.

### Definition 2

(Temporal Walk) Given a temporal graph $$\mathcal {G} = (V,E,T, \alpha, \beta)$$ and two vertices s,zV, a temporal walk of length k from s to z is a sequence $$\left (\left (v_{i-1},v_{i},t_{i},\lambda _{i} \right)\right)_{i=1}^{k}$$ of time-arcs such that s=v0, z=vk, and ti+λi+α(vi)≤ti+1ti+λi+β(vi) for all i[k−1].

A temporal path is a temporal walk where all vertices are pairwise distinct. We use the notation $$P= \left (\left (v_{i-1},v_{i},t_{i},\lambda _{i} \right)\right)_{i=1}^{k}$$ for a temporal walk or a temporal path, that is, a sequence of k time-arcs. The value of k is the length of P and for each i[k] the tuple (vi−1,vi,ti,λi) is a time-arc from vi−1 to vi starting in time step ti. The value of λi is the time needed to traverse the time-arc, that is, one arrives at time step ti+λi at vi.

Optimal Temporal Walk. Due to the time aspect, there are several, potentially contradicting criteria that can be optimized in a temporal walk. We formally define the criteria that were already motivated in “Modeling of optimal temporal walks” section.

### Definition 3

(Optimal Temporal Walk) Let $$\mathcal {G} = (V,E,T, \alpha, \beta)$$ be a temporal graph, let $$c\colon E \rightarrow \mathbb{N}$$ be a cost function, and let s,zV be two vertices. A temporal walk $$P=\left (\left (v_{i-1},v_{i},t_{i},\lambda _{i} \right)\right)_{i=1}^{k}$$ from s to z is called optimal if it minimizes or maximizes a certain value among all temporal walks from s to z: Note that the most-likely criterion can easily be transformed into cheapest. For the most-likely criterion, the cost values of the time-arcs represent probabilities, implying c(e)[0,1] for all eE. Hence, maximizing $$\prod _{i=1}^{k} c((v_{i-1},v_{i},t_{i},\lambda _{i})$$ is equivalent to minimizing

$$\sum_{i=1}^{k} -\log c((v_{i-1},v_{i},t_{i},\lambda_{i})).$$

Hence, we neglect considering the most-likely criterion separately. We further call a temporal walk $$P=\left (\left (v_{i-1},v_{i},t_{i},\lambda _{i} \right)\right)_{i=1}^{k}$$ from s to z an optimal temporal walk with respect to a linear combination with $$\delta _{1},\ldots,\delta _{7} \in \mathbb{Q}^{+}_{0}$$ if it minimizes

$$\begin{array}{*{20}l} \text{lin}(P) = ~&\delta_{1} \cdot(t_{k} + \lambda_{k}) &\textit{Foremost}\\ + ~&\delta_{2}\cdot(-t_{1}) &\textit{Reverse-Foremost}\\ + ~&\delta_{3}\cdot(t_{k} + \lambda_{k} - t_{1}) &\textit{Fastest} \\ + ~&\delta_{4}\cdot \sum_{i=1}^{k} \lambda_{i} &\textit{Shortest} \\ + ~ &\delta_{5}\cdot \sum_{i=1}^{k} c((v_{i-1},v_{i},t_{i},\lambda_{i})) &\textit{Cheapest}\\ + ~&\delta_{6}\cdot k &\textit{Minimum Hop-Count}\\ + ~&\delta_{7}\cdot \sum_{i=1}^{k-1} (t_{i+1} - (t_{i} + \lambda_{i})) &\textit{Minimum Waiting Time} \end{array}$$

among all temporal walks from s to z.

## Transformation

To simplify the presentation of the forthcoming algorithm in “Algorithm” section for computing optimal temporal walks, we design it to run only on instantaneous temporal graphs, that is, temporal graphs with no transmission times (λ=0 for all (v,w,t,λ)E) and no minimum-waiting-time constraints (α(v)=0 for all vV). This is no restriction since we can eliminate these with the following transformation.

### Transformation 1

(Remove α and λ.) Let $$\mathcal {G} = (V,E,T, \alpha, \beta)$$ be a temporal graph and let $$c\colon E \rightarrow \mathbb{N}$$ be a cost function. Transform $$(\mathcal {G},c)$$ into $$(\mathcal {G}',c',c_{\lambda },\text {ind},A)$$ where

• $$\mathcal {G}'$$ is an instantaneous temporal graph $$\mathcal {G}'=(V',E',T,\beta ')$$ with

• V=VVE with VE:={veeE},

• E=EOEI with EO:={(v,ve,t)e=(v,u,t,λ)E} and EI={(ve,u,t+λ+α(u))e=(v,u,t,λ)E},

• $$\beta ' \colon V' \rightarrow \mathbb{N}$$ with β(v):=β(v) for all vV, else β(v):=T,

• $$c' \colon E' \rightarrow \mathbb{N}$$ is a cost function with $$c'(e) := c(\hat e)$$ for all $$e=(v,v_{\hat e},t) \in E^{O}$$, else c(e):=0,

• $$c_{\lambda } \colon E' \rightarrow \mathbb{N}$$ is a transmission-cost function with cλ(e):= for $$e=(v_{\hat e},w,t + \ell + \alpha (w)) \in E^{I}$$ and $$\hat e = (v,w,t,\ell) \in E$$, else cλ(e):=0,

• ind:V→{0,1} is a vertex-index function with ind(v):=1 if vV, else ind(v):=0, and

• A(v):V→{0,1} is an auxiliary function with A(v):=α(v) if vV, else A(v):=0.

We now show that any temporal graph can be transformed by Transformation 1 into an equivalent instantaneous temporal graph in linear time such that any optimal temporal walk in the instantaneous temporal graphs directly corresponds to an optimal temporal walk in the original graph and vice versa. To this end, we have to slightly adapt the formula for the linear combination as shown in the following proposition.

### Proposition 1

Let $$\mathcal {G} = (V,E,T, \alpha, \beta)$$ be a temporal graph, let $$c\colon E \rightarrow \mathbb{N}$$ be a cost function, and let s,zV. Let further $$(\mathcal {G}' = (V',E',T', \beta '),c',c_{\lambda },\text {ind},A)$$ be the result of applying Transformation 1 to $$(\mathcal {G},c)$$.

For $$\delta _{1},\ldots,\delta _{7}\in \mathbb{Q}^{+}_{0}$$, there exists a temporal walk $$P :=\left (\left (v_{i-1},v_{i},t_{i},\lambda _{i} \right)\right)_{i=1}^{k} =\left (e_{i}\right)_{i=1}^{k}$$ from s to z in $$\mathcal {G}$$ which is optimal with respect to a linear combination of δ1,…,δ7 if and only if the temporal walk

$$P':= \left(\left (v_{i-1},v_{e_{i}},t_{i}),(v_{e_{i}},v_{i},t_{i}+\lambda_{i}+\alpha(v_{i}))\right)\right)_{i=1}^{k} = (e'_{i})_{i=1}^{2k} = (v'_{i-1},v'_{i},t'_{i})_{i=1}^{2k}$$

from s to z in $$\mathcal {G}'$$ is optimal with respect to the new formula for a linear combination of our optimality criteria defined as follows:

$$\begin{array}{*{20}l} \text{lin}^{\text{T}}(P') = ~&\delta_{1} \cdot t'_{2k} &\textit{Foremost}\\ + ~&\delta_{2}\cdot(-t'_{1}) &\textit{Reverse-Foremost}\\ + ~&\delta_{3}\cdot(t'_{2k} - t'_{1}) &\textit{Fastest}\\ + ~&\delta_{4}\cdot \sum_{i=1}^{2k} c_{\lambda}(e'_{i}) &\textit{Shortest}\\ + ~&\delta_{5}\cdot \sum_{i=1}^{2k} c(e'_{i}) &\textit{Cheapest}\\ + ~&(\delta_{6} /2) \cdot 2k &\textit{Minimum Hop-Count}\\ + ~&\delta_{7} \cdot \sum_{i=1}^{2k-1} ((t'_{i+1} - (t'_{i} - A(v'_{i}))) \cdot \text{ind}(v'_{i})) &\textit{Minimum Waiting Time}. \end{array}$$

Transformation 1 runs in O(|V|+|E|) time.

### Proof

We will show that any temporal walk P in G corresponds to a temporal walk P in G such that lin(P)=linT(P) and vice versa. To this end, observe that each vertex vVE has an in-going and an out-going arc and the vertex set V=VVE is an independent set in G. Hence, each temporal walk in G from s to z alternately uses vertices in V and VE. Since each vertex in VE represents an arc in G, each temporal walk in G has a unique representation in G and vice versa. It remains to show that lin(P)=linT(P)−C for any temporal walk P in G where C is a constant only depending on the last vertex in P. Observe that by construction each vertex vi in P is the same vertex as $$v^{\prime }_{2i}$$ in P and the arc (vi−1,vi,ti,λi) is represented by the vertex $$v^{\prime }_{2i}$$ and the arcs $$e^{\prime }_{2i-1}$$ and $$e^{\prime }_{2i}$$. It holds that λi=cλ(e2i′)=cλ(e2i−1′)+cλ(e2i′) and c(ei)=c(e2i′)=c(e2i−1′)+c(e2i′). Finally, ti+1=t2i+1′ and ti+λi=t2i′−A(v2i′) (recall A(v)=α(v) if vV and A(v)=0 otherwise) and hence ti+1−(ti+λi)=t2i+1′−(t2i′−A(v2i′)). Thus,

$$\begin{array}{*{20}l} \text{lin}(&P) =\\ ~&\delta_{1} \cdot(t_{k} + \lambda_{k}) + \delta_{2}\cdot(-t_{1}) + \delta_{3}\cdot(t_{k} + \lambda_{k} - t_{1}) + \delta_{4}\cdot \sum_{i=1}^{k} \lambda_{i} \\ ~&+ \delta_{5}\cdot \sum_{i=1}^{k} c(e_{i}) + \delta_{6}\cdot k + \delta_{7}\cdot \sum_{i=1}^{k-1} (t_{i+1} - (t_{i} + \lambda_{i})) \\ = ~&\delta_{1} \cdot(t_{k} + \lambda_{k} + \alpha(t_{k}) - \alpha(t_{k})) + \delta_{2}\cdot(-t_{1}) \\ ~&+ \delta_{3}\cdot(t_{k} + \lambda_{k} + \alpha(t_{k}) - \alpha(t_{k}) - t_{1}) + \delta_{4}\cdot \sum_{i=1}^{k} \lambda_{i} + \delta_{5}\cdot \sum_{i=1}^{k} c(e_{i})\\ ~&+ \delta_{6}\cdot k + \delta_{7}\cdot \sum_{i=1}^{k-1} (t_{i+1} - (t_{i} + \lambda_{i} + \alpha(t_{i}) - \alpha(t_{i})))\\ = ~&\delta_{1} \cdot(t'_{2k-1} - A(v'_{2k})) + \delta_{2}\cdot(-t'_{1}) + \delta_{3}\cdot(t'_{2k-1} - A(v'_{2k}) - t'_{1})\\ ~&+ \delta_{4}\cdot \sum_{i=1}^{2k} c_{\lambda}(e'_{i}) + \delta_{5}\cdot \sum_{i=1}^{2k} c'(e'_{i}) + (\delta_{6}/2)\cdot 2k\\ ~&+ \delta_{7}\cdot \left(\sum_{i=1}^{k} ((t'_{2i} - (t'_{2i-1} - A(v'_{2i-1}))) \cdot 0) + \sum_{i=1}^{k-1} (t'_{2i+1} - (t'_{2i} - A(v'_{2i})))\right) \end{array}$$
$$\begin{array}{*{20}l} = ~&\delta_{1} \cdot(t'_{2k-1} - A(v'_{2k})) + \delta_{2}\cdot(-t'_{1}) \\ ~&+ \delta_{3}\cdot(t'_{2k-1} - A(v'_{2k}) - t'_{1}) + \delta_{4}\cdot \sum_{i=1}^{2k} c_{\lambda}(e'_{i}) + \delta_{5}\cdot \sum_{i=1}^{2k} c'(e'_{i})\\ ~&+ (\delta_{6}/2)\cdot 2k + \delta_{7}\cdot \sum_{i=1}^{2k-1} ((t'_{i+1} - (t'_{i} - A(v'_{i}))) \cdot \text{ind}(v'_{i})) \\ = ~&\text{lin}^{\text{T}}(P') - (\delta_{1} + \delta_{3}) \cdot A(v'_{2k}). \end{array}$$

Observe that (δ1+δ3A(v2k′) is independent of the temporal walk P and hence any optimal walk P in G corresponds to an optimal temporal walk P in G. Lastly, notice that Transformation 1 runs in O(|V|+|E|) time. □

The algorithm for computing optimal temporal walks that we will introduce in the forthcoming section will find temporal walks optimizing the formula linT(·) introduced in Proposition 1. For instantaneous temporal graphs, where we do not have to use Transformation 1, optimizing according to linT(·) is not a drawback as stated in the following (recall that the definitions of lin and linT depend on the parameters δ1,…,δ7):

### Observation 2

Let $$\mathcal {G} = (V,E,T, \beta)$$ be an instantaneous temporal graph and let $$c\colon E \rightarrow \mathbb{N}$$be a cost function. Let further $$P:=\left (\left (v_{i-1},v_{i},t_{i},\lambda _{i} \right)\right)_{i=1}^{k}=\left (e_{i}\right)_{i=1}^{k}$$ be a temporal walk in $$\mathcal {G}$$. For $$\delta _{1},\ldots,\delta _{7}\in \mathbb{Q}^{+}_{0}$$, it holds that

$$\text{lin}(P) = \text{lin}^{\text{T}}(P) + (\delta_{6}/2) \cdot k$$

for c=c, cλ≡0, ind≡1, and A≡0.

## Algorithm

In this section, we present a single-source optimal-walks algorithm with respect to any linear combination of our optimality criteria. That is, given a temporal graph $$\mathcal {G} = (V,E,T, \beta)$$, a cost function $$c \colon E \rightarrow \mathbb{N}$$, and a source vertex sV, we compute optimal temporal walks with respect to any linear combination with δ1,…,δ7 from s to all vertices in the temporal graph (if they exist). To this end, we first apply Transformation 1 to $$\mathcal {G}$$ to obtain an instantaneous temporal graph. Algorithm 1 then performs for each t[T] three main steps: GraphGeneration. Generate graph G which only contains the arcs present at time step t and add arcs from s to each vertex v in G that has been reached within the last β(v) time steps. ModDijkstra. Run a modified version of Dijkstra’s algorithm to compute for each v in G the optimal walk from s to v that arrives at time step t (if it exists). Update. Update a list storing information on optimal walks from s to each vV. More precisely, for each vV a list of tuples of arrival times and corresponding optimal values is updated.

Efficiently storing and accessing the value of an optimal walk from s to v that arrives at a certain time step t is the heart of the algorithm. We can maintain this information in O(|E|) time during a run of Algorithm 1 such that this information can be accessed in constant time, leading to the following theorem:

### Theorem 1

With respect to any linear combination of the optimality criteria, optimal temporal walks from a source vertex s to each vertex in a temporal graph $$\mathcal {G} = (V,E,T, \beta)$$ can be computed in O(|V|+|E| log|E|) time. Algorithm Details. Let $$\mathcal {G}'$$ be a temporal graph with a cost function $$c'\colon E \rightarrow \mathbb{N}$$ and let sV be the source. We can apply Transformation 1 to $$(\mathcal {G}',c')$$ to obtain $$(\mathcal {G} = (V,E,T, \beta),c,c_{\lambda },\text {ind},A)$$ where $$\mathcal {G}$$ is an instantaneous temporal graph. If $$\mathcal {G}'$$ is already an instantaneous temporal graph, then we set c=c, cλ≡0, ind≡1, and A≡0 as justified by Observation 2.

For given δ1,…,δ7, Algorithm 1 for all vV now computes an optimal walk $$P=\left (\left (v_{i-1},v_{i},t_{i}\right)\right)_{i=1}^{k}=\left (e_{i}\right)_{i=1}^{k}$$ from s to v with respect to

$$\begin{array}{*{20}l} \text{lin}^{\text{T}}(P)= &\delta_{1} \cdot(t_{k}) + \delta_{2}\cdot(-t_{1}) + \delta_{3}\cdot(t_{k} - t_{1}) + \delta_{4}\cdot \sum_{i=1}^{k} c_{\lambda}(e_{i}) \\ &+\delta_{5}\cdot \sum_{i=1}^{k} c(e_{i}) + \delta_{6}\cdot k + \delta_{7} \cdot \sum_{i=1}^{k-1} (t_{i+1} - t_{i} + A(v_{i+1})) \cdot \text{ind}(v_{i}). \end{array}$$

We have shown in Proposition 1 that an optimal walk with respect to linT(P) in $$\mathcal {G}$$ directly corresponds to an optimal walk with respect to lin(P) in the original temporal graph $$\mathcal {G}'$$.

For each vertex vV{s}, Algorithm 1 stores in opt(v) the value of an optimal walk from s to v and in L(v) a list of all relevant arrival times from s to v with their optimal values. In the beginning, opt(v)= and L(v) is an empty list (Line 1 in Algorithm 1). Then, for each time step t and each vV, Algorithm 1 computes the optimal walk from the source s to v that arrives in time step t (if it exists). Thus, Algorithm 1 performs for each t{1,…,T} the following steps: GraphGeneration. Generate a static graph G with GenerateGraph (Line 3 and Lines 9 to 19). This graph consists of the static graph Gt=(Vt,Et), that is, the static graph induced by all time-arcs with time stamp t, and the source vertex s.

The weight of an arc (v,w)Et is set to δ4·cλ(v,w)+δ5·c(v,w)+δ6. If further v=s, then we have to add (δ2+δ3)·(Tt) to take the departure time in s into account for the criteria reverse-foremost and fastest, see Line 12.

Additionally, non-existing arcs from s to each vertex vVt are added if there exists a temporal walk from s to v that arrived not later than β(v) time steps ago. Let opta be the optimal value among all walks that arrive within the time interval [tβ(v),t] and let a be the corresponding arrival time in v. Additionally, the minimum waiting time A(v) plus the additional waiting time (ta) in v has to be taken into account if ind(v)=1. Hence, the weight of arc (s,v) is set to opta+δ7·ind(v)·(ta+A(v)), see Line 18. Let Er be the set of these additional arcs. Then, G=(Vt{s},EtEr,dt,dr). ModDijkstra. Run a modified Dijkstra Algorithm on G with modDijkstra (Line 4 and Lines 20 to 31). Instead of computing a shortest walk (using the original Dijkstra Algorithm) in G, compute a shortest walk among all walks that end in an arc of Et. This represents a temporal walk that arrives in time step t with optimal value. The function modDijkstra returns the set V of vertices that can be reached within G via an arc in Et and the function $$\text {opt}_{t} \colon V' \rightarrow \mathbb{N}$$ that maps each vertex vV to its optimal value of a walk from s to v arriving exactly at time t. Update. For each vV, set the optimum opt(v) to the minimum of its current value and the optimal value of a newly computed walk, that is, opt(v):= min{opt(v),δ1·t+δ3·(tT)+optt(v)} (Line 6). Herein, we have to add the arrival time t that has not been taken into account in the calculation of the optimal value because it is the same for all walks found at time step t. Add the tuple (optt(v),t) to list L(v) (Line 7).

After the Update step for time step t, the list L(v) contains all tuples (optar,ar) such that there exists a walk from s to v that arrives at time ar[tβ(v),t] with its optimal cost value optar. We want to have constant-time access to the optimal value of a walk that arrives in v within time interval [tβ(v),t]. This can be achieved by deleting tuples from list L(v) that are redundant, that is these tuples are not meaningful for the correct computation of optimal walks. Let

$$L(v)=[(\text{opt}_{a_{1}},a_{1}), \ldots,(\text{opt}_{a_{k}},a_{k})]$$

be such a list for a time step t with tβ(v)≤a1<…<akt. A tuple (optar,ar) is redundant if there exists a tuple with an arrival time greater than ar such that its optimal value is smaller than optar plus the additional waiting time. This is shown with the following lemma:

### Lemma 1

For a time step t{1,…,T} and a vertex vV, if there are two tuples $$(\text {opt}_{a_{i}},a_{i}),(\text {opt}_{a_{j}},a_{j}) \in L(v)$$ with ai<aj and

$$\text{opt}_{a_{j}} \leq \text{opt}_{a_{i}} + \delta_{7} \cdot \text{ind}(v) \cdot (a_{j}-a_{i}),$$

then $$(\text {opt}_{a_{i}},a_{i})$$ is redundant and can be removed from L(v).

### Proof

After all time-arcs with time stamp t have been processed, Algorithm 1 only considers time-arcs with time stamp t>t. In the generated graph G (Line 3), the algorithm adds an arc from s to $$\phantom {\dot {i}\!}v\in V_{t^{\prime }}$$ if a walk from s arrives in v within [tβ(v),t]. If ai[tβ(v),t], then aj[tβ(v),t] because ai<aj<t. Furthermore, let (opt,a) be the optimal value and the arrival time of a walk from s to v that arrives within time interval [tβ(v),t] that minimizes

$$\text{opt} + \delta_{7} \cdot \text{ind}(v) (t' - a + A(v)).$$

Then, the weight of the arc (s,v) is set to this value. Since ai<aj[tβ(v),t] and $$\text {opt}_{a_{i}} + \delta _{7} \cdot \text {ind}(v) \cdot (a_{j}-a_{i}) \geq \text {opt}_{a_{j}}$$, we know that

$$\text{opt}_{a_{j}} + \delta_{7} \cdot \text{ind}(v) (t' - a_{j} + A(v))\leq \text{opt}_{a_{i}} + \delta_{7} \cdot \text{ind}(v) (t' - a_{i} + A(v)).$$

Hence, the tuple $$(\text {opt}_{a_{i}},{a_{i}})$$ is not needed in the list L(v) at time step t and can be removed. □

If L(v) does not contain any redundant tuples, then it also holds that

$$\text{opt}_{a_{1}} + \delta_{7} \cdot \text{ind}(v) \cdot (a_{2}-a_{1})< \cdots < \text{opt}_{a_{k}}.$$

Hence, $$\phantom {\dot {i}\!}(a_{1}, \text {opt}_{a_{1}})$$ contains the optimal value and arrival time of a walk that arrives within time interval [tβ(v),t] and minimizes opt+δ7·ind(v)(ta+A(v)). It follows that finding opt= min{opta(opta,a)L(v)} in Line 18 takes constant time. The deletion of redundant tuples takes O(|E|) time during the whole run of Algorithm 1. With these considerations at hand, we can derive the following lemma.

### Lemma 2

Algorithm 1 runs in O(|V|+|E| log|E|) time.

### Proof

The initialization in Algorithm 1 can be done in O(|V|) time. Furthermore, the time-arcs have to be sorted by time stamps which takes O(|E| log|E|) time. Then, for each time step t[T], Algorithm 1 generates in O(|Et|+|Vt|) time a static directed graph G=(Vt{s},EtEr) with O(|Vt|) vertices and O(|Et|+|Vt|) arcs.

For each generated graph G, modDijkstra is executed in O(|Et| log|Et|) time. The updates of opt and L afterwards run in O(|Vt|) time. Note that |Vt| is the number of vertices that have at least one in-going or out-going time-arc at time step t. Consequently, it holds that |Vt|≤2|Et|.

Due to the sorting of L(v), maintaining these lists in Lines 15 and 7 takes O(|E|) time during the whole run of the algorithm as shown Lemma 1. In the list L(v), we delete at most as many elements as there are time-arcs in the temporal graph. Recall that if (opta,a)L(v), then there exists a time-arc (w,v,a)E.

We can analyze the running time by

$$\begin{array}{*{20}l} &O\big(|V| + |E| + \sum_{t=1}^{T} (|E_{t}|) + (|V_{t}| \log |V_{t}|) \big)\\ = ~&O\big(|V| + |E| + \sum_{t=1}^{T} (|E_{t}|) + (|E_{t}| \log |E_{t}|) \big)\\ = ~&O\big(|V| + |E| + \sum_{t=1}^{T} |E_{t}| \log |E_{t}| \big)\\ \subseteq ~&O\big(|V| + |E| \log |E| \big). \end{array}$$

Hence, Algorithm 1 runs in O(|V|+|E| log|E|) time. □

Next, we show the correctness of Algorithm 1. We prove that for every time step t and for every vertex v, Algorithm 1 computes an optimal walk from s to v that arrives at time step t (if it exists).

### Lemma 3

For a time step t[T] and a vertex vV, Algorithm 1 computes the optimal value of a temporal walk from s to v that arrives exactly in time step t.

### Proof

The proof is by induction on the time step t{1,…,T}.

In the beginning, L(v) is empty. For t=1, the algorithm generates a graph G=(V1{s},E1). For all arcs (s,w)E1, the weights are set to

$$d_{1}(s,w) := (\delta_{2}+ \delta_{3}) \cdot(T-1) + \delta_{4} \cdot c_{\lambda}((v,w,1))+ \delta_{5} \cdot c((v,w,1)) + \delta_{6};$$

for the other arcs (v,w)E1 the weights are set to

$$d_{1}(v,w)=\delta_{4} \cdot c_{\lambda}(v,w)+ \delta_{5} \cdot c((v,w,1)) + \delta_{6}.$$

Note that if there is an optimal temporal walk arriving in time step 1, then there also exists an optimal temporal walk arriving at time step 1. Now if there is an optimal walk $$P=\left (\left (v_{i-1},v_{i},1\right)\right)^{k}_{i=1}=\left (e_{i}\right)^{k}_{i=1}$$ from s to a vertex vV that arrives exactly in time step 1, then there exists a path $$P'=\left (\left (v_{i-1},v_{i}\right)\right)^{k}_{i=1}=\left (a_{i}\right)^{k}_{i=1}$$ from s to v in G with value

$$\begin{array}{*{20}l} \sum_{i=1}^{k} d_{t}(a_{i}) &= (\delta_{2}+ \delta_{3}) \cdot(T-1) + \sum_{i=1}^{k} \delta_{4} \cdot c_{\lambda}(v_{i-1},v_{i})+ \delta_{5} \cdot c(v_{i-1},v_{i}) + \delta_{6}\\ &= \text{opt}_{1}(v). \end{array}$$

Algorithm 1 finds in modDijkstra the path P, adds (opt1(v),1) to L(v) and sets

$$\begin{array}{*{20}l} \text{opt}(v) := ~&\delta_{1} \cdot 1 - \delta_{2} \cdot T + \delta_{3} \cdot (1-T) + \text{opt}_{1}(v)\\ = ~&\delta_{1} \cdot 1 - \delta_{2} \cdot T + \delta_{3} \cdot (1-T) + (\delta_{2}+ \delta_{3}) \cdot(T-1) + \sum_{i=1}^{k} \delta_{4} \cdot c_{\lambda}(v_{i-1},v_{i})\\ &+ \delta_{5} \cdot c(v_{i-1},v_{i}) + \delta_{6} \cdot k\\ = ~&\delta_{1} \cdot 1 - \delta_{2}\cdot 1 + \delta_{3}\cdot 0 + \delta_{4}\cdot \sum_{i=1}^{k} c_{\lambda}(e_{i}) \\ &+\delta_{5}\cdot \sum_{i=1}^{k} c(e_{i}) + \delta_{6}\cdot k + \delta_{7} \cdot \sum_{i=1}^{k-1} (t_{i+1} - t_{i} + A(v_{i})) \cdot \text{ind}(v_{i})\\ = ~&\text{lin}^{\text{T}}(P). \end{array}$$

Note that A(vi)=0 for i[k−1] by Transformation 1 in time step 1. If there exists an optimal path P in G, then this directly translates to the existence of a temporal path P that arrives also in time step 1 with a smaller optimal value than P, contradicting the assumption that P is optimal.

Now, let us assume that for all time steps t{1,…,t} Algorithm 1 computed the optimal value opt of a walk from s to vV that arrives exactly in time step t and added (opt−δ1·t+δ2·Tδ3·(tT),t) to L(v). If for time step t+1 a vertex vV has no in-going time-arc with time step t+1, then there cannot exist a temporal walk from s to v that arrives exactly in time step t+1. Thus, only vertices in Vt+1 are candidates for a temporal walk that arrives exactly in time step t+1.

Let vVt+1 be a vertex such that there is a temporal walk from s to v that arrives exactly in time step t+1. Let $$P=\left (\left (v_{i-1},v_{i},1\right)\right)^{k}_{i=1}=\left (e_{i}\right)^{k}_{i=1}$$ be an optimal walk from s to v that arrives exactly in time step t+1 with the optimal value

$$\begin{array}{*{20}l} \text{lin}^{\text{T}}(P) &= \delta_{1} \cdot t_{1} - \delta_{2}\cdot t_{k} + \delta_{3}\cdot (t_{k} - t_{1}) + \delta_{4}\cdot \sum_{i=1}^{k} c_{\lambda}(e_{i}) \\ &~~~+\delta_{5}\cdot \sum_{i=1}^{k} c(e_{i}) + \delta_{6}\cdot k + \delta_{7} \cdot \sum_{i=1}^{k-1} (t_{i+1} - t_{i} + A(v_{i})) \cdot \text{ind}(v_{i}). \end{array}$$

Assume towards a contradiction that Algorithm 1 does not find a walk from s to v with optimal value linT(P).

First consider the case that ti=t+1 for all i[k], that is, all time-arcs of the temporal walk P have time stamp t+1. Then, we can assume that P is a temporal path. Hence there exists a path $$P'=\left (\left (v_{i-1},v_{i}\right)\right)^{k}_{i=1}=\left (a_{i}\right)^{k}_{i=1}$$ from s to v in Gt+1 and therefore in G with optimal value

$$\begin{array}{*{20}l} \sum_{i=1}^{k} d_{t}(a_{i}) &= (\delta_{2}+ \delta_{3}) \cdot(T-(t+1)) + \sum_{i=1}^{k} \delta_{4} \cdot c_{\lambda}(v_{i-1},v_{i}) + \delta_{5} \cdot c(v_{i-1},v_{i}) + \delta_{6}\\ &= \text{opt}_{t+1}(v). \end{array}$$

Algorithm 1 finds in modDijkstra the path P, adds (optt+1(v),t+1) to L(v), and updates opt(v) to the minimum of opt(v) and

$$\begin{array}{*{20}l} &\delta_{1} \cdot (t+1) - \delta_{2} \cdot T + \delta_{3} \cdot (t+1-T) + \text{opt}_{t+1}(v)\\ = ~&\delta_{1} \cdot (t+1) - \delta_{2} \cdot T + \delta_{3} \cdot (t+1-T) + (\delta_{2}+ \delta_{3}) \cdot(T-(t+1)) \\ &+ \sum_{i=1}^{k} \delta_{4} \cdot c_{\lambda}(v_{i-1},v_{i}) + \delta_{5} \cdot c(v_{i-1},v_{i}) + \delta_{6} \cdot k\\ = ~&\delta_{1} \cdot t_{1} - \delta_{2}\cdot t_{k} + \delta_{3}\cdot (t_{k} - t_{1}) + \delta_{4}\cdot \sum_{i=1}^{k} c_{\lambda}(e_{i}) \\ &+\delta_{5}\cdot \sum_{i=1}^{k} c(e_{i}) + \delta_{6}\cdot k + \delta_{7} \cdot \sum_{i=1}^{k-1} (t_{i+1} - t_{i} + A(v_{i})) \cdot \text{ind}(v_{i})\\ = ~&\text{lin}^{\text{T}}(P). \end{array}$$

Note again that A(vi)=0 for i[k−1] if ti−1=ti by Transformation 1. Hence, we find a walk from s to v at time step t+1 with optimal value linT(P), contradicting our assumption.

Now assume for P that there exists an {1,…,k−1} such that for j[] it holds that tj<t+1 and for j{i+1,…,k} it holds that $$\phantom {\dot {i}\!}t_{j^{\prime }} = t+1$$. The temporal walk $$P_{\ell }= \left (\left (v_{i-1},v_{i},t_{i}\right)\right)^{\ell }_{i=1}=\left (e_{i}\right)^{k}_{i=1}$$ is an optimal subwalk from s to v that arrives exactly in time step t, otherwise P is not optimal because it could be improved by replacing P. The subwalk P has an optimal value

$$\begin{array}{*{20}l} \text{lin}^{\text{T}}(P_{\ell}) = ~& \delta_{1} \cdot t_{1} - \delta_{2}\cdot t_{\ell} + \delta_{3}\cdot (t_{\ell} - t_{1}) + \delta_{4}\cdot \sum_{i=1}^{k} c_{\lambda}(e_{i}) \\ & +\delta_{5}\cdot \sum_{i=1}^{\ell} c(e_{i}) + \delta_{6}\cdot k + \delta_{7} \cdot \sum_{i=1}^{\ell-1} (t_{i+1} - t_{i} + A(v_{i})) \cdot \text{ind}(v_{i}). \end{array}$$

Then

$$\begin{array}{*{20}l} \text{opt}_{t_{\ell}}(v_{\ell}) = ~&\text{opt}_{P_{\ell}} - \delta_{1} \cdot t_{\ell} + \delta_{2} \cdot T - \delta_{3} \cdot (t_{\ell} -T)\\ = ~&(\delta_{2}+ \delta_{3}) \cdot(T-t_{\ell}) + \delta_{4}\cdot \sum_{i=1}^{\ell} c_{\lambda}(e_{i}) \\ &+\delta_{5}\cdot \sum_{i=1}^{\ell} c(e_{i}) + \delta_{6}\cdot k + \delta_{7} \cdot \sum_{i=1}^{\ell-1} (t_{i+1} - t_{i} + A(v_{i})) \cdot \text{ind}(v_{i}). \end{array}$$

By our induction hypothesis, the tuple $$(\text {opt}_{t_{\ell }}(v_{\ell }),t_{\ell })$$ was added to L(v). If the tuple $$(\text {opt}_{t_{\ell }}(v_{\ell }),t_{\ell })$$ is not in L(v) in time step t+1, then due to Lemma 1 there must be another tuple $$(\text {opt}_{\hat t}(v_{\ell }),\hat t)$$ in L(v) with $$t_{\ell } < \hat t < t+1 < t_{\ell } + \beta (v_{\ell }) \leq \hat t + \beta (v_{\ell })$$ and

$$\text{opt}_{t_{\ell}}(v_{\ell}) + \delta_{7} \cdot \text{ind}(v_{\ell}) (t+1 - t_{\ell} + A(v_{\ell})) = \text{opt}_{\hat t}(v_{\ell}) + \delta_{7} \cdot \text{ind}(v_{\ell}) (t+1 - \hat t + A(v_{\ell})).$$

Otherwise P is not optimal because it could be improved by replacing P by the temporal walk represented by $$(\text {opt}_{\hat t}(v_{\ell }),\hat t)$$.

Now consider the generated graph G=(Vt+1{s},Et+1Er). The arc sequence $$P_{t+1}=\left (\left (v_{i-1},v_{i}\right)\right)^{k}_{i=\ell +1}=\left (a_{i}\right)^{k}_{i=\ell +1}$$ is a path in Gt+1=(Vt+1,Et+1) and, thus, contained in G. The arc a=(s,v) is contained in Er with weight

$$d_{r}(s,v_{\ell}) = \text{opt}_{t_{\ell}}(v_{\ell}) + (t+1 - t_{\ell} + A(v_{\ell})) \cdot \text{ind}(v_{\ell}).$$

Thus, there is a walk from s to v in G and modDijkstra on G returns the vertex v because akEt+1 with the optimal value

$$\begin{array}{*{20}l} &d_{r}(a_{\ell}) + \sum_{i=\ell+1}^{k} d_{t}(a_{i}) \\ = ~&\text{opt}_{t_{\ell}}(v_{i}) + \text{ind}(v_{\ell})\cdot (t+1 - t_{\ell} + A(v_{\ell})) \\ &+ \sum_{i=\ell+1}^{k} \delta_{4} \cdot c_{\lambda}(v_{i-1},v_{i},t+1)+ \delta_{5} \cdot c(v_{i-1},v_{i},t+1) + \delta_{6}\\ = ~&(\delta_{2}+ \delta_{3}) \cdot(T-t_{\ell}) + \sum_{i=1}^{\ell} \big (\delta_{4}\cdot c_{\lambda}(e_{i}) +\delta_{5}\cdot c(e_{i}) + \delta_{6} \big)\\ &+ \delta_{7} \cdot \sum_{i=1}^{\ell-1} \text{ind}(v_{i}) \cdot (t_{i+1} - t_{i} + A(v_{i})) \\ &+ \text{ind}(v_{\ell})\cdot (t+1 - t_{\ell} + A(v_{\ell}))\\ &+\sum_{i=\ell+1}^{k} \big (\delta_{4} \cdot c_{\lambda}(v_{i-1},v_{i})+ \delta_{5} \cdot c(v_{i-1},v_{i}) + \delta_{6} \big) \\ = ~&(\delta_{2}+ \delta_{3}) \cdot(T-t_{\ell}) + \delta_{4}\cdot \sum_{i=1}^{k} c_{\lambda}(e_{i}) \\ &+\delta_{5}\cdot \sum_{i=1}^{k} c(e_{i}) + \delta_{6}\cdot k + \delta_{7} \cdot \sum_{i=1}^{\ell} (t_{i+1} - t_{i} + A(v_{i})) \cdot \text{ind}(v_{i})\\ = ~&(\delta_{2}+ \delta_{3}) \cdot(T-t_{\ell}) + \delta_{4}\cdot \sum_{i=1}^{k} c_{\lambda}(e_{i}) \\ &+\delta_{5}\cdot \sum_{i=1}^{k} c(e_{i}) + \delta_{6}\cdot k + \delta_{7} \cdot \sum_{i=1}^{k-1} (t_{i+1} - t_{i} + A(v_{i})) \cdot \text{ind}(v_{i})\\ = ~&\text{opt}_{t+1}(v). \end{array}$$

Note that by Transformation 1A(vi)=0 for i[+1,k−1] if ti−1=ti. Consequently, the tuple (optt+1(v),t+1) is added to L(v) and opt(v) is set to the minimum of its current value and

$$\begin{array}{*{20}l} &\delta_{1} \cdot (t+1) -\delta_{2} \cdot T + \delta_{3} (t+1 -T) + \text{opt}_{t+1}(v)\\ = ~&\delta_{1} \cdot (t+1) -\delta_{2} \cdot T + \delta_{3} (t+1 -T)\\ &+(\delta_{2}+ \delta_{3}) \cdot(T-t_{1}) + \delta_{4} \cdot \sum_{i=1}^{k} c_{\lambda}(e_{i})\\ &+\delta_{5}\cdot \sum_{i=1}^{k} c(e_{i}) + \delta_{6}\cdot k + \delta_{7} \cdot \sum_{i=1}^{k-1} (t_{i+1} - t_{i} + A(v_{i})) \cdot \text{ind}(v_{i}) \end{array}$$
$$\begin{array}{*{20}l} = ~& \delta \cdot (t+1) + \delta_{2} \cdot (t_{k}) + \delta_{3} (t+1 -t_{1}) +\delta_{4}\cdot \sum_{i=1}^{k} c_{\lambda}(e_{i}) \\ &+\delta_{5}\cdot \sum_{i=1}^{k} c(e_{i}) + \delta_{6}\cdot k + \delta_{7} \cdot \sum_{i=1}^{k-1} (t_{i+1} - t_{i} + A(v_{i})) \cdot \text{ind}(v_{i})\\ = ~&\text{lin}^{\text{T}}(P). \end{array}$$

This is a contradiction to our assumption.

Lastly, observe that the algorithm only computes temporal walks that are contained in G as it only uses arcs from Gt which all correspond to temporal walks in G (single arcs or longer walks starting in s). Thus, for t{1,…,T}, Algorithm 1 computes an optimal temporal walk from s to vV that arrives exactly in time step t. □

Based on this statement, we can finally prove the correctness of Algorithm 1. This concludes the proof of Theorem 1.

### Lemma 4

Algorithm 1 computes optimal walks from a given source vertex s to all vertices.

### Proof

Let $$P=\left (\left (v_{i-1},v_{i},1\right)\right)^{k}_{i=1}=\left (e_{i}\right)^{k}_{i=1}$$ be a walk with minimum linT(P) among all temporal walks from s to a vertex v. The walk P is also an optimal walk from s to v that arrives exactly in time step tk. This is computed by Algorithm 1 in time step tk as shown in Lemma 3. □

## Experimental results

We implemented Algorithm 1 and performed experimental studies including comparisons to existing state-of-the-art algorithms by Wu et al. (2016). Note that the algorithms by Wu et al. (and our algorithm as well) are Dijkstra-like algorithms adjusted to the specific temporal setting. A notable difference is that our algorithm stops the graph exploration if no more vertex can be visited, whereas the algorithms by Wu et al. (2016) always iterate over all time-arcs. We show that our algorithm—while being able to solve a more general problem—can compete with these algorithms on real-world instances for the special case of computing temporal walks with no maximum-waiting-time constraints. We further examine the influence of different maximum-waiting-time values on the existence and structure (e.g., the number of cycles) of optimal temporal walks and on the running time of Algorithm 1.

### Setup and statics

We implemented Algorithm 1 in C++ (v11) and performed our experiments on an Intel Xeon E5-1620 c omputer with 64 GB of RAM and four cores clocked at 3.6 GHz each. The operating system was Debian GNU/Linux 7.0 where we compiled the program with GCC v7.3.0 on optimization level -O3. We compare Algorithm 1 to the algorithms of Wu et al. (2016) using their C++ code and testing it on the same hardware and with the same compiler. We tested our algorithm on the same freely available data sets as Wu et al. (2016) from the well-established KONECT library (KONECT 2017). The graphs are listed in Table 2 with some relevant statistics.

For each optimization criterion, each βc,c{1,2,4,8,…,2logT}, and each data set, Algorithm 1 ran for 100 fixed source vertices of the data set chosen independently and uniformly at random. Our open source code is freely available at https://fpt.akt.tu-berlin.de/temporalwalks.

### Findings

In the following, we first compare Algorithm 1 to the algorithm by Wu et al. (2016) in terms of running times in our experiments. In the second part, we analyze the effects of different maximum-waiting-time values β on Algorithm 1.

#### Comparison

When comparing with the algorithms by Wu et al. (2016), we only use the runs with no maximum-waiting-time constraints (βT) and we tested all algorithms on the same set of randomly chosen starting vertices. In the experiments, we could only measure a very small effect of the optimization criteria on the running time. This even holds for linear combinations. The only exception was the computation of foremost which was a bit faster in comparison to the computation of the other criteria. For this reason we only include two examples here. We chose foremost and shortest as these are the two criteria where Algorithm 1 performed the best and the worst compared to the algorithms by Wu et al. (2016), respectively. The respective findings are illustrated in the box plots in Fig. 3.

As one can observe in Fig. 3, Algorithm 1 has a larger variance and, therefore, is more dependent on the choice of starting vertices. The reason is that even for βT, that is, no maximum waiting time constraints, not all vertices can reach all other vertices by temporal walks in the considered graphs: Algorithm 1 only considers arcs that start in vertices that were already visited and, hence, if many verices are not reached then the algorithm stops. In contrast, the algorithm by Wu et al. (2016) always considers the whole sorted time-arc list and, therefore, has almost no variance in the running time.

The high variance is also the reason why our algorithm has a higher average running time but a comparable median running time: On average, the algorithm by Wu et al. (2016) is 16.4 times faster for computing the foremost walk and 7.6 times slower for shortest walks. Considering the median running times, however, our algorithm is 5.8 times faster for the foremost walk but the algorithm by Wu et al. (2016) is 1.2 times faster for shortest walks. The higher average running time is a clear weakness of our algorithm. We believe, however, that the algorithm is still a valuable contribution as it solves more general problems: it can easily combine multiple optimization criteria and it can cope with maximum waiting times and instantaneous arcs, that is, arcs with λ=0.

When looking at the time to read the data we can observe that our algorithm takes roughly twice to thrice the time for preprocessing compared to the algorithms by Wu et al. This is due to the fact that for each arc in the input graph Transformation 1 constructs a new vertex and a new arc and so the resulting graph is almost thrice the size. The time to read in the data is much larger than the time of the actual algorithm and so Algorithm 1 takes roughly thrice the time of the algorithms by Wu et al. (2016) if preprocessing is taken into account.

Finally, we compared the running time of Algorithm 1 with a single optimization criterion against the same algorithm with a linear combination of all criteria considered. Figure 4 displays the average and median running time for βT on all considered data sets.

As expected, the linear combination of optimization criteria does not change the running time compared to a single criterion.

#### Effect of different maximum waiting-time values β

We next analyze the impact that the maximum-waiting-time constraint β has on Algorithm 1. Decreasing β can have two different effects: First, it can make temporal walks invalid as the maximum allowed waiting time in a vertex is exceeded. Thus, with small β-values certain vertices can only reach few vertices by temporal walks. The second effect is that a temporal walk is invalidated but can be fixed by a detour that starts and ends in the vertex in which the maximal waiting time was exceeded.

We first investigate the second effect. To this end, we partition the optimization criteria into two categories: The first category contains all optimization criteria for which a detour has no negative effect on the solution. These are foremost, reverse-foremost, fastest, and minimum waiting time. Since the solution for, e. g., fastest is only depending on the first and last time-arc of the temporal walk, adding a cycle somewhere in between does not change the solution. Minimum waiting time plays a special role here as this value can decrease when adding intermediate cycles. The second category contains all other optimization criteria, that is, those for which a detour has a negative effect on the solution. These are minimum hop count, cheapest, and shortest. Since we could not measure significant differences for the different optimization criteria within a category, we only display one figure for each category in Fig. 5.Footnote 2

We remark that in the first category we implemented the algorithm such that irrelevant cycles (cycles which do not change the optimality value) are kept in the solution. Hence Fig. 5 (top left plot) displays values close to the upper bound on the number of cycles in an optimal solution.

Figure 5 (two bottom plots) show that the different categories behave very similarly when it comes to the running-time dependence on the value of β. It seems to be more likely that the first effect we described in the beginning of this subsection (that decreasing β-values can make temporal walks invalid as the maximum allowed waiting time in a vertex is exceeded) is more important for explaining the running times. With very small β-values, a vertex can only reach few other vertices and hence only few time-arcs are considered by Algorithm 1. With increasing β-values, there seems to be a critical value (around 0.1%−10% of the lifetime of the temporal graph) where suddenly much more connections appear and hence the running time increases drastically. This observation is affirmed by Fig. 6, which shows that (almost) independently of the input graph, the running time is linearly depending on the number of vertices that are visited.

We believe that the difference for small β-values comes from the initialization which is again more depending on the input graph compared to the algorithms by Wu et al. This would explain, why our algorithms have a higher running time variance.

## Conclusion

Building on and widening previous work of Wu et al. (2016), we provided a theoretical and experimental study of computing optimal temporal walks under waiting-time constraints. The performed experiments indicate the practical relevance of our approach. As to future challenges, recall that moving from walks to paths would yield NP-hard optimization problems (Casteigts et al. 2015). Hence, for the path scenario the study of approximation, fixed-parameter, or heuristic algorithms is a natural next step. For the scenario considered in this work, note that we did not study the natural extension to Pareto-optimal walks (under several optimization criteria). Moreover, for (temporal) network centrality measures based on shortest paths and walks, counting or even listing all optimal temporal walks or paths would be of interest. First results in this direction indicate that for several optimization criteria counting temporal paths is computationally hard even without waiting time constraints; in contrast, counting temporal walks seems easier (Rad et al. 2017; Buß et al. 2020).

## Availability of data and materials

The data sets used and analyzed during the current study are available in the KONECT library, http://konect.cc/networks/(KONECT 2017). The open source code of the algorithm is freely available at https://fpt.akt.tu-berlin.de/temporalwalks.

1. 1.

Waiting-time constraints play a particularly important role in standard spreading models of infectious diseases such as the SIS-model (Susceptible-Infected-Susceptible) (Newman 2018, Chapter 17).

2. 2.

We omitted the data sets facebook-wosn-links, flickr-growth, ca-cit-HepPh, and youtube-u-growth in Fig. 5 to keep the figure clear. There is no information gain in displaying these data sets.

## References

1. Ahuja, RK, Magnanti TL, Orlin JB (1993) Network Flows: Theory, Algorithms, and Applications. Prentice Hall, Upper Saddle River.

2. Axiotis, K, Fotakis D (2016) 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), 149–114914.. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Saarbrücken.

3. Barabási, A-L (2016) Network Science. Cambridge University Press, Cambridge.

4. Bast, H, Delling D, Goldberg A, Müller-Hannemann M, Pajor T, Sanders P, Wagner D, Werneck RF (2016) Route planning in transportation networks In: Algorithm Engineering - Selected Results and Surveys. Lecture Notes in Computer Science, 19–80.. Springer.

5. Buß, S, Molter H, Niedermeier R, Rymar M (2020) Algorithmic aspects of temporal betweenness In: Proceedings of the 26th SIGKDD Conference on Knowledge Discovery and Data Mining (KDD ’20), 2084–2092.. ACM.

6. Casteigts, A, Flocchini P, Godard E, Santoro N, Yamashita M (2015) On the expressivity of time-varying graphs. Theor Comput Sci 590:27–37.

7. Casteigts, A, Flocchini P, Quattrociocchi W, Santoro N (2012) Time-varying graphs and dynamic networks. Int J Parallel Emergent Distrib Syst 27(5):387–408.

8. Casteigts, A, Himmel A-S, Molter H, Zschoche P (2019) The computational complexity of finding temporal paths under waiting time constraints. arXiv preprint arXiv:1909.06437. To appear at ISAAC ’20.

9. Dean, BC (2004) Algorithms for minimum-cost paths in time-dependent networks with waiting policies. Networks 44:41–46.

10. Fluschnik, T, Molter H, Niedermeier R, Renken M, Zschoche P (2020) Temporal graph classes: A view through temporal separators. Theor Comput Sci 806:197–218.

11. Fluschnik, T, Niedermeier R, Schubert C, Zschoche P (2020) Multistage s-t path: Confronting similarity with dissimilarity. arXiv preprint arXiv:2002.07569. To appear at ISAAC ’20.

12. Himmel, A, Bentert M, Nichterlein A, Niedermeier R (2019) Efficient computation of optimal temporal walks under waiting-time constraints In: Proceedings of the 8th International Conference on Complex Networks and Their Applications (COMPLEX NETWORKS ’19). Studies in Computational Intelligence, 494–506.. Springer, New York.

13. Holme, P (2015) Modern temporal network theory: a colloquium. Eur Phys J B 88(9):234.

14. Holme, P (2016) Temporal network structures controlling disease spreading. Phys Rev E 94(2):022305.

15. Holme, P, Saramäki J (2012) Temporal networks. Physics Reports 519(3):97–125.

16. Holme, P, Saramäki J (2013) Temporal networks as a modeling framework. In: Holme P Saramäki J (eds)Temporal Networks, 1–14.. Springer, New York.

17. Holme, P, Saramäki J (2019) Temporal Network Theory. Springer, New York.

18. Kempe, D, Kleinberg J, Kumar A (2002) Connectivity and inference problems for temporal networks. J Comput Syst Sci 64(4):820–842.

19. Kim, H, Anderson R (2012) Temporal node centrality in complex networks. Phys Rev E 85(2):026107.

20. Kivelä, M, Cambe J, Saramäki J, Karsai M (2018) Mapping temporal-network percolation to weighted, static event graphs. Sci Rep 8(1):12357.

21. KONECT (2017) DNC emails network dataset. Inst Web Sci Technol. http://konect.uni-koblenz.de/networks/dnc-temporalGraph. Accessed 2017.

22. Lightenberg, W, Pei Y, Fletcher G, Pechenizkiy M (2018) Tink: A temporal graph analytics library for Apache Flink In: Proc. of WWW ’18, 71–72.. ACM, New York.

23. Masuda, N, Holme P (2013) Predicting and controlling infectious disease epidemics using temporal networks. F1000prime Rep 5.

24. Mertzios, GB, Michail O, Spirakis PG (2019) Temporal network optimization subject to connectivity constraints. Algorithmica 81(4):1416–1449.

25. Modiri, AB, Karsai M, Kivelä M (2019) Efficient limited time reachability estimation in temporal networks. arXiv preprint arXiv:1908.11831.

26. Newman, MEJ (2018) Networks. Oxford University Press, Oxford.

27. Nicosia, V, Tang J, Mascolo C, Musolesi M, Russo G, Latora V (2013) Graph metrics for temporal networks In: Temporal Networks, 15–40.. Springer, New York.

28. Nicosia, V, Tang J, Musolesi M, Russo G, Mascolo C, Latora V (2012) Components in time-varying graphs. Chaos Interdisc J Nonlinear Sci 22(2):023101.

29. Pan, RK, Saramäki J (2011) Path lengths, correlations, and centrality in temporal networks. Phys Rev E 84(1):016105.

30. Rad, AA, Flocchini P, Gaudet J (2017) Computation and analysis of temporal betweenness in a knowledge mobilization network. Comput Soc Netw 4(1):5.

31. Salathé, M, Kazandjieva M, Lee JW, Levis P, Feldman MW, Jones JH (2010) A high-resolution human contact network for infectious disease transmission. Proc Natl Acad Sci 107(51):22020–22025.

32. Santoro, N, Quattrociocchi W, Flocchini P, Casteigts A, Amblard F2011. Time-varying graphs and social network analysis: Temporal indicators and metrics.

33. Wu, H, Cheng J, Ke Y, Huang S, Huang Y, Wu H (2016) Efficient algorithms for temporal path computation. IEEE Trans Knowl Data Eng 28(11):2927–2942.

34. Xuan, BB, Ferreira A, Jarry A (2003) Computing shortest, fastest, and foremost journeys in dynamic networks. Int J Found Comput Sci 14(02):267–285.

35. Zschoche, P, Fluschnik T, Molter H, Niedermeier R (2020) The complexity of finding small separators in temporal graphs. J Comput Syst Sci 107:72–92.

## Acknowledgements

We thank Lilian Jacobs (TU Berlin) for her programming work helping to enable our experimental studies and the anonymous reviewers of COMPLEX NETWORKS 2019 and Applied Network Science for their constructive feedback.

## Funding

ASH was supported by the DFG, project FPTinP (NI 369/16). Open access funding provided by Projekt DEAL.

## Author information

Authors

### Contributions

Parts of this work originated from the master thesis of ASH. Overall, all authors have contributed equally to the paper. All authors read and approved the final manuscript.

### Corresponding author

Correspondence to Matthias Bentert.

## Ethics declarations

### Competing interests

The authors declare that they have no competing interests.

### Publisher’s Note

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

Anne-Sophie Himmel is supported by the DFG, project FPTinP (NI~369/16).

## Rights and permissions
{"ft_lang_label":"__label__en","ft_lang_prob":0.8585434,"math_prob":0.9964968,"size":59976,"snap":"2021-43-2021-49","text_gpt3_token_len":15488,"char_repetition_ratio":0.1690122,"word_repetition_ratio":0.077377185,"special_character_ratio":0.25146726,"punctuation_ratio":0.11464442,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.999584,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,4,null,4,null,6,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-12-06T15:14:19Z\",\"WARC-Record-ID\":\"<urn:uuid:ced7b852-f051-428b-87c5-0ff3157ad3ec>\",\"Content-Length\":\"345571\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b4413f8b-3439-413a-9f44-00c6dc83531d>\",\"WARC-Concurrent-To\":\"<urn:uuid:754da81b-abe7-4443-a6ed-5cf549dfbb2e>\",\"WARC-IP-Address\":\"146.75.32.95\",\"WARC-Target-URI\":\"https://appliednetsci.springeropen.com/articles/10.1007/s41109-020-00311-0\",\"WARC-Payload-Digest\":\"sha1:B4OORNJ622STL53H2PDQIMRNZYCYTAPQ\",\"WARC-Block-Digest\":\"sha1:7PGRGIUQ7PLDF4S2LLNY4IJI6NIILNXY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964363301.3_warc_CC-MAIN-20211206133552-20211206163552-00493.warc.gz\"}"}