mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01: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
|
# b c
|
||||||
# / \
|
# / \
|
||||||
# d e
|
# d e
|
||||||
edges = {"a": ["c", "b"], "b": ["d", "e"], "c": [], "d": [], "e": []}
|
edges: dict[str, list[str]] = {
|
||||||
vertices = ["a", "b", "c", "d", "e"]
|
"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."""
|
"""Perform topological sort on a directed acyclic graph."""
|
||||||
current = start
|
current = start
|
||||||
# add current to visited
|
# add current to visited
|
||||||
|
|
Loading…
Reference in New Issue
Block a user