What is the best way to search for a relatively small subgraph (< 50 nodes typically) but in a huge database?

I'm applying Neo4j to the problem of diagram chasing, so my graph database holds diagrams that the users draw using my software. I need the ability to search for the user's drawing so as we don't have duplicates. Is the best way just to build up a really long query using Cypher? I will need to make use of regexes when matching.

Thanks!

Can you provide a sample query and some additional explanation? It would help to know the inputs and expected outputs.

1 Like

I don't know the sample query yet but I heard you have to "build path patterns", which is probably what I'll do.

I have a local copy of a "graph" in PyQt5 objects. In each object I store their databaseID(), I need to take a small set of nodes and arrows and perform a matching over the whole thing. These query graphs are relatively small though, so I'm sure something is doable...

By that I mean a matching based on their labels which I store in a property (a list of strings). I want to match the subgraph if their is a regular directed graph isomorphism and the query graph labels match a subset of the matched result labels for each node / edge.

If your id's are indexed you can find the nodes by id (list) and then establish if there are neighborhood connections between them.
like

MATCH (a:Label) where a.id IN $ids
WITH collect(a) as nodes
WITH * WHERE all(a IN nodes where any(b IN nodes where b = a OR (b)-[:REL]-(a))
return nodes

Something like this?

1 Like