An all-pair shortest path problem from a programming competition.
Wormholes can reduce the travel distance between some planets to zero. Given the location of Earth, planets, and wormholes, the goal is to determine the shortest travel distance between any pairs of planets. This problem uses a complete directed graph, and the existence of wormholes will influence the weight of some edges. The solution uses Floyd-Warshall algorithm to compute all-pair shortest paths.