Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compute the critical path of a directional acyclic graph?

What is the best (regarding performance) way to compute the critical path of a directional acyclic graph when the nodes of the graph have weight?

For example, if I have the following structure:

            Node A (weight 3)
               /            \
     Node B (weight 4)      Node D (weight 7)
     /               \
Node E (weight 2)   Node F (weight 3)

The critical path should be A->B->F (total weight: 10)

like image 525
Panagiotis Korros Avatar asked Sep 20 '08 08:09

Panagiotis Korros


People also ask

How do you find shortest path in directed acyclic graph explain with an example?

Given a Weighted Directed Acyclic Graph and a source vertex in the graph, find the shortest paths from given source to all other vertices. For a general weighted graph, we can calculate single source shortest distances in O(VE) time using Bellman–Ford Algorithm.

What is the critical path in a graph?

The critical path (or paths) is the longest path (in time) from Start to Finish; it indicates the minimum time necessary to complete the entire project. This method of depicting a project graph differs in some respects from that used by James E. Kelley, Jr., and Morgan R.


1 Answers

I would solve this with dynamic programming. To find the maximum cost from S to T:

  • Topologically sort the nodes of the graph as S = x_0, x_1, ..., x_n = T. (Ignore any nodes that can reach S or be reached from T.)
  • The maximum cost from S to S is the weight of S.
  • Assuming you've computed the maximum cost from S to x_i for all i < k, the maximum cost from S to x_k is the cost of x_k plus the maximum cost to any node with an edge to x_k.
like image 65
James Cook Avatar answered Sep 22 '22 01:09

James Cook