Ask Question

For each vertex v of the DAG, in the topological ordering, compute the length of the longest path ending at v by looking at its incoming neighbors and adding one to the maximum length recorded for those neighbors. If v has no incoming neighbors, set the length of the longest path ending at v to zero. In either case, record this number so that later steps of the algorithm can access it.

+3
Answers (1)
  1. 20 April, 17:14
    0
    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)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “For each vertex v of the DAG, in the topological ordering, compute the length of the longest path ending at v by looking at its incoming ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers