[Libre-soc-bugs] [Bug 1094] insndb instruction database visitor-walker is needed

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Thu Jun 8 11:51:13 BST 2023


--- Comment #62 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---

ah - i know how to make this do breadth-first(?) order:

def walk(node):
    from collections import deque
    todo = deque([node])
    todonext = deque()
    while todo:
        node = todo.popleft()
        yield node
        if not todo:
            todo = todonext
            todonext = deque()

and that should do breadth-first node-walking.  i am not entirely sure
how to do depth-first.. is it that you just move the "yield node" up?
i leave it with you to work out?

You are receiving this mail because:
You are on the CC list for the bug.

More information about the libre-soc-bugs mailing list