Articulation Points and Bridges - Problem
Given an undirected connected graph, find all articulation points (cut vertices) and bridges (cut edges) in the graph.
An articulation point is a vertex whose removal (along with its edges) increases the number of connected components in the graph.
A bridge is an edge whose removal increases the number of connected components in the graph.
Return a list containing two arrays: the first array contains all articulation points, and the second array contains all bridges (each bridge represented as an array of two vertices).
Input & Output
Example 1 — Simple Bridge Graph
$
Input:
graph = [[1], [0, 2], [1]]
›
Output:
[[1], [[0,1],[1,2]]]
💡 Note:
Vertex 1 is an articulation point because removing it disconnects vertices 0 and 2. Both edges [0,1] and [1,2] are bridges since removing either would split the graph into two components.
Example 2 — Triangle (No Critical Elements)
$
Input:
graph = [[1, 2], [0, 2], [0, 1]]
›
Output:
[[], []]
💡 Note:
This is a triangle (cycle of 3 vertices). No vertex is articulation point and no edge is bridge because removing any single element still keeps the graph connected through alternative paths.
Example 3 — Complex Graph
$
Input:
graph = [[1, 2], [0, 2, 3], [0, 1], [1, 4], [3]]
›
Output:
[[1, 3], [[3,4]]]
💡 Note:
Vertices 1 and 3 are articulation points. Vertex 1 connects the triangle {0,1,2} to vertex 3. Vertex 3 connects the main graph to vertex 4. Edge [3,4] is the only bridge.
Constraints
- 1 ≤ graph.length ≤ 1000
- 0 ≤ graph[i].length ≤ 1000
- 0 ≤ graph[i][j] ≤ graph.length - 1
- graph[i] does not contain duplicate values
- The graph is connected and undirected
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code