Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing hints in grandiso #63

Open
j6k4m8 opened this issue Feb 1, 2025 · 1 comment
Open

Support passing hints in grandiso #63

j6k4m8 opened this issue Feb 1, 2025 · 1 comment
Labels
enhancement New feature or request performance

Comments

@j6k4m8
Copy link
Member

j6k4m8 commented Feb 1, 2025

grandiso.find_motifs supports a hints attribute with is a list of partial-mappings, instead of requiring an exhaustive search:

host = nx.DiGraph()
nx.add_path(host, ["A", "B", "C", "A"])
motif = nx.DiGraph()
nx.add_path(motif, ["A", "B", "C", "A"])
assert (
    find_motifs(
        motif,
        host,
        count_only=True,
        # ↓ won't yield anything ↓   ↓ results in 1 match ↓
        hints=[{"A": "A", "B": "C"}, {"A": "A", "B": "B"}],
    )
    == 1
)

It would be a HUGE query savings if we could optionally pass a set of hints directly to the grandcypher constructor:

GrandCypher(G.nx).run(" ... ", grandiso_hints=[{"A": "A", "B": "B"}])

It would also be a huge performance boost if we took the attributes that have "simple" mappings (attribute equality, for instance) and auto-generated a set of hints from that. For example,

MATCH (A)-[]->(B)
WHERE B.username == "j6k4m8"
RETURN A

We should see that B can be easily found first, and populate a set of hints with all valid matches for B before we even call the motif search here.

@j6k4m8 j6k4m8 added enhancement New feature or request performance labels Feb 1, 2025
@davidmezzetti
Copy link
Contributor

This does seem like a really interested idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance
Projects
None yet
Development

No branches or pull requests

2 participants