---
title: 'CLDG: Contrastive Learning on Dynamic Graphs'
url: https://www.emergentmind.com/topics/cldg
type: topic
---

# CLDG: Contrastive Learning on Dynamic Graphs

Searching arXiv for the CLDG paper and closely related versions to ground the article in current metadata.
CLDG, short for **Contrastive Learning on Dynamic Graphs**, is an unsupervised framework for dynamic graph representation learning that uses **timespan views** of an evolving graph as contrastive positives under a **temporal translation invariance** assumption. Rather than constructing self-supervision through stochastic edge or feature perturbations, CLDG treats different contiguous time windows of the same graph as semantically meaningful views and learns node embeddings that remain consistent across them. In later formulations, the framework is extended to **CLDG++**, which augments local topology with graph-diffusion global context and supports anomaly detection by measuring cross-timespan consistency [2412.14451, 2605.27063].

## 1. Conceptual definition and problem setting

CLDG operates on dynamic graphs in either discrete-time or continuous-time form. In the continuous-time formulation, the graph is written as $G=(V,E,T)$, where $V$ is a fixed vertex set, $E\subseteq V\times V$ is the edge set, and $T:V\cup E\to\mathbb R^+$ assigns timestamps. An equivalent view at time $t$ is $G_t=(V,E_t,X_t)$, where $E_t$ denotes the edges in a time window around $t$ and $X_t\in\mathbb R^{|V|\times d_0}$ are the node features at that time [2412.14451].

The framework is motivated by a limitation of standard graph contrastive learning on dynamic data. Existing methods typically maximize mutual information between augmented views of a static graph, but in dynamic graphs the augmentation process can alter semantics and labels, which the CLDG paper identifies as a source of degraded downstream performance. CLDG therefore replaces synthetic augmentations with temporally grounded views sampled directly from the graph’s own evolution [2412.14451].

The resulting task formulation is unsupervised pretraining followed by downstream evaluation. In the node-classification protocol reported for CLDG, embeddings are first learned without labels, then frozen, and a linear classifier is trained on the train split only; final Accuracy and Weighted-F1 are reported on the test split [2412.14451]. In the later formulation, the same learned representations are also used for dynamic graph anomaly detection by quantifying inconsistency across timespans [2605.27063].

## 2. Temporal translation invariance

The central inductive bias of CLDG is **temporal translation invariance** (TTI). The underlying empirical claim is that, in many real-world dynamic graphs, the semantic label or class of a node tends to remain stable as the observation window shifts forward or backward in time. The detailed exposition states that, if one trains separate encoders on different snapshots, the fraction of nodes whose predicted label changes from one snapshot to the next is very low, often below $20\%$ [2605.27063].

In CLDG, TTI is expressed at two levels. The **local-level TTI** condition states that for any node $v$ and two sampled timespans $T_p,T_k$, the projected embeddings of the same node should be close, so $\|z_v^{T_p}-z_v^{T_k}\|$ is small. The **global-level TTI** condition states that the embedding of $v$ in one timespan should also be close to a pooled representation of $v$’s neighborhood in another timespan, so $\|z_v^{T_p}-z_{N_v}^{T_k}\|$ is small [2412.14451].

This inductive bias gives CLDG its basic contrastive semantics: different times are treated as naturally occurring views of the same latent entity. The later formulation makes the same point in mutual-information language, describing the method as maximizing the mutual information between representations of the same node at different times without requiring manual data augmentation [2605.27063]. A plausible implication is that CLDG is most appropriate when node identity, role, or community membership evolves smoothly rather than discontinuously.

## 3. Timespan-view sampling and contrastive objectives

The first operational component of CLDG is a **timespan view sampling layer**. Let $\Delta t=\max T-\min T$ denote the total temporal span of the graph. Two hyperparameters are used: $s\in\mathbb N_{>0}$ controls the length of each sampled window, which is $\Delta t/s$, and $v\in\mathbb N_{>0}$ controls the number of windows sampled per minibatch. For sampled centers $\{T_1,\dots,T_v\}$, each graph view is constructed as a contiguous temporal subgraph containing exactly the edges and node features occurring in the interval $[T_i-\Delta t/(2s),\,T_i+\Delta t/(2s)]$ [2412.14451].

Four sampling strategies are specified. **Sequential** uses non-overlapping windows whose centers differ by integer multiples of $\Delta t/s$. **High-overlap** enforces $75\%$ overlap, with adjacent centers separated by $\Delta t/(4s)$. **Low-overlap** enforces $25\%$ overlap, with adjacent centers separated by $3\Delta t/(4s)$. **Random** samples centers uniformly in $[\min T+\Delta t/(2s),\,\max T-\Delta t/(2s)]$ [2412.14451].

