pygmtools provides graph matching solvers in Python API and supports numpy and pytorch backends. pygmtools also provides dataset API for standard graph matching benchmarks.
Project description
pygmtools
is published in JMLR! Please cite our paper
if our tools are useful in your research!
pygmtools
(Python Graph Matching Tools) provides graph matching solvers in Python and is easily accessible via:
$ pip install pygmtools
Official documentation: https://pygmtools.readthedocs.io
Source code: https://github.com/Thinklab-SJTU/pygmtools
Graph matching is a fundamental yet challenging problem in pattern recognition, data mining, and others. Graph matching aims to find node-to-node correspondence among multiple graphs, by solving an NP-hard combinatorial optimization problem.
Doing graph matching in Python used to be difficult, and this library wants to make researchers' lives easier.
To highlight, pygmtools
has the following features:
- Support various solvers, including traditional combinatorial solvers (including linear, quadratic, and multi-graph) and novel deep learning-based solvers;
- Support various backends, including
numpy
which is universally accessible, and some state-of-the-art deep learning architectures with GPU support:pytorch
,paddle
,jittor
,tensorflow
,mindspore
; - Deep learning friendly, the operations are designed to best preserve the gradient during computation and batched operations support for the best performance.
Installation
You can install the stable release on PyPI:
$ pip install pygmtools
or get the latest version by running:
$ pip install -U https://github.com/Thinklab-SJTU/pygmtools/archive/master.zip # with --user for user install (no root)
Now the pygmtools is available with the numpy
backend.
The following packages are required, and shall be automatically installed by pip
:
Python >= 3.8
requests >= 2.25.1
scipy >= 1.4.1
Pillow >= 7.2.0
numpy >= 1.18.5
easydict >= 1.7
appdirs >= 1.4.4
tqdm >= 4.64.1
networkx >= 2.8.8
aiohttp
async-timeout
Available Graph Matching Solvers
This library offers user-friendly API for the following solvers:
- Two-Graph Matching Solvers
- Linear assignment solvers including the differentiable soft Sinkhorn algorithm [1], and the exact solver Hungarian [2].
- Soft and differentiable quadratic assignment solvers, including spectral graph matching [3] and random-walk-based graph matching [4].
- Discrete (non-differentiable) quadratic assignment solver integer projected fixed point method [5].
- Multi-Graph Matching Solvers
- Composition based Affinity Optimization (CAO) solver [6] by optimizing the affinity score, meanwhile gradually infusing the consistency.
- Multi-Graph Matching based on Floyd shortest path algorithm [7].
- Graduated-assignment based multi-graph matching solver [8][9] by graduated annealing of Sinkhorn’s temperature.
- Neural Graph Matching Solvers
- Intra-graph and cross-graph embedding based neural graph matching solvers PCA-GM and IPCA-GM [10] for matching individual graphs.
- Channel independent embedding (CIE) [11] based neural graph matching solver for matching individual graphs.
- Neural graph matching solver (NGM) [12] for the general quadratic assignment formulation.
- Graph edit neural network A-star (GENN-A*) [13] for the graph edit distance problem.
Available Backends
This library is designed to support multiple backends with the same set of API. Please follow the official instructions to install your backend.
The following backends are available:
- Numpy (default backend, CPU only)
- PyTorch (GPU friendly, deep learning friendly)
- Jittor (GPU friendly, JIT support, deep learning friendly)
- PaddlePaddle (GPU friendly, deep learning friendly)
- Tensorflow (GPU friendly, deep learning friendly)
Development status
Numpy | PyTorch | Jittor | PaddlePaddle | Tensorflow | MindSpore | |
---|---|---|---|---|---|---|
Linear Solvers | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
Classic Solvers | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
Multi-Graph Solvers | ✔ | ✔ | ✔ | ✔ | 📆 | 📆 |
Neural Solvers | ✔ | ✔ | ✔ | ✔ | 📆 | 📆 |
Examples Gallery | ✔ | ✔ | ✔ | ✔ | 📆 | 📆 |
✔: Supported; 📆: Planned for future versions (contributions welcomed!).
For more details, please read the documentation.
Pretrained Models
The library includes several neural network solvers. The pretrained models shall be automatically downloaded upon
needed from Google Drive. If you are experiencing issues accessing Google Drive, please download the pretrained models
manually and put them at ~/.cache/pygmtools
(for Linux).
Available at: [google drive] [baidu drive]
The Deep Graph Matching Benchmark
pygmtools
is also featured with a standard data interface of several graph matching benchmarks. Please read
the corresponding documentation for details.
We also maintain a repository containing non-trivial implementation of deep graph matching models, please check out ThinkMatch if you are interested!
Chat with the Community
If you have any questions, or if you are experiencing any issues, feel free to raise an issue on GitHub.
We also offer the following chat rooms if you are more comfortable with them:
Contributing
Any contributions/ideas/suggestions from the community is welcomed! Before starting your contribution, please read the Contributing Guide.
Developers and Maintainers
pygmtools
is developed and maintained by members from ThinkLab at
Shanghai Jiao Tong University.
Citing Pygmtools
pygmtools
is published on Journal of Machine Learning Research (JMLR). If you find our toolkit helpful in your
research, please cite:
Runzhong Wang, Ziao Guo, Wenzheng Pan, Jiale Ma, Yikai Zhang, Nan Yang, Qi Liu, Longxuan Wei, Hanxue Zhang, Chang Liu, Zetian Jiang, Xiaokang Yang, and Junchi Yan.
Pygmtools: A Python Graph Matching Toolkit.
Journal of Machine Learning Research, 25(33):1−7, 2024.
In Bibtex format:
@article{wang2024pygm,
author = {Runzhong Wang and Ziao Guo and Wenzheng Pan and Jiale Ma and Yikai Zhang and Nan Yang and Qi Liu and Longxuan Wei and Hanxue Zhang and Chang Liu and Zetian Jiang and Xiaokang Yang and Junchi Yan},
title = {Pygmtools: A Python Graph Matching Toolkit},
journal = {Journal of Machine Learning Research},
year = {2024},
volume = {25},
number = {33},
pages = {1-7},
url = {https://jmlr.org/papers/v25/23-0572.html},
}
References
[1] Sinkhorn, Richard, and Paul Knopp. "Concerning nonnegative matrices and doubly stochastic matrices." Pacific Journal of Mathematics 21.2 (1967): 343-348.
[2] Munkres, James. "Algorithms for the assignment and transportation problems." Journal of the Society for Industrial and Applied Mathematics 5.1 (1957): 32-38.
[3] Leordeanu, Marius, and Martial Hebert. "A spectral technique for correspondence problems using pairwise constraints." International Conference on Computer Vision (2005).
[4] Cho, Minsu, Jungmin Lee, and Kyoung Mu Lee. "Reweighted random walks for graph matching." European conference on Computer Vision (2010).
[5] Leordeanu, Marius, Martial Hebert, and Rahul Sukthankar. "An integer projected fixed point method for graph matching and map inference." Advances in Neural Information Processing Systems 22 (2009).
[6] Yan, Junchi, et al. "Multi-graph matching via affinity optimization with graduated consistency regularization." IEEE Transactions on Pattern Analysis and Machine Intelligence 38.6 (2015): 1228-1242.
[7] Jiang, Zetian, Tianzhe Wang, and Junchi Yan. "Unifying offline and online multi-graph matching via finding shortest paths on supergraph." IEEE Transactions on Pattern Analysis and Machine Intelligence 43.10 (2020): 3648-3663.
[8] Solé-Ribalta, Albert, and Francesc Serratosa. "Graduated assignment algorithm for multiple graph matching based on a common labeling." International Journal of Pattern Recognition and Artificial Intelligence 27.01 (2013): 1350001.
[9] Wang, Runzhong, Junchi Yan, and Xiaokang Yang. "Unsupervised Learning of Graph Matching with Mixture of Modes via Discrepancy Minimization." IEEE Transactions on Pattern Analysis and Machine Intelligence 45.8 (2023): 10500-10518.
[10] Wang, Runzhong, Junchi Yan, and Xiaokang Yang. "Combinatorial learning of robust deep graph matching: an embedding based approach." IEEE Transactions on Pattern Analysis and Machine Intelligence 45.6 (2023): 6984-7000.
[11] Yu, Tianshu, et al. "Learning deep graph matching with channel-independent embedding and hungarian attention." International Conference on Learning Representations. 2019.
[12] Wang, Runzhong, Junchi Yan, and Xiaokang Yang. "Neural graph matching network: Learning lawler’s quadratic assignment problem with extension to hypergraph and multiple-graph matching." IEEE Transactions on Pattern Analysis and Machine Intelligence 44.9 (2022): 5261-5279.
[13] Wang, Runzhong, Junchi Yan, and Xiaokang Yang. "Combinatorial Learning of Graph Edit Distance via Dynamic Embedding." IEEE/CVF Conference on Computer Vision and Pattern Recognition (2021): 5241-5250.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pygmtools-0.5.3.tar.gz
.
File metadata
- Download URL: pygmtools-0.5.3.tar.gz
- Upload date:
- Size: 164.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85c1ef7d65c41b75788a38822bebdc81649d71b074e42dd2ae4bab898679dbee |
|
MD5 | e8af51248722f958cfa350651a52c802 |
|
BLAKE2b-256 | 47440739547d905a7b4995f789023b460922cd1fc9a2860dfcb11d000e0f3a00 |
File details
Details for the file pygmtools-0.5.3-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: pygmtools-0.5.3-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 290.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1166ff8255f58bc8d54b0c6557fe09dd1a92bafec6fbc116ab8f99cb478b6feb |
|
MD5 | 36fc886bea73304274e7e80bd42bb876 |
|
BLAKE2b-256 | 5de5d4bd6d07c8b59a22a2c8ca09092eda60ac7cd75b8279c74667bc15c78f0f |
File details
Details for the file pygmtools-0.5.3-cp310-cp310-manylinux2014_x86_64.whl
.
File metadata
- Download URL: pygmtools-0.5.3-cp310-cp310-manylinux2014_x86_64.whl
- Upload date:
- Size: 790.3 kB
- Tags: CPython 3.10
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32cf0ffe7cd9c9b8bb50f0f0dfd2eb509bec31a0731de56be9b164c7303a1c50 |
|
MD5 | 6564542a3ced5a51356a03f9a2ad764a |
|
BLAKE2b-256 | e5a5969ccdbc4ad0c78eb78d9789b8fdf0211031df2c9fa13203f4ebd5563046 |
File details
Details for the file pygmtools-0.5.3-cp310-cp310-macosx_10_9_universal2.whl
.
File metadata
- Download URL: pygmtools-0.5.3-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 355.2 kB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a1045611ebb9e2d57c7e674e522a0588947806b141b9ada2dd9a0622118077b |
|
MD5 | ed25f1631357b40369221f342c068d91 |
|
BLAKE2b-256 | 21efeb4d8a8b59415f55b62ffbc425340271c6da3d5f0767b53c6e5b29e5de40 |
File details
Details for the file pygmtools-0.5.3-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: pygmtools-0.5.3-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 302.7 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e29b0d8b7f84c7fb15959a24abd19a30137345c5f9a2e0b644bac257c2c22ca3 |
|
MD5 | a91e8bee1bec5b7f3e7f42e7cc142bfc |
|
BLAKE2b-256 | 4787a93a6a4527b3902a01cd70092680f06793a8d513a0df06ed5369e30a12d7 |
File details
Details for the file pygmtools-0.5.3-cp39-cp39-manylinux2014_x86_64.whl
.
File metadata
- Download URL: pygmtools-0.5.3-cp39-cp39-manylinux2014_x86_64.whl
- Upload date:
- Size: 789.9 kB
- Tags: CPython 3.9
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93a48e8008761a7c20e5d5617b86f532e5d77bb0a795bb3621e3f155a9d3b5b9 |
|
MD5 | f000e1be2ec2daf3dbe58825477ad936 |
|
BLAKE2b-256 | ee35824b10344ae5c64ab6756d5486cdc97c9617489ea88e274ab2073d6cc623 |
File details
Details for the file pygmtools-0.5.3-cp39-cp39-macosx_10_9_universal2.whl
.
File metadata
- Download URL: pygmtools-0.5.3-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 355.1 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5abd9fe5ea21b809fcc338a0465cff3fe71b20b7302c9c195595a7f2c0286b92 |
|
MD5 | a0903c0f78f06d3a0f3d4f4e3367b801 |
|
BLAKE2b-256 | 1f574bd9eeb2ee739452573f3c8dcb5a60a01be579e5879798b188a7c871b201 |
File details
Details for the file pygmtools-0.5.3-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: pygmtools-0.5.3-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 301.8 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb0f096765ad51885a677db098c41fabe25de2b38234cb642f979598125b5217 |
|
MD5 | d2a2d9ce60b8a4920423d726903ab60c |
|
BLAKE2b-256 | 7cd39ec92dfc2f6f0c0db6b6f7dcd4f5c4f4b0979538b49848615b10617c6647 |
File details
Details for the file pygmtools-0.5.3-cp38-cp38-manylinux2014_x86_64.whl
.
File metadata
- Download URL: pygmtools-0.5.3-cp38-cp38-manylinux2014_x86_64.whl
- Upload date:
- Size: 793.9 kB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53858cc062822813c6edbff231d188c68606f7c09ae77b4fc2603206fe48b8f6 |
|
MD5 | 579957196863a6a59db2ba867e8b53c8 |
|
BLAKE2b-256 | b3df9d2b64ccc1c0ca41639f9c0c3867486a7531efd0301dc4a8e8b4567eca66 |
File details
Details for the file pygmtools-0.5.3-cp38-cp38-macosx_11_0_universal2.whl
.
File metadata
- Download URL: pygmtools-0.5.3-cp38-cp38-macosx_11_0_universal2.whl
- Upload date:
- Size: 353.1 kB
- Tags: CPython 3.8, macOS 11.0+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d392eeb42a1e29008491dd0f91432735c7d0efaf366641d7802270cef1fcdd81 |
|
MD5 | 3be8aa4e35d3b7911edc8b332b8c23c8 |
|
BLAKE2b-256 | 8f57ec7a7464ff4381e7eecc72a5c4c8c217707c4bedc1cd12ba1ff38ed6d172 |