Reputation: 111
I have a very large graph that has one root node that fans out into multiple nodes. I need to get a list of ALL of the nodes in the subgraph. Other than label, they don't have a common attribute. They are only connected by the "connections"
Looking at my very simplified graph, I wanted to start from B
MATCH (n: {label:'B'}) and get a list of all the subnodes [E,C,H,F]
or Start with D and get [G] or start with C and get [H,F]
I though this would get me where I needed to go
https://neo4j.com/labs/apoc/4.1/graph-querying/expand-subgraph/
But i can't get the results.
Upvotes: 0
Views: 146
Reputation: 66989
Something like this should get all the nodes in the B
subtree (including the B
node).
MATCH p=(:Foo {label: 'B'})-[*0..]->(n)
RETURN n
Warning: Variable length relationships without a reasonable upper bound can run for a very long time and/or run out of memory.
Upvotes: 1