@@ -269,16 +269,16 @@ def static_order(self):
269269# That's a lot of work, though, and we can get most of the benefit much
270270# more easily just by showing a single specific cycle.
271271#
272- # Finding a cycle is most natural via a breadth first search, which can
273- # easily be arranged to find a shortest-possible cycle. But memory
274- # burden can be high, because every path-in-progress has to keep its own
275- # idea of what "the path" is so far.
272+ # Approaches to that are based on breadth first or depth first search
273+ # (BFS or DFS). BFS is most natural, which can easily be arranged to
274+ # find a shortest-possible cycle. But memory burden can be high, because
275+ # every path-in-progress has to keep its own idea of what "the path" is
276+ # so far.
276277#
277- # Depth first search (DFS) is much easier on RAM, only requiring keeping
278- # track of _the_ path from the starting node to the current node at the
279- # current recursion level. But there may be any number of nodes, and so
280- # there's no bound on recursion depth short of the total number of
281- # nodes.
278+ # DFS is much easier on RAM, only requiring keeping track of _the_ path
279+ # from the starting node to the current node at the current recursion
280+ # level. But there may be any number of nodes, and so there's no bound
281+ # on recursion depth short of the total number of nodes.
282282#
283283# So we use an iterative version of DFS, keeping an exploit list
284284# (`stack`) of the path so far. A parallel stack (`itstack`) holds the
@@ -303,5 +303,6 @@ def static_order(self):
303303# successor to consider, emulating a chain of returns in a recursive
304304# version.
305305#
306- # Worst case time is linear in the number of nodes plus the number of
307- # edges. Worst case memory burden is linear in the number of nodes.
306+ # Worst cases: O(V+E) for time, and O(V) for memory, where V is the
307+ # number of nodes and V the number edges (which may be quadratic in V!).
308+ # It requires care to ensure these bounds are met.
0 commit comments