Minimum vertex cut

Write codeHard40 min

Your task

Given an undirected graph with n nodes (0..n-1) and edges [u, v], and two distinct non-adjacent-or-adjacent nodes s and t, return the minimum number of intermediate vertices (other than s and t) whose removal disconnects t from s. By Menger's theorem this equals the maximum number of internally vertex-disjoint s-t paths. Use the node-splitting trick (split each vertex into in/out with a unit internal edge, infinite for s and t) and run max flow. Assume 1 <= n <= 120.

Examples

min_vertex_cut_st(n: int, edges: list[list[int]], s: int, t: int) -> int
Example 1
Inputmin_vertex_cut_st(4, [[0, 1], [0, 2], [1, 3], [2, 3]], 0, 3)
Output2