We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent abc4239 commit 3a1279cCopy full SHA for 3a1279c
1 file changed
10/6.py
@@ -18,10 +18,12 @@
18
def topology_sort():
19
result = [] # 알고리즘 수행 결과를 담을 리스트
20
q = deque() # 큐 기능을 위한 deque 라이브러리 사용
21
+
22
# 처음 시작할 때는 진입차수가 0인 노드를 큐에 삽입
23
for i in range(1, v + 1):
24
if indegree[i] == 0:
25
q.append(i)
26
27
# 큐가 빌 때까지 반복
28
while q:
29
# 큐에서 원소 꺼내기
@@ -33,6 +35,7 @@ def topology_sort():
33
35
# 새롭게 진입차수가 0이 되는 노드를 큐에 삽입
34
36
37
38
39
# 위상 정렬을 수행한 결과 출력
40
for i in result:
41
print(i, end=' ')
0 commit comments