diff --git a/data_structures/Graph/Breadth_First_Search.py b/data_structures/Graph/Breadth_First_Search.py index 1a3fdfd4d90f..97a51c6b16dd 100644 --- a/data_structures/Graph/Breadth_First_Search.py +++ b/data_structures/Graph/Breadth_First_Search.py @@ -29,20 +29,7 @@ def bfs(self,v): print('%d visited' % (u +1)) queue.pop(0) -g = Graph(10) - -g.add_edge(1,2) -g.add_edge(1,3) -g.add_edge(1,4) -g.add_edge(2,5) -g.add_edge(3,6) -g.add_edge(3,7) -g.add_edge(4,8) -g.add_edge(5,9) -g.add_edge(6,10) -g.bfs(4) -======= - print self.graph + print(self.graph) def add_edge(self, i, j): self.graph[i][j]=1 @@ -64,7 +51,7 @@ def bfs(self,s): e=int(input("Enter the no of edges : ")) print("Enter the edges (u v)") for i in range(0,e): - u,v=map(int, raw_input().split()) + u,v=map(int, input().split()) g.add_edge(u,v) s=int(input("Enter the source node :")) g.bfs(s) diff --git a/data_structures/Graph/Deep_First_Search.py b/data_structures/Graph/Deep_First_Search.py index 656ddfbafd34..b1160eb33f3e 100644 --- a/data_structures/Graph/Deep_First_Search.py +++ b/data_structures/Graph/Deep_First_Search.py @@ -7,7 +7,7 @@ def __init__(self, nodes): def show(self): - print self.graph + print(self.graph) def add_edge(self, i, j): self.graph[i][j]=1 @@ -26,7 +26,7 @@ def dfs(self,s): e=int(input("Enter the no of edges : ")) print("Enter the edges (u v)") for i in range(0,e): - u,v=map(int, raw_input().split()) + u,v=map(int, input().split()) g.add_edge(u,v) s=int(input("Enter the source node :")) g.dfs(s)