Skip to content

Commit 3a1279c

Browse files
authored
Update 6.py
1 parent abc4239 commit 3a1279c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

10/6.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
def topology_sort():
1919
result = [] # 알고리즘 수행 결과를 담을 리스트
2020
q = deque() # 큐 기능을 위한 deque 라이브러리 사용
21+
2122
# 처음 시작할 때는 진입차수가 0인 노드를 큐에 삽입
2223
for i in range(1, v + 1):
2324
if indegree[i] == 0:
2425
q.append(i)
26+
2527
# 큐가 빌 때까지 반복
2628
while q:
2729
# 큐에서 원소 꺼내기
@@ -33,6 +35,7 @@ def topology_sort():
3335
# 새롭게 진입차수가 0이 되는 노드를 큐에 삽입
3436
if indegree[i] == 0:
3537
q.append(i)
38+
3639
# 위상 정렬을 수행한 결과 출력
3740
for i in result:
3841
print(i, end=' ')

0 commit comments

Comments
 (0)