23 #ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_
24 #define SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_
26 #include <gudhi/Skeleton_blocker_complex.h>
27 #include <gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h>
28 #include <gudhi/Utils.h>
57 template<
typename ComplexType>
58 class Skeleton_blocker_sub_complex :
public ComplexType {
60 template<
class T>
friend class Skeleton_blocker_link_complex;
62 typedef typename ComplexType::Graph Graph;
63 typedef typename ComplexType::Edge_handle Edge_handle;
65 typedef typename ComplexType::boost_vertex_handle boost_vertex_handle;
68 using ComplexType::add_vertex;
69 using ComplexType::add_edge;
70 using ComplexType::add_blocker;
72 typedef typename ComplexType::Vertex_handle Vertex_handle;
75 typedef typename ComplexType::Root_simplex_handle Root_simplex_handle;
82 typedef std::map<Root_vertex_handle, Vertex_handle> IdAddressMap;
83 typedef typename IdAddressMap::value_type AddressPair;
84 typedef typename IdAddressMap::iterator IdAddressMapIterator;
85 typedef typename IdAddressMap::const_iterator IdAddressMapConstIterator;
86 std::map<Root_vertex_handle, Vertex_handle> adresses;
97 assert(!this->contains_vertex(global));
98 Vertex_handle address(boost::add_vertex(this->skeleton));
99 this->num_vertices_++;
100 (*this)[address].activate();
101 (*this)[address].set_id(global);
102 adresses.insert(AddressPair(global, address));
103 this->degree_.push_back(0);
112 void add_edge(Root_vertex_handle v1_root, Root_vertex_handle v2_root) {
115 assert(v1_sub && v2_sub);
116 this->ComplexType::add_edge(*v1_sub, *v2_sub);
125 auto blocker_sub = this->
get_address(blocker_root);
127 this->
add_blocker(
new Simplex_handle(*blocker_sub));
136 const Simplex_handle& simplex) {
139 for (
auto x : simplex) {
140 assert(parent_complex.contains_vertex(x));
142 (*this)[x_local] = parent_complex[x];
146 for (
auto x : simplex) {
148 Simplex_handle x_neigh;
149 parent_complex.add_neighbours(x, x_neigh,
true);
150 x_neigh.intersection(simplex);
151 for (
auto y : x_neigh) {
157 for (
auto blocker : parent_complex.const_blocker_range()) {
159 if (simplex.contains(*blocker)) {
160 Root_simplex_handle blocker_root(parent_complex.get_id(*(blocker)));
161 Simplex_handle blocker_restr(
163 this->
add_blocker(
new Simplex_handle(blocker_restr));
170 ComplexType::clear();
177 boost::optional<Vertex_handle>
get_address(Root_vertex_handle global)
const {
178 boost::optional < Vertex_handle > res;
179 IdAddressMapConstIterator it = adresses.find(global);
180 if (it == adresses.end())
200 const Root_simplex_handle & s)
const {
201 std::vector < boost::optional<Vertex_handle> > res;
215 template<
typename ComplexType>
216 bool proper_face_in_union(
217 Skeleton_blocker_sub_complex<ComplexType> & link,
218 std::vector<boost::optional<typename ComplexType::Vertex_handle> > & addresses_sigma_in_link,
219 int vertex_to_be_ignored) {
222 bool vertices_sigma_are_in_link =
true;
223 typename ComplexType::Simplex_handle sigma_in_link;
224 for (
int i = 0; i < addresses_sigma_in_link.size(); ++i) {
225 if (i != vertex_to_be_ignored) {
226 if (!addresses_sigma_in_link[i]) {
227 vertices_sigma_are_in_link =
false;
230 sigma_in_link.add_vertex(*addresses_sigma_in_link[i]);
236 return vertices_sigma_are_in_link && link.contains(sigma_in_link);
263 template<
typename ComplexType>
264 bool proper_faces_in_union(
265 Skeleton_blocker_simplex<typename ComplexType::Root_vertex_handle> & sigma,
266 Skeleton_blocker_sub_complex<ComplexType> & link1,
267 Skeleton_blocker_sub_complex<ComplexType> & link2) {
268 typedef typename ComplexType::Vertex_handle Vertex_handle;
269 std::vector < boost::optional<Vertex_handle> > addresses_sigma_in_link1 =
270 link1.get_addresses(sigma);
271 std::vector < boost::optional<Vertex_handle> > addresses_sigma_in_link2 =
272 link2.get_addresses(sigma);
274 for (
int current_index = 0; current_index < addresses_sigma_in_link1.size();
276 if (!proper_face_in_union(link1, addresses_sigma_in_link1, current_index)
277 && !proper_face_in_union(link2, addresses_sigma_in_link2,
289 #endif // SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_
Vertex_handle add_vertex(Root_vertex_handle global)
Definition: Skeleton_blocker_sub_complex.h:96
void clear()
Definition: Skeleton_blocker_sub_complex.h:168
void add_edge(Root_vertex_handle v1_root, Root_vertex_handle v2_root)
Definition: Skeleton_blocker_sub_complex.h:112
boost::optional< Vertex_handle > get_address(Root_vertex_handle global) const
Definition: Skeleton_blocker_sub_complex.h:177
void add_blocker(const Root_simplex_handle &blocker_root)
Definition: Skeleton_blocker_sub_complex.h:124
std::vector< boost::optional< Vertex_handle > > get_addresses(const Root_simplex_handle &s) const
Definition: Skeleton_blocker_sub_complex.h:199
boost::optional< Simplex_handle > 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:902
void make_restricted_complex(const ComplexType &parent_complex, const Simplex_handle &simplex)
Definition: Skeleton_blocker_sub_complex.h:135
Root_vertex_handle get_id(Vertex_handle local) const
Definition: Skeleton_blocker_complex.h:452
Vertex_handle add_vertex()
Adds a vertex to the simplicial complex and returns its Vertex_handle.
Definition: Skeleton_blocker_complex.h:382
Abstract simplex used in Skeleton blockers data-structure.
Definition: Skeleton_blocker_simplex.h:50
Root_vertex_handle and Vertex_handle are similar to global and local vertex descriptor used in boost ...
Definition: SkeletonBlockerDS.h:50