Find critical graph bridges
For a simple undirected graph on vertices 0 through n-1, return sorted [u,v] bridges with u<v, ordered lexicographically. An edge is a bridge if removing it increases component count.
entered_parent, entered_child, low_child = 1, 2, 2
print(low_child > entered_parent) # bridgeReason about the state
Depth-first discovery times and low-link values record whether a subtree can reach an ancestor without its parent edge. Explore every disconnected component. Before writing code, identify what each variable means after one iteration. Walk through the example and explain why the next transition preserves that meaning. Then check the smallest permitted input and a case with repeated values. A correct answer follows the contract for every input, including the boundary cases in the checks. Keep any input mutation within the stated rules; return a fresh result when the task asks for one.
Your task
For a simple undirected graph on vertices 0 through n-1, return sorted [u,v] bridges with u<v, ordered lexicographically. An edge is a bridge if removing it increases component count.
The explanation opens here once every check passes.