Shortest Path by Topological Sorting