simplextree (version 1.0.1)

collapse: Elementary collapse

Description

Performs an elementary collapse.

Usage

collapse(st, pair, w = NULL)

Arguments

st

a simplex tree.

pair

list of simplices to collapse.

w

vertex to collapse to, if performing a vertex collapse.

Value

boolean indicating whether the collapse was performed.

Details

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 \(\sigma\) is said to be collapsible through one of its faces \(\tau\) if \(\sigma\) is the only coface of \(\tau\) (excluding \(\tau\) itself). This function checks whether its possible to collapse \(\sigma\) through \(\tau\), (if \(\tau\) has \(\sigma\) as its only coface), and if so, both simplices are removed. 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.

References

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.

Examples

Run this code
# 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