2
votes

I use Neo4j1.9m05. I want to calculate the shortest path between every pair of nodes. Right now I use this Cypher query:

START a=node(1), b=node(1-1000) MATCH p=shortestPath(a-[:cooperate*..50]-b) RETURN length(p)

1-1000 just means there are 1000 nodes. This simple query costs more than 2 minutes, which is too slow. I just want to query for 1000 pairs of shortest path length. Can anyone help?

1

1 Answers

1
votes

Things to try

Did you run the query on a cold cache? Try running it twice to verify.

Check if there is sufficient memory. Shortest path queries take a massive hit if the relevant portion of the graph does not fit into the cache.

I noticed that you are searching for an undirected path. You could help the algorithm by specifying the direction if possible.