23 #ifndef GUDHI_SKELETON_BLOCKER_SUB_COMPLEX_H
24 #define GUDHI_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"
54 template<
typename ComplexType>
55 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;
69 using ComplexType::add_vertex;
70 using ComplexType::add_edge;
71 using ComplexType::add_blocker;
73 typedef typename ComplexType::Vertex_handle Vertex_handle;
75 typedef typename ComplexType::Simplex_handle Simplex_handle;
76 typedef typename ComplexType::Root_simplex_handle Root_simplex_handle;
103 typedef std::map<Root_vertex_handle, Vertex_handle> IdAddressMap;
104 typedef typename IdAddressMap::value_type AddressPair;
105 typedef typename IdAddressMap::iterator IdAddressMapIterator;
106 typedef typename IdAddressMap::const_iterator IdAddressMapConstIterator;
107 std::map<Root_vertex_handle, Vertex_handle> adresses;
119 assert(!this->contains_vertex(global));
120 Vertex_handle address(boost::add_vertex(this->skeleton));
121 this->num_vertices_++;
122 (*this)[address].activate();
123 (*this)[address].set_id(global);
124 adresses.insert(AddressPair(global, address));
125 this->degree_.push_back(0);
135 void add_edge(Root_vertex_handle v1_root, Root_vertex_handle v2_root){
138 assert(v1_sub && v2_sub);
139 this->ComplexType::add_edge(*v1_sub, *v2_sub);
148 auto blocker_sub = this->
get_address(blocker_root);
150 this->
add_blocker(
new Simplex_handle(*blocker_sub));
164 for (
auto x : simplex){
165 assert(parent_complex.contains_vertex(x));
167 (*this)[x_local] = parent_complex[x];
171 for (
auto x : simplex){
173 Simplex_handle x_neigh;
174 parent_complex.add_neighbours(x, x_neigh,
true);
175 x_neigh.intersection(simplex);
176 for (
auto y : x_neigh){
182 for (
auto blocker : parent_complex.const_blocker_range()){
184 if (simplex.contains(*blocker)){
185 Root_simplex_handle blocker_root(parent_complex.get_id(*(blocker)));
187 this->
add_blocker(
new Simplex_handle(blocker_restr));
196 ComplexType::clear();
203 boost::optional<Vertex_handle>
get_address(Root_vertex_handle global)
const{
204 boost::optional<Vertex_handle> res;
205 IdAddressMapConstIterator it = adresses.find(global);
206 if (it == adresses.end()) res.reset();
207 else res = (*it).second;
224 std::vector<boost::optional<Vertex_handle> >
get_addresses(
const Root_simplex_handle & s)
const{
225 std::vector<boost::optional<Vertex_handle> > res;
242 template<
typename ComplexType>
243 bool proper_face_in_union(
244 Skeleton_blocker_sub_complex<ComplexType> & link,
245 std::vector<boost::optional<typename ComplexType::Vertex_handle> > & addresses_sigma_in_link,
246 int vertex_to_be_ignored)
250 bool vertices_sigma_are_in_link =
true;
251 typename ComplexType::Simplex_handle sigma_in_link;
252 for (
int i = 0; i < addresses_sigma_in_link.size(); ++i){
253 if (i != vertex_to_be_ignored){
254 if (!addresses_sigma_in_link[i]){
255 vertices_sigma_are_in_link =
false;
258 else sigma_in_link.add_vertex(*addresses_sigma_in_link[i]);
263 return vertices_sigma_are_in_link && link.contains(sigma_in_link);
292 template<
typename ComplexType>
294 proper_faces_in_union(Skeleton_blocker_simplex<typename ComplexType::Root_vertex_handle> & sigma, Skeleton_blocker_sub_complex<ComplexType> & link1, Skeleton_blocker_sub_complex<ComplexType> & link2)
296 typedef typename ComplexType::Vertex_handle Vertex_handle;
297 std::vector<boost::optional<Vertex_handle> > addresses_sigma_in_link1 = link1.get_addresses(sigma);
298 std::vector<boost::optional<Vertex_handle> > addresses_sigma_in_link2 = link2.get_addresses(sigma);
300 for (
int current_index = 0; current_index < addresses_sigma_in_link1.size(); ++current_index)
303 if (!proper_face_in_union(link1, addresses_sigma_in_link1, current_index)
304 && !proper_face_in_union(link2, addresses_sigma_in_link2, current_index)){
Vertex_handle add_vertex(Root_vertex_handle global)
Definition: Skeleton_blocker_sub_complex.h:118
void clear()
Definition: Skeleton_blocker_sub_complex.h:194
void add_edge(Root_vertex_handle v1_root, Root_vertex_handle v2_root)
Definition: Skeleton_blocker_sub_complex.h:135
boost::optional< Vertex_handle > get_address(Root_vertex_handle global) const
Definition: Skeleton_blocker_sub_complex.h:203
void add_blocker(const Root_simplex_handle &blocker_root)
Definition: Skeleton_blocker_sub_complex.h:147
std::vector< boost::optional< Vertex_handle > > get_addresses(const Root_simplex_handle &s) const
Definition: Skeleton_blocker_sub_complex.h:224
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:957
void make_restricted_complex(const ComplexType &parent_complex, const Simplex_handle &simplex)
Definition: Skeleton_blocker_sub_complex.h:161
Root_vertex_handle get_id(Vertex_handle local) const
Definition: Skeleton_blocker_complex.h:511
Vertex_handle add_vertex()
Adds a vertex to the simplicial complex and returns its Vertex_handle.
Definition: Skeleton_blocker_complex.h:443
Root_vertex_handle and Vertex_handle are similar to global and local vertex descriptor used in boost ...
Definition: SkeletonBlockerDS.h:50