
Last chance! 50% off unlimited learning
Sale ends in
Traverses specific subsets of a simplicial complex.
traverse(traversal, f, ...)straverse(traversal, f, ...)
ltraverse(traversal, f, ...)
the type of traversal.
the function to apply to each simplex.
unused.
NULL; for list or vector-valued returns, use ltraverse
and straverse
respectively.
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.
# 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