We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 239b8c8 commit 7ac458dCopy full SHA for 7ac458d
sorts/topological_sort.py
@@ -17,11 +17,11 @@
17
18
def topological_sort(start: str, visited: list[str], sort: list[str]) -> list[str]:
19
"""Perform topological sort on a directed acyclic graph."""
20
+ # consider edge direction from top to bottom
21
current = start
22
# add current to visited
23
visited.append(current)
24
neighbors = edges[current]
- # direction not given so consider from top to bottom
25
# as the current node encounter add it to the topo sort list
26
sort.append(current)
27
for neighbor in neighbors:
0 commit comments