Topological sort will sort the nodes in a [[directed acyclic graph]] in an order that maintains the dependencies (the critical path). Use [[depth first search]] and then sort the nodes by descending finish times. Confirm there is no back edge in the depth first search to ensure the graph is truly acyclic (or else the sort is possible but non-sensical).