Skip to content

Commit 834e228

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 6a6876f commit 834e228

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sorts/topological_sort.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
vertices: list[str] = ["a", "b", "c", "d", "e"]
1818

1919
"""Perform topological sort on a directed acyclic graph(DAG) starting from the specified node"""
20+
21+
2022
def topological_sort(start: str, visited: list[str], sort: list[str]) -> list[str]:
2123
current = start
2224
# Mark the current node as visited
@@ -42,11 +44,12 @@ def topological_sort(start: str, visited: list[str], sort: list[str]) -> list[st
4244
# Return sorted list
4345
return sort
4446

47+
4548
if __name__ == "__main__":
4649
# Topological Sorting from node "a" (Returns the order in bottom up approach)
4750
sort = topological_sort("a", [], [])
4851

4952
# Reversing the list to get the correct topological order (Top down approach)
50-
sort.reverse()
53+
sort.reverse()
5154

52-
print(sort)
55+
print(sort)

0 commit comments

Comments
 (0)