https://github.com/aplbrain/grandiso-networkx
Performant, pure-Python subgraph isomorphism and monomorphism search (aka "motif search")
https://github.com/aplbrain/grandiso-networkx
algorithm aplbrain bossdb connectomics dotmotif grand-graphs grand-iso graphs network network-analysis network-biology subgraph-isomorphism ullman vf2
Last synced: 3 months ago
JSON representation
Performant, pure-Python subgraph isomorphism and monomorphism search (aka "motif search")
- Host: GitHub
- URL: https://github.com/aplbrain/grandiso-networkx
- Owner: aplbrain
- License: apache-2.0
- Created: 2020-08-10T18:46:38.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-16T11:20:41.000Z (9 months ago)
- Last Synced: 2025-02-09T14:13:14.102Z (3 months ago)
- Topics: algorithm, aplbrain, bossdb, connectomics, dotmotif, grand-graphs, grand-iso, graphs, network, network-analysis, network-biology, subgraph-isomorphism, ullman, vf2
- Language: Python
- Homepage:
- Size: 175 KB
- Stars: 58
- Watchers: 10
- Forks: 10
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Grand Isomorphisms
Subgraph isomorphism is a resource-heavy (but branch-parallelizable) algorithm that is hugely impactful for large graph analysis. SotA algorithms for this (Ullmann, VF2, BB-Graph) are heavily RAM-bound, but this is due to a large number of small processes each of which hold a small portion of a traversal tree in memory.
_Grand-Iso_ is a subgraph isomorphism algorithm that exchanges this resource-limitation for a parallelizable partial-match queue structure.
It performs favorably compared to other pure-python (and even some non-pure-python!) implementations:
See the [wiki](https://github.com/aplbrain/grandiso-networkx/wiki) for more documentation.
## Example Usage
```python
from grandiso import find_motifs
import networkx as nxhost = nx.fast_gnp_random_graph(10, 0.5)
motif = nx.Graph()
motif.add_edge("A", "B")
motif.add_edge("B", "C")
motif.add_edge("C", "D")
motif.add_edge("D", "A")len(find_motifs(motif, host))
```Directed graph support:
```python
from grandiso import find_motifs
import networkx as nxhost = nx.fast_gnp_random_graph(10, 0.5, directed=True)
motif = nx.DiGraph()
motif.add_edge("A", "B")
motif.add_edge("B", "C")
motif.add_edge("C", "D")
motif.add_edge("D", "A")len(find_motifs(motif, host))
```## Counts-only
For very large graphs, you may use a good chunk of RAM not only on the queue of hypotheses, but also on the list of results. If all you care about is the NUMBER of results, you should pass `count_only=True` to the `find_motifs` function. This will dramatically reduce your RAM overhead on higher-count queries.
There are many other arguments that you can pass to the motif search algorithm. For a full list, see [here](https://github.com/aplbrain/grandiso-networkx/wiki/Algorithm-Arguments).
## Hacking on this repo
### Running Tests
```shell
coverage run --source=grandiso -m pytest
```## Citing
If this tool is helpful to your research, please consider citing it with:
```bibtex
# https://doi.org/10.1038/s41598-021-91025-5
@article{Matelsky_Motifs_2021,
title={{DotMotif: an open-source tool for connectome subgraph isomorphism search and graph queries}},
volume={11},
ISSN={2045-2322},
url={http://dx.doi.org/10.1038/s41598-021-91025-5},
DOI={10.1038/s41598-021-91025-5},
number={1},
journal={Scientific Reports},
publisher={Springer Science and Business Media LLC},
author={Matelsky, Jordan K. and Reilly, Elizabeth P. and Johnson, Erik C. and Stiso, Jennifer and Bassett, Danielle S. and Wester, Brock A. and Gray-Roncal, William},
year={2021},
month={Jun}
}
```---