Not early, the first template, do some questions to analyze it;
the strongly connected Tarjan algorithm + forward star template is as follows:
Const intmaxn= the;Const intmaxm=10010;structedge{intTo,next;}; Edge E[MAXN];intHead[maxn],ecou;intStack[maxn],top;intBelong[maxn],lfcou;intIndex;intDFN[MAXN],LOW[MAXN];BOOLINSTACK[MAXN];voidTarjan (intu) { intv; Low[u]=dfn[u]=++Index; Stack[top++]=u; Instack[u]=1; for(inti=head[u];i!=-1; i=E[i].next) {v=e[i].to; if(!Dfn[v]) {Tarjan (v); if(low[u]>Low[v]) Low[u]=Low[v]; } Else if(instack[v]&&low[u]>Dfn[v]) Low[u]=Dfn[v]; } if(low[u]==Dfn[u]) { ++Lfcou; Do{v=stack[--top]; INSTACK[V]=0; BELONG[V]=Lfcou; } while(v!=u)}}voidGETSCC (intN) { for(intI=1; i<=n;i++) if(!Dfn[i]) Tarjan (i);}voidAdd_edge (intUintv) {e[ecou].to=v; E[ecou].next=Head[u]; Head[u]=ecou++;}voidInitintN) {Ecou=index=lfcou=top=0; for(intI=1; i<=n;i++) {Instack[i]=dfn[i]=0; Head[i]=-1; }}
Connectivity of graphs: a strong connected-tarjan algorithm