Shortest Path Problem

The algorithm is very comprehensive and here it is….

Algorithm:-

  1. Set the starting vertex
  2. Find the BFS (or DFS) for it
  3. For every vertex in the BFS
    1. Find the shortest path from it to the starting vertex
    2. Add that shortest path to the resultant TREE if its already not there and not forming a loop

Leave a comment