scikit-bio is back in active development! Check out our announcement of revitalization.

skbio.tree.TreeNode.levelorder#

TreeNode.levelorder(include_self=True)[source]#

Perform levelorder iteration over tree.

Parameters:
include_selfbool

include the initial node if True

Yields:
TreeNode

Traversed node.

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["((a,b)c,(d,e)f);"])
>>> for node in tree.levelorder():
...     print(node.name)
None
c
f
a
b
d
e