Tarjan's Algorithm #
This file implements Tarjan's algorithm for finding the strongly connected components (SCCs) of a graph.
State for Tarjan's algorithm.
- id : Std.HashMap â„• â„•
id[v]is the index of the vertexvin the DFS traversal. - lowlink : Std.HashMap â„• â„•
lowlink[v]is the smallest index of any node on the stack that is reachable fromvthroughv's DFS subtree. The stack of visited vertices used in Tarjan's algorithm.
- onStack : Std.HashSet â„•
onStack.contains viffvis instack. The structure is used to check it efficiently. - time : â„•
A time counter that increments each time the algorithm visits an unvisited vertex.
Instances For
The Tarjan's algorithm. See Wikipedia.
Finds the strongly connected components of the graph g. Returns a hashmap where the value at
key v represents the SCC number containing vertex v. The numbering of SCCs is arbitrary.