CoDCL: Counterfactual Data Augmentation Contrastive Learning for Continuous-Time Dynamic Network Link Prediction

Hantong Feng, Yonggang Wu, Duxin Chen, Wenwu Yu

Abstract: The rapid growth and continuous structural evolution of dynamic networks make effective predictions increasingly challenging. To enable prediction models to adapt to complex temporal environments, they need to be robust to emerging structural changes. We propose a dynamic network learning framework CoDCL, which combines counterfactual data augmentation with contrastive learning to address this deficiency. Furthermore, we devise a comprehensive strategy to generate high-quality counterfactual data, combining a dynamic treatments design with efficient structural neighborhood exploration to quantify the temporal changes in interaction patterns. Crucially, the entire CoDCL is designed as a plug-and-play universal module that can be seamlessly integrated into various existing temporal graph models without requiring architectural modifications. Extensive experiments on multiple real-world datasets demonstrate that CoDCL significantly gains state-of-the-art baseline models in the field of dynamic networks, confirming the critical role of integrating counterfactual data augmentation into dynamic representation learning.

Introduction

Continuous-time dynamic networks—such as social networks, financial transaction systems, and mobility tracking—are in a state of constant evolution. Predicting future links or interactions within these networks requires models to capture intricate spatiotemporal patterns. However, most existing dynamic graph learning methods operate as "black boxes," relying on inductive generalization from historical data. While effective at identifying statistical co-occurrences, these models often fail to distinguish true causal relationships from spurious correlations. As network structures shift over time, historical patterns may lose predictive value, leading to performance degradation.

Problem Statement

The core challenge addressed by this work is the embedding of causal reasoning into dynamic network representation learning. By moving beyond superficial statistical correlations, the goal is to develop models robust to emerging structural changes and capable of identifying the underlying drivers of link formation rather than coincidental temporal associations.

Methodology

The proposed framework, CoDCL (Counterfactual Data Augmentation Contrastive Learning), is a universal, plug-and-play module compatible with various dynamic graph architectures, such as DyGFormer, TGAT, or CorDGT. The framework operates through three primary stages:

  1. Dynamic Treatment Variables: Utilizing causal inference principles, a "treatment" is defined based on the temporal structural proximity between nodes (e.g., shared neighbors within a time window). A global threshold binarizes this into high vs. low interaction frequency treatments.
  2. Counterfactual Link Completion: For each observed factual interaction, the model performs a $k$-hop breadth-first search to identify a "counterfactual pair"—nodes with similar structural features but the opposite treatment (e.g., similar neighborhoods but rare interaction). Research indicates that searching just 1 or 2 hops away ($k_{max} \le 2$) is usually sufficient.
  3. Counterfactual Contrastive Learning: An InfoNCE-based contrastive loss is employed to align factual link representations with positive samples while distancing them from negative samples and generated counterfactual pairs.
The CoDCL framework architecture, illustrating the integration of counterfactual link completion with a dynamic backbone for contrastive learning.

Experiments and Results

CoDCL was evaluated across eight diverse real-world datasets, including social networks (Wikipedia, Reddit), online education (MOOC), user behavior (LastFM), communication (Enron), mobility (UCI), and political interaction (CanParl).

The framework demonstrated consistent performance improvements in Average Precision (AP) across all baselines, with gains ranging from 0.09% on Reddit to 1.10% on CanParl. Notably, CoDCL exhibited strong inductive generalization, maintaining robustness on entirely unseen nodes. Ablation studies highlighted the necessity of the counterfactual learning component; its removal led to the most significant performance drops, particularly on the UCI and CanParl datasets.

Ablation study results across multiple datasets, demonstrating the significant impact of counterfactual learning (CL) on model performance.

Conclusion

CoDCL introduces a novel approach to dynamic link prediction by integrating causal reasoning via counterfactual data augmentation. Its plug-and-play nature allows for seamless integration into existing state-of-the-art models without architectural changes. While the model shows sensitivity to the treatment threshold and introduces some computational overhead during data preparation, its ability to learn robust, generalizable features marks a significant advancement in dynamic network analysis.

Summary updated

BibTeX
@misc{feng2026codcl,
  author = {Hantong Feng and Yonggang Wu and Duxin Chen and Wenwu Yu},
  title = {{CoDCL: Counterfactual Data Augmentation Contrastive Learning for Continuous-Time Dynamic Network Link Prediction}},
  year = {2026},
  eprint = {2601.22427},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2601.22427},
}
Figure