Invariant Graph Representations for Continuous-Time Dynamic Graphs Under Distribution Shifts

Kaiyu Feng\(^1\) Hanning Yuan\(^1\)
\(^1\)Beijing Institue of Technology
\(^2\) Southeast University
\(^3\) Wuhan University
ltfang@bit.edu.cn, 406674524@qq.com, z15334025555@163.com, {fengky, yhn6}
bit.edu.cn?


Abstract

Continuous-Time Dynamic Graphs (CTDGs) enable fine-grained modeling of evolving relational systems. However, most existing CTDG representation learning methods are tailored to in-distribution settings and exhibit limited robustness under out-of-distribution (OOD) shifts. Although recent causal approaches learn invariant representations via interventions, they are primarily designed for static or discrete-time graphs and become computationally prohibitive for CTDGs due to the combinatorial explosion of structural and temporal variations. To address these challenges, we propose CIR, a framework grounded in a novel structural causal model termed the ICCM. To avoid exhaustive interventions, we leverage the Normalized Weighted Geometric Mean (NWGM) to efficiently approximate interventional predictions. We further instantiate ICCM within a practical deep learning architecture that jointly captures invariant structural and temporal patterns through dedicated subgraph extractors, and maintains an environment memory bank to model distributional shifts across evolving contexts. Extensive experiments demonstrate that CIR consistently outperforms existing methods under diverse OOD scenarios.

1 Introduction↩︎

Many real-world systems exhibit continuously evolving relational structures, which are naturally modeled as dynamic graphs [1]. Existing dynamic graph models can be broadly categorized into Discrete-Time Dynamic Graphs (DTDGs) [2], [3], which represent evolution as a sequence of temporal snapshots, and Continuous-Time Dynamic Graphs (CTDGs) [4][7], which capture fine-grained structural changes via continuous node and edge updates. Although existing methods have achieved significant success in modeling temporal dynamics, they predominantly overlook robustness under out-of-distribution (OOD) scenarios.

Therefore, this paper focuses on invariant representation learning for CTDGs under OOD scenarios. While techniques such as subgraph extraction [8], [9] and attention mechanisms [10] can partially alleviate distribution shifts, they remain vulnerable to exploiting spurious correlations [11]. For example, in the link prediction setting illustrated in Figure 1, a triadic closure pattern (highlighted in red) constitutes the invariant subgraph underlying the formation of the target link \((u, v)\). However, because a bridging link \((x, u)\) (highlighted in blue), also appears before \((u, v)\) in most training graphs, the model may incorrectly treat \((x, u)\) as the invariant subgraph for \((u, v)\). As a result, at test time, the model may falsely predict the existence of \((u, v)\) based solely on \((x, u)\), ignoring the absent of the triadic closure pattern.

Figure 1: Examples of training data.

Recent structural causal model (SCM) based methods [12][15] have been proposed to mitigate spurious correlations by identifying and intervening on invariant subgraphs, either across multiple environments or through sampling-based interventions. However, these approaches implicitly assume a fixed or bounded graph structure, where the set of nodes and candidate edges remains stable over time, as in static graphs or DTDGs. Under this assumption, causal invariance can be meaningfully defined and estimated over a shared structural support. In contrast, CTDGs allow nodes and edges to be added or removed at arbitrary time points, resulting in a non-stationary and exponentially expanding space of graph topologies. This fundamentally challenges existing SCM-based intervention mechanisms.

In this paper, we propose Continuous-time Invariant Representation (CIR), a novel method that captures invariant representation and mitigates OOD effects from a new SCM perspective. To effectively address OOD generalization in CTDGs, CIR is designed to satisfy three essential properties: (1) robust mitigation of OOD distribution shifts, which is fundamental for generalization across unseen environments; (2) simultaneous capture of invariant subgraphs across both structural and temporal dimensions, which is crucial in CTDGs where graph topology and event timing evolve continuously; and (3) computationally efficient causal interventions, necessitated by the exponentially large space of possible structural–temporal subgraphs.

CIR is theoretically grounded in a structural causal model termed the Independent and Confounded Causal Model (ICCM), which explicitly models both in-distribution and OOD environments. Directly intervening on all possible structural and temporal subgraphs is computationally infeasible. To address this challenge, we leverage the Normalized Weighted Geometric Mean (NWGM) [16] to efficiently approximate the expected interventional outcome, substantially reducing computational cost. We instantiate ICCM within a practical deep learning framework. The architecture first employs dual subgraph extractors to capture causal structural and temporal patterns. An environment memory bank is then maintained to learn environment-specific representations, which are used to condition the prediction process. To approximate the expected outcome of causal interventions defined in ICCM, we aggregate environment-conditioned predictions using the NWGM. Finally, the causal structural and temporal patterns are encoded into invariant representations, and the model performs predictions based on the learned invariant representations together with the environment representations. The main contributions of this paper are summarized as follows:

  • To the best of our knowledge, we are the first to investigate invariant representation learning problem for CTDGs under OOD shifts.

  • We introduce ICCM, a novel structural causal model that characterizes invariant causal subgraphs in CTDGs, and develop an efficient intervention strategy based on the NWGM to approximate interventional predictions, avoiding exhaustive enumeration of structural and temporal subgraphs.

  • We design a framework named CIR that instantialize ICCM, enabling the joint learning of invariant structural and temporal representations along with environment-specific features.

2 Related Work↩︎

In this section, we review two areas closely related to our study: dynamic graph neural networks and invariant graph representation.

2.0.0.1 Dynamic Graph Neural Networks.

Dynamic graph neural networks encompass two primary classifications: Discrete-Time Dynamic Graphs (DTDGs) [3], [17] and Continuous-Time Dynamic Graphs (CTDGs) [6], [7], [18]. DTDGs comprise a sequence of static graph snapshots captured at regular time intervals [19][21]. CTDGs capture the evolution of graphs by considering modifications on the graph that occur continuously rather than discretely at predefined time steps [22][24]. However, these GNNs focus primarily on modeling graph dynamics while overlooking robustness to OOD scenarios.

