skbio.tree.TreeNode.pre_and_postorder

TreeNode.pre_and_postorder(include_self=True)[source]

Performs iteration over tree, visiting node before and after

Parameters:

include_self : bool

include the initial node if True

Returns:

GeneratorType

Yields successive TreeNode objects

Examples

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