Eulerian Walks in Temporal Graphs

An Eulerian walk (or Eulerian trail) is a walk (resp. trail) that visits every edge of a graph G at least (resp. exactly) once. This notion was first discussed by Leonhard Euler while solving the famous Seven Bridges of Königsberg problem in 1736. But what if Euler had to take a bus? In a temporal graph (G,λ)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{(G,\lambda )}$$\end{document}, with λ:E(G)→2[τ]\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{\lambda : E(G)}\varvec{\rightarrow } \varvec{2}^{\varvec{[\tau ]}}$$\end{document}, an edge e∈E(G)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{e}\varvec{\in } \varvec{E(G)}$$\end{document} is available only at the times specified by λ(e)⊆[τ]\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{\lambda (e)}\varvec{\subseteq } \varvec{[\tau ]}$$\end{document}, in the same way the connections of the public transportation network of a city or of sightseeing tours are available only at scheduled times. In this paper, we deal with temporal walks, local trails, and trails, respectively referring to edge traversal with no constraints, constrained to not repeating the same edge in a single timestamp, and constrained to never repeating the same edge throughout the entire traversal. We show that, if the edges are always available, then deciding whether (G,λ)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{(G,\lambda )}$$\end{document} has a temporal walk or trail is polynomial, while deciding whether it has a local trail is NP\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{\texttt {NP}}$$\end{document}-complete even if τ=2\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{\tau = 2}$$\end{document}. In contrast, in the general case, solving any of these problems is NP\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{\texttt {NP}}$$\end{document}-complete, even under very strict hypotheses. We finally give XP\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{\texttt {XP}}$$\end{document} algorithms parametrized by τ\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{\tau }$$\end{document} for walks, and by τ+tw(G)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{\tau +tw(G)}$$\end{document} for trails and local trails, where tw(G)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{tw(G)}$$\end{document} refers to the treewidth of G\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varvec{G}$$\end{document}.


Introduction
An Eulerian walk (or Eulerian trail) is a walk (resp. trail) that visits every edge of a graph G at least once (resp. exactly once). The Eulerian trail notion was first discussed by Leonhard Euler while solving the famous Seven Bridges of Königsberg problem in 1736, where one wanted to pass by all the bridges over the river Preger without going twice over the same bridge. Imagine now a similar problem, where you have a set of tourist sights linked by possible routes. If the routes themselves are also of interest, a sightseeing tourism company might want to plan visits on different days that cover all the routes. One could do that with no constraints at all (thus performing a walk), or with the very strict constraint of never repeating a route (thus getting a trail), or constraining oneself to at least not repeating the same route on the same day (thus getting what we called a local trail). If we further assume that some routes might not be always accessible, we then get distinct problems defined on temporal graphs.
In a temporal graph (G, λ) with lifetime τ , we have λ : E(G) → 2 [τ ] , and an edge e ∈ E(G) is available only at the times specified by λ(e) ⊆ [τ ], in the same way the connections of the public transportation network of a city or of sightseeing tours are available only at scheduled times. In this scenario, paths and walks are valid only if they traverse a sequence of adjacent edges e 1 , . . . , e k at non-decreasing times t 1 ≤ . . . ≤ t k , respectively, with t i ∈ λ(e i ) for every i ∈ [k] (similarly, one can consider strictly increasing sequences, i.e. with t 1 < . . . < t k ). The research on temporal graphs has attracted a lot of attention in the past decade (we refer the reader to the surveys of [21,24], and the seminal paper of [19]). They have appeared also under different names, e.g. as time-varying graphs [6], as evolving networks [4]), and as link streams [21].
Several translations of Eulerian trails and walks are possible in temporal terms, depending on the constraints we consider. In particular, we study the following variations. Below, all the walks and trails are implicitly considered to be temporal, as defined in the previous paragraph.
Problem Given a temporal graph (G, λ), we consider the following problems: • Eulerian Walk: deciding whether (G, λ) has an Eulerian walk, i.e. a walk traversing each edge of G at least once. • Eulerian Local Trail: deciding whether (G, λ) has an Eulerian local trail, i.e. a walk traversing each edge of G at least once, and at most once in each timestamp. • Eulerian Trail: deciding whether (G, λ) has an Eulerian trail, i.e. a walk traversing each edge of G exactly once.
We also consider the related problems where the walks/trails are closed (first vertex equal to the last one), respectively referring to them as Eulerian Closed Walk, Eulerian Local Tour, and Eulerian Tour. Finally, for all of the above problems, we add the prefix Strict to refer to the variation in which walks must be strictly increasing sequences of edges. Observe that, when τ = 1, then both Eulerian Trail and Eulerian Local Trail degenerate into the original formulation of the Seven Bridges of Königsberg problem. This is why we think they appear to be more natural adaptations of the static version of the problem.
One of the concepts closest to ours is the one defined by [26], where he gives a polynomial-time algorithm to check the existence of an Eulerian closed walk (i.e. a tour) in dynamic graphs. However, the dynamic graph model is quite different from the temporal graph model used in this paper, as pointed out by [24]. Indeed, looking at the corresponding time-expanded graph related to the one of [26], temporal edges can go back in time and the graph is infinite. Nevertheless, the results presented there seemed to point towards the polynomiality of the problems investigated here, as observed by [24]: "the results proved for it [the dynamic graph model] are resounding and possibly give some first indications of what to expect when adding to combinatorial optimization problems a time dimension". We found however that this is not the case, as we will show that even Eulerian Walk turns out to be NP-complete on temporal graphs. Taking inspiration by [26], we also define a dynamic-based temporal graph as a temporal graph whose edges are always available, and we analyze the complexity of the above problems on these particular instances.
In this paper we prove the following results. These are summarized in Table 1, which also reports some recent results that will be discussed shortly.