2.0.0.2 Invariant Graph Representation.

Invariant learning enhances the robustness of GNNs by identifying stable, environment-invariant patterns. Existing approaches fall broadly into two categories: disentangled learning and causal learning. Disentangled learning [25][27] aims to learn representations in which latent factors are separated and interpretable, capturing distinct variations in the data. Such representations have been shown to improve robustness to adversarial attacks and enhance generalization. However, these methods are limited in their ability to identify causal variables that remain invariant in the presence of shortcuts or spurious correlations. Causal inference methods [28], [29] focus on unveiling and comprehending the true causal variables that drive observed phenomena. On real-world graphs, uncovering these causal variables becomes an act of explanation, revealing the “why” behind intricate relationships. However, most of these methods are largely restricted to static settings. To extend causal inference into dynamic scenarios, DIDA [30] has been proposed as an invariant rational discovery framework for DTDGs. However, DIDA requires constructing an intervention set for each snapshot, making it computationally intensive when applied to CTDGs. EAGLE [31] employs a VAE-based model as an environment sample generation network. However, when the number of environments is large and the available sample size is limited, the generated samples may not adequately represent the underlying environments, thereby impairing generalization performance. In this work, we focus on the more realistic and challenging setting of CTDGs, where interactions evolve continuously rather than at discrete time intervals. Existing causal inference methods are generally inapplicable to this setting because they predominantly rely on snapshot-based assumptions, which fail to capture the fine-grained temporal dynamics inherent in CTDGs.

3 Problem Formulation↩︎

Definition 1 (CTDG). A Continuous Time Dynamic Graph (CTDG) \(G = (\mathcal{V}, \mathcal{E}, \mathcal{T})\) consists of a set of vertices \(\mathcal{V}\), a set of edges \(\mathcal{E}\), and a continuous time domain \(\mathcal{T}\). The graph evolves over \(t\in \mathcal{T}\) through edge additions, removals, or changing characteristics. We represent \(G\) as a sequence of time-stamped edges \(G = \langle e_{ij}(t_k)\rangle\), where \(e_{ij}(t_k)\) denotes an interaction between node \(v_i\) and \(v_j\) at time \(t_k\) with feature vector \(x_{ij}^e(t_k)\). Each node \(v_i\) has a feature vector \(x_i^n\).

Given a CTDG \(G = (\mathcal{V}, \mathcal{E})\), the task is to predict whether an interaction \(e_{ij}(t)\) will occur at a future time \(t\), based on the historical sequence of nodes, edges, and their features. To evaluate OOD robustness, the model is trained on one environment and tested on CTDGs from other environments, where structural and temporal distributions may differ.

4 Independent and Confounded Causal Model↩︎

In this section, we introduce a novel structural causal model framework, termed Independent and Confounded Causal Model (ICCM).

In dynamic graphs, the existence of an edge can be influenced by both the structural topology (e.g., triadic closure) and temporal dynamics (e.g., temporal burst) [32]. These mechanisms may act independently or become entangled through latent confounders, and their influence can vary across environments. Existing causal formulations typically conflate structural and temporal effects, limiting their ability to disentangle spurious correlations under distribution shifts.

To explicitly capture both independent causal effects and environment-dependent confounding, ICCM models structural and temporal causal processes as distinct but potentially confounded components. We formalize ICCM by inspecting the causalities among nine variables: the structural causal subgraph \(C_s\subseteq G\), the temporal causal subgraph \(C_t\subseteq G\), the hidden representations \(H^T\) and \(H^S\), the structural confounder \(\mathcal{D}_s\), the temporal confounder \(\mathcal{D}_t\), the edge existence probability in the in-distribution environment \(Y^I\), the edge existence probability in OOD environments \(Y^O\), and the final prediction result \(Y\). Assumption 1 summarizes the core principles underlying ICCM:

Assumption 1 (ICCM). \[\begin{align} &H^S= f_{s}(C_s), \quad H^T= f_{t}(C_t), \quad Y^I = f^{I}_o(H^S, H^T) \\ &Y^C= f^C_o(H^S,H^T, \mathcal{D}_s, \mathcal{D}_t), \quad \text{s.t.} \quad C_s \bot \mathcal{D}_s, \quad C_t \bot \mathcal{D}_t, \\ & Y = f_o(Y^I, Y^C). \end{align}\]

In this assumption, \(C_s\) and \(C_t\) are causal structural and temporal subgraph. These subgraphs are encoded into latent representations \(H^S\) and \(H^T\) via \(f_s(\cdot)\) and \(f_t(\cdot)\). The in-distribution prediction \(Y^I\) is determined by the outcome function \(f_o^I(H^S, H^T)\): \[\label{eq:overview95ICM} Y^I = f_o^I(H^S, H^T)= \sigma \bigl( W^I(W^I_1H^S+W^I_2H^T )\bigr).\tag{1}\]

In OOD environments, however, structural and temporal confounders introduce spurious correlations that degrade model generalization. Specifically, structural confounders establish backdoor paths \(C_s\leftarrow C_b^s \rightarrow Y\) and \(C_s \leftarrow U_s \rightarrow Y\), where \(C_b^s=G\setminus C_s\), and \(U_s\) represent unobserved variables. These paths induce spurious correlations between \(C_s\) and \(Y^C\). Temporal confounders exert a similar influence. To mitigate these spurious correlations, we employ the do-operation introduced by Pearl [33]. The do-operation allows us to block backdoor paths, thereby eliminating spurious correlations and isolating the invariant causal effect. Using the do-operation, the prediction \(Y^C\) can be formulated as: \[\label{eq:adjust95s} \begin{align} Y^C=& f^C_o(H^S,H^T, \mathcal{D}_s, \mathcal{D}_t) \quad \text{s.t.} \quad C_s \bot \mathcal{D}_s, \quad C_t \bot \mathcal{D}_t,\\ =&\mathbb{E}_{u\in \mathcal{D}_S, v\in \mathcal{D}_T}\left[f_o^C(H^S, H^T, u, v) \right] \\ \end{align}\tag{2}\] where \(\mathcal{D}_s=\{ C^s_b, U_s\}\) and \(\mathcal{D}_t=\{C^t_b, U_t\}\), respectively, \(f^C_o\) is output network network: \[\label{eq:overview95CCM} \begin{align} f^C_o(H^S,H^T,u, v)= & \sigma \bigl(W^c_1f_y^s(H^S)+W^c_2f_y^t(H^T) \\ \qquad\qquad \qquad \qquad &+W^c_3f_y^u(u) +W^c_4f_y^v(v) \bigr). \end{align}\tag{3}\] where \(W^*_*\) denotes the model parameters, \(f_y^*(\cdot)\) denotes linear network, \(\sigma\) denotes the activation function. However, we observe Equation 2 is computationally intractable. It necessitates enumerating all possible pairs of invariant causal subgraphs across the space of structural confounders \(\mathcal{D}_s\) and temporal confounders \(\mathcal{D}_t\). In the context of large-scale CTDGs, this combinatorial explosion of potential subgraph configurations leads to prohibitive computational costs, making exhaustive intervention infeasible.

