• Stars
    star
    327
  • Rank 128,686 (Top 3 %)
  • Language
    Jupyter Notebook
  • Created over 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Neural Subgraph Learning Library

Neural Subgraph Learning (NSL) is a general library that implements various tasks related to learning of subgraph relations.

It is able to perform 2 tasks:

  1. Neural subgraph matching.
  2. Frequent subgraph mining.

Neural Subgraph Matching

The library implements the algorithm NeuroMatch.

Problem setup

Given a query graph Q anchored at node q, and a target graph T anchored at node v, predict if there exists an isomorphism mapping a subgraph of T to Q, such that the isomorphism maps v to q. The framework maps the query and target into an embedding space, and either uses MLP/Neural tensor network + cross entropy loss or order embedding + max margin loss to obtain a prediction score and make the binary prediction of subgraph relationship based on a threshold of the score.

See paper and website for detailed explanation of the algorithm.

Train the matching GNN encoder

  1. Train the encoder: python3 -m subgraph_matching.train --node_anchored. Note that a trained order embedding model checkpoint is provided in ckpt/model.pt.
  2. Optionally, analyze the trained encoder via python3 -m subgraph_matching.test --node_anchored, or by running the "Analyze Embeddings" notebook in analyze/

By default, the encoder is trained with on-the-fly generated synthetic data (--dataset=syn-balanced). The dataset argument can be used to change to a real-world dataset (e.g. --dataset=enzymes), or an imbalanced class version of a dataset (e.g. --dataset=syn-imbalanced). It is recommended to train on a balanced dataset.

Usage

The module python3 -m subgraph_matching.alignment.py [--query_path=...] [--target_path=...] provides a utility to obtain all pairs of corresponding matching scores, given a pickle file of the query and target graphs in networkx format. Run the module without these arguments for an example using random graphs. If exact isomorphism mapping is desired, a conflict resolution algorithm can be applied on the alignment matrix (the output of alignment.py). Such algorithms are available in recent works. For example: Deep Graph Matching Consensus and Convolutional Set Matching for Graph Similarity.

Both synthetic data (common/combined_syn.py) and real-world data (common/data.py) can be used to train the model. One can also train with synthetic data, and transfer the learned model to make inference on real data (see subgraph_matching/test.py). The neural_matching folder contains an encoder that uses GNN to map the query and target into the embedding space and make subgraph predictions.

Available configurations can be found in subgraph_matching/config.py.

Frequent Subgraph Mining

This package also contains an implementation of SPMiner, a graph neural network based framework to extract frequent subgraph patterns from an input graph dataset.

Running the pipeline consists of training the encoder on synthetic data, then running the decoder on the dataset from which to mine patterns.

Full configuration options can be found in subgraph_matching/config.py and subgraph_mining/config.py.

Run SPMiner

To run SPMiner to identify common subgraph pattern, the prerequisite is to have a checkpoint of trained subgraph matching model (obtained by training the GNN encoder). The config argument args.model_path (subgraph_matching/config.py) specifies the location of the saved checkpoint, and is shared for both the subgraph_matching and subgraph_mining models.

  1. python3 -m subgraph_mining.decoder --dataset=enzymes --node_anchored

Full configuration options can be found in decoder/config.py. SPMiner also shares the configurations of NeuroMatch subgraph_matching/config.py since it's used as a subroutine.

Analyze results

  • Analyze the order embeddings after training the encoder: python3 -m analyze.analyze_embeddings --node_anchored
  • Count the frequencies of patterns generated by the decoder: python3 -m analyze.count_patterns --dataset=enzymes --out_path=results/counts.json --node_anchored
  • Analyze the raw output from counting: python3 -m analyze.analyze_pattern_counts --counts_path=results/

Dependencies

The library uses PyTorch and PyTorch Geometric to implement message passing graph neural networks (GNN). It also uses DeepSNAP, which facilitates easy use of graph algorithms (such as subgraph operation and matching operation) to be performed during training for every iteration, thanks to its synchronization between an internal graph object (such as a NetworkX object) and the Pytorch Geometric Data object.

Detailed library requirements can be found in requirements.txt

More Repositories

1

snap

Stanford Network Analysis Platform (SNAP) is a general purpose network analysis and graph mining library.
C++
2,167
star
2

ogb

Benchmark datasets, data loaders, and evaluators for graph machine learning
Python
1,906
star
3

GraphGym

Platform for designing and evaluating Graph Neural Networks (GNN)
Python
1,669
star
4

pretrain-gnns

Strategies for Pre-training Graph Neural Networks
Python
955
star
5

deepsnap

Python library assists deep learning on graphs
Python
546
star
6

GraphRNN

Python
408
star
7

med-flamingo

Python
375
star
8

stark

