summaryrefslogtreecommitdiff
path: root/src/Toplex_map/include
diff options
context:
space:
mode:
authorfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-11-21 18:38:25 +0000
committerfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-11-21 18:38:25 +0000
commitbf84494b3e7f3d2a36661b66defb131e515cdc5b (patch)
tree1e94f295a7285350a95af1e8347fe67787bce93b /src/Toplex_map/include
parent8d3be7f7008eb06b001797510c965a2b2a4009a9 (diff)
...
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/toplex_map@2926 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d872eef9342046002b81f55cc12760e799df0c1d
Diffstat (limited to 'src/Toplex_map/include')
-rw-r--r--src/Toplex_map/include/gudhi/Fake_simplex_tree.h69
-rw-r--r--src/Toplex_map/include/gudhi/Filtered_toplex_map.h11
2 files changed, 37 insertions, 43 deletions
diff --git a/src/Toplex_map/include/gudhi/Fake_simplex_tree.h b/src/Toplex_map/include/gudhi/Fake_simplex_tree.h
index 6a0782ea..3de962af 100644
--- a/src/Toplex_map/include/gudhi/Fake_simplex_tree.h
+++ b/src/Toplex_map/include/gudhi/Fake_simplex_tree.h
@@ -1,14 +1,14 @@
#ifndef FAKE_SIMPLEX_TREE_H
#define FAKE_SIMPLEX_TREE_H
+#include <cmath>
+
#include <gudhi/Simplex_tree.h>
#include <gudhi/Filtered_toplex_map.h>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/bron_kerbosch_all_cliques.hpp>
-#define filtration_upper_bound std::numeric_limits<Filtration_value>::max()
-
namespace Gudhi {
struct Visitor {
@@ -35,33 +35,31 @@ public:
typedef void Insertion_result_type;
- /** \brief Inserts a given range `Gudhi::rips_complex::Rips_complex::OneSkeletonGraph` in the simplicial
+ /** \brief Inserts the flag complex of a given range `Gudhi::rips_complex::Rips_complex::OneSkeletonGraph` in the simplicial
* complex. */
template<class OneSkeletonGraph>
void insert_graph(const OneSkeletonGraph& skel_graph);
- /** \brief Expands the simplicial complex containing only its one skeleton until a given maximal dimension as
- * explained in \ref ripsdefinition. */
+ /** \brief Do nothing */
void expansion(int max_dim);
- /** \brief Returns the number of vertices in the simplicial complex. */
+ /** \brief Returns the number of vertices stored i.e. the number of max simplices */
std::size_t num_vertices() const;
- Simplex_ptr_set candidates(int min_dim=-1) const;
-
std::size_t dimension() const;
+ std::size_t dimension(Simplex_ptr& sptr) const;
+
std::size_t num_simplices() const;
Simplex simplex_vertex_range(const Simplex& s) const;
std::vector<Simplex> max_simplices() const;
- std::vector<Simplex> filtration_simplex_range() const;
+ std::vector<Simplex> filtration_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::vector<Simplex> skeleton_simplex_range(int d) const;
- std::size_t dimension(Simplex_ptr& sptr) const;
protected:
@@ -74,8 +72,8 @@ protected:
template<class OneSkeletonGraph>
void Fake_simplex_tree::insert_graph(const OneSkeletonGraph& skel_graph){
- toplex_maps.emplace(filtration_upper_bound,Toplex_map());
- bron_kerbosch_all_cliques(skel_graph, Visitor(&(this->toplex_maps.at(filtration_upper_bound))));
+ toplex_maps.emplace(nan(""),Toplex_map());
+ bron_kerbosch_all_cliques(skel_graph, Visitor(&(this->toplex_maps.at(nan("")))));
}
void Fake_simplex_tree::expansion(int max_dim){}
@@ -95,6 +93,10 @@ std::size_t Fake_simplex_tree::dimension() const {
return max-1;
}
+std::size_t Fake_simplex_tree::dimension(Simplex_ptr& sptr) const{
+ return sptr->size();
+}
+
std::size_t Fake_simplex_tree::num_simplices() const {
//return filtration_simplex_range().size();
return max_simplices().size();
@@ -112,42 +114,35 @@ Simplex Fake_simplex_tree::simplex_vertex_range(const Simplex& s) const {
return s;
}
-std::vector<Simplex> Fake_simplex_tree::filtration_simplex_range() const{
+std::vector<Simplex> Fake_simplex_tree::max_simplices() const{
+ std::vector<Simplex> max_s;
+ for(auto kv : toplex_maps)
+ for(const Simplex_ptr& sptr : kv.second.maximal_cofaces(Simplex()))
+ max_s.emplace_back(*sptr);
+ return max_s;
+}
+
+std::vector<Simplex> Fake_simplex_tree::filtration_simplex_range(int d) const{
std::vector<Simplex> m = max_simplices();
- std::vector<Simplex> seen1;
- Simplex_ptr_set seen2;
+ std::vector<Simplex> range;
+ Simplex_ptr_set seen;
while(m.begin()!=m.end()){
Simplex s(m.back());
m.pop_back();
- if(seen2.find(get_key(s))==seen2.end()){
- seen1.emplace_back(s);
- seen2.emplace(get_key(s));
+ if(seen.find(get_key(s))==seen.end()){
+ if(s.size()-1<=d)
+ range.emplace_back(s);
+ seen.emplace(get_key(s));
if(s.size()>0)
for(Simplex& sigma : facets(s))
m.emplace_back(sigma);
}
}
- return seen1;
+ return range;
}
std::vector<Simplex> Fake_simplex_tree::skeleton_simplex_range(int d) const{
- std::vector<Simplex> simplices;
- for(const Simplex& s : max_simplices())
- if(s.size()<=d)
- simplices.emplace_back(s);
- return simplices;
-}
-
-std::vector<Simplex> Fake_simplex_tree::max_simplices() const{
- std::vector<Simplex> max_s;
- for(auto kv : toplex_maps)
- for(const Simplex_ptr& sptr : kv.second.maximal_cofaces(Simplex()))
- max_s.emplace_back(*sptr);
- return max_s;
-}
-
-std::size_t Fake_simplex_tree::dimension(Simplex_ptr& sptr) const{
- return sptr->size();
+ return filtration_simplex_range(d);
}
} //namespace Gudhi
diff --git a/src/Toplex_map/include/gudhi/Filtered_toplex_map.h b/src/Toplex_map/include/gudhi/Filtered_toplex_map.h
index 3a0064dc..a0c24304 100644
--- a/src/Toplex_map/include/gudhi/Filtered_toplex_map.h
+++ b/src/Toplex_map/include/gudhi/Filtered_toplex_map.h
@@ -2,10 +2,9 @@
#define FILTERED_TOPLEX_MAP_H
#include <gudhi/Toplex_map.h>
+#include <map>
#include <limits>
-#define filtration_upper_bound std::numeric_limits<Filtration_value>::max()
-
namespace Gudhi {
class Filtered_toplex_map {
@@ -14,7 +13,7 @@ public:
typedef double Filtration_value;
template <typename Input_vertex_range>
- std::pair<Simplex, bool> insert_simplex_and_subfaces(const Input_vertex_range &vertex_range, Filtration_value f = filtration_upper_bound);
+ std::pair<Simplex, bool> insert_simplex_and_subfaces(const Input_vertex_range &vertex_range, Filtration_value f = nan(""));
template <typename Input_vertex_range>
Filtration_value filtration(const Input_vertex_range &vertex_range) const;
@@ -23,7 +22,7 @@ public:
bool membership(const Input_vertex_range &vertex_range) const;
protected:
- std::unordered_map<Filtration_value, Toplex_map> toplex_maps;
+ std::map<Filtration_value, Toplex_map> toplex_maps;
};
template <typename Input_vertex_range>
@@ -40,8 +39,8 @@ template <typename Input_vertex_range>
Filtered_toplex_map::Filtration_value Filtered_toplex_map::filtration(const Input_vertex_range &vertex_range) const{
for(auto kv : toplex_maps)
if(kv.second.membership(vertex_range))
- return kv.first;
- return filtration_upper_bound;
+ return kv.first; //min only because a map is ordered
+ return nan("");
}
template <typename Input_vertex_range>