Once views are sampled, each snapshot is encoded independently. In the standard formulation, if $z_i^{\tau_q}$ denotes the projected representation of node $i$ in view $q$, then the local contrastive term between views $q$ and $k$ is

$$
\mathrm{ctr}(z_i^{\tau_q},z_i^{\tau_k})
=
-\log
\frac{\exp(z_i^{\tau_q}\cdot z_i^{\tau_k}/\tau)}
{\sum_{j=1}^n \exp(z_i^{\tau_q}\cdot z_j^{\tau_k}/\tau)},
$$

where $\tau>0$ is a temperature. The total CLDG loss sums this term over all nodes and view pairs [2605.27063].

The 2024 formulation presents the same idea as two parallel InfoNCE objectives. For node-level invariance,

$$
L_i^{\mathrm{node}}(p,k)
=
-\log
\frac{\exp(z_i^{T_p}\cdot z_i^{T_k}/\tau)}
{\sum_{j=1}^N \exp(z_i^{T_p}\cdot z_j^{T_k}/\tau)}.
$$

For graph-level invariance, if $z_{N_i}^{T_k}$ is a pooled neighbor embedding, then

$$
L_i^{\mathrm{graph}}(p,k)
=
-\log
\frac{\exp(z_i^{T_p}\cdot z_{N_i}^{T_k}/\tau)}
{\sum_{j=1}^N \exp(z_i^{T_p}\cdot z_{N_j}^{T_k}/\tau)}.
$$

Training may use either local TTI, global TTI, or a weighted sum such as $L_{\mathrm{total}}=L^{\mathrm{node}}+\lambda L^{\mathrm{graph}}$ [2412.14451].

## 4. CLDG++, multi-scale contrasts, and anomaly detection

A subsequent development introduces **CLDG++**, which supplements the local adjacency view with a diffusion-based global view. For each timespan $i$, CLDG++ computes a similarity matrix $S_i$ using either **PPR diffusion**

$$
S^{\mathrm{PPR}}=\alpha\cdot \bigl(I-(1-\alpha)D^{-1/2}AD^{-1/2}\bigr)^{-1},
$$

or the **heat-kernel diffusion**

$$
S^{\mathrm{heat}}=\exp(t\cdot A\cdot D^{-1}-t\cdot I),
$$

where $D$ is the degree matrix and $\alpha\in(0,1)$ and $t>0$ are hyperparameters [2605.27063].

CLDG++ then applies two encoders with separate weights, producing local and global features

$$
H_i^{l}=f_l(A_i,X_i), \qquad H_i^{g}=f_g(S_i,X_i),
$$

which are projected into a contrastive space. The extension introduces a **multi-scale contrastive learning objective** composed of **local-local**, **global-global**, and **local-global** terms. The paper gives the practical form

$$
L_{\mathrm{CLDG++}}
=
\sum_{i=1}^n \sum_{q\neq k}
\Bigl[
\mathrm{ctr}(z_{i,l}^{\tau_q},z_{i,l}^{\tau_k})
+
\mathrm{ctr}(z_{i,g}^{\tau_q},z_{i,g}^{\tau_k})
+
\mathrm{ctr}(z_{i,l}^{\tau_q},z_{i,g}^{\tau_q})
+
\mathrm{ctr}(z_{i,l}^{\tau_k},z_{i,g}^{\tau_k})
\Bigr].
$$

This extension is presented as a way to capture multi-scale topology and obtain richer embeddings [2605.27063].

The same cross-timespan consistency mechanism is used for anomaly detection. After training, one samples $v$ sequential views, computes projected node embeddings $\{z_{i,l}^{\tau_1},\dots,z_{i,l}^{\tau_v}\}$, and measures pairwise cosine distance

$$
D(q,k)=1-\frac{q\cdot k}{\|q\|\|k\|}.
$$

For node $v_i$, the mean distance and its standard deviation are

$$
\bar S_i
=
\frac{1}{v(v-1)}\sum_{q\neq k} D(z_{i,l}^{\tau_q},z_{i,l}^{\tau_k}),
$$

and

$$
\sigma_i
=
\sqrt{
\frac{1}{v(v-1)}
\sum_{q\neq k}
\bigl[D(z_{i,l}^{\tau_q},z_{i,l}^{\tau_k})-\bar S_i\bigr]^2
}.
$$

The anomaly score is then

$$
S(v_i)=\bar S_i+\sigma_i.
$$

