Is the Graph Biconnected?

Determine whether an undirected graph is biconnected. A graph is biconnected if it is connected and remains connected after removing any single vertex. Pattern focus: Articulation Points. A graph is biconnected exactly when it has no cut vertices.

Input Format

n = number of vertices, edges = undirected edges [u, v]

Output Format

true if the graph is connected and has no articulation point

Constraints

  • 1 <= n <= 10^5
  • 1 <= edges.length <= 2 * 10^5

Examples

Example 1:

Input:

n = 4
edges = [[1,2],[2,3],[3,4],[4,1]]

Output:

true

Explanation:

A simple cycle is biconnected.

Example 2:

Input:

n = 4
edges = [[1,2],[2,3],[3,4]]

Output:

false

Explanation:

A path has articulation points, so it is not biconnected.

Example 3:

Input:

n = 5
edges = [[1,2],[2,3],[3,1],[3,4],[4,5]]

Output:

false

Explanation:

Vertex 3 is a cut vertex, so the graph is not biconnected.

Loading...
Is the Graph Biconnected? - Advanced Graphs