Alternative of shortestPath

Hii, I am using shortestpath method to get the path between two nodes.
If there is any alternative to this method where I can get distance directly instead of path, also if no path is found it should return 0.

Are you asking to find the least cost path, where the cost is determined by relationship properties? If so, I think you need to use the GDS library.

If you can’t to calculate a distance given the shortest path, where each relationship has a distance metric, you can us the reduce clause for lists. You would iterate over the relationships of the path.

Hi, thank you for replying.
Yes, I am trying to find a path between two nodes - the number of edges between two nodes.
Using shortestPath() is the correct solution to my problem.
I am doing p = shortestPath(n-[:r]-p), then length(p).
I am searching for some other method that directly returns length instead of the complete path.

1 Like