From 9dcd981a5776f5b2d2ff2b5867a17a3d8fcf06d5 Mon Sep 17 00:00:00 2001 From: mounaim Date: Tue, 25 Jul 2017 16:08:54 +0100 Subject: [PATCH] Update Breadth_First_Search.py Fixed the fact that all nodes except source are marked as visited twice --- Graphs/Breadth_First_Search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Graphs/Breadth_First_Search.py b/Graphs/Breadth_First_Search.py index 5af471027..19b278093 100644 --- a/Graphs/Breadth_First_Search.py +++ b/Graphs/Breadth_First_Search.py @@ -15,10 +15,10 @@ class GRAPH: def bfs(self,s): queue=[s] + self.visited[s]=1 while len(queue)!=0: x=queue.pop(0) print(x) - self.visited[x]=1 for i in range(0,self.nodes): if self.graph[x][i]==1 and self.visited[i]==0: queue.append(i)