“Tarjan有三种算法 你们知道吗”——Tar乙己

void tarjan(int x)
{
    low[x]=dfn[x]=++ind;
    q[++top]=x;mark[x]=1;
    for(int i=last[x];i;i=e[i].next)
        if(!dfn[e[i].to])
        {
            tarjan(e[i].to);
            low[x]=min(low[x],low[e[i].to]);
        }
        else if(mark[e[i].to])
            low[x]=min(low[x],dfn[e[i].to]);
    if(low[x]==dfn[x])
    {
        int now=0;scc++;
        while(now!=x)
        {
            now=q[top--];mark[now]=0;
            bl[now]=scc;num[scc]++;
        }
    }
}
缩点

相关文章:

  • 2021-09-16
  • 2022-12-23
猜你喜欢
  • 2021-08-31
  • 2022-01-17
  • 2022-12-23
  • 2021-12-30
  • 2021-10-05
相关资源
相似解决方案