Learn R Programming

simplextree (version 1.0.1)

generate_ids: Generates vertex ids.

Description

Generates vertex ids representing 0-simplices not in the tree.

Usage

generate_ids(st, n)

Arguments

st

a simplex tree.

n

the number of ids to generate.

Details

This function generates new vertex ids for use in situations which involve generating new new 0-simplices, e.g. insertions, contractions, collapses, etc. There are two 'policies' which designate the generating mechanism of these ids: 'compressed' and 'unique'. 'compressed' generates vertex ids sequentially, starting at 0. 'unique' tracks an incremental internal counter, which is updated on every call to generate_ids. The new ids under the 'unique' policy generates the first sequential n ids that are strictly greater max(counter, max vertex id).

Examples

Run this code
# NOT RUN {
st <- simplex_tree()
print(st$id_policy)
## "compressed"
st %>% generate_ids(3) 
## 0 1 2
st %>% generate_ids(3) 
## 0 1 2
st %>% insert(list(1,2,3))
print(st$vertices) 
## 1 2 3
st %>% insert(as.list(st %>% generate_ids(2)))
st %>% print_simplices() 
# 0, 1, 2, 3, 4
st %>% remove(4)
st %>% generate_ids(1) 
# 4
# }

Run the code above in your browser using DataLab