11 #ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_
12 #define SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_
14 #include <gudhi/Skeleton_blocker_complex.h>
15 #include <gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h>
16 #include <gudhi/Debug_utils.h>
23 namespace skeleton_blocker {
45 template<
typename ComplexType>
50 typedef typename ComplexType::Graph Graph;
51 typedef typename ComplexType::Edge_handle Edge_handle;
53 typedef typename ComplexType::boost_vertex_handle boost_vertex_handle;
56 using ComplexType::add_vertex;
57 using ComplexType::add_edge_without_blockers;
58 using ComplexType::add_blocker;
60 typedef typename ComplexType::Vertex_handle Vertex_handle;
61 typedef typename ComplexType::Root_vertex_handle Root_vertex_handle;
62 typedef typename ComplexType::Simplex Simplex;
63 typedef typename ComplexType::Root_simplex_handle Root_simplex_handle;
70 typedef std::map<Root_vertex_handle, Vertex_handle> IdAddressMap;
71 typedef typename IdAddressMap::value_type AddressPair;
72 typedef typename IdAddressMap::iterator IdAddressMapIterator;
73 typedef typename IdAddressMap::const_iterator IdAddressMapConstIterator;
74 std::map<Root_vertex_handle, Vertex_handle> addresses;
85 assert(!this->contains_vertex(global));
86 Vertex_handle address(boost::add_vertex(this->skeleton));
87 this->num_vertices_++;
88 (*this)[address].activate();
89 (*this)[address].set_id(global);
90 addresses.insert(AddressPair(global, address));
91 this->degree_.push_back(0);
103 assert(v1_sub && v2_sub);
104 this->ComplexType::add_edge_without_blockers(*v1_sub, *v2_sub);
113 auto blocker_sub = this->
get_address(blocker_root);
124 const Simplex& simplex) {
127 for (
auto x : simplex) {
128 assert(parent_complex.contains_vertex(x));
130 (*this)[x_local] = parent_complex[x];
134 for (
auto x : simplex) {
137 parent_complex.add_neighbours(x, x_neigh,
true);
138 x_neigh.intersection(simplex);
139 for (
auto y : x_neigh) {
145 for (
auto blocker : parent_complex.const_blocker_range()) {
147 if (simplex.contains(*blocker)) {
148 Root_simplex_handle blocker_root(parent_complex.get_id(*(blocker)));
149 Simplex blocker_restr(
158 ComplexType::clear();
165 boost::optional<Vertex_handle>
get_address(Root_vertex_handle global)
const {
166 boost::optional < Vertex_handle > res;
167 IdAddressMapConstIterator it = addresses.find(global);
168 if (it == addresses.end())
189 const Root_simplex_handle & s)
const {
190 std::vector < boost::optional<Vertex_handle> > res;
202 template<
typename ComplexType>
203 bool proper_face_in_union(
204 Skeleton_blocker_sub_complex<ComplexType> & link,
205 std::vector<boost::optional<typename ComplexType::Vertex_handle> > & addresses_sigma_in_link,
206 std::size_t vertex_to_be_ignored) {
209 bool vertices_sigma_are_in_link =
true;
210 typename ComplexType::Simplex sigma_in_link;
211 for (std::size_t i = 0; i < addresses_sigma_in_link.size(); ++i) {
212 if (i != vertex_to_be_ignored) {
213 if (!addresses_sigma_in_link[i]) {
214 vertices_sigma_are_in_link =
false;
217 sigma_in_link.add_vertex(*addresses_sigma_in_link[i]);
223 return vertices_sigma_are_in_link && link.contains(sigma_in_link);
231 template<
typename ComplexType>
232 bool proper_faces_in_union(
233 Skeleton_blocker_simplex<typename ComplexType::Root_vertex_handle> & sigma,
234 Skeleton_blocker_sub_complex<ComplexType> & link1,
235 Skeleton_blocker_sub_complex<ComplexType> & link2) {
237 std::vector < boost::optional<Vertex_handle> > addresses_sigma_in_link1 =
238 link1.get_addresses(sigma);
239 std::vector < boost::optional<Vertex_handle> > addresses_sigma_in_link2 =
240 link2.get_addresses(sigma);
242 for (std::size_t current_index = 0; current_index < addresses_sigma_in_link1.size();
244 if (!proper_face_in_union(link1, addresses_sigma_in_link1, current_index)
245 && !proper_face_in_union(link2, addresses_sigma_in_link2,
255 namespace skbl = skeleton_blocker;
boost::optional< Simplex > get_simplex_address(const Root_simplex_handle &s) const
Compute the local vertices of 's' in the current complex If one of them is not present in the complex...
Definition: Skeleton_blocker_complex.h:919
Vertex_handle add_vertex()
Adds a vertex to the simplicial complex and returns its Vertex_handle.
Definition: Skeleton_blocker_complex.h:372
Root_vertex_handle get_id(Vertex_handle local) const
Definition: Skeleton_blocker_complex.h:443
Class representing the link of a simplicial complex encoded by a skeleton/blockers pair....
Definition: Skeleton_blocker_link_complex.h:31
Simplicial subcomplex of a complex represented by a skeleton/blockers pair.
Definition: Skeleton_blocker_sub_complex.h:46
std::vector< boost::optional< Vertex_handle > > get_addresses(const Root_simplex_handle &s) const
Definition: Skeleton_blocker_sub_complex.h:188
void clear()
Definition: Skeleton_blocker_sub_complex.h:156
void make_restricted_complex(const ComplexType &parent_complex, const Simplex &simplex)
Definition: Skeleton_blocker_sub_complex.h:123
boost::optional< Vertex_handle > get_address(Root_vertex_handle global) const
Definition: Skeleton_blocker_sub_complex.h:165
void add_blocker(const Root_simplex_handle &blocker_root)
Definition: Skeleton_blocker_sub_complex.h:112
Vertex_handle add_vertex(Root_vertex_handle global)
Definition: Skeleton_blocker_sub_complex.h:84
void add_edge_without_blockers(Root_vertex_handle v1_root, Root_vertex_handle v2_root)
Definition: Skeleton_blocker_sub_complex.h:100
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:15