Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-18-2022 08:07 PM
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,
03-25-2022 04:08 AM
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.
All the sessions of the conference are now available online