【模板】tarjan 基环树找环
作者:互联网
void tarjan(int x,int from){
dfn[x] = ++sz;
for (int i = head[x]; ~i; i = fail[i]) {
if (i == (from ^ 1)) continue;
int v = edge[i];
if (dfn[v]) {
if (dfn[v] < dfn[x]) continue;
cyc[x] = true;
for (; v != x; v = father[v]){ cyc[v] = true;}
}else father[v] = x, tarjan(v,i);
}
}
标签:tarjan,continue,int,father,基环树,dfn,true,模板 来源: https://www.cnblogs.com/wxywxywxy/p/15256543.html