tree_visitor: Tree Visitor Function

Description Usage Arguments Details Value Author(s)

View source: R/tree_visitor.R

Description

This function visits each node in a tree-like object in an order determined by the relationOf function. The function given by tfun is called for each set of nodes and the function nfun determines which nodes to test next optionally making use of the result of the previous test.

Usage

1
2
3
tree_visitor(g, start, tfun, nfun, relationOf)
topdown_tree_visitor(g, start, tfun, nfun)
bottomup_tree_visitor(g, start, tfun, nfun)

Arguments

g

A tree-like object that supports the method given by relationOf.

start

The set of nodes to start the computation (can be a list of siblings), but the nodes should all belong to the same level of the tree (same path length to root node).

tfun

The test function applied to each list of siblings at each level starting with start. The signature of tfun should be (start, g, prev_ans).

nfun

A function with signature (ans, g) that processes the result of tfun and returns a character vector of node names corresponding to nodes that were involved in an "interesting" test. This is used to determine the next set of nodes to test (see details).

relationOf

The method used to traverse the tree. For example childrenOf or parentOf.

Details

The tree_visitor function is intended to allow developers to quickly prototype different statistical testing paradigms on trees. It may be possible to extend this to work for DAGs.

The visit begins by calling tfun with the nodes provided by start. The result of each call to tfun is stored in an environment. The concept is visitation by tree level and so each result is stored using a key representing the level (this isn't quite right since the nodes in start need not be first level, but they will be assigned key "1". After storing the result, nfun is used to obtain a vector of accepted node labels. The idea is that the user should have a way of determining which nodes in the next level of the tree are worth testing. The next start set is determined by start <- relationOf(g, accepted) where accepted is unique(nfun(ans, g)).

Value

A list. See the return value of cb_test to get an idea. Each element of the list represents a call to tfun at a given level of the tree.

Author(s)

Seth Falcon


Category documentation built on Nov. 8, 2020, 10:58 p.m.