Hello, This is my first time playing with neo4j, I modeled a graph that looks like this:
A ---> B
A ---> C
B ----> D
B ----> E
C ----> F
now, i my input can contain several nodes, let's say i get "A and B", and i want to find the direct connections of A + the direct ones of B, meaning, to return the nodes:
"B", "C", "D","E"
unwind ['A', 'B'] as input
match(n where n.name = input)
match (n)-[:REL]->(m)
return n.name, collect(m) as children
Replace the literal array ['A','B'] with your parameter containing your inputs. Also, replace the match condition with your unique identifier and the relationship type in the pattern match with yours. The result is a row for each of your inputs, with a list of each input's direct connected nodes.
If you prefer a list instead of a collection, replace the 'return' clause with this return clause 'return n.name, m', giving the following alternative result:
If you want just a list of the child nodes, replace the return clause with this return clause 'return collect(m)', giving the following result: