Temporal graph patterns by timed automata

Temporal graphs represent graph evolution over time, and have been receiving considerable research attention. Work on expressing temporal graph patterns or discovering temporal motifs typically assumes relatively simple temporal constraints, such as journeys or, more generally, existential constraints, possibly with finite delays. In this paper we propose to use timed automata to express temporal constraints, leading to a general and powerful notion of temporal basic graph pattern (BGP). The new difficulty is the evaluation of the temporal constraint on a large set of matchings. An important benefit of timed automata is that they support an iterative state assignment, which can be useful for early detection of matches and pruning of non-matches. We introduce algorithms to retrieve all instances of a temporal BGP match in a graph, and present results of an extensive experimental evaluation, demonstrating interesting performance trade-offs. We show that an on-demand algorithm that processes total matchings incrementally over time is preferable when dealing with cyclic patterns on sparse graphs. On acyclic patterns or dense graphs, and when connectivity of partial matchings can be guaranteed, the best performance is achieved by maintaining partial matchings over time and allowing automaton evaluation to be fully incremental.

Fig. 1: Example of a temporal graph.Each edge is associated with the set of timepoints during which it is active.

Introduction
Graph pattern matching, the problem of finding instances of one graph in a larger graph, has been extensively studied since the 1970s, and numerous algorithms have been proposed [13,15,20,32,46,52].Initially, work in this area focused on static graphs, in which information about changes in the graph is not recorded.Finding patterns in static graphs can be helpful for many important tasks, such as finding mutual interests among users in a social network.However, understanding how interests of social network users evolve over time, support for contact tracing, and many other research questions and applications require access to information about how a graph changes over time.Consequently, the focus of research has shifted to pattern matching in temporal graphs for tasks such as finding temporal motifs, temporal journeys, and temporal shortest paths [24,30,44,47,50,61,66,67].
Figure 1 gives our running example, showing an interaction graph, where each node represents an employee (node label emp), a customer (cst), or an office (ofc), and each edge represents either an email message (msg) or a visit (visit) from a source node to a target node.Each edge is associated with the set of timepoints when an interaction occurred.Such graphs with static nodes but dynamic edges that are active at multiple timepoints are commonly used to represent interaction networks [44,65].
Example 1 Assume our temporal graph holds information about a publicly traded company.Suppose that employee v 1 shared confidential information with their colleagues v 2 and v 3 , and that one of them subsequently shared this information with customer v 4 , potentially constituting insider trading.Assuming that we have no access to the content of the messages, only to when they were sent, can we identify employees who may have leaked confidential information to v 4 ?
Based on graph topology alone, both v 2 and v 3 could have been the source of the information leak to v 4 .However, by considering the timepoints on the edges, we observe that there is no path from v 1 to v 4 that goes through v 3 and visits the nodes in temporal order.We will represent this scenario with the following basic graph pattern (BGP), augmented with a temporal constraint: Here, v 1 and v 4 are node constants, x is a node variable, y 1 and y 2 are edge variables, and y 1 .T and y 2 .T refer to the sets of timepoints associated with edges y 1 and y 2 .The temporal constraint states that there must exist a pair of timepoints t 1 , associated with edge y 1 , and t 2 , associated with edge y 2 , such that t 1 occurs before t 2 .We refer to such combinations of BGPs and temporal constraints as temporal BGPs.
The temporal constraint in the above example is existential : it requires the existence of timepoints where the edges from a BGP matchings are active, so that these timepoints satisfy some condition (in the example, a simple inequality).Existential constraints are typical in the literature on temporal graph pattern matching [24,44,50,61,66,67].Various forms of conditions, beyond inequalities on the timepoints, have been considered.For example, one may require that the timepoints belong to a common interval with a given start-and end-time ("temporal clique" [66]) or with a given length ("δ-motifs" [44]), or one may specify lower and upper bounds on the gaps between the timepoints [67].
In this paper, our goal is to go beyond existential constraints.Indeed, many useful temporal constraints are not existential.We give two examples over temporal graphs such as the one in Figure 1.
Example 2 When monitoring communication patterns, we may want to look for extended interactions between customers and employees.Specifically, we are looking for matchings of the BGP shown in Figure 2a, where edge variables y 1 and y 2 represent email messages exchanged by customer x 1 and employee x 2 .We impose the temporal constraint that y 1 and y 2 are active in an interleaved, alternating fashion: first y 1 was active, then y 2 , then y 1 again, etc.This constraint is not existential.In Figure 1, it is satisfied in the communication between v 5 and v 1 , but not between v 7 and v 1 .
Example 3 In contact tracing, we may want to look for pairs of employees who have shared an office for a contiguous period of time with some minimal duration.We are looking for matchings of the BGP x 2 : emp y1:visit − −−−− → x 1 : ofc y2:visit ← −−−− − x 3 : emp.As a temporal constraint, we impose that there exists a contiguous sequence of timepoints in the graph's temporal domain, of duration at least, say, 3 time units, in which y 1 and y 2 were both active.This constraint is, again, not existential.In Figure 1, the only matching of the BGP (involving employees v 2 and v 4 and office v 8 ) does not satisfy the constraint; as a matter of fact, v 2 and v 4 were never active (i.e., at the office) at the same time!Indeed, "y 1 and y 2 are never active at the same time" would be another natural example of a temporal constraint that is not existential.
In order to express temporal constraints (existential or not), we need a language.When the goal is the expression of possibly complex constraints, an obvious approach would be to use SQL.Indeed, any temporal graph can be naturally represented by three relations Node(vid , label ), Edge(eid , vid 1 , vid 2 , label ), and Active(eid , time), where vid and eid are node (vertex) and edge identifiers.The problem with this approach is that temporal constraints do not fit well in the SQL idiom.SQL is certainly expressive enough, but the resulting expressions tend to be complicated and hard to optimize.The alternating communication pattern from Example 2 would be expressed in SQL as follows: The hypothesis put forward in this paper is that specification formalisms used in fields such as complex event recognition [22] or verification of real-time systems [8] may be much more suitable for the expression of complex temporal constraints.In this paper, we specifically investigate the use of timed automata [2,8].
Example 4 Figure 2 shows various examples of timed automata that can be applied to matchings of a BGP with two edge variables y 1 and y 2 , such as the BGPs considered in Examples 2 and 3.One can think of the automaton as running over the snapshots of the temporal graph.A matching is accepted if there is a run such that, after seeing the last snapshot, the automaton is in an accepting state.The edge variables serve as Boolean conditions on the transitions of the automaton.When the edge matched to y 1 (y 2 ) is active in the current snapshot, the Boolean variable y 1 (y 2 ), is true.
The alternation constraint of Example 2 is expressed by TA 1 .TA 2 is similar but additionally requires that each message gets a reply within 3 time units (a clock c is used for this purpose).The contiguous-duration constraint of Example 3 is expressed by TA 7 , also using a clock.The constraint "y 1 and y 2 are never active together" is expressed by TA 6 ; the opposite constraint "y 1 and y 2 are always active together" by TA 5 .Likewise, TA 8 expresses that y 2 is active whenever y 1 is (in SQL, this constraint would correspond to a set containment join [7]).Finally, TA 3 expresses that y 1 has been active strictly before the first time y 2 becomes active.Also, existential constraints such as the one from Example 1 are readily expressible by timed automata (see Section 3).Timed automata offer not only a good balance between expressivity and simplicity.A temporal constraint expressed by a timed automaton can also be processed efficiently, as the iterative state assignment mechanism allows early acceptance and early rejection of matchings.In this paper, we will introduce three algorithms for the evaluation of temporal BGPs with timed automata as temporal constraints.The first is a baseline algorithm intended for offline processing when the complete history of graph evolution is available at the time of execution.The second is an on-demand algorithm that supports online query processing when the temporal graph arrives as a stream.The third is a partialmatch algorithm that speeds up processing by sharing computation between multiple matches.
We will present an implementation of these algorithms in a dataflow framework, and will analyze performance trade-offs induced by the properties of the temporal BGP and of the underlying temporal graph.We will also compare performance with main-memory SQL systems, and will observe that temporal BGPs with temporal constraints that are not existential can be impractical when expressed and processed as SQL queries.

