Reputation: 8833
Right now, to return a sub graph from Neo4J, I use
Match(n{id:"<uuid>"}) OPTIONAL MATCH (n)-[*..25]->(m) RETURN DISTINCT *
This is very inefficient for deeply interconnected graphs (as without RETURN DISTINCT, I get 100k results as apposed to a measly under 100 results.
How do I efficiently request all sub-nodes of a node without using APOC? (AKA, make the DISTINCT redundant instead of required in the matching; AKA, visit each node only once during matching?)
Upvotes: 3
Views: 1693
Reputation: 8833
Starting with Neo4j 3.2.x, (start)-[*..25]->(children)
behaves as desired.
Before that, you need to use the APOC expand function apoc.path.spanningTree
Upvotes: 1