Answer:
Following are the step by step algorithms is explain below.
Explanation:
Following are the algorithm for searching shortest distances.
- Firstly, Initialize the array variable distance[] = {INF, INF, ….} as well as distance[s] = 0 in which the variable 's' is the beginning vertex
- Then, you have to develop a topological order of the following vertices.
- So, Do in the following for mostly vertex that is the variable 'u' in the topological order.
Do on the following for mostly contiguous vertex that is 'v' of 'u'
if (dist[v] > dist[u] + weight(u, v))
dist[v] = dist[u] + weight(u, v)