Skip to content

Commit 742a130

Browse files
committedJun 30, 2017
Depth First Search Graph Traversals
1 parent c9d065b commit 742a130

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎Graph/P02_DepthFirstSearch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ def __init__(self):
66

77
# for printing the Graph vertexes
88
def printGraph(self):
9+
print(self.vertex)
910
for i in self.vertex.keys():
1011
print(i,' -> ', ' -> '.join([str(j) for j in self.vertex[i]]))
1112

@@ -34,7 +35,7 @@ def DFSRec(self, startVertex, visited):
3435
print(startVertex, end = ' ')
3536

3637
# Recur for all the vertexes that are adjacent to this node
37-
for i in self.vertex[startVertex]:
38+
for i in self.vertex.keys():
3839
if visited[i] == False:
3940
self.DFSRec(i, visited)
4041

0 commit comments

Comments
 (0)
Please sign in to comment.