summaryrefslogtreecommitdiff
path: root/src/Toplex_map
diff options
context:
space:
mode:
authorfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-03-27 18:46:18 +0000
committerfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-03-27 18:46:18 +0000
commit7f3ea79d26c78c8b2107a6a85feba933bd5512ac (patch)
treeadef85730a69005fa532165877accf9c57bee7ae /src/Toplex_map
parent6485e6957ef3c9310f618db6caaf2858cc56db66 (diff)
sb_wrapper working
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/toplex_map@3308 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c7400a11583b8b67483974664e410f4c77232fb1
Diffstat (limited to 'src/Toplex_map')
-rw-r--r--src/Toplex_map/include/gudhi/Fake_simplex_tree.h17
-rw-r--r--src/Toplex_map/include/gudhi/Filtered_toplex_map.h10
-rw-r--r--src/Toplex_map/include/gudhi/Toplex_map.h7
-rw-r--r--src/Toplex_map/test/toplex_map_unit_test.cpp2
4 files changed, 22 insertions, 14 deletions
diff --git a/src/Toplex_map/include/gudhi/Fake_simplex_tree.h b/src/Toplex_map/include/gudhi/Fake_simplex_tree.h
index abd815f9..55955e7b 100644
--- a/src/Toplex_map/include/gudhi/Fake_simplex_tree.h
+++ b/src/Toplex_map/include/gudhi/Fake_simplex_tree.h
@@ -31,9 +31,6 @@ struct Visitor {
class Fake_simplex_tree : public Filtered_toplex_map {
public:
- /** The type of the sets of Simplex_ptr.
- * \ingroup toplex_map */
- typedef Toplex_map::Simplex_ptr_set Simplex_ptr_set;
/** Handle type to a vertex contained in the simplicial complex.
* \ingroup toplex_map */
@@ -87,6 +84,8 @@ public:
* \ingroup toplex_map */
std::vector<Toplex_map::Simplex> skeleton_simplex_range(int d) const;
+ Toplex_map::Vertex contraction(const Toplex_map::Vertex x, const Toplex_map::Vertex y);
+
protected:
@@ -99,14 +98,14 @@ protected:
template<class OneSkeletonGraph>
void Fake_simplex_tree::insert_graph(const OneSkeletonGraph& skel_graph){
- toplex_maps.emplace(nan(""),Toplex_map());
+ toplex_maps.emplace(nan(""), new Toplex_map());
using vertex_iterator = typename boost::graph_traits<OneSkeletonGraph>::vertex_iterator;
vertex_iterator vi, vi_end;
for (std::tie(vi, vi_end) = boost::vertices(skel_graph); vi != vi_end; ++vi) {
Simplex s; s.insert(*vi);
insert_simplex_and_subfaces(s);
}
- bron_kerbosch_all_cliques(skel_graph, Visitor(&(this->toplex_maps.at(nan("")))));
+ bron_kerbosch_all_cliques(skel_graph, Visitor(this->toplex_maps.at(nan(""))));
}
void Fake_simplex_tree::expansion(int max_dim){}
@@ -150,7 +149,7 @@ Toplex_map::Simplex Fake_simplex_tree::simplex_vertex_range(const Simplex& s) co
std::vector<Toplex_map::Simplex> Fake_simplex_tree::max_simplices() const{
std::vector<Toplex_map::Simplex> max_s;
for(auto kv : toplex_maps)
- for(const Toplex_map::Simplex_ptr& sptr : kv.second.maximal_cofaces(Simplex()))
+ for(const Toplex_map::Simplex_ptr& sptr : kv.second->maximal_cofaces(Simplex()))
max_s.emplace_back(*sptr);
return max_s;
}
@@ -178,6 +177,12 @@ std::vector<Toplex_map::Simplex> Fake_simplex_tree::skeleton_simplex_range(int d
return filtration_simplex_range(d);
}
+Toplex_map::Vertex Fake_simplex_tree::contraction(const Toplex_map::Vertex x, const Toplex_map::Vertex y){
+ for(auto kv : toplex_maps)
+ kv.second->contraction(x,y,true);
+ return y;
+}
+
} //namespace Gudhi
#endif /* FAKE_SIMPLEX_TREE_H */
diff --git a/src/Toplex_map/include/gudhi/Filtered_toplex_map.h b/src/Toplex_map/include/gudhi/Filtered_toplex_map.h
index 379c65dd..a3653acd 100644
--- a/src/Toplex_map/include/gudhi/Filtered_toplex_map.h
+++ b/src/Toplex_map/include/gudhi/Filtered_toplex_map.h
@@ -50,15 +50,15 @@ public:
bool membership(const Input_vertex_range &vertex_range) const;
protected:
- std::map<Filtration_value, Toplex_map> toplex_maps;
+ std::map<Filtration_value, Toplex_map*> toplex_maps;
};
template <typename Input_vertex_range>
std::pair<Toplex_map::Simplex, bool> Filtered_toplex_map::insert_simplex_and_subfaces(const Input_vertex_range &vertex_range, Filtration_value f){
Simplex s(vertex_range.begin(),vertex_range.end());
if(membership(s)) return make_pair(s,false);
- if(!toplex_maps.count(f)) toplex_maps.emplace(f,Toplex_map());
- toplex_maps.at(f).insert_simplex(vertex_range);
+ if(!toplex_maps.count(f)) toplex_maps.emplace(f,new Toplex_map());
+ toplex_maps.at(f)->insert_simplex(vertex_range);
return make_pair(s,true);
}
@@ -66,7 +66,7 @@ std::pair<Toplex_map::Simplex, bool> Filtered_toplex_map::insert_simplex_and_sub
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))
+ if(kv.second->membership(vertex_range))
return kv.first; //min only because a map is ordered
return nan("");
}
@@ -74,7 +74,7 @@ Filtered_toplex_map::Filtration_value Filtered_toplex_map::filtration(const Inpu
template <typename Input_vertex_range>
bool Filtered_toplex_map::membership(const Input_vertex_range &vertex_range) const{
for(auto kv : toplex_maps)
- if(kv.second.membership(vertex_range))
+ if(kv.second->membership(vertex_range))
return true;
return false;
}
diff --git a/src/Toplex_map/include/gudhi/Toplex_map.h b/src/Toplex_map/include/gudhi/Toplex_map.h
index 00127baf..ccea34d5 100644
--- a/src/Toplex_map/include/gudhi/Toplex_map.h
+++ b/src/Toplex_map/include/gudhi/Toplex_map.h
@@ -69,7 +69,7 @@ public:
* The edge has to verify the link condition if you want to preserve topology.
* Returns the remaining vertex.
* \ingroup toplex_map */
- Toplex_map::Vertex contraction(const Toplex_map::Vertex x, const Toplex_map::Vertex y);
+ Toplex_map::Vertex contraction(const Toplex_map::Vertex x, const Toplex_map::Vertex y, bool force=false);
/** Adds the given simplex to the complex.
* The simplex must not have neither maximal face nor coface in the complex.
@@ -196,17 +196,18 @@ Toplex_map::Simplex_ptr_set Toplex_map::maximal_cofaces(const Input_vertex_range
return cofaces;
}
-Toplex_map::Vertex Toplex_map::contraction(const Toplex_map::Vertex x, const Toplex_map::Vertex y){
+Toplex_map::Vertex Toplex_map::contraction(const Toplex_map::Vertex x, const Toplex_map::Vertex y, bool force){
if(!t0.count(x)) return y;
if(!t0.count(y)) return x;
int k, d;
- if(t0.at(x).size() > t0.at(y).size())
+ if(force || (t0.at(x).size() > t0.at(y).size()))
k=x, d=y;
else
k=y, d=x;
for(const Toplex_map::Simplex_ptr& sptr : Simplex_ptr_set(t0.at(d))){
//Copy constructor needed because the set is modified
Simplex sigma(*sptr);
+ Simplex s; s.insert(2);
erase_maximal(sptr);
sigma.erase(d);
sigma.insert(k);
diff --git a/src/Toplex_map/test/toplex_map_unit_test.cpp b/src/Toplex_map/test/toplex_map_unit_test.cpp
index b7a9251c..b714cd2a 100644
--- a/src/Toplex_map/test/toplex_map_unit_test.cpp
+++ b/src/Toplex_map/test/toplex_map_unit_test.cpp
@@ -1,6 +1,8 @@
#include <iostream>
#include <gudhi/Filtered_toplex_map.h>
#include <gudhi/Fake_simplex_tree.h>
+#include <gudhi/Sb_wrapper.h>
+
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "toplex map"