Find the bridges of this graph with one DFS. Each vertex gets a discovery time, its position in the order label, and a low-link, the badge: the earliest discovery time it can reach by walking down tree edges and then along a single back edge. A tree edge u-v is a bridge when v cannot climb above u at all, low[v] > disc[u].
Finding bridges over 7 vertices.
Enter 0 at time 0: disc[0] = low[0] = 0. Until a back edge or a child says otherwise, the earliest vertex 0 can reach is itself.
Enter 0, discovery time 0.
Enter 1 at time 1: disc[1] = low[1] = 1. Until a back edge or a child says otherwise, the earliest vertex 1 can reach is itself.
Enter 1, discovery time 1.
Enter 2 at time 2: disc[2] = low[2] = 2. Until a back edge or a child says otherwise, the earliest vertex 2 can reach is itself.
Enter 2, discovery time 2.
Edge 2-0 leads to a vertex seen at time 0, an ancestor on the current path. That is earlier than low[2] = 2, so low[2] becomes 0: 2 can climb to 0.
Back edge 2 to 0, low of 2 is 0.
Enter 3 at time 3: disc[3] = low[3] = 3. Until a back edge or a child says otherwise, the earliest vertex 3 can reach is itself.
Enter 3, discovery time 3.
Enter 4 at time 4: disc[4] = low[4] = 4. Until a back edge or a child says otherwise, the earliest vertex 4 can reach is itself.
Enter 4, discovery time 4.
Enter 5 at time 5: disc[5] = low[5] = 5. Until a back edge or a child says otherwise, the earliest vertex 5 can reach is itself.
Enter 5, discovery time 5.
Edge 5-3 leads to a vertex seen at time 3, an ancestor on the current path. That is earlier than low[5] = 5, so low[5] becomes 3: 5 can climb to 3.
Back edge 5 to 3, low of 5 is 3.
Enter 6 at time 6: disc[6] = low[6] = 6. Until a back edge or a child says otherwise, the earliest vertex 6 can reach is itself.
Enter 6, discovery time 6.
dfs(6) returned with low[6] = 6. low[5] stays 3. low[6] = 6 > disc[5] = 5: nothing below 6 reaches 5 or above, so 5-6 is a bridge.
Back in 5, low 3.
dfs(5) returned with low[5] = 3. low[4] drops to 3. low[5] = 3 <= disc[4] = 4: a back edge below 5 reaches 4 or higher, so 4-5 lies on a cycle.
Back in 4, low 3.
dfs(4) returned with low[4] = 3. low[3] stays 3. low[4] = 3 <= disc[3] = 3: a back edge below 4 reaches 3 or higher, so 3-4 lies on a cycle.
Back in 3, low 3.
Edge 3-5 leads to a vertex seen at time 5, already finished. low[3] = 3 is already that early or earlier, so nothing changes.
Back edge 3 to 5, low of 3 is 3.
dfs(3) returned with low[3] = 3. low[2] stays 0. low[3] = 3 > disc[2] = 2: nothing below 3 reaches 2 or above, so 2-3 is a bridge.
Back in 2, low 0.
dfs(2) returned with low[2] = 0. low[1] drops to 0. low[2] = 0 <= disc[1] = 1: a back edge below 2 reaches 1 or higher, so 1-2 lies on a cycle.
Back in 1, low 0.
dfs(1) returned with low[1] = 0. low[0] stays 0. low[1] = 0 <= disc[0] = 0: a back edge below 1 reaches 0 or higher, so 0-1 lies on a cycle.
Back in 0, low 0.
Edge 0-2 leads to a vertex seen at time 2, already finished. low[0] = 0 is already that early or earlier, so nothing changes.
Back edge 0 to 2, low of 0 is 0.
Bridges: 5-6, 2-3. Each is the only route between its two sides. every other edge lies on a cycle. Found by one DFS, O(V + E).
2 bridges.