11#ifndef SIMPLEX_TREE_H_
12#define SIMPLEX_TREE_H_
14#include <gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h>
15#include <gudhi/Simplex_tree/Simplex_tree_siblings.h>
16#include <gudhi/Simplex_tree/Simplex_tree_iterators.h>
17#include <gudhi/Simplex_tree/indexing_tag.h>
21#include <gudhi/Debug_utils.h>
23#include <boost/container/flat_map.hpp>
24#include <boost/iterator/transform_iterator.hpp>
25#include <boost/graph/adjacency_list.hpp>
26#include <boost/range/adaptor/reversed.hpp>
27#include <boost/range/adaptor/transformed.hpp>
28#include <boost/range/size.hpp>
29#include <boost/container/static_vector.hpp>
32#include <tbb/parallel_sort.h>
40#include <initializer_list>
65struct Simplex_tree_options_full_featured;
80template<
typename SimplexTreeOptions = Simplex_tree_options_full_featured>
104 typedef typename boost::container::flat_map<Vertex_handle, Node> Dictionary;
111 struct Key_simplex_base_real {
112 Key_simplex_base_real() : key_(-1) {}
118 struct Key_simplex_base_dummy {
119 Key_simplex_base_dummy() {}
121 void assign_key(Simplex_key);
122 Simplex_key key()
const;
124 struct Extended_filtration_data {
127 Extended_filtration_data(){}
130 typedef typename std::conditional<Options::store_key, Key_simplex_base_real, Key_simplex_base_dummy>::type
133 struct Filtration_simplex_base_real {
134 Filtration_simplex_base_real() : filt_(0) {}
140 struct Filtration_simplex_base_dummy {
141 Filtration_simplex_base_dummy() {}
142 void assign_filtration(
Filtration_value GUDHI_CHECK_code(f)) { GUDHI_CHECK(f == 0,
"filtration value specified for a complex that does not store them"); }
146 Filtration_simplex_base_dummy>::type Filtration_simplex_base;
157 typedef typename Dictionary::iterator Dictionary_it;
158 typedef typename Dictionary_it::value_type Dit_value_t;
160 struct return_first {
230 boost::make_transform_iterator(root_.members_.begin(), return_first()),
231 boost::make_transform_iterator(root_.members_.end(), return_first()));
275 return filtration_vect_;
304 template<
class SimplexHandle>
321 template<
class SimplexHandle>
1758template<
typename...T>
1760 for (
auto sh : st.filtration_simplex_range()) {
1762 for (
auto v : st.simplex_vertex_range(sh)) {
1770template<
typename...T>
1773 std::vector<typename ST::Vertex_handle> simplex;
1779 int dim =
static_cast<int> (simplex.size() - 1);
1780 if (max_dim < dim) {
1798 typedef int Vertex_handle;
1799 typedef double Filtration_value;
1800 typedef std::uint32_t Simplex_key;
1801 static const bool store_key =
true;
1802 static const bool store_filtration =
true;
1803 static const bool contiguous_vertices =
false;
1814 typedef int Vertex_handle;
1815 typedef float Filtration_value;
1816 typedef std::uint32_t Simplex_key;
1817 static const bool store_key =
true;
1818 static const bool store_filtration =
true;
1819 static const bool contiguous_vertices =
true;
Extended simplex type data structure for representing the type of simplices in an extended filtration...
Iterator over the simplices of the boundary of a simplex and their opposite vertices.
Definition Simplex_tree_iterators.h:190
Iterator over the simplices of the boundary of a simplex.
Definition Simplex_tree_iterators.h:83
Iterator over the simplices of a simplicial complex.
Definition Simplex_tree_iterators.h:300
Data structure to store a set of nodes in a SimplexTree sharing the same parent node.
Definition Simplex_tree_siblings.h:31
Iterator over the vertices of a simplex in a SimplexTree.
Definition Simplex_tree_iterators.h:38
Iterator over the simplices of the skeleton of a given dimension of the simplicial complex.
Definition Simplex_tree_iterators.h:374
Simplex Tree data structure for representing simplicial complexes.
Definition Simplex_tree.h:81
static Siblings * self_siblings(SimplexHandle sh)
Definition Simplex_tree.h:886
Simplex_tree(Simplex_tree &&complex_source)
User-defined move constructor relocates the whole tree structure.
Definition Simplex_tree.h:349
bool operator==(Simplex_tree &st2)
Checks if two simplex trees are equal.
Definition Simplex_tree.h:474
Options::Filtration_value Filtration_value
Type for the value of the filtration function.
Definition Simplex_tree.h:88
Cofaces_simplex_range cofaces_simplex_range(const Simplex_handle simplex, int codimension)
Compute the cofaces of a n simplex.
Definition Simplex_tree.h:1023
Simplex_tree_boundary_opposite_vertex_simplex_iterator< Simplex_tree > Boundary_opposite_vertex_simplex_iterator
Iterator over the simplices of the boundary of a simplex and their opposite vertices.
Definition Simplex_tree.h:198
void reset_filtration(Filtration_value filt_value, int min_dim=0)
This function resets the filtration value of all the simplices of dimension at least min_dim....
Definition Simplex_tree.h:1723
void assign_filtration(Simplex_handle sh, Filtration_value fv)
Sets the filtration value of a simplex.
Definition Simplex_tree.h:548
bool make_filtration_non_decreasing()
This function ensures that each simplex has a higher filtration value than its faces by increasing th...
Definition Simplex_tree.h:1401
Dictionary::iterator Simplex_handle
Handle type to a simplex contained in the simplicial complex represented by the simplex tree.
Definition Simplex_tree.h:154
Vertex_handle vertex_with_same_filtration(Simplex_handle sh)
Returns a vertex of sh that has the same filtration value as sh if it exists, and null_vertex() other...
Definition Simplex_tree.h:1658
Filtration_simplex_range const & filtration_simplex_range(Indexing_tag=Indexing_tag())
Returns a range over the simplices of the simplicial complex, in the order of the filtration.
Definition Simplex_tree.h:273
std::pair< Simplex_handle, bool > insert_simplex(const InputVertexRange &simplex, Filtration_value filtration=0)
Insert a simplex, represented by a range of Vertex_handles, in the simplicial complex.
Definition Simplex_tree.h:782
Vertex_handle null_vertex() const
Returns a Vertex_handle different from all Vertex_handles associated to the vertices of the simplicia...
Definition Simplex_tree.h:569
boost::iterator_range< Boundary_simplex_iterator > Boundary_simplex_range
Range over the simplices of the boundary of a simplex.
Definition Simplex_tree.h:194
Simplex_vertex_range simplex_vertex_range(Simplex_handle sh) const
Returns a range over the vertices of a simplex.
Definition Simplex_tree.h:284
void clear_filtration()
Clears the filtration cache produced by initialize_filtration().
Definition Simplex_tree.h:949
Simplex_tree_simplex_vertex_iterator< Simplex_tree > Simplex_vertex_iterator
Iterator over the vertices of a simplex.
Definition Simplex_tree.h:184
static Simplex_key key(Simplex_handle sh)
Returns the key associated to a simplex.
Definition Simplex_tree.h:520
static Filtration_value filtration(Simplex_handle sh)
Returns the filtration value of a simplex.
Definition Simplex_tree.h:537
bool operator!=(Simplex_tree &st2)
Checks if two simplex trees are different.
Definition Simplex_tree.h:482
bool has_children(SimplexHandle sh) const
Returns true if the node in the simplex tree pointed by sh has children.
Definition Simplex_tree.h:630
Cofaces_simplex_range star_simplex_range(const Simplex_handle simplex)
Compute the star of a n simplex.
Definition Simplex_tree.h:1012
void expansion_with_blockers(int max_dim, Blocker block_simplex)
Expands a simplex tree containing only a graph. Simplices corresponding to cliques in the graph are a...
Definition Simplex_tree.h:1282
boost::iterator_range< Simplex_vertex_iterator > Simplex_vertex_range
Range over the vertices of a simplex.
Definition Simplex_tree.h:186
void remove_maximal_simplex(Simplex_handle sh)
Remove a maximal simplex.
Definition Simplex_tree.h:1530
std::pair< Simplex_handle, Simplex_handle > endpoints(Simplex_handle sh)
Definition Simplex_tree.h:879
void assign_key(Simplex_handle sh, Simplex_key key)
Assign a value 'key' to the key of the simplex represented by the Simplex_handle 'sh'.
Definition Simplex_tree.h:872
Options::Simplex_key Simplex_key
Key associated to each simplex.
Definition Simplex_tree.h:92
Simplex_tree()
Constructs an empty simplex tree.
Definition Simplex_tree.h:332
void maybe_initialize_filtration()
Initializes the filtration cache if it isn't initialized yet.
Definition Simplex_tree.h:940
boost::iterator_range< Complex_simplex_iterator > Complex_simplex_range
Range over the simplices of the simplicial complex.
Definition Simplex_tree.h:206
Simplex_tree_boundary_simplex_iterator< Simplex_tree > Boundary_simplex_iterator
Iterator over the simplices of the boundary of a simplex.
Definition Simplex_tree.h:192
Simplex_tree_siblings< Simplex_tree, Dictionary > Siblings
Set of nodes sharing a same parent in the simplex tree.
Definition Simplex_tree.h:107
Simplex_handle find(const InputVertexRange &s)
Given a range of Vertex_handles, returns the Simplex_handle of the simplex in the simplicial complex ...
Definition Simplex_tree.h:643
std::vector< Simplex_handle > Cofaces_simplex_range
Range over the cofaces of a simplex.
Definition Simplex_tree.h:188
Boundary_opposite_vertex_simplex_range boundary_opposite_vertex_simplex_range(SimplexHandle sh)
Given a simplex, returns a range over the simplices of its boundary and their opposite vertices.
Definition Simplex_tree.h:322
Simplex_handle edge_with_same_filtration(Simplex_handle sh)
Returns an edge of sh that has the same filtration value as sh if it exists, and null_simplex() other...
Definition Simplex_tree.h:1672
Simplex_tree_complex_simplex_iterator< Simplex_tree > Complex_simplex_iterator
Iterator over the simplices of the simplicial complex.
Definition Simplex_tree.h:204
Simplex_handle simplex(Simplex_key idx) const
Returns the simplex that has index idx in the filtration.
Definition Simplex_tree.h:528
void initialize_filtration()
Initializes the filtration cache, i.e. sorts the simplices according to their order in the filtration...
Definition Simplex_tree.h:916
Skeleton_simplex_range skeleton_simplex_range(int dim)
Returns a range over the simplices of the dim-skeleton of the simplicial complex.
Definition Simplex_tree.h:253
boost::transform_iterator< return_first, Dictionary_it > Complex_vertex_iterator
Iterator over the vertices of the simplicial complex.
Definition Simplex_tree.h:178
void insert_batch_vertices(VertexRange const &vertices, Filtration_value filt=0)
Inserts several vertices.
Definition Simplex_tree.h:1167
std::vector< Simplex_handle > Filtration_simplex_range
Range over the simplices of the simplicial complex, ordered by the filtration.
Definition Simplex_tree.h:216
Filtration_simplex_range::const_iterator Filtration_simplex_iterator
Iterator over the simplices of the simplicial complex, ordered by the filtration.
Definition Simplex_tree.h:220
Extended_filtration_data extend_filtration()
Extend filtration for computing extended persistence. This function only uses the filtration values a...
Definition Simplex_tree.h:1596
Simplex_handle minimal_simplex_with_same_filtration(Simplex_handle sh)
Returns a minimal face of sh that has the same filtration value as sh.
Definition Simplex_tree.h:1705
Options::Vertex_handle Vertex_handle
Type for the vertex handle.
Definition Simplex_tree.h:96
std::pair< Filtration_value, Extended_simplex_type > decode_extended_filtration(Filtration_value f, const Extended_filtration_data &efd)
Retrieve the original filtration value for a given simplex in the Simplex_tree. Since the computation...
Definition Simplex_tree.h:1567
size_t num_vertices() const
Returns the number of vertices in the complex.
Definition Simplex_tree.h:574
void expansion(int max_dim)
Expands the Simplex_tree containing only its one skeleton until dimension max_dim.
Definition Simplex_tree.h:1185
Simplex_tree(const Simplex_tree &complex_source)
User-defined copy constructor reproduces the whole tree structure.
Definition Simplex_tree.h:339
boost::iterator_range< Complex_vertex_iterator > Complex_vertex_range
Range over the vertices of the simplicial complex.
Definition Simplex_tree.h:180
static Simplex_key null_key()
Returns a fixed number not in the interval [0, num_simplices()).
Definition Simplex_tree.h:563
Boundary_simplex_range boundary_simplex_range(SimplexHandle sh)
Returns a range over the simplices of the boundary of a simplex.
Definition Simplex_tree.h:305
int dimension(Simplex_handle sh)
Returns the dimension of a simplex.
Definition Simplex_tree.h:602
bool prune_above_filtration(Filtration_value filtration)
Prune above filtration value given as parameter.
Definition Simplex_tree.h:1455
int upper_bound_dimension() const
Returns an upper bound on the dimension of the simplicial complex.
Definition Simplex_tree.h:613
Siblings * root()
Definition Simplex_tree.h:895
int dimension()
Returns the dimension of the simplicial complex.
Definition Simplex_tree.h:621
std::pair< Simplex_handle, bool > insert_simplex_and_subfaces(const InputVertexRange &Nsimplex, Filtration_value filtration=0)
Insert a N-simplex and all his subfaces, from a N-simplex represented by a range of Vertex_handles,...
Definition Simplex_tree.h:811
size_t num_simplices()
returns the number of simplices in the simplex_tree.
Definition Simplex_tree.h:580
Simplex_tree_skeleton_simplex_iterator< Simplex_tree > Skeleton_simplex_iterator
Iterator over the simplices of the skeleton of the simplicial complex, for a given dimension.
Definition Simplex_tree.h:211
Simplex_tree & operator=(Simplex_tree &&complex_source)
User-defined move assignment relocates the whole tree structure.
Definition Simplex_tree.h:383
boost::iterator_range< Boundary_opposite_vertex_simplex_iterator > Boundary_opposite_vertex_simplex_range
Range over the simplices of the boundary of a simplex and their opposite vertices.
Definition Simplex_tree.h:200
Simplex_tree & operator=(const Simplex_tree &complex_source)
User-defined copy assignment reproduces the whole tree structure.
Definition Simplex_tree.h:366
void insert_graph(const OneSkeletonGraph &skel_graph)
Inserts a 1-skeleton in an empty Simplex_tree.
Definition Simplex_tree.h:1110
void set_dimension(int dimension)
Set a dimension for the simplicial complex.
Definition Simplex_tree.h:903
boost::iterator_range< Skeleton_simplex_iterator > Skeleton_simplex_range
Range over the simplices of the skeleton of the simplicial complex, for a given dimension.
Definition Simplex_tree.h:214
void print_hasse(std::ostream &os)
Write the hasse diagram of the simplicial complex in os.
Definition Simplex_tree.h:1383
~Simplex_tree()
Destructor; deallocates the whole tree structure.
Definition Simplex_tree.h:361
static Simplex_handle null_simplex()
Returns a Simplex_handle different from all Simplex_handles associated to the simplices in the simpli...
Definition Simplex_tree.h:558
Complex_simplex_range complex_simplex_range()
Returns a range over the simplices of the simplicial complex.
Definition Simplex_tree.h:239
Complex_vertex_range complex_vertex_range()
Returns a range over the vertices of the simplicial complex. The order is increasing according to < o...
Definition Simplex_tree.h:228
Graph simplicial complex methods.
This file includes common file reader for GUDHI.
bool read_simplex(std::istream &in_, std::vector< Vertex_handle > &simplex, Filtration_value &fil)
Read a face from a file.
Definition reader_utils.h:158
Value type for a filtration function on a cell complex.
Definition FiltrationValue.h:20
Node of a simplex tree with filtration value and simplex key.
Definition Simplex_tree_node_explicit_storage.h:29
Definition Simplex_tree.h:1812
Definition Simplex_tree.h:1796
Tag for a linear ordering of simplices.
Definition indexing_tag.h:20
Concept describing an indexing scheme (see FilteredComplex) for applying continuous maps to a cell co...
Definition IndexingTag.h:18
Key type used as simplex identifier.
Definition SimplexKey.h:15
Concept of the template parameter for the class Gudhi::Simplex_tree<SimplexTreeOptions>.
Definition SimplexTreeOptions.h:15
static const bool store_filtration
If true, each simplex has extra storage for one Filtration_value, and this value is propagated by ope...
Definition SimplexTreeOptions.h:27
static constexpr bool contiguous_vertices
If true, the list of vertices present in the complex must always be 0, ..., num_vertices-1,...
Definition SimplexTreeOptions.h:29
Handle type for the vertices of a cell complex.
Definition VertexHandle.h:15