Fix the `topological_sort` function in the `Graph` class without changing its signature.
