Implement prototype(n, edges) and solve(n, edges). Vertices are 0..n-1; directed edges are [u, v, weight] with integer weights. Return an n-by-n minimum-cost matrix in vertex order, null for unreachable pairs, zero diagonal when no negative cycle exists. Keep the cheapest parallel edge. n=0 returns [].
For n=3 and edges [[0, 1, 3], [1, 2, 2], [0, 2, 9]], return [[0, 3, 5], [null, 0, 2], [null, null, 0]]. Negative n, invalid endpoints or any negative cycle throws RangeError.
Prototype: Bellman-Ford per vertex, propagating any cycle error. Final: Floyd-Warshall O(V³) time/O(V²) space. Preserve inputs on success and failure.
All numeric inputs and finite arithmetic results in this lesson are safe-integer Numbers. Use null for documented absence, not undefined or a numeric sentinel. Return actual booleans where the contract requires them. Do not add validation requirements beyond the documented inputs.
Run with Node.js 20+ from this directory:
node main.mjs --stage prototype
node main.mjs --stage finalEdit exercise.mjs; keep main.mjs unchanged. Both stages begin as unfinished learner functions. The website uses the same test functions in a separate browser worker. Tests check deterministic examples, boundaries, documented validation, input preservation, and stage-specific cases. Passing tests does not prove the required time complexity.
Complete the starter code, then run the checks.
Results and errors will appear here.