In all pair shortest path, when a weighted graph is represented by its weight matrix W then objective is to find the distance between every pair of nodes.
We will apply dynamic programming to solve the all pairs shortest path.
In all pair shortest path algorithm, we first decomposed the …