Find the shortest path in a directed acyclic graph