mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Add typing to topological_sort.py (#9650)
* Add typing * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Jeremy Tan <jeremytan@stripe.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
81661bd2d0
commit
12431389e3
|
@ -5,11 +5,17 @@
|
|||
# b c
|
||||
# / \
|
||||
# d e
|
||||
edges = {"a": ["c", "b"], "b": ["d", "e"], "c": [], "d": [], "e": []}
|
||||
vertices = ["a", "b", "c", "d", "e"]
|
||||
edges: dict[str, list[str]] = {
|
||||
"a": ["c", "b"],
|
||||
"b": ["d", "e"],
|
||||
"c": [],
|
||||
"d": [],
|
||||
"e": [],
|
||||
}
|
||||
vertices: list[str] = ["a", "b", "c", "d", "e"]
|
||||
|
||||
|
||||
def topological_sort(start, visited, sort):
|
||||
def topological_sort(start: str, visited: list[str], sort: list[str]) -> list[str]:
|
||||
"""Perform topological sort on a directed acyclic graph."""
|
||||
current = start
|
||||
# add current to visited
|
||||
|
|
Loading…
Reference in New Issue
Block a user