You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9 lines
264 B
C++

void tarjan(int u, int p)
{
dfn[u] = low[u] = ++idx;
for (int e = head[u]; e; e = next[e])
if (!dfn[to[e]])
tarjan(to[e], u), low[u] = min(low[u], low[to[e]]);
else if (to[e] != p)
low[u] = min(low[u], dfn[to[e]]);
}