mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-27 17:06:44 +00:00
Fixed compilation errors, fixes for readability/convention, changed double equals to boolean equality operator 'is'
This commit is contained in:
parent
3ecb193ae6
commit
dc5e86b701
@ -23,7 +23,7 @@ class GRAPH:
|
|||||||
v = queue[0]
|
v = queue[0]
|
||||||
for u in range(self.vertex):
|
for u in range(self.vertex):
|
||||||
if self.graph[v][u] == 1:
|
if self.graph[v][u] == 1:
|
||||||
if visited[u]== False:
|
if visited[u] is False:
|
||||||
visited[u] = True
|
visited[u] = True
|
||||||
queue.append(u)
|
queue.append(u)
|
||||||
print('%d visited' % (u +1))
|
print('%d visited' % (u +1))
|
||||||
@ -41,8 +41,8 @@ g.add_edge(4,8)
|
|||||||
g.add_edge(5,9)
|
g.add_edge(5,9)
|
||||||
g.add_edge(6,10)
|
g.add_edge(6,10)
|
||||||
g.bfs(4)
|
g.bfs(4)
|
||||||
=======
|
|
||||||
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
|
||||||
@ -63,8 +63,10 @@ n=int(input("Enter the number of Nodes : "))
|
|||||||
g = GRAPH(n)
|
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, raw_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