Views on a persistent graph
The same temporal view functions you use on a regular Graph – at(), before(), after(), and window() – work on a PersistentGraph, but they behave differently. Instead of filtering by update events, they filter by whether an edge was active at the queried time.
Querying an instant with at()
As we can see, the edge's presence in the graph is inclusive of the timestamp at which it was added, but exclusive of the timestamp at which it was deleted. Equivalently, the Alice-Bob edge is present on the interval 2 ≤ t < 5.
Node visibility depends on activity within the view. A node appears in a view if it either:
- Was explicitly added at or before the queried time (once added, nodes exist forever from that point onwards), OR
- Has an active edge within the time bounds
In the example, Charlie was explicitly added at t=3, so he appears at t=3 and all later times. Alice and Bob were never explicitly added – they only exist because the edge created them. Once their edge is deleted at t=5, they have no activity and disappear from the view.
Getting the graph before a point with before()
Here we see that before(T) is exclusive of the end point T, creating an intersection between the time interval -∞ < t < T and 2 ≤ t < 5 where T is the argument.
Getting the graph after a point with after()
after(T) is also exclusive of the starting point T.
Windowing the graph with window()
window(T1, T2) creates a half-open interval T₁ ≤ t < T₂ intersecting the edge's active time (2 ≤ t < 5 in this case). When the window is completely inside the edge active time and when the edge's active time is strictly inside the window, the edge is treated as present in the graph.
Graph-type-agnostic snapshots
If you're writing code that needs to work with both Graph and PersistentGraph, use snapshot_at() and snapshot_latest() instead of at() or before().
These methods adapt their behavior based on the underlying graph type:
| Method | On Graph | On PersistentGraph |
|---|---|---|
snapshot_at(t) | Equivalent to before(t + 1) | Equivalent to at(t) |
snapshot_latest() | No-op (returns the graph as-is) | Equivalent to latest() |
This is useful when you want to ask "what does the graph look like at time T?" without worrying about whether edges are events or persistent relationships.