Returns iterator over descendants
This is a depth-first traversal. Since the trees are not binary, preorder and postorder traversals are possible, but inorder traversals would depend on the data in the tree and are not handled here.
Parameters: | self_before : bool
self_after : bool
include_self : bool
`self_before` and `self_after` are independent. If neither is `True`, only terminal nodes will be returned. Note that if self is terminal, it will only be included once even if `self_before` and `self_after` are both `True`. |
---|---|
Returns: | GeneratorType
|
See also
preorder, postorder, pre_and_postorder, levelorder, tips, non_tips
Examples
>>> from six import StringIO
>>> from skbio import TreeNode
>>> tree = TreeNode.read(StringIO("((a,b)c);"))
>>> for node in tree.traverse():
... print(node.name)
None
c
a
b