From 2efd1f46fc12d66b1a25299de4e932bb84f352e9 Mon Sep 17 00:00:00 2001 From: Ved Prakash Vishwakarma Date: Sun, 20 Oct 2024 13:24:24 +0530 Subject: [PATCH] comment improved --- sorts/topological_sort.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sorts/topological_sort.py b/sorts/topological_sort.py index c790cc93d54b8..246fc09c720ba 100644 --- a/sorts/topological_sort.py +++ b/sorts/topological_sort.py @@ -21,9 +21,10 @@ def topological_sort(start: str, visited: list[str], sort: list[str]) -> list[st # add current to visited visited.append(current) neighbors = edges[current] - #as we are traversing in from top to down in tree like graph (direction not given) we consider direction from top to down - #as the current node encounter add it to the topo sort list + #traversal from top to down in tree like graph (direction not given) we consider direction from top to down + #current node encounter add it to the topo sort list sort.append(current) + for neighbor in neighbors: # if neighbor not in visited, visit if neighbor not in visited: