Original link: https://blog.aeilot.top/2022/12/04/cut-vertex/
I recently learned graph theory, and wrote a problem solution to record it.
definition
- For an undirected graph, if the number of maximum connected components of the graph increases after a point is deleted, then this point is the cut point (also known as the cut top) of the graph.
This blog mainly introduces that the Tarjan algorithm is used to find cut points.
cut point
Tarjan algorithm, record the node access time stamp dfn
, and the time stamp low
of the earliest point that the node can go back to.
For a certain point:
- If this point is the root node and there are more than two connected components connected to it, then this point is a cut point.
- If the successor of a certain point is a connected component, and this point is not the root node, then this point is a cut point.
the first case
We need to record the root node fa
. When traversing, if fa
is repeatedly visited, it means that a connected component under fa
has been found.
the second case
Assuming the current point s
, for the next node y
to visit:
If low[y] >= dfn[s]
, it means that there is a connected component under this point.
Note: This is similar to min(low[s],dfn[y])
we did when Tarjan was seeking SCC.
the code
1 |
void tarjan ( int s, int fa) { |
This article is transferred from: https://blog.aeilot.top/2022/12/04/cut-vertex/
This site is only for collection, and the copyright belongs to the original author.