Skip to content

Commit beb499c

Browse files
author
robot
committed
fix: 图使用 deque
1 parent 8b58511 commit beb499c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/codeTemplates/grapth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def topologicalSort(graph):
342342
using BFS
343343
"""
344344
indegree = [0] * len(graph)
345-
queue = []
345+
queue = collections.deque([])
346346
topo = []
347347
cnt = 0
348348
@@ -355,7 +355,7 @@ def topologicalSort(graph):
355355
queue.append(i)
356356
357357
while queue:
358-
vertex = queue.pop(0)
358+
vertex = queue.popleft()
359359
cnt += 1
360360
topo.append(vertex)
361361
for x in graph[vertex]:

0 commit comments

Comments
 (0)