Temporal graphs and temporal graph patterns
We begin by recalling the standard notions of graph and graph pattern used in graph databases [4,56].Assume some vocabulary L of labels.We define: Definition 1 (Graph) A graph is a tuple (N, E, ρ, λ), where: Fig. 2: Example of a temporal BGP and example timed automata explained in Example 4.
-N and E are disjoint sets of nodes and edges, respectively; ρ : E → (N × N ) indicates, for each edge, its source and destination nodes; and λ : N ∪ E → L assigns a label to every node and edge.Figure 1 gives an example of a graph, with Next, recall the conventional notion of basic graph pattern (BGP).

Definition 2 (Basic graph pattern (BGP))
A BGP is a tuple (C, X, Y, ρ, λ), where: -C, X and Y are pairwise disjoint finite sets of node constants, node variables, and edge variables, respectively; ρ : Y → (C ∪ X) × (C ∪ X) indicates, for each edge variable, its source and destination, which can be a node constant or a node variable; and λ : X ∪ Y → L is a partial function, assigning a label from L to some of the variables.
The fundamental task related to BGPs is to find all matchings in a graph, defined as follows: -Let y be an edge variable in Z and let ρ P (y) = (x 1 , x 2 ).Then, for i = 1, 2, if x i is a node variable, where we agree that µ(c) = c for any node constant c. -For every z ∈ Z for which λ P (z) is defined, we have λ(µ(z)) = λ P (z).
If Z equals X ∪ Y then µ is called a (total) matching.
Consider the BGP in Figure 2a.Evaluating it over the graph in Figure 1 yields 7 partial matchings: − → v 7 as total matchings.We now present the notion of a temporal graph in which edges are associated with sets of timepoints, while nodes persist over time.Extending our work to temporal property graphs in which both nodes and edges are associated with temporal information, and where the properties of nodes and edges can change over time [37], is an interesting direction for further research.We assume that timepoints are strictly positive real numbers and define: Definition 4 (Temporal graph) A temporal graph is a pair (G, ξ), where G is a graph and ξ assigns a finite set of timepoints to each edge of G.When e is an edge and t ∈ ξ(e), we say that e is active at time t.
To extend the notion of matching to temporal graphs, we enrich BGPs with temporal constraints, defined as follows.
Definition 5 (Temporal variables, assignments, and constraints) Let V be a set of temporal variables.A temporal assignment α on V is a function that assigns a finite set of timepoints to every variable in V .A temporal constraint over V is a set of temporal assignments on V .This set is typically infinite.When a temporal assignment α belongs to a temporal constraint Γ , we also say that α satisfies Γ .
For the moment, this is a purely semantic definition of temporal constraints; in Section 3 we will present how such constraints may be specified using timed automata.
If we have a matching µ from a BGP in a graph G, and we consider a temporal graph (G, ξ) based on G, we automatically obtain a temporal assignment on the edge variables of the BGP.Indeed, each edge variable is matched to an edge in G, and we take the set of timepoints of that edge.Thus, edge variables serve as temporal variables, and we arrive at the following definition: Definition 6 (Temporal BGP, matching) A temporal BGP is a pair (P, Γ ) where P is a BGP and Γ is a temporal constraint over Y (the edge variables of P ).
Let (G, ξ) be a temporal graph.Given a matching µ of P in G, we can consider the temporal assignment α µ on Y defined by for y ∈ Y .Now a matching of the temporal BGP (P, Γ ) in the temporal graph (G, ξ) is any matching µ of P in G such that α µ satisfies Γ .
In the next section, we describe how timed automata such as that in Figure 2b can be used to represent and enforce such constraints.