Theorem 1 Given a temporal graph (G, λ) with lifetime τ ,
1. Eulerian Walk is NP-complete, even if either each snapshot of (G, λ) is a forest with a constant number of edges, or each edge appears at most 3 times. Also, it is polynomial-time solvable if (G, λ) is dynamic-based, and is in XP when parameterized by τ . 2. Eulerian Local Trail is NP-complete for each τ ≥ 2, even if (G, λ) is dynamic-based. It is in XP when parameterized by τ + tw(G). 3. Eulerian Trail is NP-complete for each τ ≥ 2. It is polynomial if (G, λ) is dynamic-based. It is in XP when parameterized by τ + tw(G).
The same results hold for tours, i.e. for Eulerian Closed Walk, Eulerian Local Tour, and Eulerian Tour.
Theorem 1 gives a complete taxonomy of our problems, also focusing on the possibility of getting polynomial-time algorithms when we have a small lifetime τ . In particular, for Eulerian Trail and Eulerian Local Trail, since they become polynomial when τ = 1, the bound for τ is optimal, giving us a complete dichotomy with respect to the lifetime of (G, λ). In contrast, Eulerian Walk is easily solvable for every fixed τ , meaning that walks are easier than trails even on the temporal context. We also show that Eulerian Trail and Eulerian Local Trail are solvable in XP time if parameterized by τ + tw(G). Our negative results for constant τ combined with known negative results for constant tw(G) (see Table 1) exclude the possibility of XP algorithms if parameterized just by τ or tw(G). An FPT algorithm parameterized by τ + tw(G) could still exist.
It is important to remark that none of the variations we considered immediately implies any of the others. We will show indeed that the property of being Eulerian for the static base graph G is in general a necessary but not sufficient condition for the existence of an Eulerian trail, becoming sufficient only if we restrict to dynamic-based temporal graphs. In the case of Eulerian local trail, we will see that this property is not even necessary. In addition, if only strictly increasing temporal walks/trails are For general temporal graphs (first row), for dynamic-based temporal graphs (second row), for temporal graphs whose base graph has bounded treewidth (last row). k refers to the maximum number of appearances of an edge. † corresponds to deciding whether G is connected. Blue are direct applications or easy implications of results by [5]. Corresponds to deciding whether G has an Eulerian trail. All the results to Strict Eulerian Walk, Strict Eulerian Local Trail, Strict Eulerian Trail, except that we τ = (m) is necessary, with m = |E(G)|, as when τ < m the answer is trivially NO allowed, then our reductions for the first row of Table 1 can be easily modified, thus giving NP-completeness results also in this case. Observe that in this case a necessary condition for a positive answer is τ ≥ |E(G)|; this is why we do not have the same bounds for τ as in Theorem 1. Also in the case of dynamic-based temporal graphs (second row of Table 1), the polynomiality is preserved for strictly increasing Eulerian walks and Eulerian trails and we leave open the question whether Strict Eulerian Local Trail is still NP-complete on dynamic-based temporal graphs.
As a byproduct of our reductions we get the following result about static graphs, which can be of independent interest. Corollary 3 Given a graph G, deciding whether the edges of G can be covered with two trails is NP-complete.
A preliminary version of this paper appeared in [23]. With respect to that version, we now present complete proofs of Theorems 5 and 8, we add an XP algorithm parameterized by treewidth and lifetime (Sect. 6), and we discuss the dynamic graph result by [26] in Appendix A.

Related work
Eulerian Walk is related to the TEXP problem investigated by [25], which consists of, given a temporal graph (G, λ), finding a strictly increasing temporal walk that visits all vertices in G (possibly, more than once) whose arrival time is minimum. [25] prove that TEXP is NP-complete and even not approximable unless ¶ = NP. This is in stark contrast with the static version of the problem, which can be trivially solved in linear time. A lot of research has been devoted to temporal exploration, e.g. bounding the arrival time of such walks in special instances [11,13] and extending previous results in the case of non-strictly increasing paths [12]. Akrida et al. [1] proved that TEXP is NP-complete even when restricted to temporal stars in which each edge appears at most k times, for all fixed k ≥ 6. This result has been improved by [5] to all fixed k ≥ 4. On the other hand, Akrida et al. [1] showed that if each edge appears at most k = 3 times, then the problem is polynomial-time solvable on temporal stars. Observe that, in a star, passing by all the leaves translates into passing by all the edges. Therefore their result implies NP-completeness for Strict Eulerian Walk with the same constraints as before. Note that in contrast Eulerian Walk is trivial on stars since one can always go back to the central vertex. Nevertheless, as will be discussed in Sect. 6, Eulerian Walk is NP-complete on general trees by a modification of the reduction presented by [5], as highlighted by Table 1. Notice also that, unlike stars, our main theorem says that Eulerian Walk on general temporal graphs is NP-complete when edges appear at most 3 times. Now, note that Strict Eulerian Walk is equivalent to (Strict) Eulerian Local Trail. Hence, still from the previous paragraph, we get that (Strict) Eulerian Local Trail is NP-complete on stars. In particular, we get that Eulerian Local Trail is NP-complete when restricted to temporal graphs where each edge appears at most k times, for all fixed k ≥ 4. We improve this bound for k = 2 even when the temporal graph is dynamic based, and present an algorithm that runs in XP time when parametrized by τ + tw(G).
Concerning Eulerian Trail, to the best of our knowledge, there is only one other paper investigating this problem, that appeared in the same volume as the preliminary version of this paper and focuses on the Eulerian Trail variation, giving independent and broadly different results [5]. In particular, other than proving the results on TEXP mentioned above, they prove that Eulerian Trail is NP-complete even if each edge appears at most k times, for every fixed k ≥ 3. Observe that our result improves that to k = 2, since we prove it is NP-complete even if the lifetime is 2. Nevertheless, even though their reduction produces a temporal graph with unbounded lifetime, it also gives a base graph with very simple structure (a set of triangles intersecting in a single vertex, which is a graph with treewidth 2). In addition, they also introduce a parameter for temporal graphs, that they called interval-membership width (denoted by imw(G, λ)), and provide an algorithm FPT when parametrized by k + imw(G, λ), as also reported in Table 1. As k +imw(G, λ) is not related to τ +tw(G), our algorithm XP in τ + tw(G) is of independent interest.
When considering dynamic-based temporal graphs, as edges are assumed to be always available during the lifetime τ , we could relate our problems to several other problems on static graphs. A closely related one would be the Chinese Postman problem, where the edges of the graph have positive weights and one wants to find an Eulerian closed walk on G with minimum weight; in other words, one wants to add copies of existing edges in order to obtain an Eulerian graph of minimum sum weight. Even if we regard the Chinese Postman problem where the weights are all equal to 1, this is very different from our approach since for us, repetition of a long common trail in different snapshots does not make the solution worse, while it would when considering the Chinese Postman problem. It is easy to see though that the solution for the Chinese Postman problem would give us an upper bound for the amount of time spent on an Eulerian local tour of a dynamic-based graph, as we could start a new trail on a new snapshot whenever an edge repetition was detected. The Chinese Postman problem is largely known to be polynomial [18], and some variations that take time into consideration have been investigated, mostly from the practical point of view (see e.g. [7,27,28]), but none of which is equivalent to our problems. Among these, we mention the so-called HCPP (Hierarchical Chinese Postman Problem), where the set E of all the edges is partitioned into clusters, i.e.
and there is a partial order < between clusters. The HCPP aims to find a path of minimum weight passing through all the edges and such that, if an edge in E j is traversed, all the edges in E i for every i < j must be previously traversed. This has been shown to be NP-hard in general and polynomial if the order is linear and other conditions are met [10]. As it can be seen, this problem is very different from our problems for several reasons: a walk is free to traverse an edge E j and then an edge in E i with i < j, each edge belongs to just one time stamp, and each walk must traverse all the edges in the previous timestamps.
The problem of trying to obtain an Eulerian subgraph (as opposed to a supergraph, as was the case in the previous paragraph) has also been studied. [8] study a family of problems where the goal is to make a static graph Eulerian by a minimum number of deletions. They completely classify the parameterized complexity of various versions of the problem: vertex or edge deletions, undirected or directed graphs, with or without the requirement of connectivity. Also, [15] study the parameterized complexity of the following Euler subgraph problems: (i) Largest Euler Subgraph -for a given graph G and integer parameter k, does G contain an induced Eulerian subgraph with at least k vertices?; and (ii) Longest Circuit -for a given graph G and integer parameter k, does G contain an Eulerian subgraph with at least k edges?
Eulerian Local Trail on dynamic-based graphs is actually more closely related to the problem of covering the edges of a graph with the minimum number of (not necessarily disjoint) trails, whereas the aforementioned problems are more concerned with either minimizing edge repetitions or maximizing the subgraph covered by a single trail. Even if the trail cover problem can be so naturally defined and involve such a basic structure as trail, up to our knowledge it has not been previously investigated yet. Note that Eulerian Local Trail is slightly different from trail cover, since we also require that together the trails form a walk. In any case, a small modification of our proof of Theorem 1.1 implies that deciding whether the edges of a graph can be covered with at most two trails is NP-complete (Corollary 3). We mention that the vertex version of this problem, namely the path cover problem, has been largely investigated (see e.g. [2,17,22]).

