simplextree (version 1.0.1)

traverse: traverse

Description

Traverses specific subsets of a simplicial complex.

Usage

traverse(traversal, f, ...)

straverse(traversal, f, ...)

ltraverse(traversal, f, ...)

Arguments

traversal

the type of traversal.

f

the function to apply to each simplex.

...

unused.

Value

NULL; for list or vector-valued returns, use ltraverse and straverse respectively.

Details

traverse allows for traversing ordered subsets of the simplex tree. The specific subset and order are determined by the choice of traversal: examples include the preorder traversal, the cofaces traversal, etc. See the links below. Each simplex in the traversal is passed as the first and only argument to f, one per simplex in the traversal. traverse does nothing with the result; if you want to collect the results of applying f to each simplex into a list, use ltraverse (or straverse), which are meant to be used like lapply and sapply, respectively.

Examples

Run this code
# NOT RUN {
## Starter example complex 
st <- simplex_tree()
st %>% insert(list(1:3, 2:5))

## Print out complex using depth-first traversal. 
st %>% preorder() %>% traverse(print)

## Collect the last labels of each simplex in the tree. 
last_labels <- st %>% preorder() %>% straverse(function(simplex){ tail(simplex, 1) })
# }

Run the code above in your browser using DataLab