MCPcopy
hub / github.com/TheAlgorithms/JavaScript / topoSort

Method topoSort

Graphs/Kosaraju.js:50–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48 }
49
50 topoSort() {
51 // Function to perform topological sorting
52 const visited = new Set()
53 const nodes = Object.keys(this.connections).map((key) => Number(key))
54 for (const node of nodes) {
55 if (!visited.has(node)) this.dfsTopoSort(node, visited)
56 }
57 }
58
59 dfsKosaraju(node, visited) {
60 visited.add(node)

Callers 1

constructorMethod · 0.95

Calls 2

dfsTopoSortMethod · 0.95
hasMethod · 0.45

Tested by

no test coverage detected