mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-05-09 05:43:57 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
e3c6e81716
commit
7a2ee6eba2
@ -14,10 +14,12 @@ edges: dict[str, list[str]] = {
|
||||
}
|
||||
vertices: list[str] = ["a", "b", "c", "d", "e"]
|
||||
|
||||
|
||||
class Topo:
|
||||
def topo_sort(self):
|
||||
visited = set()
|
||||
stack = []
|
||||
|
||||
def dfs(node):
|
||||
visited.add(node)
|
||||
|
||||
@ -26,9 +28,9 @@ class Topo:
|
||||
dfs(neighbor)
|
||||
|
||||
stack.append(node)
|
||||
|
||||
|
||||
return stack
|
||||
|
||||
|
||||
result = dfs("a")
|
||||
return result[::-1]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user