An algorithm for the ranking of shortest paths