Bellman-Ford Algorithm
Demo
- On the left-hand side you can see the order of the edges that the algorithm will follow.
- Current Edge and current iteration would be highlighted.
- You can use the next or previous button to move to the next or previous state.
- The red color represents that the edge is relaxed whereas the yellow color represents that the edge is not relaxed.
Observation
- The distance and parent array above the graph shows the distance from the source node to all the other nodes and the parent of each node respectively.
- After relaxation observe the changes in the distance and parent array.
Practice
- On the left-hand side you can see the order of the edges that the algorithm will follow.
- For each iteration, you need to select the edges that are going to be relaxed. You can select the edges by clicking on them. To deselect an edge, click on it again.
- After selecting the edges you can click on the Next Iteration button to move to the next iteration. You would be able to next iteration only if the edges that you have selected are correct.
- You can move to previous iterations to see the changes in the distance and parent array.
Observation
- The distance and parent array above the graph shows the distance from the source node to all the other nodes and the parent of each node respectively.
- Observe the changes in the distance and parent array after each iteration.
Exercise
- On the left-hand side you can see the order of the edges that the algorithm will follow.
- Select the iteration from the tabs above the graph and select the edges that are going to be relaxed. You can select the edges by clicking on them. To deselect an edge, click on it again.
- After selecting the edges in all iterations click on submit to check your answer.
Observation
- You could see whether your answer is correct or not.
- After submission you could see the final distance and parent array created by the selected edges.