Expressing Temporal Constraints
Our conception of a temporal BGP, as a standard BGP P equipped with a temporal constraint Γ on the edge variables of P , leaves open how Γ is specified.We pursue the idea to use timed automata, an established formalism for expressing temporal constraints in the area of verification [2,8].Timed automata are often interpreted over infinite words, but here we will use them on finite words.Timed automata A timed automaton over a finite set Y of variables is an extension of the standard notion of non-deterministic finite automata (NFA), over the alphabet Σ = 2 Y (the set of subsets of Y ).Recall that an NFA specifies a finite set of states: an initial state, a set of final states, and a set of transitions of the form (s 1 , θ, s 2 ), where s 1 and s 2 are states and θ is a Boolean formula over Y .The automaton reads a word over Σ, starting in the initial state.Whenever the automaton is in a current state s 1 , the next letter to be read is a, and there exists a transition (s 1 , θ, s 2 ) such that a satisfies θ, the automaton can change state to s 2 and move to the next letter.If, after reading the last letter, the automaton is in a final state, the run accepts.If there is no suitable transition at some point, or if the last state is not final, then the run fails.A word is accepted if there exists an accepting run.
The extra feature added by timed automata to the standard NFA apparatus is a finite set C of clocks, which can be used to measure time gaps between successive letters in a timed word (to be defined momentarily).Transitions are of the extended form where s 1 , θ and s 2 are as in NFAs; δ is a Boolean combination of clock conditions; and R is a subset of C.
Here, by a clock condition, we mean a condition of the form c g or c ≥ g, where c is a clock and g is a real number constant representing a time gap.
As just mentioned, a timed automaton works over timed words.A timed word over an alphabet Σ is a sequence of the form where each a i ∈ Σ, and t 1 < • • • < t n are timepoints.When the automaton is started on the timed word, all clocks are initially set to t 0 := 0. For i = 1, . . ., n the automaton runs as follows.Upon reading position (t i , a i ), every clock has increased by t i − t i+1 .Now the automaton can take a transition ( * ) as above on condition that the current state is s 1 and a i satisfies θ, as before; and, moreover, the current valuation of the clocks satisfies δ.If this is so, the automaton can change state to s 2 , move to the next position in the timed word, and must reset to zero all clocks in R. As with NFAs, a run is accepting if it ends in a final state, and a timed word is accepted if there exists an accepting run.
Using timed automata to express temporal BGP constraints A timed automaton defines the set of timed words that it accepts.But how does it define, as announced, a temporal constraint over Y , which is not a set of timed words, but a set of temporal assignments?This is simple once we realize that a temporal assignment over Y , in the context of a temporal graph H = (G, ξ), is nothing but a timed word over Σ = 2 Y .We can see this as follows.Let T = {ξ(e) | e ∈ E} be the set of all distinct timepoints used in H; we also refer to T as the temporal domain of H. Let T = {t 1 , . . ., t n }, ordered as t 1 < • • • < t n .We can then view NFAs are a special case of timed automata without any clocks, and this special case is already useful for expressing temporal constraints.For example, consider the NFA in Figure 3 which expresses the existential constraint ∃t 1 ∈ y 1 ∃t 2 ∈ y 2 : t 1 < t 2 from Example 1. Suppose we instead want to express the existential constraint ∃t 1 ∈ y 1 ∃t 2 ∈ y 2 : t 1 < t 2 − 7. We can do this by introducing a clock c.When we see y 1 , we reset the clock (c := 0).Then, when we see y 2 , we check that the clock has progressed beyond the desired 7 time units (c > 7).
Of course, as already argued in the Introduction, timed automata are much more powerful than mere existential constraints.In what follows, we will discuss several algorithms for processing temporal BGPs with temporal constraints given as timed automata.
4 Algorithms for timed-automaton temporal graph pattern matching

Temporal graph representation
Assume that we are given a temporal graph H = (G, ξ) where G = (N, E, ρ G , λ G ).We are also given a temporal BGP Q = (P, Γ ) where P = (X, Y, ρ P , λ P ) as defined in Section 2. Our goal is to compute all matchings µ of Q in H; recall that this means that µ must be a matching of P in G, and, moreover, the temporal assignment α µ must satisfy Γ (Definition 5).We assume that Γ is specified as a timed automaton over the alphabet Σ = 2 Y .
We recall the natural notion of snapshot from temporal databases: Definition 7 (Snapshot) For any timepoint t i in the temporal domain of H, the snapshot of H at time t i is the subgraph of G induced by all edges that are active at time t i .We denote this subgraph by H ti .
The snapshot can be represented by the relevant slices of the tables N ode, Edge and Active.
We next present three algorithms for finding the matchings of a temporal BGP in a temporal graph, when the temporal constraint is given by a timed automaton.We start by presenting our baseline algorithm that operates in two stages.First, it generates all matchings of the BGP; next, it filters out those matchings that violate the temporal constraint.Our second on-demand algorithm works incrementally.It considers the graph in temporal order, snapshot by snapshot.As time progresses, more edges of the graph are seen so that more and more BGP matchings are found.Also, at each timestep, the possible transitions of the automaton are evaluated to keep track of the possible states for each matching.For newly found matchings, however, the automaton has to catch up from the beginning.This catching up is avoided in our third partialmatch algorithm, which incrementally maintains all partial matches of the BGP, refining them as time progresses.

Baseline algorithm
Assume a temporal BGP Q = (P, Γ ), where Γ is specified as a timed automaton.Given a temporal graph H = (G, ξ), we want to find all the matchings of Q in H.We do this in two stages: Find the BGP matchings: Find all matchings of P in G using any of the available algorithms for this task [42,3].Run the automaton: For each obtained matching µ: (a) Convert the assignment α µ into a timed word over the temporal domain of H, as described in Section 3. We denote this timed word by w µ .(b) Check if w µ is accepted by automaton Γ .
We next describe how the automaton stages (a) and (b) can be done synchronously, for all matchings µ in parallel.We use a table States that holds triples (µ, s, ν), where µ is a matching; s is a state of the automaton; and ν is an assignment of timepoints to the clocks of Γ .Since Γ is nondeterministic, the same µ may be paired with different s and ν.Naturally, in the initial content of States, each µ is paired with state s 0 and ν 0 that maps every clock to 0.
Let T = {t 1 , . . ., t n } with t 1 < • • • < t n be the temporal domain of H as described in Section 3, and let t 0 := 0. Recall that the active timepoints for each edge are stored in the table Active(eid , time).We obtain T by first sorting Active on time and then scanning through it.Now during this scan, for i = 1, . . ., n, we do the following: Early acceptance or rejection After the iteration for i = n, the matchings that are accepted by the automaton Γ are those that are paired in States with an accepting state.We may also be able to accept results early: when, during the iteration, a matching µ is paired with an accepting state s, and all states reachable from s in the automaton are also accepting, then µ can already be output.On the other hand, when all states reachable from s are not accepting, we can reject µ early.
Example 5 Consider again the temporal graph in Figure 1, and suppose that we want to find all cycles of length 2 shown in Figure 2a, under the temporal constraint T A 2 shown in Figure 2c.The first stage of the baseline algorithm identified two matchings, µ = (e 5 , e 6 ) and µ = (e 8 , e 9 ).These are considered by the timed automaton in the second stage.
Figure 4 shows the States relation with the timed words w µ at times between 0 to 3. At t = 0, both matchings are at s = s 0 , no clocks have been set, and, since neither of the matchings has any edges, b 1 = 0 and b 2 = 0.At time t = 1, e 5 is active, hence the bit b 1 for the matching (e 5 , e 6 ) is set to 1, and, since there is a rule in the timed automaton, state is updated to s 1 and clock x is set to 1. Matching (e 8 , e 9 ) does not exist at time 1, and so no change is made in that row of the State table.At times t = 1.1 and t = 1.9, neither of the matchings' edges are active, hence the only change is that the clock is updated for (e 5 , e 6 ).At time t = 2, for matching (e 5 , e 6 ), the edge e 6 is active and the clock x is less than 2, hence we move back to state s 0 .For the matching (e 8 , e 9 ), e 8 is active so we move to s 1 and set the clock.At time t = 3, (e 5 , e 6 ) continues to alternate, but for (e 8 , e 9 ) we see that e 8 is active, hence, we set b 1 = 1 and b 2 = 0, and, seeing that the timed automaton does not have a transition, we drop this matching (shown as grayed out in Figure 4).Between times 3-6, the matching (e 5 , e 6 ) continues alternating between s 0 and s 1 .From time 7-9, we observe neither of e 5 or e 6 , and hence no change happens to the state of this matching.The final output of this algorithm is that matching (e 5 , e 6 ) is accepted at state s 0 .

