cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Bellman-Ford algorithm

Is it possible to use the Bellman Ford algorithm to calculate the shortest path?

I looked into the shortest path algorithms and saw that Bellman Ford supports negative distances, which is what I would like to use.

I guess Neo4j uses Dijkstra's as default, but Dijkstra's doesn't support negative distances so I wonder if there is a way to use Bellman instead of Dijkstra's .

I saw this post on github from 2016 saying it would add the Bellman-Ford algorithm, but I don't know if it was implemented.
I searched the apoc documentation but there is nothing about Bellman-Ford.

Thanks,

1 REPLY 1

Unfortunately Bellman-Ford isn't available. The GDS package supports A* and Yen, but disclosure, they both only support positive weights.

In your situation, I would consider normalizing your negative weights to positive numbers and then using your choice of the available options in the link above.