Leveraging Diffusion Model as Pseudo-Anomalous Graph Generator for Graph-Level Anomaly Detection

Jinyu Cai, Yunhe Zhang, Fusheng Liu, See-Kiong NgICML 2025

TL;DR

AGDiff (Anomalous Graph Diffusion) is a novel framework that solves the "data scarcity" problem in graph-level anomaly detection by using a latent diffusion model to generate realistic "pseudo-anomalous" graphs. By training a classifier to distinguish these subtle, synthetic deviations from normal data, AGDiff achieves state-of-the-art performance on both moderate and large-scale imbalanced datasets without requiring any real-world anomaly labels.

What Problem Does This Paper Address?

Graph-Level Anomaly Detection (GLAD) is the task of identifying entire graphs (e.g., a specific molecule or a social network snapshot) that deviate from a "normal" distribution. This is notoriously difficult because:

  1. Data Imbalance: In the real world, anomalies are rare. Most training sets contain only normal data or a tiny fraction of anomalies.
  2. Subtlety: Many anomalies aren't obvious outliers; they might have subtle structural or attribute differences that "reconstruction-based" models (which look for high error) often miss.
  3. Complexity: Modeling the global topology and geometric properties of a graph is far more complex than identifying a single anomalous node or edge.

Existing unsupervised methods focus on modeling "normality," but without seeing examples of "abnormality," they struggle to define a sharp decision boundary. AGDiff bridges this gap by generating its own "training enemies"—pseudo-anomalies that look almost normal but are just "off" enough to teach the model where the boundary lies.

Methods

The AGDiff framework operates in three distinct phases, as illustrated in the architecture diagram:

The AGDiff framework: (1) Pre-training a graph encoder/decoder, (2) Generating pseudo-anomalies via latent diffusion, and (3) Jointly training an anomaly detector.
  1. Modeling Normality (Pre-training): The authors first train a Variational Graph Autoencoder (VGAE) to map graphs into a continuous, well-structured latent space. This ensures that the latent embeddings capture the essential "normality" of the training data.
  2. Generating Pseudo-Anomalies (Latent Diffusion): Instead of adding random noise to the raw graph (which would create unrealistic "garbage" graphs), AGDiff performs diffusion in the latent space.
  3. Forward Process: Gradually adds Gaussian noise to the latent representation.
  4. Conditional Reverse Process: A denoising network attempts to recover the graph embedding, but it is influenced by a Perturbation Condition. This learnable condition ensures the generated embeddings are "pseudo-anomalous"—they retain the core structure of the original graph but incorporate controlled, subtle deviations.
  5. Joint Training: A GIN-based (Graph Isomorphism Network) classifier is trained to distinguish between the original normal graphs and the generated pseudo-anomalies. Crucially, the diffusion model and the classifier are optimized together. As the classifier gets better at spotting anomalies, the diffusion model learns to generate more "informative" (harder) pseudo-anomalies to challenge it.

Datasets

The authors evaluated AGDiff on two categories of benchmarks:

  • Moderate-Scale Datasets: MUTAG, DD, COX2, and ER_MD. These are primarily molecular and bioinformatics graphs.
  • Large-Scale Imbalanced Datasets: SW-620, MOLT-4, PC-3, and MCF-7. These represent chemical compounds tested for anti-cancer activity, where the "active" compounds (the anomalies) are a very small fraction of the total samples.

Key Insights and Ideas

  • The "Subtle Deviation" Philosophy: The authors argue that generating "hard" examples—graphs that are very close to the normal distribution—is more effective for training than generating obvious outliers. By retaining core structures while subtly altering connectivity, the model learns a sharper boundary.
  • Bypassing the "Reconstruction Flip": Traditional models assume anomalies always have higher reconstruction errors. Recent research shows this isn't always true. By using a discriminative classifier trained on pseudo-anomalies, AGDiff avoids relying on this flawed assumption.
  • Latent vs. Raw Space: Performing diffusion in the latent space allows for "fine-grained control" over deviations. It ensures that the generated graphs remain valid and structurally coherent while still being anomalous.
  • Joint Refinement: The iterative feedback loop between the generator and the detector leads to a more robust decision boundary. The generator essentially acts as an automated "red team," finding the weaknesses in the detector's current logic.

Key Results

AGDiff consistently outperformed both classical kernel methods and modern GNN-based baselines.

  • Superior Accuracy: On the DD dataset, AGDiff achieved an AUC of 88.23%, significantly higher than the next best unsupervised baseline (OCGTL at 77.52%).
  • Beating Semi-Supervised Models: Remarkably, AGDiff (which is unsupervised) often outperformed iGAD, a semi-supervised method that actually has access to some real anomaly labels. For example, on the PC-3 dataset, AGDiff reached 94.32% AUC compared to iGAD's 86.04%.
  • Better Separation: Score distribution analysis demonstrates that AGDiff achieves clear separation between normal and anomalous graphs, effectively isolating anomalies from the normal data distribution.
Frequency density histogram showing the clear separation in anomaly scores between normal and anomalous data.

Limitations and Future Work

The authors identify two main limitations:

  1. Representative Normality: The model assumes the training set is a sufficiently representative distribution of "normal" graphs. If the environment is highly heterogeneous or shifting, the model might struggle.
  2. Static Graphs: Currently, AGDiff is designed for static graphs. It does not yet account for dynamic or temporal graph settings where anomalies might be defined by changes over time.

Future work includes exploring more flexible noise scheduling in the diffusion process and investigating how to apply this framework to heterogeneous or dynamic graph environments.

Summary updated

BibTeX
@inproceedings{cai2025leveraging,
  author = {Jinyu Cai and Yunhe Zhang and Fusheng Liu and See-Kiong Ng},
  title = {{Leveraging Diffusion Model as Pseudo-Anomalous Graph Generator for Graph-Level Anomaly Detection}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=Zm2M92TZyO},
}
Figure