You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: graph/tarjan.ts
+22-23Lines changed: 22 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,29 @@
1
1
/**
2
2
* @function tarjan
3
-
* @description Given a graph, find the strongly connected components(SCC). A set of nodes form a SCC if there is a path between all pairs of points within that set.
3
+
* @description Given a graph, find the strongly connected components(SCC) in reverse topological order. A set of nodes form a SCC if there is a path between all pairs of points within that set.
4
4
* @Complexity_Analysis
5
5
* Time complexity: O(V + E). We perform a DFS of (V + E)
6
6
* Space Complexity: O(V). We hold numerous structures all of which at worst holds O(V) nodes.
7
7
* @param {[number, number][][]} graph - The graph in adjacency list form
8
-
* @return {number[][]} - An array of SCCs, where an SCC is an array with the indices of each node within that SCC.
8
+
* @return {number[][]} - An array of SCCs, where an SCC is an array with the indices of each node within that SCC. The order of SCCs in the array are in reverse topological order.
0 commit comments