-
Notifications
You must be signed in to change notification settings - Fork 10
Not Using NetworkX
Jordan Matelsky edited this page Mar 18, 2021
·
1 revision
GrandIso was written for NetworkX-flavored graphs, but you may want to run the algorithm on a graph that lives in another graph/network toolkit library.
Our library, Grand (pip install grand-graph
), is a library that enables you to run one graph algorithm on a graph stored in another library's format. For example, you can run IGraph algorithms on a NetworkX graph.
You should be able to use these libraries seamlessly by using the Grand networkx
dialect:
import networkx as nx
import networkit as nk
from grand import Graph
from grand.backends.networkit import NetworkitBackend
from grandiso import find_motifs
# Create a new Erdős–Rényi graph using Networkit:
er = nk.generators.ErdosRenyiGenerator(50, 0.1).generate()
# Load the graph into a Grand backend:
nb = NetworkitBackend(graph=er)
g = Graph(backend=nb)
# Create a motif. This motif is a NetworkX graph (i.e.
# it would usually be incompatible with the `er` variable)
motif = nx.complete_graph(3)
# Using the `Grand.nx` dialect, we can search for motifs
# in the Networkit graph:
results = find_motifs(motif, g.nx)
[{0: 2, 2: 28, 1: 39},
{0: 2, 2: 39, 1: 40},
{0: 2, 2: 39, 1: 28},
{0: 2, 2: 40, 1: 39},
{0: 4, 2: 9, 1: 45},
{0: 4, 2: 25, 1: 31},
{0: 4, 2: 31, 1: 25},
{0: 4, 2: 45, 1: 9},
{0: 6, 2: 41, 1: 47},
{0: 6, 2: 47, 1: 41},
{0: 8, 2: 12, 1: 32},
{0: 8, 2: 12, 1: 23},
...
]
If this tool is helpful to your research, please consider citing it with:
# 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}
}