ytree.data_structures.tree_node.TreeNode
- class ytree.data_structures.tree_node.TreeNode(uid, arbor=None, root=False)[source]
Class for objects stored in Arbors.
Each TreeNode represents a halo in a tree. A TreeNode knows its halo ID, the level in the tree, and its global ID in the Arbor that holds it. It also has a list of its ancestors. Fields can be queried for it, its progenitor list, and the tree beneath.
- __init__(uid, arbor=None, root=False)[source]
Initialize a TreeNode with at least its halo catalog ID and its level in the tree.
Methods
__init__(uid[, arbor, root])Initialize a TreeNode with at least its halo catalog ID and its level in the tree.
clear_fields()If a root node, delete field data.
find_root()Find the root node.
get_leaf_nodes([selector])Get all leaf nodes from the tree of which this is the head.
get_node(selector, index)Get a single TreeNode from a tree.
Get all root nodes from the forest to which this node belongs.
query(key)Return field values for this TreeNode, progenitor list, or tree.
save_tree([filename, fields])Save the tree to a file.
walk_to_root()Walk descendents until root.
Attributes
ancestorsReturn a generator of ancestor nodes.
desc_uidsArray of descendent uids for all nodes in the tree.
descendentReturn the descendent node.
is_rootIs this node the last in the tree?
tree_idReturn the index of this node in a list of all nodes in the tree.
tree_sizeNumber of nodes in the tree.
uidsArray of uids for all nodes in the tree.