from simplextree import SimplexTree
= SimplexTree([[0,1,2], [0,1], [4,5]])
st print(st)
Simplex Tree with (5, 4, 1) (0, 1, 2)-simplices
You can construct a SimplexTree
by supplying simplices. Any collection of integer-valued Iterable
’s will do, e.g. a list of lists:
Simplex Tree with (5, 4, 1) (0, 1, 2)-simplices
Batch insertion, removal, and membership queries are supported
Collections of simplices are returned as simple lists-of-lists:
[(0,), (1,), (2,), (4,), (5,), (0, 1), (0, 2), (1, 2), (1, 4), (1, 5), (4, 5), (0, 1, 2)]
Various parameters can be given to restrict a given subset to certain subsets or orders:
Familiar Pythonic Collection semantics are supported, including __contains__, __iter__ support, and __len__:
True
[1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3]
12
The cofaces of any simplex can be listed with cofaces
:
Cofaces([1]): [(1,), (1, 2), (1, 4), (1, 5), (0, 1), (0, 1, 2)]
The maximal simplices can be listed with maximal
:
Basic properties are also available as attributes
(array([5, 6, 1], dtype=uint64), 2, [0, 1, 2, 4, 5], [1, 1, 1, 1, 1])
Interoperability with numpy is provided whenever possible
Other complex-wide operations are supported, like k-expansions
The trie-structure can also be inspected on the python side with print_tree
:
0 (h = 2): .( 1 2 )..( 2 )
1 (h = 2): .( 2 4 5 )..( 5 )
2 (h = 0):
4 (h = 1): .( 5 )
5 (h = 0):
Yet another way is to traverse the complex in a depth-first manner (prefix-order), printing every simplex as it appears in the traversal:
(0,)
(0, 1)
(0, 1, 2)
(0, 2)
(1,)
(1, 2)
(1, 4)
(1, 4, 5)
(1, 5)
(2,)
(4,)
(4, 5)
(5,)
Several traversal orderings are provided, e.g. breadth-first could be used as well (level-order):
(0,)
(1,)
(2,)
(4,)
(5,)
(0, 1)
(0, 2)
(1, 2)
(1, 4)
(1, 5)
(4, 5)
(0, 1, 2)
(1, 4, 5)
In fact, most operations on the Simplex tree are actually implemented using traversals. For example,
st.traverse(“maximal”, f=print)