PyDocs

Nav

Data Types

TopologicalSorter.static_order

  • TopologicalSorter.static_order()
Returns an iterable of nodes in a topological order.

The particular order that is returned may depend on the specific
order in which the items were inserted in the graph.

Using this method does not require to call "prepare" or "done". If any
cycle is detected, :exc:`CycleError` will be raised.
1 Example
>>> ts = TopologicalSorter()
>>> ts.add(3, 2, 1)
>>> ts.add(1, 0)
>>> print([*ts.static_order()])
[2, 0, 1, 3]

>>> ts2 = TopologicalSorter()
>>> ts2.add(1, 0)
>>> ts2.add(3, 2, 1)
>>> print([*ts2.static_order()])
[0, 2, 1, 3]
from the Python docs
See Also
No see-alsos for graphlib/TopologicalSorter.static_order
0 Notes
No notes for TopologicalSorter.static_order