Difference between Neo4j Dijkstra and shortestPath performance?

965 views Asked by At

I have a database populated with random data with social relationships like person-> attended -> university, person1 -> friends-> person2 etc. There are 4 types of nodes. My database has about 3M nodes and 12M edges.

When I try querying paths between 2 random nodes using the REST API I get the response from shortestPath algorithm in about 3-4 secs. But running the same query with Dijkstra never returns.

I understand Dijkstra is expensive but is there something I might be doing wrong?

URL - http://localhost:7474/db/data/node/499052/paths

payload for shortest path-

{ "to": "http://localhost:7474/db/data/node/296431", "algorithm": "shortestPath", "max_depth":4 }

payload for dijkstra-

{ "to": "http://localhost:7474/db/data/node/296431", "cost_property": "weight", "algorithm": "dijkstra", "max_depth":4 }
1

There are 1 answers

7
Anton Persson On

No you are not doing anything wrong, the performance difference between shortestPath and dijkstra is that large unfortunately. If your weights are all 1 then I would definitely recommend using shortestPath.