oak (version 0.2.1)

parent: Parent of a node

Description

The function parent returns the parent of a node in a given tree. If the node is not found in the tree or has no parent, the empty tree is returned.

Usage

parent(.node, .tree, degree = 1L)

# S3 method for rtree parent(.node, .tree, degree = 1L)

has.parent(.node, .tree)

Arguments

.node

node or character. The node or node label considered.

.tree

A tree.

degree

integer. Currently not used.

Value

A node.

Examples

Run this code
# NOT RUN {
## Rooted tree
(tr0 = c_("Bob", "Carl", "Daniel"))
(tr1 = c_("Bill", "Caroline", "Dimitri", "Enoc"))
(tr2 = r_("Alice", s = list(tr0, tr1)))

## Unrooted tree
(tr3 = r_(s = list(tr2, c_("Son", "Father", "Grand-Mother"))))
parent("Alice", tr3)
parent("Bob", tr3)
parent("any node", tr3)

# }

Run the code above in your browser using DataCamp Workspace