Performs an elementary collapse.
collapse(st, pair, w = NULL)
a simplex tree.
list of simplices to collapse.
vertex to collapse to, if performing a vertex collapse.
boolean indicating whether the collapse was performed.
This function provides two types of elementary collapses.
The first type of collapse is in the sense described by (1), which is
summarized here. A simplex tau
and sigma
are sorted before comparison.
To perform this kind of elementary collapse, call collapse
with two simplices as arguments, i.e. tau
before sigma
.
Alternatively, this method supports another type of elementary collapse, also called a vertex collapse, as described in (2). This type of collapse maps a pair of vertices into a single vertex. To use this collapse, specify three vertex ids, the first two representing the free pair, and the last representing the target vertex to collapse to.
1. Boissonnat, Jean-Daniel, and Clement Maria. "The simplex tree: An efficient data structure for general simplicial complexes." Algorithmica 70.3 (2014): 406-427.
2. Dey, Tamal K., Fengtao Fan, and Yusu Wang. "Computing topological persistence for simplicial maps." Proceedings of the thirtieth annual symposium on Computational geometry. ACM, 2014.
# NOT RUN {
st <- simplextree::simplex_tree(1:3)
st %>% print_simplices()
# 1, 2, 3, 1 2, 1 3, 2 3, 1 2 3
st %>% collapse(list(1:2, 1:3))
# 1, 2, 3, 1 3, 2 3=
st %>% insert(list(1:3, 2:5))
st %>% print_simplices("column")
# 1 2 3 4 5 1 1 2 2 2 3 3 4 1 2 2 2 3 2
# 2 3 3 4 5 4 5 5 2 3 3 4 4 3
# 3 4 5 5 5 4
# 5
st %>% collapse(list(2:4, 2:5))
st %>% print_simplices("column")
# 1 2 3 4 5 1 1 2 2 2 3 3 4 1 2 2 3
# 2 3 3 4 5 4 5 5 2 3 4 4
# 3 5 5 5
# }
Run the code above in your browser using DataLab