SubgraphXAI is a research prototype exploring graph-level explainability for graph neural networks (GNNs), with a focus on extracting, analysing, and reusing explanation subgraphs as first-class artefacts.
The project investigates whether explanation subgraphs can act as compact, semantically meaningful representations for downstream tasks such as graph generation, evaluation, and robustness analysis.
The current implementation targets homogeneous, undirected graphs and uses a toy benchmark dataset (PROTEINS) to validate the end-to-end pipeline before extending to real-world program analysis graphs (e.g. control-flow graphs).
Part of my PhD studies, paused from 2023
Graph explainability methods often stop at visualisation.
SubgraphXAI treats explanation subgraphs as reusable signal, asking:
- Can explanation subgraphs replace full graphs without significant performance loss?
- Can they serve as inputs to graph generators or evaluators?
- Do they expose structure that is hidden in full-graph representations?
SubgraphXAI currently implements the following pipeline:
- Graph Classification
- Train a GNN-based graph classification model.
- Graph-Level Explainability
- Extract explanation subgraphs using
GNNExplainer.
- Extract explanation subgraphs using
- Explanation Subgraph Analysis
- Store, visualise, and reuse explanation subgraphs.
- (Planned) Graph Generation
- Generate candidate graphs from explanation subgraphs.
- Evaluate generated graphs based on prediction confidence.
- Graph classification using a simple GCN with pooling
- Graph-level explanations using GNNExplainer
- Extraction of node feature and edge importance masks
- Visualisation of explanation subgraphs overlaid on original graphs
- Modular design for modelling, evaluation, and explainability
- PROTEINS dataset from the TUDataset collection (via PyTorch Geometric)
- Used as a toy dataset for rapid prototyping and validation
The current pipeline trains the following components:
- Graph Classification Model
- Simple GCN architecture
- Graph-level pooling
- Graph Explanation Model
GNNExplainerwith log-probability objective- Produces node feature and edge importance masks
- Graph Generator (Planned)
- Generator architectures under investigation
- Candidate methods listed in
generators.py
subgraphxai/
│
├── main.py # Entry point for training and explanation
├── modelling/ # GNN model definitions
├── evaluation/ # Training, testing, and explanation utilities
├── utils/ # Dataset statistics and helper functions
├── setup.py # pip dependencies
└── README.md
GNNExplaineris applied at the graph level- Explanation outputs include:
- Node feature importance masks
- Edge importance masks
- Explanation subgraphs are:
- Thresholded by influence
- Visualised alongside original graphs
- Stored for future reuse
- Graph classification with PyTorch Geometric (toy dataset)
- Graph-level explanations with GNNExplainer
- Explanation subgraph visualisation
- Store explanation subgraphs for efficient dataloading
- Implement graph generators using explanation subgraphs as input
- Evaluate generated graphs using prediction confidence
- Integrate Devign source code (epicosy)
- Parse and adapt Devign data (see epicosy/devign Issue #7)
- Adapt pipeline to CFG-only graphs
- Test pretrained Devign models and resolve compatibility issues
- Adapt GNNExplainer for Devign
- How does model performance change when using explanation subgraphs instead of full graphs?
- Do explanation subgraphs preserve class-discriminative structure?
- Can explanation subgraphs act as compact inputs for graph generation?
- How transferable are explanation methods from toy datasets to real-world program graphs?
- SubgraphXAI is an experimental research prototype.
- The code prioritises clarity and experimentation over optimisation.
- The scope is intentionally limited to homogeneous graphs before extending to heterogeneous settings.