skbio.tree.TreeNode.pre_and_postorder

TreeNode.pre_and_postorder(include_self=True)[source]

Performs iteration over tree, visiting node before and after

State: Experimental as of 0.4.0.

Parameters

include_self (bool) – include the initial node if True

Yields

TreeNode – Traversed node.

Examples

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