3 Bellman–Ford algorithm and its adaptation
The choice of a suitable shortest-path algorithm for porting onto hardware is mainly dictated by the ability to parallelise its operations. Most attempts at hardware implementation of the single-source shortest-path problem have been based on variations of the Bellman–Ford algorithm. Given a weighted, directed graph and a source node, it finds a shortest path from the source node to every other node. For a graph G(V, E) with n nodes and e links, the pseudocode of the Bellman–Ford shortest-path algorithm is presented below.
Bellman–Ford algorithm:
1. for each node k [ V
2. cost [k] ¼ 1
3. predecessor [k] ¼ nil
4. end for
5. cost [s] ¼ 0
6. for j ¼ 1 to n 2 1
7. for each link (u, v) [ E
8. temp ¼ cost [u] + w [u, v]
9. if temp , cost [v]
10. cost [v] ¼ temp
11. predecessor [v] ¼ u
12. end if
13. end for
14. end for