On-demand algorithm
A clear disadvantage of the baseline algorithm is that we must first complete the first stage (BGP matching on the whole underlying graph G) before we can move to the automaton stage.This delay may be undesirable and prohibits returning results early in situations where the temporal graph is streamed over time.We next describe our second algorithm, which works incrementally by processing snapshots in chronological order.
Recall Definition 7 of snapshots.We also define: Definition 8 (History) The history of H until time t i , denoted H ti , is the union of all snapshots H tj for j = 1, . . ., i.For t 0 := 0, we define H t0 to be the empty graph.
The baseline algorithm is now modified as follows.We no longer have a first stage.Snapshots arrive chronologically at timepoints t 1 , . . ., t n ; it is not necessary for the algorithm to know the entire temporal domain {t 1 , . . ., t n } in advance.For i = 1, . . ., n: 1. We receive as input the next snapshot H ti .In previous iterations we have already computed all matchings of P in the preceding history H ti−1 .Using this information and the next snapshot, we compute the new matchings, i.e., the matchings of P in the current history H ti that were not yet matchings of P in the preceding history.Incremental BGP matching is a well-researched topic, and any of the available algorithms can be used here [62,23,21,28].2. We use the table States as in the baseline algorithm.For each newly discovered matching µ, we must catch up and run the automaton from the initial state on the prefix of w µ of length i − 1.We add to States all triples (µ, s, ν), such that the configuration (s, ν) is a possible configuration of the automaton after reading the prefix.3.All matchings we already had remain valid; indeed, if µ is a matching of P in H ti−1 then µ is also a matching of P in H ti .States is now updated for the i-th letter of the timed words of all matchings, new and old, as in the baseline algorithm.
We call this the "on-demand" algorithm because the automaton is run from the beginning, on demand, each time new matchings are found, in order to catch up with table States holding the possible automaton configurations.
Example 6 Figure 5 shows the State relation for the on-demand algorithm, for the same BGP and temporal constraint as in Example 5.The first time a cycle of length 2 exists in the graph in Figure 1 is t = 2, hence there will be no matching in any iteration before t = 2 and no temporal automaton would run.At time t = 2 the incremental matching algorithm finds the matching (e 5 , e 6 ) and passes it to the timed automaton that runs it for t = 0, t = 1, t = 1.1 and t = 1.9 as was described in Example 5.At time t = 9, edge e 9 is received and gives rise to a new matching (e 8 , e 9 ).At that point, the timed automaton is invoked for all t < 9.The process is similar to what we described in Example 5, and the ondemand automaton will eliminate this matching at t = 3 because no rule in the automaton can be satisfied.The final output is the same as for the baseline algorithm: matching (e 5 , e 6 ) accepted at state s 0 .Note that using on-demand algorithm, we can process the graph that arrives as a stream.

Partial-match algorithm
A disadvantage of the on-demand algorithm is the catchingup of the automaton on newly found matchings.Inter-  estingly, we can avoid any catching-up and obtain a fully incremental algorithm, provided we keep not only the total matchings of P in the current history, but also all partial matchings.Specifically, we will work with maximal partial matchings: these are partial matchings that cannot be extended to a strictly larger partial matching on the same graph.Now, for any partial matching µ of P in G, we can define a timed word w µ , in the same way as for total matchings.Formally, w µ = (t 1 , a 1 ) . . .(t n , a n ), where now a i = {y ∈ Y | µ is defined on y and t i ∈ ξ(µ(y))}.
The following property now formalizes how a fully incremental approach is possible: (proof in supplementary materials) Proposition 1 Let µ be a maximal partial matching of P in H ti−1 , and let µ be a partial matching of P in H ti , such that µ ⊆ µ .Then the timed words w µ and w µ have the same prefix of length i − 1.
We must show that a j = b j for j = 1, . . ., i − 1.The containment from left to right is straightforwardly verified.Indeed, take y ∈ a j .Then µ(y) is defined and t j ∈ ξ(µ(y)).Since µ ⊆ µ , also µ (y) = µ(y) is defined and we see that y ∈ b j as desired.
For the containment from right to left, take y ∈ b j .Then µ (y) is defined and t j ∈ ξ(µ (y)).For the sake of contradiction, suppose µ(y) would not be defined.Let ρ P (y) = (x 1 , x 2 ), and strictly extend µ to µ by mapping y to µ (y); x 1 to µ (x 1 ); and x 2 to µ (x 2 ).
Since µ is a partial matching of P in G, we know that µ (y) is an edge in G from node µ (x 1 ) to node µ (x 2 ).Moreover, since t j ∈ ξ(µ (y)), the edge µ (y) is present in H tj , so certainly also in H ti−1 since j i−1.Thus, µ is a partial matching of P in H ti−1 , contradicting the maximality of µ.We conclude that µ(y) is defined, and y ∈ a j .
Concretely, the partial-match algorithm incrementally maintains, for i = 1, . . ., n, all maximal partial matchings µ of H ti , along with the possible configurations (s, ν) of the automaton after reading the i-th prefix the timed word w µ .The triples (µ, s, ν) are kept in the table States as before.Initially, States contains just the single triple (∅, s 0 , ν 0 ), where ∅ is the empty partial matching, and s 0 (initial automaton state) and ν 0 (every clock set to 0) are as in the initialization of the baseline algorithm.For i = 1, . . ., n, we receive the next snapshot H ti and do the following: 1. From previous iterations, States contains all tuples (µ, s, ν), where µ is a maximal partial matching of P in H ti−1 and (s, ν) is a possible configuration of the automaton on the i−1-th prefix of w µ .Now, using an incremental query processing algorithm, compute Extend : the set of all pairs (µ, µ ) such that µ appears in States, µ extends µ, and µ is a maximal partial matching of P in H ti .2. With Extend computed in the previous iteration, update by a project-join query.By Proposition 1, States now contains all tuples (µ, s, ν), where µ is a maximal partial matching of P in H ti (as opposed to H ti−1 ) and (s, ν) is a possible configuration of the automaton on the i − 1-th prefix of w µ .

