summaryrefslogtreecommitdiff
path: root/src/Toplex_map/include/gudhi/Fake_simplex_tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Toplex_map/include/gudhi/Fake_simplex_tree.h')
-rw-r--r--src/Toplex_map/include/gudhi/Fake_simplex_tree.h142
1 files changed, 63 insertions, 79 deletions
diff --git a/src/Toplex_map/include/gudhi/Fake_simplex_tree.h b/src/Toplex_map/include/gudhi/Fake_simplex_tree.h
index 10ef39d7..b318acb4 100644
--- a/src/Toplex_map/include/gudhi/Fake_simplex_tree.h
+++ b/src/Toplex_map/include/gudhi/Fake_simplex_tree.h
@@ -1,9 +1,12 @@
#ifndef FAKE_SIMPLEX_TREE_H
#define FAKE_SIMPLEX_TREE_H
+#include <gudhi/Simplex_tree.h>
#include <gudhi/Filtered_toplex_map.h>
+
#include <boost/graph/adjacency_list.hpp>
+
namespace Gudhi {
class Fake_simplex_tree : public Filtered_toplex_map {
@@ -12,7 +15,7 @@ public:
typedef Vertex Vertex_handle;
- typedef Simplex_ptr Simplex_handle;
+ typedef Simplex Simplex_handle;
typedef void Insertion_result_type;
@@ -36,20 +39,16 @@ public:
void set_dimension(int d);
- Simplex simplex_vertex_range(Simplex_ptr &sptr) const;
+ Simplex simplex_vertex_range(const Simplex& s) const;
- std::vector<Simplex_ptr> max_simplices() const;
+ std::vector<Simplex> max_simplices() const;
- std::unordered_set<Simplex_ptr> filtration_simplex_range() const;
+ std::vector<Simplex> filtration_simplex_range() const;
- std::unordered_set<Simplex_ptr> skeleton_simplex_range(int d=std::numeric_limits<int>::max()) const;
+ std::vector<Simplex> skeleton_simplex_range(int d=std::numeric_limits<int>::max()) const;
std::size_t dimension(Simplex_ptr& sptr) const;
- void assign_filtration(Simplex_ptr& f_simplex, Filtration_value alpha_complex_filtration);
-
- void make_filtration_non_decreasing();
-
protected:
/** \internal Does all the facets of the given simplex belong to the complex ?
@@ -65,28 +64,34 @@ void Fake_simplex_tree::set_dimension(int d){
template<class OneSkeletonGraph>
void Fake_simplex_tree::insert_graph(const OneSkeletonGraph& skel_graph){
- typename boost::graph_traits<OneSkeletonGraph>::edge_iterator e_it,
- e_it_end;
+ if (boost::num_vertices(skel_graph) == 0) return;
+ typename boost::graph_traits<OneSkeletonGraph>::vertex_iterator v_it, v_it_end;
+ for (std::tie(v_it, v_it_end) = boost::vertices(skel_graph); v_it != v_it_end; ++v_it){
+ Simplex s;
+ s.insert(*v_it);
+ insert_simplex_and_subfaces(s, boost::get(vertex_filtration_t(), skel_graph, *v_it));
+ }
+
+ typename boost::graph_traits<OneSkeletonGraph>::edge_iterator e_it, e_it_end;
for (std::tie(e_it, e_it_end) = boost::edges(skel_graph); e_it != e_it_end; ++e_it) {
- auto u = source(*e_it, skel_graph);
- auto v = target(*e_it, skel_graph);
- if(u<v){
+ Vertex u = source(*e_it, skel_graph);
+ Vertex v = target(*e_it, skel_graph);
+ if (u < v) {
Simplex s;
- s.emplace(u);
- s.emplace(v);
- insert_simplex_and_subfaces(s);
+ s.insert(u);
+ s.insert(v);
+ insert_simplex_and_subfaces(s, boost::get(edge_filtration_t(), skel_graph, *e_it));
}
}
}
void Fake_simplex_tree::expansion(int max_dim){
- for(int d=3; d <= max_dim; d++){
- auto cs = candidates();
+ for(int d=2; d <= max_dim; d++){
+ Simplex_ptr_set cs = candidates(); //dimension ?
+ if(cs.empty()) std::cout << d << std::endl;
if(cs.empty()) return;
- for(const Simplex_ptr& sptr: cs){
- Simplex sigma = *sptr;
- insert_simplex_and_subfaces(sigma);
- }
+ for(const Simplex_ptr& sptr: cs)
+ insert_simplex_and_subfaces(*sptr); //filtration ?
}
}
@@ -100,16 +105,18 @@ bool Fake_simplex_tree::all_facets_inside(const Input_vertex_range &vertex_range
Simplex_ptr_set Fake_simplex_tree::candidates() const{
Simplex_ptr_set c;
- std::unordered_map<Simplex_ptr, std::vector<Vertex>, Toplex_map::Sptr_hash, Toplex_map::Sptr_equal> facets_to_max;
+ std::unordered_map<Simplex_ptr, std::vector<Vertex>, Sptr_hash, Sptr_equal> facets_to_max;
for(const auto& kv : filtrations){
Simplex sigma (*(kv.first));
- for(Vertex v : sigma){
- sigma.erase(v);
- auto sptr = get_key(sigma);
- if(!facets_to_max.count(sptr)) facets_to_max.emplace(sptr, std::vector<Vertex>());
- facets_to_max.at(sptr).emplace_back(v);
- sigma.insert(v);
- }
+ if(sigma.size()>1)
+ for(Vertex v : *(kv.first)){
+ sigma.erase(v);
+ auto sptr = get_key(sigma);
+ if(!facets_to_max.count(sptr))
+ facets_to_max.emplace(sptr, std::vector<Vertex>());
+ facets_to_max.at(sptr).emplace_back(v);
+ sigma.insert(v);
+ }
}
for(const auto& kv : facets_to_max){
std::unordered_set<Vertex> facets(kv.second.begin(), kv.second.end());
@@ -132,11 +139,12 @@ std::size_t Fake_simplex_tree::dimension() const {
std::size_t max = 0;
for(auto kv : filtrations)
max = std::max(max, kv.first->size());
- return max;
+ return max-1;
}
std::size_t Fake_simplex_tree::num_simplices() const {
- return filtration_simplex_range().size();
+ //return filtration_simplex_range().size();
+ return max_simplices().size();
}
std::size_t Fake_simplex_tree::num_vertices() const {
@@ -147,42 +155,40 @@ std::size_t Fake_simplex_tree::num_vertices() const {
return vertices.size();
}
-Simplex Fake_simplex_tree::simplex_vertex_range(Simplex_ptr& sptr) const {
- return *sptr;
+Simplex Fake_simplex_tree::simplex_vertex_range(const Simplex& s) const {
+ return s;
}
-std::unordered_set<Simplex_ptr> Fake_simplex_tree::filtration_simplex_range() const{
- std::vector<Simplex_ptr> m = max_simplices();
- std::cout << m.size()<< std::endl;
- std::cout << m.size()<< std::endl;
-
- std::cout << m.size()<< std::endl;
-
- std::unordered_set<Simplex_ptr> seen;
+std::vector<Simplex> Fake_simplex_tree::filtration_simplex_range() const{
+ std::vector<Simplex> m = max_simplices();
+ std::vector<Simplex> seen1;
+ Simplex_ptr_set seen2;
while(m.begin()!=m.end()){
- Simplex_ptr& sptr = m.back();
+ Simplex s(m.back());
m.pop_back();
- if(seen.find(sptr)!=seen.end()){
- seen.emplace(sptr);
- for(Simplex& sigma : facets(*sptr))
- m.emplace_back(get_key(sigma));
+ if(seen2.find(get_key(s))==seen2.end()){
+ seen1.emplace_back(s);
+ seen2.emplace(get_key(s));
+ if(s.size()>0)
+ for(Simplex& sigma : facets(s))
+ m.emplace_back(sigma);
}
}
- return seen;
+ return seen1;
}
-std::unordered_set<Simplex_ptr> Fake_simplex_tree::skeleton_simplex_range(int d) const{
- std::unordered_set<Simplex_ptr> simplices;
- for(auto sptr: filtration_simplex_range())
- if(sptr->size()<=d)
- simplices.emplace(sptr);
+std::vector<Simplex> Fake_simplex_tree::skeleton_simplex_range(int d) const{
+ std::vector<Simplex> simplices;
+ for(auto s: filtration_simplex_range())
+ if(s.size()<=d)
+ simplices.emplace_back(s);
return simplices;
}
-std::vector<Simplex_ptr> Fake_simplex_tree::max_simplices() const{
- std::vector<Simplex_ptr> s;
+std::vector<Simplex> Fake_simplex_tree::max_simplices() const{
+ std::vector<Simplex> s;
for(auto kv : filtrations)
- s.emplace_back(kv.first);
+ s.emplace_back(*(kv.first));
return s;
}
@@ -190,28 +196,6 @@ std::size_t Fake_simplex_tree::dimension(Simplex_ptr& sptr) const{
return sptr->size();
}
-
-void Fake_simplex_tree::assign_filtration(Simplex_ptr& f_simplex, Filtration_value alpha_complex_filtration){
- filtrations.emplace(f_simplex,alpha_complex_filtration);
-}
-
-void Fake_simplex_tree::make_filtration_non_decreasing(){
- for(auto yt = filtrations.begin(); yt != filtrations.end(); ++yt)
- for (auto it = toplex_maps.begin(); it != toplex_maps.end(); ++it){
- if(it->first == yt -> second)
- break;
- if(it->second.membership(*(yt->first)))
- for(const Simplex_ptr& sptr : it->second.maximal_cofaces(*(yt->first))){
- it->second.erase_maximal(sptr);
- toplex_maps.at(yt->second).insert_simplex(*sptr);
- filtrations.emplace(sptr,yt->second);
- }
- }
-
-}
-
-
-
} //namespace Gudhi
#endif /* FAKE_SIMPLEX_TREE_H */