graph = {
1: [2, 5, 9],
2: [1, 3],
3: [2, 4],
4: [3],
5: [1, 6, 8],
6: [5, 7],
7: [6],
8: [5],
9: [1, 10],
10: [9]
}
visited = []
def dfs_recursion(adjacent_graph, cur_node, visited_array):
# 구현해보세요!
visited_array.append(cur_node)
for i in adjacent_graph:
if i not in visited_array : #이게 사실상 탈출조건!!
dfs_recursion(adjacent_graph, i , visited_array)
dfs_recursion(graph, 1, visited) # 1 이 시작노드입니다!