Skip to content

Commit d55ad54

Browse files
authored
Simplify visited list update in DFS
1 parent 453dc05 commit d55ad54

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎graphs/directed_and_undirected_weighted_graph.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,7 @@ def dfs(self, s=-2, d=-1):
425425
s = stack.pop()
426426
if visited.count(s) == 1:
427427
continue
428-
else:
429-
visited.append(s)
428+
visited.append(s)
430429
# If reached d, return
431430
if s == d:
432431
break

0 commit comments

Comments
 (0)