Skip to content

Commit 220894e

Browse files
Add typing
1 parent 81661bd commit 220894e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: sorts/topological_sort.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
# b c
66
# / \
77
# d e
8-
edges = {"a": ["c", "b"], "b": ["d", "e"], "c": [], "d": [], "e": []}
9-
vertices = ["a", "b", "c", "d", "e"]
8+
edges: dict[str, list[str]] = {"a": ["c", "b"], "b": ["d", "e"], "c": [], "d": [], "e": []}
9+
vertices: list[str] = ["a", "b", "c", "d", "e"]
1010

1111

12-
def topological_sort(start, visited, sort):
12+
def topological_sort(start: str, visited: list[str], sort: list[str]) -> list[str]:
1313
"""Perform topological sort on a directed acyclic graph."""
1414
current = start
1515
# add current to visited

0 commit comments

Comments
 (0)