STaRK: Benchmarking LLM Retrieval on Textual and Relational Knowledge Bases (NeurIPS D&B 2024)
Python
297
star
9

snap-python

SNAP Python code, SWIG related files
C++
294
star
10

cs224w-notes

CS224W Course Notes
CSS
292
star
11

KGReasoning

Multi-Hop Logical Reasoning in Knowledge Graphs
Python
274
star
12

GreaseLM

[ICLR 2022 spotlight]GreaseLM: Graph REASoning Enhanced Language Models for Question Answering
Python
229
star
13

MLAgentBench

Python
224
star
14

relbench

RelBench: Relational Deep Learning Benchmark
Python
193
star
15

GEARS

GEARS is a geometric deep learning model that predicts outcomes of novel multi-gene perturbations
Python
189
star
16

distance-encoding

Distance Encoding for GNN Design
Jupyter Notebook
181
star
17

graphwave

Jupyter Notebook
169
star
18

UCE

UCE is a zero-shot foundation model for single-cell gene expression data
Python
158
star
19

covid-mobility

Jupyter Notebook
148
star
20

roland

Jupyter Notebook
125
star
21

GIB

Graph Information Bottleneck (GIB) for learning minimal sufficient structural and feature information using GNNs
Jupyter Notebook
123
star
22

mars

Discovering novel cell types across heterogenous single-cell experiments
Jupyter Notebook
119
star
23

comet

[ICLR 2021] Concept Learners for Few-Shot Learning
Python
111
star
24

SATURN

Jupyter Notebook
103
star
25

orca

[ICLR 2022] Open-World Semi-Supervised Learning
Python
85
star
26

prodigy

Python
75
star
27

CAW

Python
72
star
28

snapvx

Python
65
star
29

conformalized-gnn

Uncertainty Quantification over Graph with Conformalized Graph Neural Networks (NeurIPS 2023)
Python
64
star
30

multiscale-interactome

Python
62
star
31

plato

Python
61
star
32

miner-data

Python
60
star
33

stellar

Jupyter Notebook
58
star
34

mambo

Jupyter Notebook
37
star
35

lamp

[ICLR23] First deep learning-based surrogate model that jointly learns the evolution model and optimizes computational cost via remeshing
Python
36
star
36

crust

[NeurIPS 2020] Coresets for Robust Training of Neural Networks against Noisy Labels
Python
33
star
37

bc-emb

Python
32
star
38

csr

Python
30
star
39

zeroc

ZeroC is a neuro-symbolic method that trained with elementary visual concepts and relations, can zero-shot recognize and acquire more complex, hierarchical concepts, even across domains
Jupyter Notebook
28
star
40

masa

Motif-Aware State Assignment in Noisy Time Series Data
Python
24
star
41

le_pde

LE-PDE accelerates PDEs' forward simulation and inverse optimization via latent global evolution, achieving significant speedup with SOTA accuracy
Jupyter Notebook
21
star
42

ConE

Python
20
star
43

BioDiscoveryAgent

BioDiscoveryAgent is an LLM-based AI agent for closed-loop design of genetic perturbation experiments
Python
19
star
44

F-FADE

Python
17
star
45

MetroMaps

MetroMaps Release
Python
16
star
46

MAG

Programs for Microsoft Academic Graph
Python
16
star
47

snap-dev

SNAP repository for Ringo
C++
14
star
48

exposure-segregation

Python
13
star
49

ringo

Next generation graph processing platform
Python
12
star
50

planet

PlaNet: Predicting population response to drugs via clinical knowledge graph
Python
12
star
51

covid-mobility-tool

Jupyter Notebook
10
star
52

llm-social-network

Jupyter Notebook
10
star
53

reddit-processing

preprocessing of Reddit data
Python
7
star
54

ViRel

ViRel: Unsupervised Visual Relations Discovery with Graph-level Analogy
Python
7
star
55

news-search

search Internet news archive
Java
7
star
56

snap-python-64

C++
6
star
57

snap-dev-64

64-bit SNAP (in development, not intended for general use)
C++
6
star
58

snapworld

Python
6
star
59

lego

5
star
60

yperf

Simple performance monitor for Linux
Python
4
star
61

pebble-fit

become less sedentary with pebble
C
4
star
62

dec2vec

Python
3
star
63

caml

Python
3
star
64

SnapTimeTF

Python
2
star
65

covid-spillovers

Jupyter Notebook
2
star
66

curis-2012

Summer 2012 Curis Project
JavaScript
2
star
67

snaptime

Python
2
star
68

GNN-reading-group

1
star
69

supply-chains

Jupyter Notebook
1
star
70

relbench-user-study

Python
1
star
71

AutoTransfer

Python
1
star
72

hash

C++
1
star