A Generalizable Anomaly Detection Method in Dynamic Graphs

Xiao Yang, Xuejiao Zhao, Zhiqi Shen

Presented at AAAI-25, GeneralDyG is a framework designed to overcome a persistent challenge in graph machine learning: creating anomaly detection models that generalize across diverse datasets without extensive retraining or manual tuning. By integrating temporal ego-graph sampling with a structure-aware Transformer, GeneralDyG provides a robust solution for identifying fraud, intrusions, and system failures in evolving networks.

The Challenge of Generalizability

Dynamic graphs—where nodes and edges change over time—are foundational to Bitcoin transaction networks, industrial sensor arrays, and social platforms. Detecting anomalies in these systems is difficult because "normal" behavior is constantly shifting. Most current deep learning models are "brittle"; a model optimized for financial fraud often fails when applied to industrial sensor data. This lack of generalizability typically stems from three issues:

  1. Inadequate encoding of structural information when raw attributes are missing.
  2. Difficulty balancing local neighborhood changes with global network trends.
  3. High computational costs for real-time, large-scale graph processing.

Methodology: The GeneralDyG Pipeline

GeneralDyG addresses these gaps through a three-stage architecture:

  1. Temporal Ego-Graph Sampling: Instead of processing the entire graph, the model samples $k$-hop "ego-graphs" around specific events. To help the model understand neighborhood hierarchy, the authors use special tokens (e.g., <|KHS|>) to mark boundaries between different hops, similar to hierarchical tokenization in NLP.
  2. TensGNN (The Extractor): The Temporal Edge-Node Based Structure Extractor (TensGNN) alternates its perspective between nodes and edges in every layer. This ensures that structural information from both entities is fused into a shared feature space, preventing the loss of critical topology data.
  3. Temporal-Aware Transformer: The data then enters a Transformer where the original event features serve as the "Value" (V), while the structural features from TensGNN define the "Query" (Q) and "Key" (K). This allows the attention mechanism to prioritize events based on their structural importance without distorting the raw data.
The GeneralDyG framework architecture, illustrating the three-stage pipeline from sampling to scoring.

Experimental Evaluation

The model was evaluated on four diverse, real-world benchmarks covering both edge-level and node-level tasks:

  • Edge-Level (Trust Networks): Bitcoin-Alpha and Bitcoin-OTC, focusing on fraudulent interactions.
  • Node-Level (Cyber-Physical Systems): SWaT (Secure Water Treatment) and WADI (Water Distribution), focusing on sensor/actuator anomalies.

Key Results and Insights

GeneralDyG demonstrated superior performance and stability across all tested scenarios. On the Bitcoin-Alpha dataset (1% anomaly setting), it achieved an Average Precision (AP) of 24.00, representing a nearly 20% improvement over the previous state-of-the-art baseline (SAD).

Performance comparison on Bitcoin-Alpha and Bitcoin-OTC datasets across different anomaly proportions.

Beyond raw metrics, the framework's most striking feature is its Generalizable Analysis. While specialized baselines saw performance plummet when moved from edge-level to node-level tasks, GeneralDyG maintained high performance across both. This suggests the model is capturing fundamental structural patterns rather than just memorizing dataset-specific quirks.

Conclusion and Future Directions

GeneralDyG offers a significant step toward "one-size-fits-most" anomaly detection in dynamic graphs. By using sampled ego-graphs, it significantly reduces the computational overhead typically associated with graph Transformers.

Future work will focus on improving interpretability—crucial for security analysts who need to understand why an event was flagged—and refining hyperparameter sensitivity, particularly regarding the optimal number of GNN layers and hops for different network scales.

Summary updated

BibTeX
@inproceedings{yang2025generalizable,
  author = {Xiao Yang and Xuejiao Zhao and Zhiqi Shen},
  title = {{A Generalizable Anomaly Detection Method in Dynamic Graphs}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i20.35508},
}
Figure