1
votes

I need to identify node pairs in my graph where there exists more than one path between the nodes. I am not looking for a particular pair of nodes, just any pair of nodes with multiple paths between them would be fine for me. So I don't want to get ALL such pairs but just some. I would like to use Cypher for that. This sound's like an easy task, but I don't find the proper query. I didn't even find a way to tell how many paths there are between two nodes in Cypher.

I hope someone can give me a hint. It is no problem when the query would run a while.

Thanks!

1

1 Answers

3
votes

Something like this, though it is really going to take long depending on the size of your graph-

START n=node(*),m=node(*) 
MATCH p=n-[r*1..]-m 
WITH count(p) AS totalPaths,n,m 
WHERE totalPaths>1 
RETURN n,m,totalPaths 
LIMIT 2

Since you said you don't want all pairs with multiple paths, you can adjust the limit (I've set it to 2 in this example).