11 #ifndef SKELETON_BLOCKER_LINK_COMPLEX_H_ 12 #define SKELETON_BLOCKER_LINK_COMPLEX_H_ 14 #include <gudhi/Skeleton_blocker_complex.h> 15 #include <gudhi/Debug_utils.h> 19 namespace skeleton_blocker {
21 template<
class ComplexType>
class Skeleton_blocker_sub_complex;
29 template<
typename ComplexType>
33 typedef typename ComplexType::Edge_handle Edge_handle;
35 typedef typename ComplexType::boost_vertex_handle boost_vertex_handle;
38 bool only_superior_vertices_;
41 typedef typename ComplexType::Vertex_handle Vertex_handle;
42 typedef typename ComplexType::Root_vertex_handle Root_vertex_handle;
44 typedef typename ComplexType::Simplex Simplex;
45 typedef typename ComplexType::Root_simplex_handle Root_simplex_handle;
49 typedef typename ComplexType::Root_simplex_handle::Simplex_vertex_const_iterator Root_simplex_handle_iterator;
52 : only_superior_vertices_(only_superior_vertices) { }
60 const Simplex& alpha_parent_adress,
61 bool only_superior_vertices =
false,
62 bool only_vertices =
false)
63 : only_superior_vertices_(only_superior_vertices) {
64 if (!alpha_parent_adress.empty())
65 build_link(parent_complex, alpha_parent_adress, only_vertices);
73 Vertex_handle a_parent_adress,
74 bool only_superior_vertices =
false)
75 : only_superior_vertices_(only_superior_vertices) {
76 Simplex alpha_simplex(a_parent_adress);
85 Edge_handle edge,
bool only_superior_vertices =
87 : only_superior_vertices_(only_superior_vertices) {
88 Simplex alpha_simplex(parent_complex.first_vertex(edge),
89 parent_complex.second_vertex(edge));
99 void compute_link_vertices(
const ComplexType & parent_complex,
100 const Simplex& alpha_parent_adress,
101 bool only_superior_vertices,
102 bool is_alpha_blocker =
false) {
103 if (alpha_parent_adress.dimension() == 0) {
106 this->compute_link_vertices(parent_complex,
107 alpha_parent_adress.first_vertex(),
108 only_superior_vertices_);
111 Simplex link_vertices_parent;
112 parent_complex.add_neighbours(alpha_parent_adress, link_vertices_parent,
113 only_superior_vertices);
116 for (
auto v_parent : link_vertices_parent) {
117 bool new_vertex =
true;
118 for (
auto beta : parent_complex.const_blocker_range(v_parent)) {
119 if (!is_alpha_blocker || *beta != alpha_parent_adress) {
120 new_vertex = !(alpha_parent_adress.contains_difference(*beta,
127 this->
add_vertex(parent_complex.get_id(v_parent));
137 void compute_link_vertices(
const ComplexType & parent_complex,
138 Vertex_handle alpha_parent_adress,
139 bool only_superior_vertices) {
141 this->skeleton.m_vertices.reserve(
142 parent_complex.degree(alpha_parent_adress));
146 for (
auto v_parent : parent_complex.vertex_range(alpha_parent_adress)) {
147 if (!only_superior_vertices
148 || v_parent.vertex > alpha_parent_adress.vertex)
149 this->
add_vertex(parent_complex.get_id(v_parent));
153 void compute_link_edges(
const ComplexType & parent_complex,
154 const Simplex& alpha_parent_adress,
155 bool is_alpha_blocker =
false) {
156 if (this->num_vertices() <= 1)
161 for (
auto y_link = x_link; ++y_link != this->
vertex_range().end();) {
162 Vertex_handle x_parent = *parent_complex.get_address(
164 Vertex_handle y_parent = *parent_complex.get_address(
166 if (parent_complex.contains_edge(x_parent, y_parent)) {
168 bool new_edge =
true;
169 for (
auto blocker_parent : parent_complex.const_blocker_range(
171 if (!is_alpha_blocker || *blocker_parent != alpha_parent_adress) {
172 if (blocker_parent->contains(y_parent)) {
173 new_edge = !(alpha_parent_adress.contains_difference(
174 *blocker_parent, x_parent, y_parent));
192 boost::optional<Vertex_handle> give_equivalent_vertex(
const ComplexType & other_complex,
193 Vertex_handle address)
const {
194 Root_vertex_handle id((*
this)[address].
get_id());
195 return other_complex.get_address(
id);
203 void compute_link_blockers(
const ComplexType & parent_complex,
204 const Simplex& alpha_parent,
205 bool is_alpha_blocker =
false) {
207 Vertex_handle x_parent = *this->give_equivalent_vertex(parent_complex,
210 for (
auto blocker_parent : parent_complex.const_blocker_range(x_parent)) {
211 if (!is_alpha_blocker || *blocker_parent != alpha_parent) {
212 Simplex sigma_parent(*blocker_parent);
214 sigma_parent.difference(alpha_parent);
216 if (sigma_parent.dimension() >= 2
217 && sigma_parent.first_vertex() == x_parent) {
218 Root_simplex_handle sigma_id(parent_complex.get_id(sigma_parent));
222 bool is_new_blocker =
true;
223 for (
auto a : alpha_parent) {
224 for (
auto eta_parent : parent_complex.const_blocker_range(a)) {
225 if (!is_alpha_blocker || *eta_parent != alpha_parent) {
226 Simplex eta_minus_alpha(*eta_parent);
227 eta_minus_alpha.difference(alpha_parent);
228 if (eta_minus_alpha != sigma_parent
229 && sigma_parent.contains_difference(*eta_parent,
231 is_new_blocker =
false;
255 const Simplex& alpha_parent_adress,
256 bool is_alpha_blocker =
false,
257 bool only_vertices =
false) {
258 assert(is_alpha_blocker || parent_complex.contains(alpha_parent_adress));
259 compute_link_vertices(parent_complex, alpha_parent_adress, only_superior_vertices_);
260 if (!only_vertices) {
261 compute_link_edges(parent_complex, alpha_parent_adress, is_alpha_blocker);
262 compute_link_blockers(parent_complex, alpha_parent_adress, is_alpha_blocker);
274 assert(blocker.dimension() >= 2);
275 assert(parent_complex.contains_blocker(blocker));
277 result.
build_link(parent_complex, blocker,
true);
283 namespace skbl = skeleton_blocker;
287 #endif // SKELETON_BLOCKER_LINK_COMPLEX_H_ Simplicial subcomplex of a complex represented by a skeleton/blockers pair.
Definition: Skeleton_blocker_link_superior.h:20
Abstract simplex used in Skeleton blockers data-structure.
Definition: Skeleton_blocker_simplex.h:38
void add_blocker(const Root_simplex_handle &blocker_root)
Definition: Skeleton_blocker_sub_complex.h:112
Skeleton_blocker_link_complex(const ComplexType &parent_complex, const Simplex &alpha_parent_adress, bool only_superior_vertices=false, bool only_vertices=false)
Definition: Skeleton_blocker_link_complex.h:59
Skeleton_blocker_link_complex(const ComplexType &parent_complex, Vertex_handle a_parent_adress, bool only_superior_vertices=false)
Definition: Skeleton_blocker_link_complex.h:72
Class representing the link of a simplicial complex encoded by a skeleton/blockers pair...
Definition: Skeleton_blocker_link_complex.h:30
Definition: SimplicialComplexForAlpha.h:14
Class representing the link of a simplicial complex encoded by a skeleton/blockers pair...
Definition: Skeleton_blocker_link_superior.h:27
Root_vertex_handle get_id(Vertex_handle local) const
Definition: Skeleton_blocker_complex.h:443
Skeleton_blocker_link_complex(const ComplexType &parent_complex, Edge_handle edge, bool only_superior_vertices=false)
Definition: Skeleton_blocker_link_complex.h:84
void build_link(const ComplexType &parent_complex, const Simplex &alpha_parent_adress, bool is_alpha_blocker=false, bool only_vertices=false)
compute vertices, edges and blockers of the link.
Definition: Skeleton_blocker_link_complex.h:254
friend void build_link_of_blocker(const ComplexType &parent_complex, Simplex &blocker, Skeleton_blocker_link_complex &result)
build the link of a blocker which is the link of the blocker's simplex if this simplex had been remov...
Definition: Skeleton_blocker_link_complex.h:271
void add_edge_without_blockers(Root_vertex_handle v1_root, Root_vertex_handle v2_root)
Definition: Skeleton_blocker_sub_complex.h:100
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
Complex_vertex_range vertex_range() const
Returns a Complex_vertex_range over all vertices of the complex.
Definition: Skeleton_blocker_complex.h:1284
void clear()
Definition: Skeleton_blocker_sub_complex.h:156