void DFS(int v, ref bool[] was, DGraph G) { was[v] = true; for (int i = 0; i < G.VertexDegree(v); ++i) if (!was[G.GetEdge(v, i).End]) DFS(G.GetEdge(v, i).End, ref was, G); TS.Add(v); }
void AddSCC(int v, ref int[] mark, DGraph G) { mark[v] = SCCCount; SCCVrt[SCCCount].Add(v); for (int i = 0; i < G.VertexDegree(v); ++i) if (mark[G.GetEdge(v, i).End] == SCCCount || mark[G.GetEdge(v, i).End] == -1) { SCCEdg[SCCCount].Add(G.GetEdge(v, i).Reverse()); if (mark[G.GetEdge(v, i).End] == -1) AddSCC(G.GetEdge(v, i).End, ref mark, G); } }