Skip to content

Commit 1186d21

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 3d3d5aa commit 1186d21

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sorts/topological_sort.py

+4-2
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)