File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -679,6 +679,29 @@ The :mod:`functools` module defines the following functions:
679
679
yield from node_group
680
680
self.done(*node_group)
681
681
682
+ The particular order that is returned may depend on the particular order in
683
+ which the items were inserted in the graph. For example:
684
+
685
+ .. doctest ::
686
+ :hide:
687
+
688
+ >>> ts = TopologicalSorter()
689
+ >>> ts.add(3 , 2 , 1 )
690
+ >>> ts.add(1 , 0 )
691
+ >>> print ([* ts.static_order()])
692
+ [2, 0, 1, 3]
693
+
694
+ >>> ts2 = TopologicalSorter()
695
+ >>> ts2.add(1 , 0 )
696
+ >>> ts2.add(3 , 2 , 1 )
697
+ >>> print ([* ts2.static_order()])
698
+ [0, 2, 1, 3]
699
+
700
+ This is due to the fact that "0" and "2" are in the same level in the graph (they
701
+ would have been returned in the same call to :meth: `~TopologicalSorter.get_ready `)
702
+ and the order between them is determined by the order of insertion.
703
+
704
+
682
705
If any cycle is detected, :exc: `CycleError ` will be raised.
683
706
684
707
.. versionadded :: 3.9
Original file line number Diff line number Diff line change @@ -415,6 +415,9 @@ def _find_cycle(self):
415
415
def static_order (self ):
416
416
"""Returns an iterable of nodes in a topological order.
417
417
418
+ The particular order that is returned may depend on the particular
419
+ order in which the items were inserted in the graph.
420
+
418
421
Using this method does not require to call "prepare" or "done". If any
419
422
cycle is detected, :exc:`CycleError` will be raised.
420
423
"""
You can’t perform that action at this time.
0 commit comments