From f015b3d65f193a8c382417e692e8cea305a9c863 Mon Sep 17 00:00:00 2001 From: Rafi Barash Date: Fri, 20 Sep 2019 21:57:22 -0500 Subject: [PATCH] Fix small issue with bfs algorithm 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.