Tarjan's algorithm
Tarjan's algorithm is a method used in graph theory to find the strongly connected components (SCCs) of a directed graph. An SCC is a subset of vertices where every vertex is reachable from every other vertex in that subset. The algorithm efficiently identifies these components using depth-first search (DFS) and maintains a stack to track the vertices.
The algorithm works by assigning each vertex a unique index and a low-link value, which indicates the smallest index reachable from that vertex. When a vertex is fully explored, it is popped from the stack, and if it is the root of an SCC, all vertices in that component are identified and output.