Define dfn[] For each point of the timestamp (search order), low[] The DFN of the lowest DFN ancestor that can be traced to each point, that is, the most shallow ancestor
Prove I really will not, can only own yy, do not make sure that every sentence is correct, if my analysis has errors please must point out ...
Go to DFS first. A graph with an SCC must have a ring, so when you search for a point that has been visited, we have found a ring, at this time all the points on this ring must be strong unicom (as the earth is round, so all along in a direction can return to the starting point), this ring is a strong unicom child map, The last thing we looked for was a great ring.
To save the read point with the stack, each encounter with a dfn==low point indicates that the ancestor of the ring was found, bouncing the ancestor and the point after which it was added to the stack, and marking the flag[pop-up point]=false,
Flag is used to make sure that a ring is picked out so that the other rings are not affected by one of the one-way edges of a ring on the ring that should be removed .
void Tarjan (int x) {
dfn[x] = low[x] = ++count;
S[++top] = x;
FLAG[X] = 1;
for (int i=last[x]; i; i=e[i].next) {
int v = e[i].to;
if (!dfn[v]) {
Tarjan (v);
if (Low[x] > Low[v])
low[x] = low[v];
else if (Dfn[v] < low[x] && Flag[v])
low[x] = dfn[v];
if (dfn[x] = = Low[x]) {
int j,k = 0;
do{
j = s[top--];
FLAG[J] = 0;
k++;
} while (j!=x);
}
}