To address this issue, we propose an efficient intervention process by leveraging the NWGM approximation [16]. The NWGM provides a computationally efficient way to estimate the expectation of a softmax or sigmoid output by moving the expectation inside the non-linearity: \[\mathbb{E}_{d\sim \mathcal{D}}[\sigma\bigl(f(x)\bigl)] \approx \sigma\bigl(\mathbb{E}_{d\sim \mathcal{D}}[f(x)]\bigl).\] By applying the NWGM approximation, the interventional prediction in Equation 2 can be reformulated as: \[\label{eq:overview95s} \begin{align} Y^C \approx & \sigma \bigl( \mathbb{E}_{u\in \mathcal{D}_s, v\in \mathcal{D}_t}[ W^c_1f_y^s(H^S)+W^c_2f_y^t(H^T) \\ &\qquad\qquad \qquad +W^c_3f_y^u(u) +W^c_4f_y^v(v) ]\bigr), \\ = & \sigma \bigl(W^c_1f_y^s(H^S)+W^c_2f_y^t(H^T) +W^c_3\mathbb{E}_{u\sim \mathcal{D}_s}[f_y^u(u)]\\ &\qquad\qquad \qquad+W^c_4\mathbb{E}_{v\sim \mathcal{D}_t}[f_y^v(v)]\bigr). \end{align}\tag{4}\] Note that \(\mathcal{D}_s\) and \(\mathcal{D}_t\) denote abstract latent confounders, which may themselves correspond to complex subgraph patterns. While the confounder space can be large, Equation 4 does not require explicit enumeration of all possible confounders. Instead, it only requires expectation over a representative set of confounding modes, which can be approximated via confounder prototypes (Explained in Section 5.2.

5 Neural Instantiation of ICCM↩︎

In this section, we describe how the proposed ICCM is instantiated within a neural architecture by mapping latent causal variables to learnable components. The complete architecture is illustrated in Figure 2.

While the theoretical ICCM assumes access to causal subgraphs \(C_s\) and \(C_t\), these variables are typically latent and unobserved in real-world scenarios. To address this, we employ causal subgraph extractors to infer structural and temporal subgraphs directly from the input data. The extractors identify invariant structural and temporal patterns and produce hidden representations \(H^S\) and \(H^T\).

For the in-distribution perspective, these representations are passed to the outcome function \(f_o^I\) to predict the label \(y^I\). For the out-of-distribution (OOD) perspective, as described in Equation 4 , the interventional prediction requires the expected representations of structural and temporal confounders: \(\mathbb{E}_{u \sim \mathcal{D}_S}[f_y^u(u)] \quad \text{and} \quad \mathbb{E}_{v \sim \mathcal{D}_T}[f_y^v(v)]\).

To estimate these expectations without exhaustive enumeration, we maintain structural and temporal memory banks that approximate the latent confounder distributions \(\mathcal{D}_s\) and \(\mathcal{D}_t\). A multi-head attention-based fusion module then aggregates the memory entries to compute the expected environmental context, which approximates the expectation over latent confounder effects. Finally, the invariant representations \(H^S\) and \(H^T\) are integrated with the computed expectations from the memory banks and fed into the outcome function \(f_o^C\) to produce the OOD prediction \(y^C\). We term this framework Continuous Invariant Representation (CIR).

Figure 2: The deep learning implementation of CIR.

5.1 Extracting and Encoding Causal/Non-causal Subgraphs↩︎

5.1.0.1 Temporal extraction and encoding.

Given a dynamic graph \(G\) and a target node pair \((u, v)\) for prediction, our goal is to identify historical temporal interactions that causally contribute to the potential existence of an edge between \(u\) and \(v\). Unlike heuristic time-window approaches, we aim to extract temporally relevant evidence that is both time-aware and pair-specific, aligning with the causal assumptions in ICCM. we first extract the temporal edges associated with nodes \(u\) and \(v\) denoted by \(S_G^u\) and \(S_G^v\), respectively. Each edge \(e_{ui}(t_k) \in S_G^u\) is encoded using a continuous-time representation following [32]: \(\cos \bigl((t_0-t_k) \omega \bigr)\), where \(t_0\) is the prediction timestamp, \(\omega=\left\{\alpha^{-(i-1)/ \beta}\right\}_{i=1}^d\) defines a set of multi-scale temporal frequencies, with \(\alpha\) and \(\beta\) representing hyperparameters. This encoding is combined with its corresponding edge features as \([\cos \bigl(\left(t_0-t_k\right) \omega\bigr) \| \mathbf{x}_{ui}^{e}\left(t_k\right)]\).

A 1-layer MLP-mixer [34] is employed to encode the edge features, \[F_u=\text{MLPmixer}(\text{stack}(S_G^u)),\] where stack\((S_G^u)\) indicates the stacking of the edge features in sequence \(S_G^u\). The MLP-Mixer enables global mixing across temporal edges, allowing the representation of higher-order temporal dependencies that are crucial for causal reasoning.

Intuitively, a historical interaction of \(v\) is considered temporally causal for predicting \((u,v)\) only if it helps explain \(u\)’s behavior, and vice versa. Therefore, we introduce a cross-node attention mechanism. The subgraph is generated by: \[\begin{align} & q_u = W^{m}_1 \text{Mean}( F_u), \quad K_v =W^{m}_2 (F_v) \\ &q_v = W^{m}_1 \text{Mean}( F_v), \quad K_u =W^{m}_2 (F_u) \\ &M^e_{v} = \text{Softmax}\left(\frac{q_u^T K_v}{\sqrt{d}}\right), \quad M^e_{u} = \text{Softmax}\left(\frac{q_v^T K_u}{\sqrt{d}}\right). \end{align}\] Here, \(d\) denotes a specific hyperparameter, and \(M^e_*[k]\) represents the importance score assigned to the \(k\)-th edge within \(S_*\). This attention mechanism filters temporal evidence based on mutual relevance, rather than local frequency or recency alone. Consequently, the highest top-\(k\) scores in \(M^e_v\) and \(M^e_u\) are selected to construct the temporal causal subgraphs \(C_t\), while the remaining edges form the temporal non-causal subgraphs \(\hat{B}_t\). Finally, the temporal representations of the causal and non-causal graphs are encoded by: \[\begin{align} & h^t_u=\text{MLPmixer}(\text{stack}(S_{C_t}^u), \quad h^t_v = \text{MLPmixer}(\text{stack}(S_{C_t}^v), \\ & x^t_u=\text{MLPmixer}(\text{stack}(S_{\hat{B}_t}^u), \quad x^t_v = \text{MLPmixer}(\text{stack}(S_{\hat{B}_t}^v), \end{align}\] The final representations are obtained by concatenation: \[H^T = [h^t_u || h^t_v], \quad X^T = [x^t_u || x^t_v].\] Causal temporal evidence is disentangled from confounding effects, supporting intervention-based learning.

5.1.0.2 Structural extraction and encoding.

Our objective is to identify structural neighbors that causally support the interaction between \(u\) and \(v\), while filtering out background nodes that may introduce spurious correlations. We first encode each node based on its n-hop neighborhood within a recent time window \(]t_0-T, t_0]\): \(z_u=x_u^{n}+\operatorname{Mean} \bigl(\{x_v^n \mid v \in \mathcal{N}^n(u ; t_0-T, t_0)\}\bigr)\). Here, \(\mathcal{N}^n(u ; t_0-T, t_0)\) denotes the n-hop neighbors of node \(u\) with valid temporal edges, where \(T\) controls the structural temporal scope. The node mask matrices are computed through the equations: \[M^n_{v} = \text{Softmax}\left(\frac{z_u^T Z_v}{\sqrt{d}}\right), \quad M^n_{u} = \text{Softmax}\left(\frac{z_v^T Z_u}{\sqrt{d}}\right).\] Here, \(Z_u\) and \(Z_v\) is the stack of the encoded node features of all nodes in \(\mathcal{N}^n(u ; t_0-T, t_0)\) and \(\mathcal{N}^n(v ; t_0-T, t_0)\), respectively. The nodes with the highest top-\(k\) scores in \(M^n_{u}\) and \(M^n_{v}\) are chosen to form the structural causal subgraph, while the remaining edges form the temporal non-causal subgraphs \(\hat{B}_s\). The final structural representation \(H^S\) is computed by: \[\begin{align} & h^s_u =x^{n}_u + \operatorname{Mean} \bigl(\{x^{n}_i| i\in \mathcal{N}^n_S(u) \}\bigr), \\ &h^s_v =x^{n}_v+ \operatorname{Mean}\bigl(\{x^{n}_i| i \in \mathcal{N}^n_S(v) \}\bigr), \\ &H^S = [h^s_u || h^s_v], \end{align}\] where \(x^{n}_v\) represents the node feature of \(v\), \(\mathcal{N}^n_S(u)\) represents the n-hop neighbors of \(u\) in \(C_s\). The final structural representation \(X^S\) for the non-causal subgraph \(\hat{B}_s\) is obtained using the same encoding method applied to \(C_s\).

5.2 Memory Banks↩︎

The memory bank is designed to capture all confounders, including both non-causal subgraphs and unobserved factors. Since unobserved factors are not directly observable, we approximate them using the representations of observable non-causal subgraphs, based on the insight that unobserved influences are often implicitly reflected in the structure of these subgraphs.

As the dynamic graph evolves, the number of non-causal subgraphs can grow exponentially, making it infeasible to consider each instance individually. To address this, each entry in the memory bank approximates a cluster of non-causal subgraphs, capturing the shared influence of similar confounders. Specifically, the memory bank consists of \(K\) prototype vectors stored in the \(\hat{\mathcal{D}}_* \in \mathbb{R}^{K \times d}\), where \(K\) denotes the number of prototypes and \(d\) represents the feature dimensionality. Each element of \(\hat{\mathcal{D}}_*\) is initialized by sampling from a standard normal distribution, after which each prototype is normalized to ensure that they lie on a unit hypersphere. The memory bank is updated during training via gradient descent, guided by two self-supervised loss functions: the alignment loss and the diversity loss.

Given non-causal graphs \(X^T\) and \(X^S\), the alignment loss is defined as: \[\begin{align} & z_T = \text{linear}(X^T) \quad z_S = \text{linear}(X^S)\\ & k_T = \arg\max_k \, z_T \hat{\mathcal{D}}_T^\top[k] \quad k_S = \arg\max_k \, z_S \hat{\mathcal{D}}_S^\top[k] \\ &\mathcal{L}_{\text{align}} = 1 - (z_T \hat{\mathcal{D}}_T[k_T]+z_S \hat{\mathcal{D}}_S[k_S]), \end{align}\] Here, \(z_T\) and \(z_S\) are encoded features of \(X^T\) and \(X^S\), respectively. The term \(z_* \hat{\mathcal{D}}_*^\top[k_*]\) (with \(*\) representing either \(T\) or \(S\)) measures the similarity between the encoded feature \(z_*\) and the \(k_*\)-th prototype in \(\hat{\mathcal{D}}_*\). Each sample is assigned to the prototype with the highest similarity. When \(z_*\) is well aligned with \(\hat{\mathcal{D}}_*[k]\), the loss contribution for that sample is minimal.

To prevent redundancy among the prototypes, we impose a diversity loss: \[\mathcal{L}_{\text{div}} = \frac{1}{K} (\sum_{i=1}^{K}\sum_{j=1}^{K} \hat{\mathcal{D}}_S[i] \cdot \hat{\mathcal{D}}_S[j]+\sum_{i=1}^{K}\sum_{j=1}^{K} \hat{\mathcal{D}}_T[i] \cdot \hat{\mathcal{D}}_T[j]).\] Minimizing this loss encourages the prototypes to be as orthogonal as possible, ensuring that each captures a distinct cluster of non-causal subgraphs.

The overall regularization loss is the sum of the alignment and diversity losses: \[\mathcal{L}_{\text{reg}} = \mathcal{L}_{\text{align}} + \mathcal{L}_{\text{div}}.\] This loss is backpropagated during training to update both the encoder parameters and the memory bank, thereby refining the prototypes to more accurately represent distinct clusters of non-causal subgraphs.

5.3 Fusion↩︎

As shown in Equations 4 , the fusion module combines the causal graph representations (\(H^S\) and \(H^T\)) with the expected contributions of confounders, as approximated by the memory banks (\(\hat{\mathcal{D}}_S\) and \(\hat{\mathcal{D}}_T\)). This step implements the ICCM-inspired interventional reasoning, where the model accounts for potential spurious effects from non-causal subgraphs and unobserved factors. We approximate the expected effect of confounders as: \[\begin{align} &Q_S = \text{Linear}(H^S) \quad K_S=\hat{\mathcal{D}}_S\quad V_S= \hat{\mathcal{D}}_S \\ &\mathbb{E}_{u \sim \hat{\mathcal{D}}_S}\left[f_y^u(u)\right] = \operatorname{Multi-head}(Q_S, K_S, V_S), \\ &Q_T = \text{Linear}(H^T) \quad K_T=\hat{\mathcal{D}}_T\quad V_T= \hat{\mathcal{D}}_T \\ &\mathbb{E}_{v \sim \hat{\mathcal{D}}_T}\left[f_y^v(v)\right] = \operatorname{Multi-head}(Q_T, K_T, V_T). \end{align}\]

The attention output is then fused with the original query using a residual connection, followed by dropout and layer normalization: \[\begin{align} & H^S_c =\text{LayerNorm}\bigl(Q+Dropout( \mathbb{E}_{u \sim \hat{\mathcal{D}}_S}\left[f_y^u(u)\right] )\bigr) \\ &H^T_c =\text{LayerNorm}\bigl(Q+Dropout( \mathbb{E}_{v \sim \hat{\mathcal{D}}_T}\left[f_y^v(v)\right] )\bigr). \end{align}\] The fused features \(H^S_c\) and \(H^T_c\) are subsequently processed by a feedforward network and output the final prediction \(y^C\).

5.4 Optimization↩︎

We define the overall learning objective as: \[\begin{align} \mathcal{R}_i &= \frac{1}{|\mathcal{E}|} \sum_{e \in \mathcal{E}} \Bigl[ y_e \log(y_e^I) + (1-y_e) \log(1-y_e^I) \Bigr],\\ \mathcal{R}_c &= \frac{1}{|\mathcal{E}|} \sum_{e \in \mathcal{E}} \left[ y_e \log(y_e^C) + (1-y_e) \log(1-y_e^C) \right],\\ \mathcal{L} &= \lambda_i \, \mathcal{R}_i(y^I, y) + \lambda_c \, \mathcal{R}_c(y^C, y) + \lambda_r \, \mathcal{L}_{\text{reg}}, \end{align}\] where \(\lambda_i\), \(\lambda_c\), and \(\lambda_r\) are hyperparameters, \(\mathcal{E}\) denotes the training dataset, which comprises pairs of positive and negative samples. Positive samples are derived from the original edge sets, while negative samples are generated by replacing the destination nodes with randomly sampled nodes from the vocabulary, ensuring a balanced ratio. The variable \(y_e\) indicates the ground-truth label for edge \(e\), with \(y_e = 1\) for positive samples and \(y_e = 0\) for negative samples.

Table 1: Comparison with SOTA graph link prediction models w.r.t. AUC (mean \(\pm\) standard deviation). The best scores are highlighted in bold.
Model MOOC REDDIT WIKI UCI
Ratio 0.2 0.4 0.6 0.2 0.4 0.6 0.2 0.4 0.6 0.2 0.4 0.6
TGN 90.39±1.27 65.49±0.81 61.99±2.21 95.44±1.09 87.70±3.55 72.69±0.31 68.56±2.03 61.92±2.63 64.97±0.65 68.93±1.41 68.43±3.58 64.68±2.47
TGAT 93.75±0.49 85.25±1.21 73.08±1.49 97.32±0.14 95.34±0.28 89.21±0.48 90.90±0.78 74.72±0.74 73.07±2.74 77.66±1.17 74.55±0.46 72.59±0.54
GraphMixer 98.06±0.27 88.11±4.62 48.71±3.02 98.41±0.33 78.85±3.10 91.74±1.32 95.90±1.15 73.61±5.39 64.01±7.36 88.67±0.68 75.45±2.93 65.35±0.39
DIDA 72.78±3.32 59.87±1.30 52.00±0.63 88.26±0.47 64.06±0.06 59.05±0.25 77.40±0.46 60.94±1.10 49.47±0.35 77.17±1.08 76.09±2.87 65.92±0.41
Ada-DyGNN 83.20±4.74 74.03±1.21 71.22±0.51 95.42±0.17 94.29±0.54 90.79±0.55 91.54±0.23 72.70±0.61 67.57±0.44 89.59±0.50 74.26±3.43 67.15±1.58
EAGLE 83.41±0.97 73.12±0.36 64.46±0.37 85.07±0.86 81.71±0.44 67.38±0.35 81.51±0.56 72.41±0.31 60.69±0.59 77.90±0.11 72.19±0.61 65.06±0.55
CIR 97.72±0.13 90.18±2.17 77.46±4.07 98.91±0.06 98.18±0.32 93.82±1.25 93.26±0.71 80.37±2.02 76.04±4.58 91.84±0.44 76.84±0.97 74.88±0.65
Table 2: Comparison with SOTA graph link prediction models w.r.t. AP.
Model MOOC REDDIT WIKI UCI
Ratio 0.2 0.4 0.6 0.2 0.4 0.6 0.2 0.4 0.6 0.2 0.4 0.6
TGN 91.51±1.5 59.69±0.8 33.75±3.2 96.47±0.6 86.68±4.0 55.41±0.5 76.18±1.8 64.09±3.8 50.30±2.8 66.82±2.2 64.34±1.4 43.01±3.2
TGAT 93.42±0.3 79.92±1.8 62.02±0.6 97.60±0.1 94.64±0.4 81.44±0.9 91.90±1.5 73.06±0.6 59.73±0.7 65.54±1.0 60.84±0.5 52.95±0.4
GraphMixer 98.48±0.2 87.71±2.2 31.19±4.9 98.87±0.3 82.84±2.6 90.85±2.1 97.13±0.5 75.68±4.5 61.14±11.7 86.99±1.5 73.13±1.4 56.50±0.6
DIDA 67.15±0.6 53.86±1.2 50.74±0.4 81.94±1.6 55.62±0.2 53.97±0.3 73.23±0.5 56.37±1.0 48.07±0.5 69.66±3.2 61.47±0.8 55.38±0.8
Ada-DyGNN 81.81±5.0 73.44±1.4 70.04±1.2 94.26±0.4 90.96±0.4 90.51±0.5 92.63±0.4 70.83±0.3 64.54±0.3 88.20±0.8 72.91±1.8 62.10±0.8
EAGLE 72.10±0.3 72.03±0.6 63.03±0.6 79.82±0.3 77.47±0.5 65.16±0.5 76.01±0.5 66.43±1.0 58.14±0.5 74.06±0.1 62.36±0.4 55.22±0.4
CIR 98.14±0.5 88.24±0.3 64.53±2.6 98.95±0.1 98.15±0.3 93.65±2.0 94.96±0.7 79.10±4.5 63.46±6.0 90.59±0.6 73.55±1.8 57.36±0.4
Table 3: Ablation study.
Dataset MOOC REDDIT WIKI UCI
AP AUC AP AUC AP AUC AP AUC
remove structural encoder 78.34±2.50 75.12±0.45 89.45±0.52 90.31±0.38 65.82±2.95 63.14±5.20 60.27±1.68 58.91±2.75
remove temporal encoder 80.12±2.42 77.85±0.41 91.62±0.49 92.78±0.36 68.30±2.88 66.42±5.08 63.50±1.62 61.75±2.60
remove \(Y^I\) 85.21±2.30 82.64±0.38 95.14±0.46 96.07±0.33 74.45±2.75 72.10±4.90 70.12±1.55 68.35±2.42
remove \(Y^C\) 81.73±1.26 83.47±0.22 89.31±0.98 90.67±0.52 70.98±1.63 68.49±1.90 67.82±0.96 62.46±0.87
CIR 90.18±2.17 88.24±0.27 98.18±0.32 98.15±0.25 80.37±2.02 79.10±4.53 76.84±0.97 73.55±1.81

6 Experiments↩︎

We conduct extensive experiments on four benchmark continuous‐time dynamic‐graph datasets to answer the following research questions:

  • RQ1: How well does CIR mitigate distribution shift?

  • RQ2: How efficient is CIR compared to existing baselines?

  • RQ3: What is the contribution of each component?

All the experiments are conducted on a computer with Intel(R) Core(TM)2 Duo CPU @2.40 GHz processor, 128 GB RAM, and Tesla T4.

6.1 Experimental Settings↩︎

Datasets We conducted experiments on four real-world datasets: Wikipedia2, Reddit3 MOOC4, UCI5. Following prior work [30], we introduce structural perturbations to the graphs to simulate distributional shifts.

Evaluation Metrics. We partitioned the datasets based on the edge occurrence time: the initial 70% of edges were designated as the training set, the subsequent 15% were allocated to the validation set, and the remaining 15% formed the test set. We employ the average precision (AP) and area under the curve (AUC) as the evaluation metrics for link prediction. AP and AUC are two common metrics used to evaluate the performance of binary classification models. AP is a measure of the average precision across all possible recall thresholds. AUC is a measure of the area under the receiver operating characteristic (ROC) curve.

Training Protocols. An early-stopping mechanism was employed, terminating training when the Average Precision (AP) metric showed no improvement for five consecutive epochs. The model underwent training for 300 epochs using the Adam optimizer with a learning rate set at 0.0001 and a weight decay of 1e-6. We set the batch size to 600, and the hidden layer dimension to 100. For the extraction of the causal subgraph, we specified the number of recent edges (\(N\)) as 50 and employed 1-hop neighbors. All MLP layers were configured to 2. Regarding the link prediction task, negative samples were set at a ratio of 1:5 in the training set and adjusted to 1:1 in both the validation and test sets.

Baselines. Given the limited research on invariant GNNs for CTDGs, we consider three categories of baselines: (1) CTDG GNN Models:TGN [35], TGAT [22], and GraphMixer [32]. These models are specifically designed for CTDGs but lack the ability to produce explainable and invariant results. Therefore, our comparison primarily focuses on link prediction. (2) Robust DTDG models:DIDA [30], EAGLE [31], and Ada-DyGNN [9].

Table 1 reports the AUC results under varying shortcut ratios (0.2, 0.4, 0.6), while Table 2 presents the corresponding AP scores. Higher values indicate better performance. We summarize the key observations below: (1) CTDG models degrade sharply under stronger shortcuts. TGN suffers a substantial performance drop, with AUC decreasing by 31.4% on MOOC and by 23.8% on REDDIT. GraphMixer achieves competitive performance at 0.2 with CIR, but suffering drastic declines, particularly on MOOC (AUC decrease of 50.3%) and WIKI (AUC decrease of 33.3%). TGAT demonstrates relatively better stability but still degrades at higher shortcut ratios. (2) Robust DTDG models perform relatively well but do not generalize as effectively as CIR. Since DTDG models operate on discrete time steps, their effectiveness on CTDGs may be constrained, as they are not explicitly designed to handle fine-grained temporal dependencies. The relatively competitive performance of Ada-DyGNN and EAGLE suggests that their robustness mechanisms still provide advantages, but their full potential might be underestimated due to the CTDG evaluation setting. (3) CIR achieves the best AUC score across all datasets and shortcut ratios. Even at the highest shortcut ratio (0.6), CIR maintains strong performance, significantly outperforming other models, demonstrating superior generalization under distributional shifts. (4) CIR maintains low variance across datasets and shortcut ratios, indicating consistent performance. In contrast, CTDG models, particularly GraphMixer and TGN, exhibit higher variance at larger shortcut ratios, suggesting instability when shortcut dependencies are removed. TGAT shows moderate variance but still struggles with higher shift levels. Among DTDG models, Ada-DyGNN demonstrates lower variance than CTDG models, reflecting its robustness in link prediction, while EAGLE’s variance remains moderate, indicating some inconsistency in handling shifts.

In conclusion, the results demonstrate that CIR achieves SOTA performance in link prediction across varying levels of distribution shift. Unlike existing CTDG and DTDG models, which either suffer from severe performance degradation or exhibit low AUC and AP scores, CIR consistently identifies stable causal structures and maintains high predictive performance with low variance. These results highlight CIR’s strong generalization ability and robustness to spurious correlations in CTDGs.

a
b

Figure 3: Average running time per edge.. a — Mooc, b — Reddit

6.3 Efficiency (RQ2)↩︎

Figure 3 reports the average inference time per edge for each method. CIR demonstrates high efficiency, with average running times per edge of \(5.4\times 10^{-4}\) seconds on Reddit and \(5.8\times 10^{-4}\) seconds on MOOC. In contrast, TGAT and TGN are slower due to their more complex encoding networks, while DIDA is also slower because it must construct a confounder dictionary for each snapshot. GraphMixer is slightly more efficient than CIR, primarily because it does not output an explainable subgraph. Despite some differences in absolute running times between the Reddit and MOOC datasets, the relative performance across models is consistent, indicating that these efficiency measurements are reproducible across diverse dynamic graph scenarios.

6.4 Ablation Study (RQ3)↩︎

Table 3 depicts the ablation study by reporting the AP and AUC across datasets with a fixed shortcut ratio of 0.4. The results reveal that each component contributes significantly to the overall performance. Removing either the structural encoder or the temporal encoder leads to substantial performance drops, particularly on the WIKI and UCI datasets. Moreover, excluding the \(Y^C\) causes a marked decline in performance. In contrast, the removal of the \(Y^I\) has a more modest impact, with performance decreases ranging from about 2% to 8.9%. This suggests that while the ICM plays a supportive role in enhancing performance, the CCM is critical for capturing the essential patterns in the data. In summary, the full CIR model, which integrates all these components, consistently outperforms the ablated versions, highlighting the necessity of each module in achieving optimal performance across diverse datasets.

7 Conclusion↩︎

This paper addresses the challenge of developing invariant and self-interpretable GNNs for continuous-time dynamic graphs. By analyzing this problem from a causal effect perspective, we introduce the ICCM, a novel causal inference model meticulously designed to address both IID and OOD scenarios for CTDGs. Building upon the theoretical foundations of ICCM, we propose a novel deep learning architecture, which translates theoretically established causal models into a practical solution for dynamic graphs. Experiments show that CIR outperforms prior methods in link prediction, and robustness under OOD scenarios.

Acknowledgments↩︎

This work was supported by the National Natural Science Foundation of China (No.62472091, 62394333, 62572361)

References↩︎

[1]
H. Zhang, B. Wu, X. Yang, X. Yuan, X. Liu, and X. Yi, “Dynamic graph unlearning: A general and efficient post-processing method via gradient transformation,” in Proceedings of the ACM on web conference 2025, 2025, pp. 931–944.
[2]
N. M. Ahmed and L. Chen, “An efficient algorithm for link prediction in temporal uncertain social networks,” Information Sciences, vol. 331, pp. 120–136, 2016.
[3]
Y. Ma, V. Tresp, and E. A. Daxberger, “Embedding models for episodic knowledge graphs,” Journal of Web Semantics, vol. 59, p. 100490, 2019.
[4]
Y. Peng, C. Yang, Z. Fan, and C. Shi, “Data-centric prompt tuning for dynamic graphs,” in Proceedings of the 34th ACM international conference on information and knowledge management, 2025, pp. 2336–2345.
[5]
Q. Yuan et al., “Dynamic graph learning with static relations for credit risk assessment,” in Proceedings of the AAAI conference on artificial intelligence, 2025, vol. 39, pp. 13133–13141.
[6]
Y. Li, R. Yu, C. Shahabi, and Y. Liu, “Diffusion convolutional recurrent neural network: Data-driven traffic forecasting,” in International conference on learning representations, 2017.
[7]
S. De Winter, T. Decuypere, S. Mitrović, B. Baesens, and J. De Weerdt, “Combining temporal aspects of dynamic networks with Node2Vec for a more efficient dynamic link prediction,” in Advances in social networks analysis and mining, 2018.
[8]
J. Deng and Y. Shen, “Self-interpretable graph learning with sufficient and necessary explanations,” in Proceedings of the AAAI conference on artificial intelligence, 2024, vol. 38, pp. 11749–11756.
[9]
H. Li, C. Li, K. Feng, Y. Yuan, G. Wang, and H. Zha, DOI: 10.1109/TKDE.2024.3388453“Robust knowledge adaptation for dynamic graph neural networks,” IEEE Transactions on Knowledge and Data Engineering, vol. 36, no. 11, pp. 6920–6933, 2024.
[10]
E. Ranjan, S. Sanyal, and P. Talukdar, “Asap: Adaptive structure aware pooling for learning hierarchical graph representations,” in Proceedings of the AAAI conference on artificial intelligence, 2020, vol. 34, pp. 5470–5477.
[11]
S. Chang, Y. Zhang, M. Yu, and T. Jaakkola, “Invariant rationalization,” in International conference on machine learning, 2020, pp. 1448–1458.
[12]
G. Li et al., “Entity graph alignment and visual reasoning for multimodal fake news detection,” in Proceedings of the 33rd ACM international conference on multimedia, 2025, pp. 2486–2495.
[13]
Y. Sui, X. Wang, J. Wu, M. Lin, X. He, and T.-S. Chua, “Causal attention for interpretable and generalizable graph classification,” in Proceedings of the 28th ACM SIGKDD conference on knowledge discovery and data mining, 2022.
[14]
B. Wang, J. Li, H. Chang, K. Zhang, and F. Tsung, “Heterophilic graph neural networks optimization with causal message-passing,” in Proceedings of the eighteenth ACM international conference on web search and data mining, 2025, pp. 829–837.
[15]
S. Fan, X. Wang, Y. Mo, C. Shi, and J. Tang, “Debiasing graph neural networks via learning disentangled causal substructure,” Advances in Neural Information Processing Systems, vol. 35, pp. 24934–24946, 2022.
[16]
K. Xu et al., “Show, attend and tell: Neural image caption generation with visual attention,” in International conference on machine learning, 2015.
[17]
X. Qin, N. Sheikh, C. Lei, B. Reinwald, and G. Domeniconi, “SEIGN: A simple and efficient graph neural network for large dynamic graphs,” in IEEE international conference on data engineering, 2023.
[18]
Y. Li, Y. Shen, L. Chen, and M. Yuan, “Zebra: When temporal graph neural networks meet temporal personalized PageRank,” Proceedings of the VLDB Endowment, vol. 16, no. 6, pp. 1332–1345, 2023.
[19]
A. Sankar, Y. Wu, L. Gou, W. Zhang, and H. Yang, “Dysat: Deep neural representation learning on dynamic graphs via self-attention networks,” in The international conference on web search and data mining, 2020.
[20]
W. Yu, W. Cheng, C. C. Aggarwal, K. Zhang, H. Chen, and W. Wang, “Netwalk: A flexible deep embedding approach for anomaly detection in dynamic networks,” in Proceedings of the 24th ACM SIGKDD international conference on knowledge discovery & data mining, 2018, pp. 2672–2681.
[21]
S. Mahdavi, S. Khoshraftar, and A. An, “dynnode2vec: Scalable dynamic network embedding,” in IEEE international conference on big data, 2018.
[22]
D. Xu, C. Ruan, E. Korpeoglu, S. Kumar, and K. Achan, “Inductive representation learning on temporal graphs,” in International conference on learning representations, 2020.
[23]
R. Trivedi, M. Farajtabar, P. Biswal, and H. Zha, “Dyrep: Learning representations over dynamic graphs,” in International conference on learning representations, 2019.
[24]
K. Feng, C. Li, X. Zhang, and J. Zhou, “Towards open temporal graph neural networks,” in International conference on learning representations, 2023.
[25]
R. Yuan, Y. Tang, and W. Zhang, “A structure-aware invariant learning framework for node-level graph OOD generalization,” in Proceedings of the 31st ACM SIGKDD conference on knowledge discovery and data mining v. 1, 2025, pp. 1879–1890.
[26]
X. Ning, Y. Wang, K. Yu, J. Miao, F. Cao, and J. Liang, “Summary graph induced invariant learning for generalizable graph learning,” IEEE Transactions on Knowledge and Data Engineering, 2025.
[27]
H. Li, X. Wang, Z. Zhang, H. Chen, Z. Zhang, and W. Zhu, “Disentangled graph self-supervised learning for out-of-distribution generalization,” in Forty-first international conference on machine learning, 2024.
[28]
P. Li et al., “Causal-aware graph neural architecture search under distribution shifts,” in Proceedings of the 31st ACM SIGKDD conference on knowledge discovery and data mining v. 2, 2025, pp. 1458–1469.
[29]
Y.-X. Wu, X. Wang, A. Zhang, X. He, and T.-S. Chua, “Discovering invariant rationales for graph neural networks,” in International conference on learning representations, 2022.
[30]
Z. Zhang, X. Wang, Z. Zhang, H. Li, Z. Qin, and W. Zhu, “Dynamic graph neural networks under spatio-temporal distribution shift,” Advances in Neural Information Processing Systems, vol. 35, pp. 6074–6089, 2022.
[31]
H. Yuan et al., https://openreview.net/forum?id=n8JWIzYPRz“Environment-aware dynamic graph learning for out-of-distribution generalization,” in Thirty-seventh conference on neural information processing systems, 2023.
[32]
W. Cong et al., “Do we really need complicated model architectures for temporal networks?” in International conference on learning representations, 2023.
[33]
J. Pearl, M. Glymour, and N. P. Jewell, Causal inference in statistics: A primer. John Wiley & Sons, 2016.
[34]
I. Tolstikhin et al., “MLP-mixer: An all-MLP architecture for vision,” in Advances in neural information processing systems, 2021, vol. 34, pp. 24261–24272.
[35]
E. Rossi, B. Chamberlain, F. Frasca, D. Eynard, F. Monti, and M. Bronstein, “Temporal graph networks for deep learning on dynamic graphs,” in International conference on machine learning, 2020.

  1. Shanshan Feng is the corresponding author.↩︎

  2. http://snap.stanford.edu/jodie/wikipedia.csv↩︎

  3. http://snap.stanford.edu/jodie/reddit.csv↩︎

  4. http://snap.stanford.edu/jodie/mooc.csv↩︎

  5. https://zenodo.org/records/7213796#.Y1cO6y8r30o↩︎