GSCbench / README.md
ush3r's picture
Update README.md
19e81b7 verified
|
Raw History Blame Contribute Delete
8.77 kB
---
pretty_name: GSCBench
size_categories:
- 1M<n<10M
tags:
- graph
- graph-edit-distance
- graph-matching
- benchmark
- cross-dataset-generalization
---
# GSCBench
GSCBench provides exact graph edit distance (GED) supervision for studying
in-collection, cross-collection, zero-shot and few-shot graph similarity models.
The GSCBench benchmark data comprise **11 collections, 5,523 graphs and
1,903,452 exact graph pairs**. The repository additionally includes a
version of PyG LINUX with isomorphic graphs removed (**89 graphs and 3,916
pairs**), used as auxiliary data for model pretraining.
## Citation
If you use GSCBench in your research, please cite our paper:
**[Revisiting the Generalization of Neural Graph Edit Distance Models](https://arxiv.org/abs/2610.04644)**.
```bibtex
@article{liu2026revisiting,
title={Revisiting the Generalization of Neural Graph Edit Distance Models},
author={Liu, Zhouyang and Liu, Ning and Chen, Yixin and He, Jiezhong and Li, Dongsheng},
journal={arXiv preprint arXiv:2610.04644},
year={2026},
url={https://arxiv.org/abs/2610.04644}
}
```
## Benchmark collections
| Collection | Graphs | Exact pairs |
| -------------- | -----: | ----------: |
| tu_AIDS | 1,488 | 1,106,325 |
| tu_BZR | 404 | 37,781 |
| tu_COX2 | 465 | 78,100 |
| tu_DHFR | 719 | 124,714 |
| tu_PTC_MR | 328 | 52,706 |
| tu_MUTAG | 175 | 15,220 |
| tu_NCI1 | 992 | 379,032 |
| tu_PROTEINS | 364 | 64,010 |
| tu_ENZYMES | 117 | 6,286 |
| tu_IMDB-BINARY | 280 | 22,703 |
| ogb_ogbg-code2 | 191 | 16,575 |
The `tu_` prefix identifies TU collections, and `ogb_ogbg-code2` identifies
the OGB code2 collection.
### Auxiliary pretraining data
| Collection | Graphs | Pairs |
| ------------- | -----: | ----: |
| ged_pyg_LINUX | 89 | 3,916 |
This PyG LINUX subset has isomorphic graphs removed and is provided to
reproduce auxiliary model pretraining.
## Files and schema
Each collection has four files:
- `graphs.jsonl`: graph ID, node count, edge index, discrete node label IDs and
the `has_node_labels` flag. Edge indices contain both directions of each
undirected edge.
- `ged_pairs.jsonl`: `graph_id_1`, `graph_id_2`, `ged`, `alignments`, and
`exact_elapsed_seconds`.
- `data.pt`: the same graph objects and ordered pair rows in a PyTorch dictionary
with keys `graphs_by_gid`, `rows`, `num_node_labels`, and `input_dim`.
Graph objects are PyTorch Geometric `Data` objects.
- `graph_id_map.csv`: released graph IDs and zero-based original collection IDs.
Graph IDs are contiguous from zero within each collection. Pair endpoints refer
to these released IDs. Node indices are preserved within each graph.
`release_manifest.csv` and `release_manifest.json` list collection identities
and counts.
## GED and mappings
`ged` is the unnormalized minimum edit cost between the two released graphs.
Graphs are undirected; each undirected edge is counted once even though
`edge_index` stores both directions.
| Edit operation | Cost |
| --------------------------------------------------------- | ---: |
| Node insertion or deletion | 1 |
| Substitution of different discrete node labels | 1 |
| Edge insertion or deletion | 1 |
The cost model uses graph structure and discrete node labels. Deleting a node
also incurs the cost of deleting its incident edges.
We retain one optimal mapping per graph pair in `alignments`. Each alignment
is a list of `[data_node, query_node]` pairs, from the data graph (`graph_id_1`)
to the query graph (`graph_id_2`); `-1` denotes a deletion or insertion. For example, `[2, 5]` matches data node 2 to query node 5,
`[3, -1]` deletes data node 3, and `[-1, 4]` inserts query node 4.
`exact_elapsed_seconds` records the exact computation time in seconds.
## Download and read
Install the download client in your Python environment:
```bash
pip install huggingface_hub
```
Download the 11 benchmark collections and auxiliary LINUX data into a relative local directory:
```python
from huggingface_hub import snapshot_download
root = snapshot_download(
repo_id="ush3r/GSCbench",
repo_type="dataset",
local_dir="GSCbench",
)
```
To download and read just MUTAG (with PyTorch and PyG installed):
```python
from huggingface_hub import snapshot_download
import torch
root = snapshot_download(
repo_id="ush3r/GSCbench",
repo_type="dataset",
local_dir="GSCbench",
allow_patterns=["tu_MUTAG/*"],
)
bundle = torch.load(root + "/tu_MUTAG/data.pt",
map_location="cpu", weights_only=False)
row = bundle["rows"][0]
data_graph = bundle["graphs_by_gid"][row["graph_id_1"]]
query_graph = bundle["graphs_by_gid"][row["graph_id_2"]]
```
Reading `data.pt` requires PyTorch and PyTorch Geometric. The files have been
checked with PyTorch 2.5.1 and PyG 2.6.1. The two JSONL files can be read with
Python's standard `json` module. The download includes all graphs and pair
labels needed for training.
To read the portable JSONL representation from a local download:
```python
import json
from pathlib import Path
folder = Path("GSCbench/tu_MUTAG")
with (folder / "graphs.jsonl").open(encoding="utf-8") as handle:
graphs = {record["graph_id"]: record for record in map(json.loads, handle)}
with (folder / "ged_pairs.jsonl").open(encoding="utf-8") as handle:
row = json.loads(next(handle))
data_graph = graphs[row["graph_id_1"]]
query_graph = graphs[row["graph_id_2"]]
```
The benchmark's existing `GSCDataset` loader reads `data.pt` when present.
Otherwise it builds and saves that file from `graphs.jsonl` and
`ged_pairs.jsonl`. Feature encoding and splits are applied when loading.
## Use with the benchmark code
After installing the GSCBench code and its dependencies using the code
repository's installation instructions, load a downloaded collection with
its existing loader:
```python
from gscbench.data.gscdataset import GSCDataset
dataset = GSCDataset(
dataset_name="tu_MUTAG",
root_dir="GSCbench",
split_seed=1729,
val_ratio=0.2,
test_ratio=0.2,
node_label_encoding="fixed_one_hot",
node_label_dim=97,
)
dataset.load()
train = dataset.get_split("train")
val = dataset.get_split("val")
test = dataset.get_split("test")
pair = train.samples[0]
```
These values illustrate loading; use the experiment config's seed, ratios,
feature encoding and pair budget for paper experiments. Set the config's
`gscbench_root_dir` to the downloaded dataset directory.
## Experimental splits
The release does not impose one train/validation/test partition. Benchmark
configs select the graph split seed, validation/test ratios, feature encoding
and training pair budget. The default benchmark graph split uses 60% training,
20% validation and 20% test graphs (with integer rounding). Training uses
train-train pairs; validation uses val-train pairs; the main test view contains
test-train, test-val and test-test pairs. Zero-shot evaluation does not train on
the target collection. Few-shot fitting uses only the selected target training
pairs.
Validation-validation pairs remain in the released data but are not used by
the default validation view. A training pair budget caps the number of
train-train pairs, rather than training graphs. The graph partition stays
the same across pair budgets for a given split seed.
## Sources
The graphs originate from the following collections:
- The ten `tu_` collections come from
[TUDataset](https://chrsmrrs.github.io/datasets/). The collection names in
the table identify their entries in the
[upstream dataset list](https://chrsmrrs.github.io/datasets/docs/datasets/).
- `ogb_ogbg-code2` comes from
[OGB's ogbg-code2 collection](https://ogb.stanford.edu/docs/graphprop/).
- `ged_pyg_LINUX` uses graphs from the LINUX collection distributed through
[PyG GEDDataset](https://pytorch-geometric.readthedocs.io/en/latest/generated/torch_geometric.datasets.GEDDataset.html).
`graph_id_map.csv` connects each released graph to its zero-based index in
the original source collection.
## Reproducibility
For a reproducible experiment, record the Hugging Face repository commit
and pass it as `revision` to `snapshot_download`, together with the benchmark
code revision, experiment config and split seed. The paper and code should
refer to that same data revision.