Skip to content

Instantly share code, notes, and snippets.

@raeidsaqur
Created April 30, 2020 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raeidsaqur/95e890f06a61992a26a3e6f1f9908760 to your computer and use it in GitHub Desktop.
Save raeidsaqur/95e890f06a61992a26a3e6f1f9908760 to your computer and use it in GitHub Desktop.
Py_3.9-TopologicalSorter
from functools import TopologicalSorter
graph = {"A": {"D"}, "B": {"D"}, "C": {"E", "H"}, "D": {"F", "G", "H"}, "E": {"G"}}
ts = TopologicalSorter(graph)
list(ts.static_order())
# ['H', 'F', 'G', 'D', 'E', 'A', 'B', 'C']
@raeidsaqur
Copy link
Author

Details: Python 3.9 doc here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment