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
INPUT GRAPHTARJAN'S ALGORITHMRESULT012Graph: [[1], [0,2], [1]]Linear chain of 3 verticesConnected: 0-1-21DFS from root2Assign discovery times3Calculate low values4Check critical conditionsVertex 1: low[2] ≥ disc[1] ✓Edge (1,2): low[2] > disc[1] ✓Articulation Points[1]Bridges[[0,1], [1,2]]All edges are criticalTime: O(V+E)Space: O(V)Key Insight:Tarjan's algorithm identifies all articulation points and bridges in a single DFS traversal by tracking discovery times and reachable ancestors through back edges.TutorialsPoint - Articulation Points and Bridges | Tarjan's Algorithm
Asked in
Google 15 Amazon 12 Microsoft 8 Facebook 6
28.5K Views
Medium Frequency
~35 min Avg. Time
890 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen