Floyd Warshall All Pairs

Given a directed weighted graph with n vertices labeled from 0 to n - 1 and a list of directed edges, compute the shortest path distance from every vertex to every other vertex.

Each edge is given as [u, v, w], representing a directed edge from u to v with weight w. If multiple edges connect the same ordered pair, the edge with the smallest weight applies. There are no negative-weight cycles.

Return an n x n matrix dist where dist[i][j] is the length of the shortest path from i to j. If j is not reachable from i, set dist[i][j] = -1. The distance from every vertex to itself is 0. Weights can be negative, so a reachable shortest distance may itself equal -1; that entry and an unreachable entry are reported with the same value.

Examples
Input: [3,[[0,1,2],[1,2,1]]]
Output: [[0,2,3],[-1,0,1],[-1,-1,0]]
Hints

Floyd Warshall All Pairs

Given a directed weighted graph with `n` vertices labeled from `0` to `n - 1` and a list of directed edges, compute the shortest path distance from every vertex to every other vertex.