skbio.tree.TreeNode.neighbors#

TreeNode.neighbors(ignore=None)[source]#

Return all nodes that are neighbors of the current node.

Neighbors are nodes that are directly connected to the current node by one branch. They usually include parent and children of the current node, if present. One may optionally ignore one node from the result.

Parameters:
ignoreTreeNode, optional

A node to ignore.

Returns:
list of TreeNode

The list of all nodes that are connected to self.

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["((a,b)c,(d,e)f)root;"])
>>> node_c = tree.find('c')
>>> [n.name for n in node_c.neighbors()]
['a', 'b', 'root']