Cut Edge: directly search (mark the reverse side), find the mark, and V is the cut edge if the time stamp U-> V is greater than U.
For (I = head [u]; I! =-1; I = edge [I]. next) {If (edge [I]. mk) continue; edge [I ^ 1]. mk = 1; V = edge [I]. v; If (! Mark [v]) DFS (V); Dep [u] = f_min (DEP [u], DEP [v]); If (DEP [v]> now [u]) {// edge [I] is a cut edge} edge [I ^ 1]. mk = 0 ;}
Cut point: if the successor node fails to find a point lighter than u, the U is the cut point. If you encounter a V that has not been searched, you can also find the point u that can be searched by V. However, if you encounter a V that has already been searched, the point it can find does not mean that u can also be searched, because V may be the point to be judged, and we cannot pass it. Therefore, the V judgment is slightly different from the above judgment.
For (I = head [u]; I! =-1; I = edge [I]. next) {If (edge [I]. mk) continue; edge [I ^ 1]. mk = 1; V = edge [I]. v; If (! Mark [v]) {/* The V */DFS (v) that can be searched out; Dep [u] = f_min (DEP [u], DEP [v]);} else Dep [u] = f_min (DEP [u], now [v]); If (DEP [v]> = now [u]) {// U is the cut point (as long as one V is satisfied)} edge [I ^ 1]. mk = 0 ;}
CodeI forgot to add one point: U is the cut point. If U is the root node, it cannot be regarded as the cut point, but it depends on whether there are two or more V that can be searched out.
Strongly Connected contraction point: you need to create more instk arrays to indicate whether a point is in the current search path (if a searched point is found in an undirected graph, it must be in the current search path, therefore, this array is not required ).
Dep update only requires = f_min (DEP [u], DEP [v.
For (I = head [u]; I! =-1; I = edge [I]. Next) {v = edge [I]. V; If (MARK [v]) continue; If (! Instk [v]) DFS (V); Dep [u] = f_min (DEP [u], DEP [v]);} if (DEP [u]> = now [u]) {// until u in the stack is a strongly connected component}
Every time you do this kind of question, you always have to think about it again. The simple method is not very popular with Templates. Let's just summarize it.