contents/graph: use popleft() instead of pop() in Topological sort queue (#685)

This commit is contained in:
Shreyash 2026-03-20 10:58:47 +05:30 committed by GitHub
parent adb77f4e32
commit 4b0cc4392f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -180,7 +180,7 @@ def graph_topo_sort(num_nodes, edges):
if nodes[node_id]['in'] == 0:
queue.append(node_id)
while len(queue):
node_id = queue.pop()
node_id = queue.popleft()
for outgoing_id in nodes[node_id]['out']:
nodes[outgoing_id]['in'] -= 1
if nodes[outgoing_id]['in'] == 0: