Compute shortest paths