sbhatt
sbhatt

Reputation: 485

cypher query to find paths between set of nodes takes a very long time

I have a graph where multiple (more than 300) paths can exist between two nodes.

I want to find paths between a particular node and set of nodes. I'm using following query to accomplish this.

// 2,153 and 485 are nodeid.

START startnode=node(2), group = node(153 ,485)
MATCH p=startnode-[:C0038969primrel*1..4]->group
RETURN DISTINCT p

If I change the depth from 1..4 to 1..3 then it returns the result but for 1..4 it doesn't return.

I'm kind of stuck because of this. Would really appreciate, moreover, grateful for your help.

Upvotes: 3

Views: 1844

Answers (1)

Michael Hunger
Michael Hunger

Reputation: 41676

Use shortestPath or allShortestPaths

START startnode=node(2), group = node(153 ,485)
MATCH p=allShortestPaths(startnode-[:C0038969primrel*..4]->group)
RETURN p

Upvotes: 8

Related Questions