Merge pull request #98 from moun3imy/patch-1

Update Breadth_First_Search.py
This commit is contained in:
Praveen 2017-08-08 13:36:58 +05:30 committed by GitHub
commit efb77ad7c1

View File

@ -15,10 +15,10 @@ class GRAPH:
def bfs(self,s): def bfs(self,s):
queue=[s] queue=[s]
self.visited[s]=1
while len(queue)!=0: while len(queue)!=0:
x=queue.pop(0) x=queue.pop(0)
print(x) print(x)
self.visited[x]=1
for i in range(0,self.nodes): for i in range(0,self.nodes):
if self.graph[x][i]==1 and self.visited[i]==0: if self.graph[x][i]==1 and self.visited[i]==0:
queue.append(i) queue.append(i)