Kahn's algorithm processes a directed graph using indegrees. Pick the tightest time complexity.
functiontopo(graph, indegree){const queue =[]for(const node of graph)if(indegree[node]===0) queue.push(node)const order =[]for(let i =0; i < queue.length; i++){const node = queue[i] order.push(node)for(const next of graph[node]){if(--indegree[next]===0) queue.push(next)}}return order
}