Skip to content
DeepForgeby svx
All problems
HardGraph Algorithmsgraph-038

Articulation Points Count

Problem

Count the articulation points of an undirected graph with n nodes: nodes whose removal increases the number of connected components.

A non-root node v is an articulation point when some DFS child w has low[w] >= disc[v]; the DFS root qualifies when it has more than one child. edges is a list of [u, v] pairs.

Hint

The root is special: it is an articulation point only with two or more DFS children.

Test cases

case 1
in: [4,[[0,1],[1,2],[2,3]]]
expected: 2
case 2
in: [3,[[0,1],[1,2],[2,0]]]
expected: 0
case 3
in: [4,[[0,1],[0,2],[0,3]]]
expected: 1
case 4
in: [5,[[0,1],[1,2],[2,0],[2,3],[3,4],[4,2]]]
expected: 1
case 5
in: [6,[[0,1],[1,2],[3,4],[4,5]]]
expected: 2
Starter codePython
def count_articulation_points(n, edges):
    # Your code here
    pass

5 test cases · run your code against them in the editor