Skip to content

Commit

Permalink
Update dfs_stack.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dremdeveloper authored Oct 2, 2023
1 parent b01b1e7 commit 617c4c5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Algorithm_with_DataStructure/dfs_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
def dfs(graph, start_node):
visited = [False] * (len(graph) + 1)
stack = [start_node]
visited[start_node] = True;

while stack:
node = stack.pop()

print(node)

for adj_node in graph[node]: # 인접한 노드 방문
if not visited[adj_node]:
stack.append(adj_node)
visited[adj_node] = True;
visited[adj_node] = True;


# 그래프를 인접 리스트로 표현
Expand Down

0 comments on commit 617c4c5

Please sign in to comment.