il void tarjan(int u)
{
dfn[u]=low[u]=++num,st[++top]=u,ins[u]=1;
G(i,u)
{
int v=ver[i];
if(!dfn[v])
{
tarjan(v);
low[u]=min(low[u],low[v]);
}
else if(ins[v]) low[u]=min(low[u],dfn[v]);
}
if(dfn[u]==low[u])
{
int t=0;
cnt++;
do
{
t=st[top--];
scc[t]=cnt;
……
……
……
ins[t]=0;
}while(u!=t);
}
}
il void solve()
{
F(i,1,n) if(!dfn[i]) tarjan(i);
memset(head,0,sizeof(head));
memset(nxt,0,sizeof(nxt));
tot=0;
F(i,1,m) if(scc[x[i]]!=scc[y[i]]) add(scc[x[i]],scc[y[i]]);
}
标签:tarjan,int,scc,ins,dfn,low,模板
From: https://www.cnblogs.com/MooSheng/p/17627004.html