From c43337fdfbf0ef7f0a2d32f6a0f6cd0cd627f5e2 Mon Sep 17 00:00:00 2001 From: Rafi Barash Date: Fri, 20 Sep 2019 22:10:12 -0500 Subject: [PATCH] Fix small issue with bfs algorithm (#141) Algorithm performed a dfs rather than bfs because of the queue.pop() error on line 78. Updated to queue.popleft() --- contents/algorithms/graph.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/algorithms/graph.md b/contents/algorithms/graph.md index 51defd02..44fd9850 100644 --- a/contents/algorithms/graph.md +++ b/contents/algorithms/graph.md @@ -75,7 +75,7 @@ def bfs(matrix): def traverse(i, j): queue = deque([(i, j)]) while queue: - curr_i, curr_j = queue.pop() + curr_i, curr_j = queue.popleft() if (curr_i, curr_j) not in visited: visited.add((curr_i, curr_j)) # Traverse neighbors.