procedure Tarjan(u:longint);
begin
num:=num+1;
dfn[u]:=num;
low[u]:=num;
inc(top);
st[top]:=u;
i:=head[u];
while i<>0 do begin
v:=vet[i];
if dfn[v]>0 then begin
begin
tarjan(v);
low[u]:=min(low[u],low[v]);
end
else if co[v]>0 then begin
low[u]:=min(low[u],dfn[v]);
end;
if low[u]=dfn[u] then begin
inc(col);
co[u]:=col;
while st[top]<>u do
begin
co[st[top]]:=col;
dec(top);
end;
dec(top);
end;
end;
强联通tarjan
最新推荐文章于 2020-02-21 17:06:04 发布