0
votes

I'm trying to find all relations between node a and node b, and the relations could be multi-directions. For example, a <- c -> b or a -> d -> b where c and d are nodes.

I've tried MATCH (a:PERSON {name: 'WD'})-[r*..3]-(b:PERSON{name: 'EK'}) RETURN r, a, b, but I got two isolated nodes, because the relation between a and b is: a <- c -> b.

Any help would be appreciated.

1
What do you mean by "isolated nodes"? The r you should have gotten would have been a list of relationships (since you used a variable-length relationship pattern).cybersam
@cybersam "Isolated nodes" means I only get two nodes without any connection. Anyway, thank you for your help! I have solved this problem.Sirui Li

1 Answers

0
votes

You can return the path if you need all the relationships and nodes in between.

Following query will You can modify your query to return full paths instead of just nodes a and b as following:

MATCH paths=(a:PERSON {name: 'WD'})-[r*..3]-(b:PERSON{name: 'EK'})
RETURN paths

This will return paths of length up to 3, change it as you need.