CurvGAD: Leveraging Curvature for Enhanced Graph Anomaly Detection
July 23, 2025 Β· View on GitHub
This is the official implementation of CurvGAD: Leveraging Curvature for Enhanced Graph Anomaly Detection accepted at ICML 2025.
π Abstract
Does the intrinsic curvature of complex networks hold the key to unveiling graph anomalies that conventional approaches overlook? Reconstruction-based graph anomaly detection (GAD) methods overlook such geometric outliers, focusing only on structural and attribute-level anomalies. To this end, we propose CurvGAD - a mixed-curvature graph autoencoder that introduces the notion of curvature-based geometric anomalies.
CurvGAD introduces two parallel pipelines for enhanced anomaly interpretability:
- Curvature-equivariant geometry reconstruction: Focuses exclusively on reconstructing the edge curvatures using a mixed-curvature, Riemannian encoder and Gaussian kernel-based decoder
- Curvature-invariant structure and attribute reconstruction: Decouples structural and attribute anomalies from geometric irregularities by regularizing graph curvature under discrete Ollivier-Ricci flow
By leveraging curvature, CurvGAD refines the existing anomaly classifications and identifies new curvature-driven anomalies. Extensive experimentation over 10 real-world datasets (both homophilic and heterophilic) demonstrates an improvement of up to 6.5% over state-of-the-art GAD methods.
ποΈ Repository Structure
curvgad-codebase/
βββ preprocessing/ # Curvature computation modules
β βββ compute_curvature.py # Main curvature computation script
β βββ ollivier_ricci_flow.py # Ollivier-Ricci flow implementation
β βββ preprocess_external_datasets.py # Dataset preprocessing
βββ models/ # Model implementations
β βββ curvgad_detector.py # Main CurvGAD detector
β βββ curvgad_gnn.py # CurvGAD GNN architecture
β βββ detector.py # Base detector classes
β βββ gnn.py # GNN implementations
β βββ attention.py # Attention mechanisms
β βββ manifold_cheb_conv.py # Manifold Chebyshev convolution
β βββ mobius_linear.py # MΓΆbius linear transformations
βββ datasets/ # Dataset storage
βββ curvature_data/ # Precomputed curvature matrices
βββ results/ # Experimental results
βββ plots/ # Generated plots and visualizations
βββ runs/ # Training logs and outputs
βββ benchmark.py # Main benchmarking script
βββ utils.py # Utility functions
βββ job.sh # SLURM job submission script
βββ requirements.txt # Python dependencies
βββ README.md # This file
π Installation
Prerequisites
- Python 3.8+
- CUDA-compatible GPU (recommended)
Setup Environment
- Clone the repository:
git clone https://github.com/your-username/curvgad-codebase.git
cd curvgad-codebase
- Create a virtual environment:
python -m venv curvgad_env
source curvgad_env/bin/activate # On Windows: curvgad_env\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Key Dependencies
- PyTorch: Deep learning framework
- DGL: Deep Graph Library for graph neural networks
- PyTorch Geometric: Graph neural network library
- Geoopt: Riemannian optimization library
- GraphRicciCurvature: Ricci curvature computation
- PyGOD: Graph outlier detection library
π Datasets
The repository supports multiple graph datasets including:
- Citation Networks: Cora, CiteSeer, PubMed
- Social Networks: Actor, Chameleon, Squirrel
- Web Networks: Texas, Cornell, Wisconsin
- Fraud Detection: Amazon, Yelp, Reddit
- Financial Networks: TFinance, Elliptic
Datasets are automatically downloaded and preprocessed when first used.
π§ Usage
Step 1: Precompute Curvature
Before running the main model, you need to compute the Ollivier-Ricci curvature for your datasets:
cd preprocessing
python compute_curvature.py --datasets cora citeseer pubmed --use_accelerated --save_matrix
Arguments:
--datasets: List of datasets to compute curvature for--use_accelerated: Use fast approximation method (recommended for large graphs)--compare_both: Compare exact vs. accelerated methods--save_matrix: Save curvature matrices for later use
Step 2: Run CurvGAD
Execute the main benchmarking script:
python benchmark.py --models CurvGAD --datasets cora --trials 10 --use_autoencoder --manifold_config H32S32E32 --optimizer riemannian_adam --lr 0.01 --K 7
Key Arguments:
--models: Model to use (CurvGAD or baseline methods)--datasets: Datasets to evaluate on--trials: Number of experimental trials--use_autoencoder: Enable autoencoder with curvature reconstruction--manifold_config: Manifold configuration (e.g., H32S32E32 for 32-dim hyperbolic, spherical, and Euclidean)--optimizer: Optimizer type (adam or riemannian_adam)--lr: Learning rate--K: Number of Chebyshev polynomial filters
Step 3: Analyze Results
Results are automatically saved in the results/ directory as Excel files. You can analyze the performance metrics including:
- AUC-ROC scores
- Average Precision (AP)
- Training time
- Memory usage
π Citation
If you use this code in your research, please cite our paper:
@misc{grover2025curvgadleveragingcurvatureenhanced,
title={CurvGAD: Leveraging Curvature for Enhanced Graph Anomaly Detection},
author={Karish Grover and Geoffrey J. Gordon and Christos Faloutsos},
year={2025},
eprint={2502.08605},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2502.08605},
}
π€ Contributing
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
π Contact
For questions or issues, please:
- Open an issue on GitHub
- Contact: karish@cs.cmu.edu