Preliminaries
We use standard definitions and notation of graph theory; we refer the unfamiliar reader to [29]. A graph G has an Eulerian tour (trail) if and only if G has at most one non-trivial component and all the vertices have even degree (at most two vertices have odd degree) (see [14]). A graph is called Eulerian if it has an Eulerian tour.
Concerning temporal graphs, we use and extend the notation in [24]. A temporal graph is a graph together with a function on the edges saying when each edge is active; more formally, a temporal graph is a pair (G, λ), where λ : E(G) → 2 N−{0} . Here, we consider only finite temporal graphs, i.e., graphs such that max e∈E(G) λ(e) is defined. This value is called the lifetime of (G, λ) and denoted by τ . Given i ∈ [τ ], we define the snapshot G i as being the subgraph of G containing exactly the edges active in time i; more formally, In what follows, in order to make the reading more fluid, we often talk about "occurrence of an edge". When this is done we are implicitly referring to the corresponding temporal edge; for instance, by "edge e occurs in G i " we mean that i ∈ λ(e) (and hence (e, i) is a temporal edge). Given We define a walk in a temporal graph similarly, except that a walk cannot go back in time. More formally, given a temporal graph We say that a temporal walk W is a trail if there are no two occurrences of the same edge of G in W . We say that W is a local trail if there are no two occurrences of the same edge of G in the same snapshot, i.e., if W restricted to G i is a trail in G for every i ∈ [τ ]. A closed (local) trail is also called a (local) tour. Finally, a temporal walk W is called Eulerian if at least one occurrence of each edge of G appears at least once in W . Observe that, by definition, an Eulerian temporal trail visits every edge of G exactly once. From now on, we omit the word "temporal" as all treated walks/trails are temporal.
A dynamic-based graph is a temporal graph (G, λ) where the edges are always available, i.e. λ(e) = [τ ] for each e ∈ E(G). 1 We denote a dynamic-based graph simply by (G, [τ ]) where τ is the lifetime of the temporal graph.

