from collections import deque
def solution(n, edge):
answer = 0
visited = [0] * (n+1)
graph = [[] for i in range(n+1)]
for e in edge:
graph[e[0]].append(e[1])
graph[e[1]].append(e[0])
q = deque([[1, 1]])
visited[1] = 1
while q:
node, deph = q.popleft()
for next_node in graph[node]:
if not visited[next_node]:
visited[next_node] = deph+1
q.append([next_node,deph+1])
_max = max(visited)
return visited.count(_max)
간단한 dfs 그래프 문제
어렵지 않은 문제였다.