mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-15 02:59:50 +00:00
Make BFS file Python3 compatible
This commit is contained in:
parent
fcecd4d8b0
commit
ca09b78a8f
@ -29,7 +29,7 @@ class GRAPH:
|
|||||||
print('%d visited' % (u +1))
|
print('%d visited' % (u +1))
|
||||||
queue.pop(0)
|
queue.pop(0)
|
||||||
|
|
||||||
print self.graph
|
print(self.graph)
|
||||||
|
|
||||||
def add_edge(self, i, j):
|
def add_edge(self, i, j):
|
||||||
self.graph[i][j]=1
|
self.graph[i][j]=1
|
||||||
@ -51,7 +51,7 @@ g=GRAPH(n)
|
|||||||
e=int(input("Enter the no of edges : "))
|
e=int(input("Enter the no of edges : "))
|
||||||
print("Enter the edges (u v)")
|
print("Enter the edges (u v)")
|
||||||
for i in range(0,e):
|
for i in range(0,e):
|
||||||
u,v=map(int, raw_input().split())
|
u,v=map(int, input().split())
|
||||||
g.add_edge(u,v)
|
g.add_edge(u,v)
|
||||||
s=int(input("Enter the source node :"))
|
s=int(input("Enter the source node :"))
|
||||||
g.bfs(s)
|
g.bfs(s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user