aplbrain / grandiso-networkx

Performant, pure-Python subgraph isomorphism and monomorphism search (aka "motif search")
Apache License 2.0
52 stars 10 forks source link

Find Larger Matches #36

Open Matt-81 opened 1 year ago

Matt-81 commented 1 year ago

Dear @j6k4m8, I am looking for a way to find matches that are larger than the input motif (possibly given a certain threshold).

For instance, given the following motif:

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")

Finding matches in a given target graph G like:

("n1", "n0", label="gen")
("n2", "n0", label="gen")
("n1", "n3", label="rel")
("n2", "n4", label="rel")
("n0", label="class")
("n1", label="subclass")
("n2", label="subclass")
("n3", label="class")
("n4", label="class")

or

("n1", "n0", label="gen")
("n2", "n0", label="gen")
("n1", "n3", label="rel")
("n1", "n4", label="rel")
("n1", "n5", label="rel")
("n0", label="class")
("n1", label="subclass")
("n2", label="subclass")
("n3", label="class")
("n4", label="class")
("n5", label="class")

etc.

It should be a kind of inexact match where the input motif is always a subset of the output matches and we can select, for instance, the number of neighbor nodes to be considered in the output matches.

Thanks in advance for your help!