Exactly as in the baseline and on-demand algorithms,
States is now updated for the i-th letter of the timed words of all partial matchings.
Note that in step 1 above, it is possible that µ = µ, which happens when the new snapshot does not contain any edges useful for extending µ, or when µ is already a total matching.On the other hand, when µ can be extended, there may be many different possible extensions µ , and table States will grow in size.

Example 7
We now illustrate the partial matching algorithm for the same BGP and temporal constraint as in Examples 5 and 6. Figure 6 shows the States relation with the timed words at t = 0, . . ., 3. (To streamline presentation, we omit edges that are not part of any

Avoiding quadratic blowup
A well-known problem with partial BGP matching, in the non-temporal setting, is that the number of partial matchings may be prohibitively large.For a simple example, consider matching a path of length 3, Note that any edge in G gives rise to a partial matching for y 1 , y 2 , and y 3 .What is worse, however, is that any pair of edges gives rise to a partial matching for y 1 and y 3 together.We thus immediately get a quadratic number of partial matchings, irrespective of the actual topology of the graph G.For example, G may have no 3-paths at all, or even no 2-paths.Such a quadratic blowup may not occur for y 1 and y 2 together.Indeed, since y 1 and y 2 form a connected subpattern, only pairs of adjacent edges give rise to a partial matching.
Of course, in the above example, G may still have many 2-paths but very few 3-paths, so connectivity is not a panacea.Still, we may expect connected subpatterns to have a number of partial matchings that is more in line with the topology of the graph.At the very least, working only with connected subpatterns avoids generating the Cartesian product of sets of partial matchings of two or more disconnected subpatterns.
Interestingly, in the temporal setting, the very presence of a temporal constraint (timed automaton) may avoid disconnected partial matchings.This happens when the temporal constraint enforces that only partial matchings of connected subpatterns can ever satisfy the constraint, allowing early rejection of when partial matchings of disconnected subpatterns.We can formalize the above hypothesis as follows.
Consider a temporal BGP Q = (P, Γ ).As usual, let Y be the set of edge variables of P .Consider a total ordering < on Y .We say that: < is connected with respect to P if, for every y ∈ Y , the subgraph of P induced by all edge variables z y is connected.< is compatible with Γ if, for any y 1 < y 2 in Y , and any timed word w satisfying Γ in which both y 1 and y 2 appear, the first position in w where y 1 appears does not come after the first position where y 2 appears.Now, when a connected, compatible ordering is available, we can modify the partial-match algorithm in the obvious manner so as to focus only on partial matchings based on the subsets of variables {y 1 , . . ., y j }, for 1 j n.By the connectedness property, we avoid Cartesian products.Moreover, by the compatibility property, we do not lose any outputs.
As a simple example, consider the path of length 3 BGP and the timed automaton Γ from Figure 8.The ordering y 1 < y 2 < y 3 is connected with respect to P , and is compatible with Γ .So our theory would predict the partial matching algorithm to work well for this temporal BGP (P, Γ ).We will show effectiveness of the partial matching algorithm in Section 6.3.
Whether or not an ordering of the edge variables is connected with respect to P is straightforward to check, by a number of graph connectivity tests.Moreover, when Γ is given by a timed automaton, it also possible to effectively check whether an ordering is compatible with Γ .
Verifying compatibility We offer the following algorithm for verifying that an ordering y 1 < • • • < y m is compatible with a temporal constraint Γ , specified by a timed automaton.

Compute an automaton defining the intersection of
Γ with all regular languages of the form for 1 i < j n.These languages contain the words where both y i and y j appear, but y j appears first, which we do not want when i < j. 2. The resulting timed automaton should represent the empty language, i.e., should not accept any timed word.
Effective algorithms for computing the intersection of timed automaton and for emptiness checking are known [2].Note that it actually suffices here to intersect a timed automaton (Γ ) with an NFA (the union of the regular languages from step 1).An interesting question for further research is to determine the precise complexity of the following problem: Problem: Compatible and connected ordering Input: A temporal BGP (P, Γ ) Output: An ordering of the edge variables that is connected w.r.t.P and compatible with Γ , or 'NO' if no such ordering exists.

Implementation
The algorithms described in Section 4 have been implemented using Rust and the Itertools library [48] as a single-threaded application.Our algorithms are easy to implement using any system supporting the dataflow model such as Apache Spark [64], Apache Flink [10], Timely Dataflow [39], or Differential Dataflow [36].
A temporal graph is stored on disk as relational data in CSV files Node, Edge, and Active.In the initial stage of the program, we load all data into memory, loading edges into two hash-tables with vid1 and vid2 as keys.We added a "first" meta-property field to the Edge relation and use it for lazy evaluation of matchings in the baseline and on-demand algorithms.
BGP matching We implement BGP matching as a selectproject-join query.For cyclic BGPs such as triangles and rectangles, we use worst-case optimal join [3], meaning that instead of the traditional pairwise join over the edges, we use a vertex-growing plan.We use a state-ofthe art method in our implementation but note that (nontemporal) BGP matching in itself is not the focus of this paper, and so any other BGP matching algorithm can be used in conjunction with the timed automata-based methods we describe.
On-demand and partial matching algorithms are both designed to work in online mode, computing new matchings at each iteration.To implement online matching for the on-demand algorithm, we build on join processing in streams [60].We can use information from the temporal constraint to avoid useless joins in the incremental computation of matchings.For example, consider two edge variables y and z coming from the BGP.With E the current history of active edges and ∆E the edges from the new snapshot, we must in principle update the join of ρ y (E) with ρ z (E) by three additional joins ρ y (E) ρ z (∆E); ρ y (∆E) ρ z (E); and ρ y (∆E) ρ z (∆E).When the temporal constraint implies, for example, that y is never active before z, the first of these three additional joins can be omitted.Such order information can be inferred from a timed automaton using similar techniques already described in the paragraph on verifying compatibility in Section 4.5.

Timed automata
We represent a timed automaton as a relation Automaton(s c , θ, δ, R, s n ), in which each tuple corresponds to a transition from the current state s c to the next state s n .For example, the timed automaton of Figure 2c is represented as follows: The specification of the timed automaton is loaded into memory as a hash table, with (s c , θ) as the key.The timed word θ (see Section 3), is encoded as a bitset.For example, in the timed automaton in Figure 2c, we encode y 1 ∧ ¬y 2 as 10, where the first bit corresponds to y 1 and the second to y 2 .If the transition condition is true then, for a matching with two variables, we add 4 rows to Automaton, one for each 00, 01, 10, and 11.Using bitsets makes automaton transitions efficient, as we will show in Section 6.4.Table Automaton also stores the clock acceptance condition δ, and a nested field R with an array of clocks to be reset during the transition to the next state.To update the state of a matching, we execute a hash-join followed by a projection between Automaton and States.
Updating the clock for each matching will be computationally expensive.Instead, during the automaton transition, for each matching, we store the current time (of last snapshot visited) value for that clock instead of setting it to zero.This way, instead of updating all clocks in every iteration, we can just get the correct value of the clock when needed and compute the current value of the clock by subtracting the value of the clock from the current time.
In many temporal graphs, due to the nature of their evolution, most edges appear for the first time during the last few snapshots.To optimize performance we implemented a simple but effective optimization for our baseline and on-demand algorithms: when the initial state of the timed automaton self-loops on the empty letter, we will not run on a matching until at least one of its edges is seen.This can be determined using the "first" meta-property of the Edge relation.This optimization is not necessary for the partial matching algorithm, where it is essentially already built-in.
We also implement the early acceptance and early rejection optimizations.

Experiments
We now describe an extensive experimental evaluation with several real datasets and temporal BGPs, and demonstrate that using timed automata is practical.We investigate the relative performance of our methods, and compare them against two state-of-the-art in-memory relational systems, DuckDB [45] and HyPer [41,40].
In summary, we observe that the on-demand and partial-match algorithms are effective at reducing the running time compared to the baseline.Interestingly, while no single algorithm performs best in all cases, the trade-off in performance can be explained by the properties of the dataset, of the BGP, and of the temporal constraint.Our results indicate that partial-match is most efficient for acylic BGPs such as paths of bounded length, while on-demand performs best for cyclic BGPs such as triangles, particularly when evaluated over sparse graphs.Interestingly, the performance gap between ondemand and partial-match is reduced with increasing graph density or BGP size, and partial-match outperforms on-demand in some cases.We also show that algorithm performance is independent of timed automaton size and of the number of clocks.
We show that our methods substantially outperform state-of-the-art relational implementations in most cases.We also demonstrate that temporal BGPs are more con- cise than the corresponding relational queries, pointing to better usability of our approach.
Experimental setup Our algorithms were executed as single-thread Rust programs, running on a single cluster node with an Intel Xeon Platinum 8268 CPU, using the Slurm scheduler [63].We used DuckDB v.0.3.1 and the HyPer API 0.0.14109provided by Tableau1 .All systems were run with 32GB of memory on a single CPU.Execution time of DuckDB and HyPer includes parsing, optimizing and executing the SQL query, and does not include the time to create database tables and load them into memory.Similarly, execution time of our algorithms includes loading the timed automaton and executing the corresponding algorithm.All execution times are averages of 3 runs; the coefficient of variation of the running times was under 10% in most cases, and at most 12%.
Remark 1 Since we are dealing with graph data and BGPs, one may ask why we implemented our algorithms in a dataflow environment, and compare to relational systems.Why not work on top of a graph database system, and compare to graph databases?The reason is that a BGP is, in essence, a multiway join query, for which the best performance is realized with the help of worst-case optimal join algorithms, or relational query processors with very good optimization.It is exactly with respect to these two environments that we conduct our experiments.On the other hand, the main advantage of graph database systems is their support of reachability queries or regular path queries, which are not part of our basic notion of BGP.Rather, our contributions lie in expressive temporal filtering of the matchings of a BGP, for which our experimental set-up provides a suitable empirical evaluation.
Datasets.Experiments were conducted on 4 real datasets, summarized in Table 1, where we list the number of distinct nodes and edges, temporal domain size ("snaps"), the number of active edges across snapshots ("active"), structural density ("struct", number of edges in the graph, divided by number of edges that would be present in a clique over the same number of nodes), and temporal density ("temp", number of timepoints during which an edge is active, divided by temporal domain size, on average).EPL, based on the English soccer dataset [18], represents 34,800 matches between 50 teams over a 25year period.We represent this data as a temporal graph with 1-year temporal resolution, where each node corresponds to a team and a directed edge connects a pair of teams that played at least one match during that year.The direction of the edge is from a team with the higher number of goals to the team with the lower number of goals in the matches they played against each other that year; edges are added in both directions in the case of a tied result.This is the smallest dataset in our evaluation, but it is very dense both structurally and temporally.
Contact is based on trajectory data of individuals at the University of Calgary over a timespan of 4 hours [43].We created a bipartite graph with 500 person nodes and 41 location nodes, where the existence of an edge from a person to a location indicates that the person has visited the location.The original dataset records time up to a second.To make this data more realistic for a contact tracing application, we made the temporal resolution coarser, mapping timestamps to 5min windows, and associated individuals with locations where they spent at least 2.5 min.
Email, based on a dataset of email communications within a large European research institution [33], represents about 1.9M email messages exchanged by 776 users over an 800-day period, with about 65K distinct pairs of users exchanging messages.This dataset has high structural density (10% of all possible pairs of users are connected at some point during the graph's history), and intermediate temporal density (3%).
FB-Wall, derived from the Facebook New Orleans user network dataset [55], represents wall posts of about 46K users over a 850-day period, with 264K unique pairs of users (author / recipient of post).This graph  has the largest temporal domain in our experiments, and it is sparse, both structurally and temporally.We also use synthetic datasets to study the impact of data characteristics on performance, and describe them in the relevant sections.

Relative performance of the algorithms
In our first set of experiments, we evaluate the relative performance of the baseline (Section 4.2), on-demand (Section 4.3), and partial-match (Section 4.4) algorithms.Note that the baseline algorithm can only be used when a graph's evolution history is fully available (rather than arriving as a stream), and that partial-match is only used when the matching is guaranteed to be connected (Section 4.5).
We use the BGP that looks for paths of length 2, with timed automata TA 1 , TA 2 and TA 3 from Figure 2. Automaton TA 3 is interesting for showing the impact of early acceptance and rejection on performance.
Figure 9 shows the execution time of the baseline, on-demand and partial-match algorithms for EPL and Email, also noting the number of temporal matches.The BGP, which is in common for all executions in this experiment, returns 47K matches on EPL and 862K matches on Email.When the temporal constraint is applied, the number of matches is reduced, and is presented on the x-axis.For example, TA 1 returns 1.8K matches on EPL and 36K on Email.
We observe that partial-match is the most efficient algorithm for all queries and both datasets, returning in under 0.12 sec for EPL, and in under 17 sec for Email in all cases.The on-demand algorithm outperforms the baseline in all cases, but is slower than partial-match.The performance difference between the baseline and on-demand is due to a join between two large relations in baseline, compared to multiple joins over smaller relations in on-demand.
We also observe that the relative performance of the algorithms depends on the number of matches, and explore this relationship further in the next experiment.To compare algorithm performance across different BGPs and datasets, we use the timed automaton TA 0 of Figure 7, which generalizes TA 1 from 2 to m edges.TA 0 specifies that edges in a matching should appear repeatedly in a strict temporal order.We use TA 0 (with m = 2, 3, or 4 as appropriate) as the temporal constraint for paths of length 2 and 3, and for cycles of length 2, 3, 4, for three of the datasets.Because the Contact dataset is a bipartite graph, we used it for instar (x BGPs of size 2 and 3. Table 2 summarizes the results.It shows number of BGP matchings ("BGP"), number of matchings accepted by TA 0 ("BGP+TA"), and running times of computing the BGP match only ("match"), and of computing both BGP and temporal matches using to the baseline, on-demand, and partial-match algorithms.
We observe that, for acylic patterns (e.g., paths, istar, o-star), partial-match is significantly faster than on-demand and baseline.For such patterns, partial matchings are shared by many total matchings and by larger partial matchings, benefiting the running time.Interestingly, for cycles of size 2 and 3, on-demand is fastest, followed by baseline.However, for cycles of size 4 partialmatch is once again the fastest algorithm.The reason for this is that there are far fewer cycles than possible partial matchings, and in smaller cycles this causes partial-match to run slower.As cycle size increases, performance of partial-match becomes comparable to, or better, than of the other two algorithms.Another graph characteristic that can affect partial-match performance is graph density, which we discuss in the next section.(Our machine's RAM could not fit cycle4 for FB-Wall, so we did not conduct that experiment.)

Comparison to in-memory databases
In this set of experiments, we compare the running time of temporal BGP matching with equivalent relational queries.We used three datasets (EPL, Contact and Email) and queried them with cyclic and acyclic BGPs of size 2, with temporal constraints specified by 9 timed automata: T A e specifies an existential constraint (Figure 3), while T A 1 . . .T A 8 express constraints that are not existential.We showed SQL queries QTA1 and QTA7 in the introduction.In the Supplementary Materials we give a complete listing of the SQL queries, with Path2, Cycl2 and Star2 expressing the BGPs used in our experiments, and QTAE, QTA1-QTA8 implementing the temporal constraints.Most of these queries are quite complicated compared to their equivalent timed automata.
For DuckDB and HyPer, we loaded the relations Node, Edge and Active into memory.To improve performance of DuckDB, we defined indexes on Edge(src), Edge(dst), and Active(eid,time).To the best of our knowledge, HyPer does not support indexes.Table 3 shows the execution time for each query, comparing the running time of the best method based on timed automata (on-demand or partial-match, column "TAA") with DuckDB and HyPer.Observe that our algorithms are significantly faster for TA 1 , TA 2 , TA 5 and TA 7 for all 3 datasets, and have comparable performance to the best-performing relational system for TA 3 and TA 4 .Relational systems outperform our algorithms on TA e and TA 6 .For TA e , relational databases compute all possible matchings at all the time points in one shot, and then filter out those that fail the temporal constraint, which can be faster than an iterative process.Similarly, for TA 6 , the XOR operator can be implemented as a join-antijoin.Interestingly, for TA 8 (set containment join, see Introduction) DuckDB is most efficient, followed by our algorithms, and then by HyPer.For the majority of other cases, DuckDB either ran out of memory (OM in Table 3) or was the slowest system.Results for EPL are in supplementary materials.Note that our system was able to handle all queries within the allocated memory, with DuckDB and HyPer both ran out of memory in some cases.10 shows the execution time of each algorithm as a function of graph density, varying from 0.1 to 1.0, where density 1.0 corresponds to a complete graph.Observe that partial-match outperforms on-demand for paths, particularly as graph density increases.For the cycle of size 3, baseline and on-demand have better performance than partial-match, but the performance gap decreases with increasing graph density.Our experiments for BGPs: path of length 4 and cycle of length 4 show similar trend.Notably, performance of on-demand is very close to the baseline.
Next, we consider the impact of temporal domain size on performance.In general, we expect execution times to increase with increasing temporal domain size.To measure this effect without changing the structure or the size of the graph, we synthetically changed the temporal resolution of the Email dataset, creating graphs with between 25 and 800 snapshots, and thus keeping the number of BGP matchings fixed.
Figure 11a shows the result of executing temporal BGP with path of length 2 and time automaton TA 1 (Figure 2b).Observe that the execution time of all algorithms increases linearly, with partial-match scaling best with increasing number of snapshots.
Finally, we study the relationship between result set size of a temporal BGP and algorithm performance.For this, we executed the path of length 2 BGP on the Email dataset, with timed automaton TA 2 in Figure 2c, and manipulated selectivity by varying the clock condition from c < 0 to c < 1024 on the logarithmic scale.With these settings, the temporal BGP accepts between 0 and 36K matchings.Figure 11b presents the result of this experiment, showing the running time (in sec) on the x-axis and the number of temporal BGP matchings (in thousands) on the y-axis.Observe that the running time increases linearly with increasing number of accepted matchings for all algorithms, and the slope of increase is small.

Impact of the number of clocks and automaton size on performance
In our final set of experiments, we investigate the impact of automaton size and of the number of clocks on performance, while keeping all other parameters fixed to the extent possible.To do this, we fix the BGP and vary the size of the automaton, as follows.We fix the BGP to cycle4 and take TA 0 (Figure 7) with m = 4 as a starting point.We can unfold the cycle of states, thus doubling the number of states but resulting in an   equivalent automaton.We do this doubling seven times, until we obtain 256 states.Figure 12a shows the execution times on the EPL dataset.Observing that the execution times remain constant, we conclude that automaton size does not significantly impact performance.
Finally, to investigate the impact of the number of clocks on performance, we added multiple clocks to the automaton in Figure 7 and we reset all clocks at every state transition.To ensure that any possible difference is not due to the change of output size, the condition of each clock is set to true. Figure 12b shows the result of this experiment, with the number of clocks on the x-axis and the execution time in seconds on the y-axis.Observe that the running time of all algorithms increases very slightly with increasing number of clocks.We thus conclude that the computational overhead of storing and updating clocks is low.

Related Work
During the past several decades, researchers considered different aspects of graph pattern matching, see Conte et al. [15] for a survey.The majority of temporal graph models use either time points [24,30,44] or intervals [38,61,67,47] to enrich graphs with temporal information.In our work, we associate each edge in a graph with a set of time points, which is an appropriate representation when events -such as messages between users or citations -are instantaneous and so do not have a duration.It is an interesting topic for further research to investigate when and how an interval-based approach can be encoded by a pointbased approach.This depends also on the considered graph model, and the considered class of queries and temporal constraints.
A prominent line of work where the point-based approach is adopted is that of mining frequent temporal subgraphs, called temporal motifs [24,30,44].There, the focus is typically on existential temporal constrains, aiming to identify graph patterns with a specific temporal order among the edges, such as in our Example 1. Timed automata can easily specify such constrains.An important type of a motif is a δ temporal motif [44], where all the edges occur inside the period of δ time units.Timed automata can use one or multiple clocks to enforce such constrains.
Züfle et al. [67] consider a particular class of temporal constraints where the time points within a query range are specified exactly up to the translation of the query range into the temporal range of the graph.Such constraints are more general than existential constraints, in that they can represent gaps.An interesting aspect of this work is that the history of each subgraph is represented as a string, and the temporal constraint is checked using substring search.While this method of expressing constraints can work over a set of time points, it is limited to ordered temporal constraints and does not support reoccurring edges.
There are various lines of research on querying temporal graphs that are complementary to our focus in this paper.For example, durable matchings [50,34] count the number of snapshots in which a matching exists.Much attention has also been paid to tracing unbounded paths in temporal graphs, under various semantics, e.g., fastest, earliest arrival, latest departure, time-forward, time travel, or continuous [9,19,27,57,58,59].A focus on unbounded paths is complementary to our work on patterns without path variables, but with powerful temporal constraints.Extending our framework with path variables is an interesting direction for further research.
An important aspect of pattern matching in graphs is efficiently extracting the matchings.Early work started with the back-tracking algorithm by Ullmann [52], with later improvements [14,53].Pruning strategies for bruteforce algorithms have been investigated as well [11,16,17].Approaches suitable for large graphs typically build up the set of matchings in a relational table [32] by a series of natural joins over the edge relation; the aim is then to find an optimal join order.Until recently, the best-performing approaches were based on edgegrowing pairwise join plans [31,49,51], but a new family of vertex-growing plans, known as worst-case optimal joins, have emerged [5,42,54], with better performance for cyclic patterns such as triangles.While we use the latter approach and implement our algorithms using relational operators, any method capable of finding matchings on a static graph can be combined with our timed automaton-based algorithms.

Conclusions and Future Work
In this paper, we proposed to use timed automata as a simple but powerful formalism for specifying temporal constraints in temporal graph pattern matching.We introduced algorithms that retrieve all temporal BGP matchings in a large graph, and presented results of an experimental evaluation, showing that this approach is practical, and identifying interesting performance trade-offs.Our code and data are available at http://github.com/amirpouya/TABGP.
An interesting open problem is how timed automata exactly compare to SQL in expressing temporal constraints (pinpointing the expressive power of SQL on ordered data is notoriously hard [35]).It is also interesting to investigate the decidability and complexity of the containment problem for temporal BGPs based on timed automata.Another natural direction for further research is to adapt our framework to a temporal graph setting where edges are active at durations (intervals), rather than at separate timepoints.Our hypothesis is that we can encode any set of non-overlapping intervals by the set of border-points.We conjecture that timed automata under such an encoding can express common constraints on intervals, such as Allen's relations [1].
A Supplementary materials for Section 6 We present the SQL queries for the temporal BGPs with timed automata used in the experiments.For this experiment, we used BGPs with two edge variables.Thus, TA 4 , originally shown in Figure 8, is adapted here to two edge variables, as shown in Figure 13.

Fig. 4 :
Fig. 4: Content of the States relation at t = 0, . . ., 3, illustrating the execution of the timed automaton in Figure 2c by the baseline algorithm of Section 4.2.

Fig. 5 :
Fig. 5: Content of the States relation at t = 0, . . ., 3, illustrating the execution of the timed automaton in Figure 2c by the on-demand algorithm of Section 4.3.

Fig. 6 :
Fig. 6: Content of the States relation at t = 0, . . ., 3, illustrating the execution of the timed automaton in Figure 2c by the partial matching algorithm of Section 4.4.

4 Fig. 10 :
Fig. 10: Running time as a function of structural density for 4 common BGPs, with timed automaton TA 4 in Figure 8.
path2 with TA 2 on Email
Complexity Each of the above steps can be accomplished by relational-algebra-like dataflow operations over the States table.In particular, step 2 is done by successive left outer joins.For j = 1, . . ., k, let A j be the Active table, filtered on time = t i , and renaming eid to b j .We left-outer join States with A j on condition y j = b j .If, in the result, b j is null, it is replaced by false; otherwise it is replaced by true.The entire second stage, for a fixed timed automaton, can be implemented in time O(A + nM ), where A is the size of the Active table, n is the size of the temporal domain, and M is the number of matchings returned from the first stage.

Table 1 :
Description of the experimental datasets.

Table 2 :
Relative performance of baseline, on-demand and partial-match, for different BGPs and automaton TA 0 .

Table 3 :
Best-performing timed-automaton algorithm (TAA) compared to DuckDB and HyPer, for SQL queries in Figure1.