Finding the shortest path in a directed graph.