Data Modeling and Utility Modules
graphlib
Provides TopologicalSorter for ordering hashable tasks according to dependencies. Its graph maps each node to its predecessors, not its successors. A cycle prevents a complete ordering. Independent nodes may have multiple valid orders; do not rely on one arbitrary tie order.
Formal Syntax & Structure
python syntaxpython
import graphlibReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from graphlib import TopologicalSorterorder = TopologicalSorter({"serve": ["cook"], "cook": ["prep"]})print(list(order.static_order()))