Closed Matt-81 closed 1 year ago
Hi @Matt-81! If you know the attributes ahead of time, you can just assign them to your motif queries like this:
import networkx as nx
from grandiso import find_motifs
motif = nx.DiGraph()
motif.add_edge("n1", "n0", label="gen")
motif.add_edge("n2", "n0", label="gen")
motif.add_node("n0", label="class")
motif.add_node("n1", label="subclass")
motif.add_node("n2", label="subclass")
find_motifs(motif, G)
As long as those attributes exist on the host graph as well, grandiso.find_motifs
will automatically restrict to these attributes!
Does that solve your problem?
Hi @j6k4m8! It works great, thank you!
Super awesome! Closing for now, feel free to reopen or start a new one if you have more questions!
Definitely! I'd also like to update you on how we're going to use it, if you're interested. Keep you posted :) Thanks again
@Matt-81 I'd love that!! Please do :)
Thank you for this very useful library, we will definitely consider it for our future research. In our specific case, we would need to count subgraph isomorphisms by edge and node labels. E.g., given a source directed graph with nodes n0, n1, and n2 with labels 'class', 'sublcass' and 'subclass' respectively, and with edges, n1->n0, n2->n0 both with labels 'gen', we would like to count the exact matches in a given target graph.
Is there an option to do this? Thank you!