(graph)
| 10 | |
| 11 | class Kosaraju { |
| 12 | constructor(graph) { |
| 13 | this.connections = {} |
| 14 | this.reverseConnections = {} |
| 15 | this.stronglyConnectedComponents = [] |
| 16 | for (const [i, j] of graph) { |
| 17 | this.addEdge(i, j) |
| 18 | } |
| 19 | this.topoSort() |
| 20 | return this.kosaraju() |
| 21 | } |
| 22 | |
| 23 | addNode(node) { |
| 24 | // Function to add a node to the graph (connection represented by set) |