#K85437. Articulation Points in an Undirected Graph

    ID: 36641 Type: Default 1000ms 256MiB

Articulation Points in an Undirected Graph

Articulation Points in an Undirected Graph

You are given an undirected graph with V vertices and E edges. An articulation point (or cut vertex) in a graph is a vertex whose removal increases the number of connected components in the graph. Your task is to find all such vertices in the graph and output them in ascending order.

The graph is provided in the following format:

  • The first line contains an integer V, the number of vertices.
  • The second line contains an integer E, the number of edges.
  • Each of the next E lines contains two integers u and v (0-indexed) representing an undirected edge between vertex u and vertex v.

If no articulation points exist in the graph, output an empty line.

The standard algorithm utilizes a depth-first search (DFS) approach with discovery times and low values defined by the following formulas in LaTeX:

disc[u]=timedisc[u] = time $$low[u] = \min\{disc[u], \min_{v \text{ is a child of } u}(low[v]), \min_{v \text{ is a back edge from } u}(disc[v])\}\}

An articulation point is found if for a vertex u (with parent not equal to -1), there exists a child v such that:

$$low[v] \ge disc[u]$$

For the root of the DFS tree (where parent == -1), it is an articulation point if and only if it has more than one child.

inputFormat

The input is given via standard input (stdin) in the following format:

  • The first line contains an integer V — the number of vertices in the graph.
  • The second line contains an integer E — the number of edges in the graph.
  • Then follows E lines, each containing two space-separated integers u and v (0-indexed) indicating an undirected edge between vertices u and v.

outputFormat

Output a single line to standard output (stdout) containing the articulation points in ascending order separated by a space. If there are no articulation points, print an empty line.

## sample
5
5
0 1
1 2
2 0
1 3
3 4
1 3