This is a C++ implementation of the Bellman-Ford algorithm. Simple interfaces are provided to make it easy to use in any project.
This software is released under the MIT license. Refer to LICENSE.md for details.
Add the following to your project:
#include "bellmanford.h"
and implement the interface BellmanFordNode<T>
.
Instantiate BellmanFordSearch
and:
-
Use
initGraph(<node list>)
to initialise the edge structures required for Bellman-Ford algorithm. -
Use
search(<source node>)
to begin Bellman-Ford search from the source node. -
Use
getDistanceMap()
to retrieve the map of distances from the source node to all other nodes in the graph.
Refer to sample.cpp for an example of how to use this class.
Special thanks to GeeksforGeeks, from which this code was adapted.