Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 200e11f

Browse files
committedOct 27, 2024·
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d0e0ea1 commit 200e11f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎sorts/topological_sort.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
vertices: list[str] = ["a", "b", "c", "d", "e"]
1818

19+
1920
# Perform topological sort on a DAG starting from the specified node
2021
def topological_sort(start: str, visited: list[str], sort: list[str]) -> list[str]:
2122
current = start
@@ -42,11 +43,12 @@ def topological_sort(start: str, visited: list[str], sort: list[str]) -> list[st
4243
# Return sorted list
4344
return sort
4445

46+
4547
if __name__ == "__main__":
4648
# Topological Sorting from node "a" (Returns the order in bottom up approach)
4749
sort = topological_sort("a", [], [])
4850

4951
# Reversing the list to get the correct topological order (Top down approach)
50-
sort.reverse()
52+
sort.reverse()
5153

52-
print(sort)
54+
print(sort)

0 commit comments

Comments
 (0)
Please sign in to comment.