Eulerian Walk
In this section we focus on Eulerian Walk, i.e. deciding if there is a temporal walk passing by each edge at least once, proving the results in Item 1 in Theorem 1, Fig. 1 First three snapshots of the construction. For simplicity, we represent only the non-trivial components of each snapshot. In this example, we have c 1 containing ( summarized in the first column of Table 1. We start by presenting a simple algorithm that solves the problem in XP time when parameterized by the lifetime.

Lemma 4 Given a temporal graph
is empty, then this snapshot can be suppressed. Our problem reduces to deciding whether there is a choice of connected components H 1 , . . . , H τ of G 1 , . . . , G τ , respectively, that together cover all the edges of G and is such that H i intersects H i+1 , for each i ∈ [τ − 1]. More formally, H 1 , . . . , H τ must be such that: In the following, we show that when τ is unbounded, deciding whether (G, λ) admits an Eulerian walk is NP-complete by reducing from 3-SAT. This is best possible because of the above lemma.

Theorem 5 Given a temporal graph (G, λ), deciding whether (G, λ) admits an Eulerian walk is NP-complete, even if either each snapshot of (G, λ) is a forest with a constant number of edges, or each edge appears in at most 3 snapshots.
Proof We make a reduction from 3-SAT. Let φ be a 3-CNF formula on variables {x 1 , . . . , x n } and clauses {c 1 , . . . , c m }, and construct G as follows. For each clause c i , add vertices {a i , b i } to G and edge a i b i . Now consider a variable x i , and let c i 1 , . . . , c i p be the clauses containing x i positively, and c j 1 , . . . , c j q be the clauses containing x i negatively. Add two new vertices x i , x i to G, and edges {x i a i k | k ∈ [p]}∪{x i a j k | k ∈ [q]}; denote the spanning subgraph of G formed by these edges by H i , and let H i be equal to H i together with edges {a i b i | i ∈ {i 1 , . . . , i p , j 1 , . . . , j q }}. We can suppose that {i 1 , . . . , i p } ∩ { j 1 , . . . , j q } = ∅ as otherwise the clauses in the intersection would always be trivially valid; thus we get that H i , H i are forests. Finally, add a new vertex T and make it adjacent to every vertex in We now describe the snapshots of (G, λ). See Fig. 1 to follow the construction. We first build 2 consecutive snapshots in (G, λ) related to x i , for each i ∈ [n]. The first one is equal to H i , and the second one contains exactly the edges this can be done because this subgraph is connected. Denote by S 1 i , S 2 i the first and second snapshot of x i , for each i ∈ [n]. Put these snapshots consecutively in timestamps 1 through 2n, in the order of the indexing of the variables. For now, observe that only the last snapshot might not be a forest; this will be fixed later. We now prove that φ is a satisfiable formula if and only if (G, λ) admits an Eulerian walk.
Observe first that, since we are dealing with a walk, we are allowed to repeat edges as many times as we want; hence, if we visit any vertex inside a component of a snapshot, we can also visit the entire component. At the same time, it is not possible to visit more than one component within a snapshot. In the following we show the proof of equivalence.
First consider a satisfying assignment of φ. Now, construct an Eulerian walk as follows. Start by visiting all the edges in the component of H 1 containing x 1 , if x 1 is true, or the one containing x 1 , otherwise. Then, in S 2 1 , jump to x 2 if x 2 is true, or to x 2 , otherwise. Repeat the process until reaching S 1 n , and at the last snapshot, visit all the edges in Because each clause c i contains at least one true variable, we know that edge a i b i is visited. Now, consider an Eulerian walk W of (G, λ), and denote by W j i the walk W restricted to S j i , for each i ∈ [n] and j ∈ [2]. We set x i to true if W 1 i contains x i , and to false otherwise. Now, consider a clause c i containing variables x k 1 , x k 2 , x k 3 . Because a i b i appears only in snapshots S 1 k 1 , S 1 k 2 , S 1 k 3 , and only in the component containing the literal that appears in c i , we get that at least one of the three literals must be set to true.
Finally, we prove that the constraints can be assumed. First, we count the number of appearances. Observe that each edge of type a i b i appears in exactly three snapshots, namely the snapshots related to the variables contained in c i . Also, for a given variable x i , the edges inside S 1 i between x i , x i and vertices in {a j | j ∈ [m]} appear once in that snapshot, and a second time in snapshot S 2 n . Finally, in a similar way the edges between T and {x i , , and a third time in snapshot S 2 n . It follows that the problem is NP-complete even if each edge appears at most 3 times. Now, we want to spread snapshot S 2 n in a way that each snapshot becomes a forest with a constant number of edges. Observe that we could repeat the same pattern as the one in the first 2n − 1 snapshots in order to visit the remaining edges in G − {a j b j | j ∈ [m]}. As long as the edges in {a i b i | i ∈ [m]} appear only in the first 2n − 1 snapshots, the same argument as before still applies, and we get the further constraint that each snapshot is a forest. Additionally, they can also be considered to have a constant number of edges since 3-SAT is NP-complete even if each variable appears at most three times [9]. Note that requiring both constraints to hold would increase the maximum number of appearances to 4.
If instead we are considering strictly increasing walks, a small modification of our construction will also imply NP-completeness, hence proving Corollary 2(i). Indeed, it suffices to relate each variable x i to a window big enough to ensure we will be able to visit all the edges of the considered component. Because each variable appears at most three times, one can see that it is enough that the edges are available for a period of 12 timestamps. So, our previous snapshot S 1 i remains available for 12 consecutive timestamps, after which we will make S 2 i available for 2 timestamps. Because the spare time can never be used to go from the component containing x i to the component containing x i , the same arguments used in Theorem 5 still hold. Now, if we consider a dynamic-based graph (G, λ), since all the edges are active throughout its lifetime, we clearly have that there exists an Eulerian walk if and only if G is connected; this proves the following Lemma.

Lemma 6 Eulerian Walk is polynomial for dynamic-based temporal graphs.
By Lemma 4, Theorem 5, and Lemma 6, we obtain Item 1 of Theorem 1. Finally, note that if one is interested in closed walks instead, not only our NP-completeness reduction can be adapted in order to ensure that we can always go back to the initial vertex, but also the complexity results still hold.

Eulerian Local Tours and Trails
In this section we focus on Item 1 of Theorem 1. In the whole section, we will focus on dynamic-based temporal graphs as the hardness results for general temporal graphs are implied by the ones we prove for this restricted class. After the preliminary result in Lemma 7, we focus on proving the hardness result for the problem of deciding whether (G, [2]) has an Eulerian local tour, explaining the construction behind our reduction from NAE 3-SAT, whose correctness is proved in Theorem 8. We also argue that, if G is a cubic graph, then being Hamiltonian is a necessary but not sufficient condition for (G, [2]) to admit an Eulerian local tour, arguing the need of an ad hoc reduction for our problem. As the reduction in Theorem 8 focuses on solving Eulerian Local Tour for τ = 2, in Corollary 9 we extend this result to each fixed τ and to trails, thus completing the proof of Item 1 of Theorem 1. The following lemma helps us in our proof.

Lemma 7 Let G be a graph. If (G, [2]) has an Eulerian local tour T , then T restricted to snapshot i must pass by all vertices of odd degree in G, for each i ∈ [2].
Proof For each i ∈ [2], denote by T i the trail in G equal to T restricted to timestamp i, and suppose, by contradiction, that u ∈ V (G) is a vertex with odd degree not contained in T 1 . Because T is a temporal tour, observe that T 1 is a trail in G starting at some s and finishing at some t, and T 2 is a trail in G starting at t and finishing at s, with possibly s = t. This means that the subgraph of G formed by the edges of T 2 is such that every x ∈ V (G) \ {s, t} has even degree. This is a contradiction because, since no edge incident to u is visited in T 1 , we get that all the edges incident to u must be visited in T 2 , i.e., u would have odd degree in T 2 . The same argument holds in case u is not in T 2 , and the lemma follows.
A simple consequence of the above lemma is that, as previously said, if G is cubic, then G must be Hamiltonian in order for (G, [2]) to have an Eulerian local tour. Since deciding whether a cubic graph is Hamiltonian is NP-complete [16], this hints towards the NP-completeness of the problem. However, since the other way around is not necessarily true (see e.g. the graph in Fig. 2), we need an explicit reduction. Indeed, the construction in Fig. 2 shows us that we might need an arbitrarily large lifetime in order to be able to visit all the edges of (G, [τ ]) even if G is a 2-connected outerplanar subcubic graph (which is trivially Hamiltonian). 2 In the following we explain the construction behind our reduction from NAE 3-SAT. Let φ be a CNF formula on variables {x 1 , . . . , x n } and clauses {c 1 , . . . , c m }. We start by presenting a meta-construction, in the sense that part of the constructed graph will be presented for now as black boxes and the actual construction is done later, as depicted in Fig. 3. The meta part concerns the clauses; so for now, denote by C i the black box related to clause c i . Without going into details, C i will contain exactly one entry vertex for each of its literals, with some additional vertices, that will be presented later. So, given a literal contained in c i , denote by I i ( ) the entry vertex for in C i . For each clause c i with literals j, k, and , the three vertices I i ( j), I i (k), and I i ( ) are distinct. Now, for each variable x i , let c i 1 , . . . , c i p be the clauses containing x i positively and c j 1 , . . . , c j q containing x i negatively. Add two new vertices, I i and O i (these will be the entry and exit vertices for the variable gadget), and add the following edges (these compose the paths shown in Fig. 3): . 4 Gadgets for the reduction in Theorem 8 The paths will function as a switch, telling us whether the variable is true or false within the considered snapshot; we then denote by P i the set of edges in the path (I i , I i 1 (x i ), . . . , I i p (x i ), O i ), and by P i the set of edges in the path . Now, to link the variable gadgets and to construct the clause gadgets, we will need a gadget that will function as an edge that must appear in the trail performed in G 1 and the one performed in G 2 . For this, we use Lemma 7 applied to the gadget in Fig. 4a; when adding such a gadget between a pair u, v, we simply say that we are adding the forced edge uv. Now, to link the variable gadgets, we add three new vertices s 1 , s 2 , t and the following forced edges.
The new vertices simply help us assume where the trail starts and finishes. Now, let T be an Eulerian local tour of (G, [2]) and denote by T i the trail in G defined by T restricted to G i , for i ∈ [2]. It is fairly easy to see (and we will prove it shortly) that if we can ensure that T 1 uses P i if and only if T 2 uses P i , then we can prove equivalence with NAE 3-SAT. In other words, the clause gadget must be so that, for every clause c j containing x i (or equivalently x i ), we get that either both edges incident to I j (x i ) in P i (or equivalently I j (x i ) in P i ) are used, or none of them is used. Such a gadget is presented in Fig. 4b, where the red edges are forced.

Theorem 8 Let G be a graph with degree at most 4. Then Eulerian Local
Tour is NP-complete on (G, [2]).
Proof Let φ and G be as previously constructed. First, consider a truth NAE assignment f to φ. We construct T 1 , T 2 ⊆ E(G) and prove that they form an Eulerian local tour of (G, [2]). Start by putting P i in T 1 and P i in T 2 if x i is true, and the other way around if x i is false. From now on, whenever we add a forced edge to T 1 and T 2 , we are actually adding the trails depicted in Fig. 5. Now, add E to both T 1 and T 2 , and consider c i with literals 1 , 2 , 3 . Suppose, without loss of generality, that 1 is true and 2 is false. We then add to T 1 the trail  Fig. 6a, and to T 2 the one depicted in Fig. 6b. Observe that all internal edges of C i are covered. Also note that the value of 3 is irrelevant (the choice remains the same, let it be true or false). We know that the remaining edges are also covered by T 1 ∪T 2 by construction. Finally, notice that both T 1 and T 2 touch all odd-degree vertices in a way that every vertex (including the even-degree ones) has even degree in T 1 and in T 2 , except s 1 , s 2 which have degree exactly 1. Also note that they form a connected graph; indeed they are formed by the cycle passing through the variable gadgets and t, together with some pending trails passing by the clause gadgets. Therefore, we can find an s 1 , s 2 -trail passing by all edges of T 1 , and an s 2 , s 1 -trail passing by all edges of T 2 , thus getting our Eulerian local tour. For the reverse, let T be an Eulerian local tour of (G, [2]), and for each i ∈ [2], denote by T i the trail in G defined by T restricted to G i . We need to prove that φ has an NAE satisfying assignment, and for this it suffices to show that, for every variable x i , either P i or P i is contained in T k for each k ∈ [2]. First observe that Lemma 7 indeed ensures that T 1 and T 2 restricted to the gadget related to a forced edge uv must be exactly as the trails depicted in Fig. 5; so in what follows we treat them exactly like edges that must appear in T 1 and T 2 . Since there are 2 vertices of degree 1, namely s 1 and s 2 , by Lemma 7 we can suppose that T 1 starts in s 1 and finishes in s 2 , while T 2 starts in s 2 and finishes in s 1 . Therefore, each of T 1 and T 2 contains a tour in G − {s 1 , s 2 }, and hence: (I) Every vertex u ∈ V (G) \ {s 1 , s 2 } has even degree in both T 1 and T 2 . Now, we prove that for each x i , if T 1 intersects P i , then T 1 does not intersect P i , the same holding for T 2 . For this, consider c i with literals 1 , 2 , 3 , and for each j ∈ [3], denote by e 1 i ( j ), e 2 i ( j ) the edges incident to I i ( j ) not contained in C i . We first prove that, for each j ∈ [3] and k ∈ [2]: is used in T k . Without loss of generality, assume j = 1 and let k ∈ [2]; suppose by contradiction that . But then we get that a i 1 a i 2 and a i 2 I i ( 1 ) are not in T k , as otherwise either a i 1 or I i ( 1 ) would have odd degree in T k . This is a contradiction since we then get a i 2 with degree 1 in T k . The same argument can be analogously applied when a i 2 I i ( 1 ) is in T k or when j ∈ {2, 3}. Consider now a variable x i , and let c i 1 , . . . , c i p be the clauses containing x i positively and c j 1 , . . . , c j q containing x i negatively. Because I i has degree 3 in G and E \ {s i t | i ∈ [2]} is contained in T 1 ∩ T 2 , we get that exactly one edge between I 1 I i 1 (x i ) and I 1 I j 1 (x i ) is contained in T 1 . From (II), we then get that either P i is contained in T 1 or P i is contained in T 1 . Observe that this implies that P i is contained in T k , while P i is contained in T 3−k , for some k ∈ [2]. We then set x i to be true if and only if T 1 contains P i . Because the edges in } separate C i from the rest of the graph and by (I), we get that both T 1 and T 2 must intersect E i . Finally by (II) we get that this assignment is a NAE truth assignment for φ.
Observe that if we add two new vertices of degree one adjacent to the vertex t, then we get a reduction to the problem of deciding whether the edges of G can be covered by two trails, proving Corollary 3. The following corollary concludes the proof of Item 1 in Theorem 1.

Corollary 9
Eulerian Local Tour and Eulerian Local Trail are NP-complete on temporal graphs with lifetime τ for every fixed τ ≥ 2. This also holds on dynamicbased graphs.
Proof We first make a reduction from Eulerian Local Tour on (G, [2]) to Eulerian Local Trail on (G , [τ ]). Given (G, [2]) constructed as in the proof of Theorem 8, let G be obtained from G by adding a star on τ +2 vertices and identifying one of its leaves with s 1 . We argue that (G, [2]) has an Eulerian local tour (starting and finishing in s 1 ) if and only if (G , [τ ]) has an Eulerian local trail. Denote the vertices of the initial star by u, v 1 , . . . , v τ +1 , where u is the central vertex, and v 2 = s 1 is the vertex where G is pending. Let T be an Eulerian local tour of (G, [2]) starting and finishing in s 1 , and T 1 , T 2 be the trails in G defined by T . Build an Eulerian local trail of (G , [τ ]) by visiting v 1 u, uv 2 and T 1 in G 1 , then performing T 2 and visiting v 2 u and uv 3 in G 2 , and finish visiting the remaining edges of the star in the obvious way. Now, let T be an Eulerian local trail of (G , [τ ]), and denote by T i the trail in G defined by T restricted to G i , for each i ∈ [τ ]. Observe that because we have τ + 1 cut edges, we get that each T i contains at most 2 of them, and in case it contains exactly 2, say v 1 u, uv 2 , then T i+1 either does not contain any cut edge, or must intersect T i in v 1 u, uv 2 . This means that the best we can do in order to finish by time τ is to visit exactly two of them in the first snapshot, and exactly one more in each of the subsequent snapshots. We can therefore suppose, without loss of generality that T i contains v i u, v i+1 u for each i ∈ [τ ]. Note that this implies that every edge of (G, [2]) must be visited in T 1 and T 2 , with T 1 starting in v 2 and T 2 finishing in v 2 , as we wanted to prove.
Finally, note that (G , [τ ]) constructed above has an Eulerian local trail if and only if (G , [τ + 1]) has an Eulerian local tour. This completes our proof.
Finally, in order to prove Corollary 2.(ii), which considers strictly increasing local trails, we can make a modification similar to the one made for walks. Observe that this transformation results in a non-dynamic-based temporal graph.

Proof of Corollary 2.(ii)
As made for walks, we slice the lifetime of (G, λ) into windows, each window allowing only for the edges of a given variable to appear. For this, first observe that, for each clause c j , a pass inside of C j uses at most 20 edges inside of C j (already considering that a pass through a forced edge consists of a path on 5 edges). This means that if we allow the edges of a variable x i appearing in c j to live long enough, we will be able to visit C j in a strictly increasing way. For simplicity, consider again that each variable appears at most 3 times in φ. We assign to each x i two time windows, one for the first passing, one for the second, each of size 70. Thus, variable x 1 will take windows {1, . . . , 70} and {70n +1, . . . , 70(n +1)}, with the edges of P 1 ∪ P 1 ∪ {O 1 I 2 } being active in the following times: the first edge of P 1 and of P 1 are active in time 1 and 70n +1, the last edges of P 1  this can be combined with the end of the first window of x n since in this window the last edges of P n and P n are active in time 70n − 5. Finally, the edges inside a clause c j will be active during the windows of the corresponding literals. One can verify that the key Property (II) in the proof of Theorem 8 holds, and NP-completeness follows.

Eulerian Tours and Trails
We finally focus on Eulerian Trail and Eulerian Tour, proving that in the general case they are both NP-complete, hence, proving Item 1 in Theorem 1. To this aim, we make an adaptation of the construction in Theorem 8. Observe that here the base graph needs to be Eulerian as otherwise the answer to Eulerian Trail is trivially NO. This also implies that the problem restricted to dynamic-based graphs is trivial: if the base graph is Eulerian, then the answer to Eulerian Tour is YES; otherwise, then the answer is NO. The trick now is to take advantage of the function λ in order to enforce the edges.
Theorem 10 Eulerian Tour and Eulerian Trail are NP-complete, even on temporal graphs with fixed lifetime τ ≥ 2.
Proof We first prove the case τ = 2. For this, we simply replace the gadget to enforce an edge uv in the construction of Sect. 4 by two paths of length 2, P 1 uv and P 2 uv , where the edges in P i uv are active only in snapshot G i , for each i ∈ [2]. Because the arguments used in Sect. 4 depended only on the fact of uv indeed being an enforced edge, we can apply the same arguments here. The only difference is that the trails in G 1 and G 2 now cannot intersect, which indeed is the case since the intersection between T 1 and T 2 in Sect. 4 is exactly the set of forced edges, and since here each appearance of a forced edge uv is actually related either to P 1 uv or to P 2 uv . Now, in order to prove the NP-completeness for higher values of τ , we add new vertices v 3 , . . . , v τ and edges . This gives us that Eulerian Trail is NP-complete on (G, λ) with lifetime τ for every fixed τ ≥ 2. And if we want a closed trail, it suffices to identify v τ with s 2 , if τ ≥ 4, and if τ = 3, we add a new vertex v 4 and edges v 3 v 4 , v 4 s 2 active only in snapshot G 3 . This concludes our proof.
Again, in order to prove Corollary 2.(iii), a modification similar to the one made for walks works. We give a more formal argument below.

Proof of Corollary 2.(iii)
As previously said, we will slice the lifetime of (G, λ) into windows, each window allowing only for the edges of a given variable to appear. For this, first observe that, for each clause c j , a pass inside of C j uses at most 11 edges (already considering that a forced edge is being replaced by two paths on 2 edges). This means that if we allow the edges of a variable x i appearing in c j to live long enough, we will be able to visit C j in a strictly increasing way. For simplicity, consider again that each variable appears at most 3 times in φ. We assign to each x i two time windows, one for the first passing, one for the second, each of size 40 (could be 39, but we choose that for roundness). Thus, variable x 1 will take windows {1, . . . , 40} and {40n + 1, . . . , 40(n + 1)}, with the edges of P 1 ∪ P 1 ∪ {O 1 I 2 } being active in the following times: the first edge of P 1 and of P 1 are active in time 1 and 40n + 1, the last edges of P 1 and of P 1 are active in time 38 and 40n + 38, forced edge O 1 , I 2 is active in times {39, 40, 40n + 39, 40(n + 1)}, and the remaining edges are active in the period {2, . . . , 37} ∪ {40n + 2, . . . , 40n + 37}. Similarly the window of x i will be {40(i − 1), . . . , 40i} ∪ {40(n + i − 1), . . . , 40(n + i)}. Note that we can link O n to I 1 directly, making them active during {40n − 1, 40n} (this is the end of the first window of x n ). Finally, the edges inside a clause c j will be active during the windows of the corresponding literals. One can verify that the key Property (II) in the proof of Theorem 8 holds, and NP-completeness follows.

Underlying Graph with Bounded Treewidth
In this section we study our problems when applied to temporal graphs (G, λ), where the graph G has bounded treewidth. In this case, first we show some negative results which are consequences of the results by [1,5], thus proving the negative blue results in Table 1. We remark that these negative results, contrarily to the ones in the previous sections, require the lifetime τ being unbounded. In the remainder of the section we complete the picture giving new algorithms for Eulerian Trail, Eulerian Local Trail and the corresponding tour problems that run in XP time when parameterized by τ + tw(G). Observe that the reductions in previous sections, combined with the following ones, exclude the possibility of algorithms XP when parameterized only by one of these two parameters.

Theorem 11
Given a temporal graph (G, λ) the following results hold. 1. Strict Eulerian Walk is NP-complete when G is a star [1,5]. Eulerian Walk is NP-complete when G is a tree. 2. Strict Eulerian Local Trail and Eulerian Local Trail are NP-complete when G is a star [1,5]. 3. Strict Eulerian Trail and Eulerian Trail are trivially polynomial for trees.
And if tw(G) = 2, then Strict Eulerian Trail is NP-complete [5], as well as Eulerian Trail.
In order to prove Theorem 11, some preliminary results on the so-called TEXP problem introduced by [25] are needed. TEXP consists of, given a temporal graph (G, λ), finding a temporal walk that visits all vertices in G (possibly, more than once) whose arrival time is minimum. In the case in which just strictly increasing walks are allowed, [1] proved that TEXP is NP-complete on temporal stars in which each edge appears at most k times, for all fixed k ≥ 6, and this result has been then improved by [5] for all fixed k ≥ 4. Since in a star, passing by all the leaves translates also into passing by all the edges, their result implies already NP-completeness for Strict Eulerian Walk for stars and hence for trees. However, in the case of Eulerian Walk these reductions cannot be applied directly and some modifications are needed, as shown by the following lemma.

Lemma 12 When increasing walks (not necessarily strictly increasing) are allowed, TEXP is NP-complete on trees even if each edge appears at most four times.
Proof We modify the reduction in [5, Theorem 1], noting that their reduction does not work directly when not necessarily strictly increasing walks are allowed. Indeed, when traversing an edge now we are allowed to go back on the same edge at the same snapshot (possibly entering more edges than expected), while the reduction requires that when traversing an edge we will go back to the center of the star in a subsequent different time. We modify the reduction, adding new leaves to the star, which will be available at suitable times in order to maintain the requirement. Doing this, our graph is not a star anymore but it is still a tree.
We modify the reduction following its notation, where, for each edge e, τ (e) corresponds to our λ(e). We do the following changes: • In the original reduction multiply all the times by 2, i.e. for each edge e each value in τ (e) becomes the double. We have thus obtained a temporal graph whose underlying graph is formed by a center with paths of length two (formed by edges e i and u i or by edges e ζ jk and u ζ jk ) departing from it, where each edge has still at most four temporal occurrences. Now, if entering from the center in e i at time t i x with x ∈ {0, 1, 2}, it is not possible to go back at time t i x because also u i must be visited and the first time in which it will be available is which is strictly greater than t i x .
Proof of Theorem 11 1. On stars Strict Eulerian Walk is equivalent to TEXP, which has been proved to be NP-complete by [1,5]. The NP-completeness for Eulerian Walk in the case of trees follows from Lemma 12. 2. Since a strict walk is also a strict local trail and vice versa, by Item 1 we obtain that Strict Eulerian Local Trail is also NP-complete when G is a star. Additionally, observe that the argument also holds if we constrain to local trails instead. Indeed every local trail is a strict walk, since it is not allowed for an edge to be visited twice in the same snapshot, and every strict walk must be a local trail similarly. 3. As for Strict Eulerian Trail and Eulerian Trail we cannot repeat edges of G. In the case of trees, these problems are trivially polynomial-time solvable, as it suffices to check whether the graph is connected and is a path. The fact that if tw(G) = 2 then Strict Eulerian Trail is NP-complete has been proved by [5] and by simply applying the idea of their reduction to the trees in Lemma 12 this result extends to Eulerian Trail. Indeed, given a temporal graph (G, λ) where G is a tree like the one in Lemma 12, i.e. a center c with s paths formed by edges e i , u i (with i ∈ {1, . . . , s}), where λ(e i ) = {t 1 , t 3 , t 5 , t 7 } and λ(u i ) = {t 2 , t 4 , t 6 } (with t i < t j if i < j), (G, λ) can be transformed into (G , λ ) such that there is a (not necessarily strictly increasing) temporal exploration in (G, λ) iff there is a (not necessarily strictly increasing) Eulerian trail in (G , λ ). G is such that each path e i , u i becomes a cycle formed by the edges e i , x i , u i , x i , e i (see the right of Figure 2 by [5] and replace each edge incident to c by a path of two edges). Then λ is as follows:

An XP Algorithm for Local Trails and Trails
In the following, we present an algorithm for Eulerian Local Trail and Eulerian Trail which runs in XP time when parameterized by the treewidth and the lifetime. It easily adapts to the tour versions of the problems, thus proving the following theorem.

Theorem 13
Let G = (G, λ) be a temporal graph with lifetime τ , and such that tw(G) = k and |V (G)| = n. Then Eulerian Local Trail, Eulerian Local Tour, Eulerian Trail and Eulerian Tour can be solved in G in time 2 k 2 ·τ · n τ .
We start by solving the Eulerian Local Trail and later explain what needs to be changed in order to solve Eulerian Trail. Before we start, we give the definitions related to tree decomposition.

Treewidth notions and notations
Given a graph G, a tree decomposition of G is a pair T = (T , X ) where T is a tree, and X assigns to each t ∈ V (T ) a subset of X t ⊆ V (G) such that: For every uv ∈ E(G), there exists t ∈ V (T ) such that {u, v} ⊆ X t ; and 3. For every t, t ∈ V (T ) and every t in the t, t -path in T , we have that X t ∩ X t ⊆ X t .
The treewidth of T is equal to max t∈V (T ) |X t | − 1, while the treewidth of G is the minimum treewith over all all tree decompositions of G; it is denoted by tw(G). To avoid confusion, the vertices of T are referred to as nodes. Also, the subsets in X are called bags. As usually done, we make use of a more well-behaved tree decomposition. A nice tree decomposition is a tree decomposition (T , X ) such that T is rooted in a vertex r , and each t ∈ V (T ) is one of the following types of nodes: • Leaf node: in this case, t is a leaf of T and X t is empty; • Forget node: t has exactly one child, t , and X t = X t \ {v}; • Introduce node: t has exactly one child, t , and X t = X t ∪ {v}; • Join node: t has exactly two children, t 1 , t 2 , and X t = X t 1 = X t 2 .
It is known that a nice tree decomposition of width at most 5tw(G) can be computed in time 2 O(tw) [3,20].
Given a nice tree decomposition (T , X ), with T rooted in r , and a node t of T , we denote by T t the subtree of T rooted in t, by V t the set containing all the vertices in a bag of T t (i.e., and by E(X t ) the set of edges in G t [X t ]. To avoid confusion with the snapshots, here we will be denoting the i-th snapshot by G[i].
An Auxiliary Problem: Partial Eulerian Local Trail Now, given a temporal graph G = (G, λ) with lifetime τ , we work on a nice tree decomposition (T , X ) of G in a bottom-up way, i.e., we solve the problem first on the leaves and move up to the root, assuming, when computing an entry of the table of a node t, that the tables of its children are known. We solve the following problem instead, which we call Partial Eulerian Local Trail: given u 1 , . . . , u τ +1 ⊆ V (G), decide whether G has a temporal Eulerian local trail passing by (u 1 , . . . , u τ +1 ). In other words, we decide whether there are subgraphs W 1 , . . . ,

The Algorithm
To solve Partial Eulerian Local Trail, we keep partial solutions of G t , for each node t of a nice tree decomposition, which means that these partial solutions might be disconnected as well as have more vertices with odd degree than allowed. In what follows, we describe the information that will be kept in each node, supposing that a partial solution W 1 , . . . , W τ for G t is known: The above description is given so as the reader can follow the algorithm more easily. However, we clearly cannot keep all the partial solutions as otherwise our algorithm cannot work in the desired time. What is done instead is that we keep only the parameters defined above and then apply dynamic programming in order to compute the desired solution.
Given a node t ∈ V (T ), we define the table E t indexed by , and the following hold: 5. e i (uv) = 1 if and only if uv ∈ E(W i ), for each i ∈ [τ ] and each uv ∈ E(X t ).
First, we show that if the tables are known, then we can find the answer to Partial Eulerian Local Trail in E r , where r is the root of the tree in the tree decomposition.

Lemma 14 There exists a temporal Eulerian local trail passing by
Proof First, consider a temporal Eulerian local trail W = (W 1 , . . . , W τ ) where W i is a u i , u i+1 -trail in G[i], for every i ∈ [τ ]. Then build the tuples (X i , C i , p i , e i ) accordingly, i.e., for each i ∈ [τ ], define: • Define p i exactly as in the statement of the theorem; and finally • For each uv ∈ E(X r ), let e i (uv) = 1 if and only if uv ∈ E(W i ).
We need to prove that E r ((X i , C i , p i , e i ) i∈[τ ] ) = 1, i.e., that Conditions 6.1-6.1 hold. First, recall that G r = G; hence Condition 6.1 holds because W is Eulerian. Conditions 6.1 and 6.1 hold by construction. Additionally, we know that since each W i is a u i , u i+1 -trail in G, we get that d W i (u) is even for every u / ∈ {u i , u i+1 }, and that d W i (u i ) and d W i (u i+1 ) are either both odd when u i = u i+1 , or u i = u i+1 and d W i (u i ) is even. This and the construction of p i ensure Condition 6.1. Finally, because W i is connected, we know that either W i does not pass through X r and hence X i = C i = ∅, or W i intersects X r and for some entry satisfying the statement, and let W 1 , . . . , W τ be subgraphs satisfying Conditions 6.1-6.1. If it holds that each W i is connected and such that every vertex has even degree, except u i and u i+1 when they are distinct vertices, then by Condition 6.1 and Euler's characterization we get that G has a temporal Eulerian local trail, as desired. Therefore, consider i ∈ [τ ]. If X i = ∅, then by assumption we know that C i = {X i }, and by Condition 6.1 we get that W i contains exactly one component. And if X i = ∅, then by Condition 6.1 we get V (W i ) ∩ X r = ∅, which in turn implies that V (C) ∩ X r = ∅ for every component C of W i , which again by Condition 6.1 implies that W i is connected. Now, concerning the parity of the degrees, by the lemma hypothesis concerning p and by Condition 6.1, one can see that indeed the only vertices allowed to have odd degrees are u i and u i+1 , and only if they are distinct.
In what follows, we explain how to compute the entry of each type of node, given that the tables of the children are known. We prove correctness for each of the operations of the nice tree decomposition through the following lemmas. We refrain from formally proving correctness of the whole algorithm since these ideas follow standard techniques.

Introduce Node
Consider an entry E t ((X i , C i , p i , e i ) i∈ [τ ] ) that we want to compute, and first consider t to be an introduce node with child t , where X t = X t ∪{u}. We explain which entries of E t must be searched for the right answer. First, observe that if u / ∈ X i , then nothing changes concerning G t [i], i.e., there will be the desired u i , u i+1 -trail in G t [i] if and only if such trail also exists in G t [i]. So suppose u ∈ X i and let C ∈ C i be such that u ∈ C; also denote X i − u by Y i . Recall that G t = G t − u and note that no changes can be made to the edges of W i − u; hence let e i denote the vector e i restricted to E(X t ). Observe also that the parity of the degree of v ∈ X t in W i restricted to G t might differ from its degree in W i depending on whether v is adjacent to u in W i or not, which can be checked by looking at e i . Hence, we construct a new parity vector p : Finally, note that u might be the vertex in W i ⊆ G t connecting some of the vertices of C. Therefore, we need to consider the partition C i obtained from C i by removing u from C, but also all the partitions obtained from C i by partitioning also C − u into further subsets. Let χ i denote the set of all such partitions. We then get that:

Lemma 15
Consider an introduce node t with child t , u ∈ V (G) be such that X t = X t ∪ {u}, and consider an entry Note that each χ i has size at most one plus the total number of partitions of C −u ⊆ X t , which is at most k k , where k = tw(G). Because we need to investigate all the possible combinations of D 1 , . . . , D τ , we get that at most k k·τ entries of E t must be accessed.

Forget Node
Now, consider t to be a forget node with child t , where X t = X t \ {u}. The vertices of X t touched by W i must be the same, except that perhaps u can be touched too. And in fact, if u ∈ {u i , u i+1 }, then u must appear in W i . Therefore, define X i to be equal to As for the partition of X ∈ X i to be considered, since G t = G t , it cannot change with respect to C i unless u ∈ X , in which case there is a family of partitions that must be considered. Define then the family of partitions χ i containing each C i that can be obtained from C i by adding u to some part, including the possibility of u being contained in a part by itself. Now consider e i ∈ {0, 1} |E(X t )| ; we say that e i is an extension of e i if e i (vw) = e i (vw) for every vw ∈ E(X t ) (i.e., e i differs from e i only on edges incident to u). Consider also D i ∈ χ i . If {u} ∈ D i , then uv cannot be in W i for every uv ∈ E(X t ). And if u ∈ C for some C ∈ D i , then uv can be in W i for some uv ∈ E(X t ) only if v ∈ C. We then say that e i agrees with D i if these conditions hold, i.e., if v ∈ C whenever e i (uv) = 1, where C ∈ D i is the part containing u. Finally, because G t = G t , the parities of the degrees do not change; also, since u ∈ V (G t − X t ), we get that either u must have even degree in W i , or u ∈ {u i , u i+1 } and u i = u i+1 , in which case u must have odd degree in W i . We then define p i to be obtained from p i by setting p i (u) to 0 if u / ∈ {u i , u i+1 } or u i = u i+1 , or to 1 otherwise. These definitions lead us to the next lemma.

Lemma 16
Consider a forget node t with child t , u ∈ V (G) be such that X t = X t \ {u}, and consider an entry [τ ] such that, for each i ∈ [τ ], we have that Y i ∈ X i , D i ∈ χ i , e i is an extension of e i that agrees with D i , and E t ((Y i , D i , p i , e i ) i∈[τ ] ) = 1.
Again, let k = tw(G). Observe that |χ i | ≤ |C i | + 1 ≤ k + 1, and that there are at most 2 k possible extensions of e i . Because |X i | ≤ 2, and all combinations must be investigated, we get a total of at most (2 k+1 (k + 1)) τ entries that need to be checked.

Join Node
Finally, consider a join node t with children t 1 , t 2 , and recall that X t = X t 1 = X t 2 . Given partitions P 1 , P 2 of a set X , we say that a partition P of X is the union of P 1 and P 2 if it is equal to the equivalent classes of the transtive closure of {(u, v) ∈ X × X | {u, v} ⊆ C, for some C ∈ P 1 ∪ P 2 }. Given entries h 1 = (X i , C 1 i , p 1 i , e i ) i∈[τ ] and h 2 = (X i , C 2 i , p 2 i , e i ) i∈ [τ ] of E t 1 , E t 2 , respectively, we say that h 1 , h 2 can be combined into h = (X i , C i , p i , e i ) i∈ [τ ] if the following hold for every i ∈ [τ ] (below, we denote by d i (u) the value |{uv ∈ E(X t ) | e i (uv) = 1}|): • C i is the union of C 1 i and C 2 i ; and • p i can be obtained from p 1 i and p 2 i by analysing the degree d i of the vertices in W i [X t ]. More formally:  Clearly, testing whether entries h 1 , h 2 can be combined into h can be done in polynomial time. Again let k = tw(G). Since there are at most |X i | |X i | = 2 k·log k partitions of X i and at most 2 k+1 vectors of size |X t | for each i ∈ [τ ], and since we need to combine every pair of such entries in order to test whether they can be combined into h, we get a running time of (2 O(τ ·k·log k) ) 2 = 2 O(τ ·k·log k) to compute entry E t (h). One can see that this dominates the complexities for the other types of nodes. Therefore, because each table has size (2 k · 2 k log k · 2 k · 2 k 2 ) τ = 2 O(k 2 ·τ ) and the tree decomposition has size O(n), where n is equal to |V (G)|, our algorithm runs in time 2 O(k 2 ·τ ) · p(n), where p is a polynomial function.
As for Eulerian Trail and Eulerian Tour, it suffices to consider vectors e i that do not allow for edge repetitions. Recall that our algorithm solves Partial Eulerian Local Trail to see that the obtained running time is as stated by Theorem 13.

Conclusions
In this paper we have investigated translations of Eulerian walks and trails in temporal terms. Eulerian walks traverse all the edges at least once, Eulerian trails traverse each edge exactly once, and Eulerian local trails traverse each edge at least once but never twice the same edge in the same snapshot. We have provided several NP-complete results, showing that all the corresponding decision problems are NP-complete even under very strict constraints. On the positive side, we have given an XP algorithm for Eulerian Walk when parameterized by τ , as well as an XP algorithm for Eulerian Trail and Eulerian Local Trail when parameterized by τ + tw(G). We ask whether these complexities can be improved, i.e., whether Eulerian Walk can be solved in FPT time when parameterized by τ , and whether Eulerian Trail and Eulerian Local Trail can be solved in FPT time when parameterized by τ + tw(G). We recall that from our and previous results, the latter problems are para-NP-complete when parameterized either by τ or by tw(G). Another possible question, and a broader one, is whether there are other possible interpretations of what an Eulerian temporal graph could be.
Additionally, as we have discussed previously, a natural generalization of the Eulerian trail problem on static graphs is the so called Chinese Postman problem. Since the latter is more general, it directly follows from the results presented here that translations in the temporal sense analogous to the ones given here for the Chinese Postman problem would already be NP-complete. However, it could be worth to investigate whether our polynomial cases would continue to be polynomial.
Finally, we mention that, looking at Table 1, one can find many open other problems either explicitly (e.g., what is the complexity of all the investigated problems on graphs with bounded treewidth when an edge is allowed to appear at most 3 times?), or related to the results presented (e.g., what other parameters would be promising for obtaining FPT algorithms?).