I'm a senior student learing informatics olympiad on algorithms, and this is my first question on stackoverflow.
In tarjan's dfs search getting lowlink(u):
low[u]=min(low[u],low[v]) (v isn't visited)
or
low[u]=min(low[u],dfn[v]) (v is still in the stack)
My question is, is it still ok to replace dfn[v] for low[v] in the second case? I know this is incorrect, but I failed finding a counter-example. Could anyone help explain this?
thx:)
 
                        
It's correct, actually.
The proof of correctness depends on two properties of
low. The first is that, for allv, there existswreachable fromvsuch thatdfn[w] <= low[v] <= dfn[v]. The second is that, when determining whethervis a root, we have for allwreachable fromvthatlow[v] <= dfn[w].We can prove inductively that the first property still holds by the fact that, if there's a path from
utovand a path fromvtow, then there's a path fromutow. As for the second, letlowbe the original array andlow'be yours. It's not hard to show that, for allv, at all times,low'[v] <= low[v], so at the critical moment forv, for allwreachable fromv, it holds thatlow'[v] <= low[v] <= dfn[w].I imagine that the algorithm is presented the way it is to avoid the need to consider intermediate values of
low.