原理
强连通分量
void tarjan(int x)
{
dfn[x] = low[x] = t ++;
s.push(x);
in[x] = true;
for (int i = h[x]; i ; i = e[i].next)
{
int y = e[i].to;
if (!dfn[y])
{
tarjan(y);
low[x] = min(low[x], low[y]);
}
else if (in[y])
low[x] = min(low[x], dfn[y]);
}
if (dfn[x] == low[x])
{
while (s.top() != x)
{
in[s.top()] = false;
cout << s.top() << ' ';
s.pop();
}
in[s.top()] = false;
cout << s.top() << '\n';
s.pop();
}
}
标签:Tarjan,min,int,top,tarjan,笔记,学习,dfn,low
From: https://www.cnblogs.com/hi-zwjoey/p/17639690.html