Loading...
Searching...
No Matches
mini_simplex_tree.cpp
/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Marc Glisse
*
* Copyright (C) 2015 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/
#include <gudhi/Simplex_tree.h>
#include <iostream>
#include <initializer_list>
// With Gudhi::Simplex_tree_options_minimal filtration values are not stored and persistence cannot be computed.
// I can still improve the memory footprint
struct MyOptions : Gudhi::Simplex_tree_options_minimal {
// As I have few vertices
typedef short Vertex_handle;
};
using ST = Gudhi::Simplex_tree<MyOptions>;
// Dictionary should be private, but for now this is the easiest way.
static_assert(sizeof(ST::Dictionary::value_type) < sizeof(Gudhi::Simplex_tree<>::Dictionary::value_type),
"Not storing the filtration and key should save some space");
int main() {
ST st;
/* Complex to build. */
/* 1 */
/* o */
/* /X\ */
/* o---o---o */
/* 2 0 3 */
auto triangle012 = {0, 1, 2};
auto edge03 = {0, 3};
st.insert_simplex_and_subfaces(triangle012);
st.insert_simplex_and_subfaces(edge03);
auto edge02 = {0, 2};
ST::Simplex_handle e = st.find(edge02);
// We are not using filtrations so everything has value 0
assert(st.filtration(e) == 0);
for (ST::Simplex_handle t : st.cofaces_simplex_range(e, 1)) {
// Only coface is 012
for (ST::Vertex_handle v : st.simplex_vertex_range(t)) // v in { 0, 1, 2 }
std::clog << v;
std::clog << '\n';
}
}
Gudhi::Simplex_tree
Simplex Tree data structure for representing simplicial complexes.
Definition Simplex_tree.h:98
Gudhi::Simplex_tree::simplex_vertex_range
Simplex_vertex_range simplex_vertex_range(Simplex_handle sh) const
Returns a range over the vertices of a simplex.
Definition Simplex_tree.h:369
Gudhi::Simplex_tree::filtration
static Filtration_value filtration(Simplex_handle sh)
Returns the filtration value of a simplex.
Definition Simplex_tree.h:727
Gudhi::Simplex_tree< MyOptions >::Simplex_handle
Dictionary::const_iterator Simplex_handle
Definition Simplex_tree.h:192
Gudhi::Simplex_tree< MyOptions >::Vertex_handle
Options::Vertex_handle Vertex_handle
Definition Simplex_tree.h:119
Gudhi::Simplex_tree::cofaces_simplex_range
Cofaces_simplex_range cofaces_simplex_range(const Simplex_handle simplex, int codimension) const
Compute the cofaces of a n simplex.
Definition Simplex_tree.h:1324
Gudhi::Simplex_tree::insert_simplex_and_subfaces
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:1074
Gudhi::Simplex_tree::find
Simplex_handle find(const InputVertexRange &s) const
Given a range of Vertex_handles, returns the Simplex_handle of the simplex in the simplicial complex ...
Definition Simplex_tree.h:899
Gudhi::Simplex_tree_options_minimal
Definition simplex_tree_options.h:64