Nodes with large scores are flagged as anomalous. The paper states that no threshold is trained; one ranks nodes or evaluates by ROC-AUC [2605.27063].

## 5. Architectures, complexity, and efficiency profile

The default encoder in CLDG is a **2-layer GCN** with

$$
H^{(l+1)}=\sigma\bigl(\tilde D^{-1/2}\tilde A\tilde D^{-1/2}H^{(l)}W^{(l)}\bigr),
\qquad
\tilde A=A+I,
\qquad
H^{(0)}=X.
$$

The framework is described as **plug-and-play**: GAT and GraphSAGE can also be used. The readout is average, sum, or max over neighbors, and the projection head is a **2-layer MLP + LeakyReLU + $\ell_2$ normalization** [2412.14451].

A recurrent theme in the CLDG literature is that the method avoids explicit temporal sequence modeling. The later exposition states that CLDG and CLDG++ rely only on graph convolutions and use **no RNNs** and **no self-attention**, which makes them lighter than LSTM-, GRU-, or Transformer-based dynamic-graph models. With $N=|V|$, $M=|E|$, $L$ the number of GCN layers, and $d$ the hidden dimension, the time complexity per epoch is

$$
O(L\cdot N\cdot d^2 + L\cdot M\cdot d),
$$

and the space complexity in trainable parameters is

$$
O(L\cdot d^2).
$$

The same source reports that, on seven real-world dynamic graphs with up to $900\text{K}$ nodes and $2.5\text{M}$ edges, CLDG trains in minutes with a few $10$’s MB of parameters, whereas sequence-based methods can run out of GPU memory or take orders of magnitude longer [2605.27063].

The 2024 CLDG paper quantifies this efficiency directly. Across seven datasets, the total parameter count of CLDG is approximately **0.05 M**, compared with **8–156 M** for CAW, **7–155 M** for TGAT, **0.10 M** for DySAT, and **2–42 M** for MNCI. It reports that, compared with existing dynamic-graph methods, the number of model parameters and training time are reduced by an average of **2,001.86 times** and **130.31 times** on seven datasets, respectively [2412.14451].

## 6. Empirical results, scope, and terminological distinction

The principal evaluation protocol for CLDG uses seven datasets—**DBLP, BitcoinOTC, TAX, BITotc, BITalpha, TAX51, Reddit**—split **1:1:8 into train/validation/test on nodes**. Training is unsupervised with Adam; the encoder and projection head use learning rate $4\times 10^{-3}$ and weight decay $5\times 10^{-4}$, while the linear classifier uses learning rate $1\times 10^{-2}$ and weight decay $1\times 10^{-4}$. Other settings include batch size $N=256$, hidden dimension $128$, output dimension $64$, up to $200$ epochs, temperature $\tau$ tuned in $\{0.1,\dots,1.0\}$, and timespan hyperparameters often set to $s=4$, $v=2$ [2412.14451].

On node classification, **CLDG\_node** is reported to achieve **state-of-the-art among all unsupervised methods on 11 out of 14 metrics**, and to outperform some supervised baselines on BitcoinOTC, BITotc, BITalpha, and Reddit. On average, **CLDG\_node** beats the best prior unsupervised GraphSAGE by **+1.47% in Accuracy** [2412.14451]. The later formulation states more generally that CLDG and CLDG++ both exhibit desirable performance on downstream tasks including node classification and dynamic graph anomaly detection [2605.27063].

Ablation results further clarify the framework’s operating regime. **Sequential** and **Random** sampling yield the best performance, while **High-overlap (75%)** is worst because the task becomes too easy and generalization degrades. Increasing the number of views from $v=2$ to $v=5$ gives diminishing but positive gains of about **0.4–0.8% average**, and replacing GCN with GAT or GraphSAGE produces results within **0.5%**, which the paper interprets as evidence of encoder-agnostic behavior [2412.14451].

The acronym requires one terminological qualification. In software engineering, **ClDG** can also denote the **Class Dependence Graph**, a source-level representation of control and data dependencies within a class, augmented in one bug-localization method by an object-state annotation function $S:V_C\to\Sigma$. That usage is unrelated to dynamic graph contrastive learning and belongs to a different research lineage centered on program dependence analysis and fault localization [1108.4094].

Taken in its graph-learning sense, CLDG denotes a family of methods built on a simple principle: dynamic graphs provide their own temporally grounded positive pairs. The combination of timespan sampling, TTI-based contrastive learning, and lightweight graph encoders yields an unsupervised representation framework whose empirical profile emphasizes both competitive downstream performance and substantial reductions in parameters and training time [2412.14451].

Source: https://www.emergentmind.com/topics/cldg