Minimum vertex cut
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.
Implement
min_vertex_cut_st(n: int, edges: list[list[int]], s: int, t: int) → intExamples
in
[4,[[0,1],[0,2],[1,3],[2,3]],0,3]out2What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 40 min
solution.py
InputExpectedGot
[4,[[0,1],[0,2],[1,3],[2,3]],0,3]2not run yetsample