Require reachability in both directions
Vertices u and v belong to the same strongly connected component when a directed path exists from u to v and from v to u. A zero-length path makes each vertex reachable from itself, so an isolated vertex is also a component. This differs from connectivity after ignoring edge directions: a one-way connection is not enough. Mutual reachability is an equivalence relation and therefore partitions the vertices into disjoint groups. Every pair inside a group need not have a direct edge. Paths through other vertices of the group are sufficient.
Condense an example into a DAG
For edges A→B, B→A, B→C, C→D, D→C and D→E, the components are {A,B}, {C,D} and {E}. Contracting each group produces a chain from the first component to the second and then to the third. A directed cycle among contracted components would imply that their vertices are mutually reachable, contradicting their separation. The condensation is consequently a DAG even when the original graph has cycles. This allows dependency reasoning at the component level, while retaining the information that vertices inside one component cannot be separated into a one-way order.
Use the correct pair of traversal orders
A Kosaraju-style algorithm computes DFS finishing order in the reversed graph, then processes the original graph in reverse finishing order. Each DFS started from an unassigned vertex collects one strongly connected component. The choice of reversed graph for the first traversal and reverse finishing order for the second belong together. Replacing that order with vertex numbers or DFS discovery order can merge different components incorrectly. A symmetric formulation exchanges the original and reversed graphs; it is also valid when used consistently. Do not mix the first pass of one formulation with the second pass of the other.
Measure representation and output costs
With adjacency lists, two DFS traversals and construction of the reversed graph take O(V+E) time. Explicitly storing reversed edges also uses O(V+E) space, in addition to O(V) marks and component identifiers. Deep graphs may exceed a language’s recursive call-stack limit, motivating an explicit stack. Component numbers are implementation-dependent labels and need not themselves be a topological ranking. Test the partition through mutual reachability or independent small-graph checks, and verify that the condensation is acyclic. Comparing arbitrary numeric component labels is not a reliable correctness test.