simplex_tree: Simplex Tree

Description Usage Arguments Details Value Fields Properties Methods Author(s) References Examples

View source: R/simplex_tree.R

Description

Simplex tree class exposed as an Rcpp Module.

Usage

1
simplex_tree(simplices = NULL)

Arguments

simplices

optional simplices to initialize the simplex tree with. See insert.

Details

A simplex tree is an ordered trie-like structure specialized for storing and doing general computation simplicial complexes. Here is figure of a simplex tree, taken from the original paper (see 1):
Figure: simplextree.png
The current implementation provides a subset of the functionality described in the paper.

Value

A queryable simplex tree, as a Rcpp_SimplexTree object (Rcpp module).

Fields

n_simplices

A vector, where each index k denotes the number (k-1)-simplices.

dimension

The dimension of the simplicial complex.

Properties

Properties are actively bound shortcuts to various methods of the simplex tree that may be thought of as fields. Unlike fields, however, properties are not explicitly stored: they are generated on access.

$id_policy

The policy used to generate new vertex ids. May be assigned "compressed" or "unique". See generate_ids.

$vertices

The 0-simplices of the simplicial complex, as a matrix.

$edges

The 1-simplices of the simplicial complex, as a matrix.

$triangles

The 2-simplices of the simplicial complex, as a matrix.

$quads

The 3-simplices of the simplicial complex, as a matrix.

$connected_components

The connected components of the simplicial complex.

Methods

$as_XPtr

Creates an external pointer.

$clear

Clears the simplex tree.

$generate_ids

Generates new vertex ids according to the set policy.

$degree

Returns the degree of each given vertex.

$adjacent

Returns vertices adjacent to a given vertex.

$insert

Inserts a simplex into the trie.

$remove

Removes a simplex from the trie.

$find

Returns whether a simplex exists in the trie.

$collapse

Performs an elementary collapse.

$contract

Performs an edge contraction.

$expand

Performs an k-expansion.

$traverse

Traverses a subset of the simplex tree, applying a function to each simplex.

$ltraverse

Traverses a subset of the simplex tree, applying a function to each simplex and returning the result as a list.

$is_face

Checks for faces.

$is_tree

Checks if the simplicial complex is a tree.

$as_list

Converts the simplicial complex to a list.

$as_adjacency_matrix

Converts the 1-skeleton to an adjacency matrix.

$as_adjacency_list

Converts the 1-skeleton to an adjacency list.

$as_edgelist

Converts the 1-skeleton to an edgelist.

Author(s)

Matt Piekenbrock

References

Boissonnat, Jean-Daniel, and Clement Maria. "The simplex tree: An efficient data structure for general simplicial complexes." Algorithmica 70.3 (2014): 406-427.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Recreating simplex tree from figure. 
st <- simplex_tree()
st %>% insert(list(1:3, 2:5, c(6, 7, 9), 7:8, 10))
plot(st)

## Example insertion
st <- simplex_tree(list(1:3, 4:5, 6)) ## Inserts one 2-simplex, one 1-simplex, and one 0-simplex
print(st) 
# Simplex Tree with (6, 4, 1) (0, 1, 2)-simplices

## More detailed look at structure
print_simplices(st, "tree")
# 1 (h = 2): .( 2 3 )..( 3 )
# 2 (h = 1): .( 3 )
# 3 (h = 0): 
# 4 (h = 1): .( 5 )
# 5 (h = 0): 
# 6 (h = 0): 
## Print the set of simplices making up the star of the simplex '2'
print_simplices(st %>% cofaces(2))
# 2, 2 3, 1 2, 1 2 3

## Retrieves list of all simplices in DFS order, starting with the empty face 
dfs_list <- ltraverse(st %>% preorder(empty_face), identity)

## Get connected components 
print(st$connected_components)
# [1] 1 1 1 4 4 5

## Use clone() to make copies of the complex (don't use the assignment `<-`)
new_st <- st %>% clone()

## Other more internal methods available via `$` 
list_of_simplices <- st$as_list()
adj_matrix <- st$as_adjacency_matrix()
# ... see also as_adjacency_list(), as_edge_list(), etc 

Example output

Attaching package:simplextreeThe following object is masked frompackage:utils:

    find

The following objects are masked frompackage:base:

    remove, serialize

Simplex Tree with (6, 4, 1) (0, 1, 2)-simplices
1 (h = 2): .( 2 3 )..( 3 )
2 (h = 1): .( 3 )
3 (h = 0): 
4 (h = 1): .( 5 )
5 (h = 0): 
6 (h = 0): 
2, 2 3, 1 2, 1 2 3
[1] 1 1 1 4 4 5

simplextree documentation built on Sept. 13, 2020, 5:06 p.m.