summaryrefslogtreecommitdiff
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
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
-rw-r--r--src/Rips_complex/example/example_rips_complex_from_fvecs.cpp8
-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
-rw-r--r--src/Witness_complex/example/example_strong_witness_complex_fvecs.cpp8
-rw-r--r--src/common/doc/main_page.h17
7 files changed, 49 insertions, 20 deletions
diff --git a/src/Rips_complex/example/example_rips_complex_from_fvecs.cpp b/src/Rips_complex/example/example_rips_complex_from_fvecs.cpp
index 5e7667bd..1b683326 100644
--- a/src/Rips_complex/example/example_rips_complex_from_fvecs.cpp
+++ b/src/Rips_complex/example/example_rips_complex_from_fvecs.cpp
@@ -1,10 +1,11 @@
#include <gudhi/Rips_complex.h>
-// to construct Rips_complex from a fvecs file of points
#include <gudhi/Simplex_tree.h>
#include <gudhi/Fake_simplex_tree.h>
+#include <gudhi/Sb_wrapper.h>
#include <gudhi/distance_functions.h>
#include <gudhi/Points_fvecs_reader.h>
+
#include <CGAL/Epick_d.h>
#include <iostream>
@@ -30,7 +31,8 @@ int main(int argc, char **argv) {
using K = CGAL::Epick_d<CGAL::Dynamic_dimension_tag>;
using Point = typename K::Point_d;
//using Simplex_tree = Gudhi::Simplex_tree<>;
- using Simplex_tree = Gudhi::Fake_simplex_tree;
+ //using Simplex_tree = Gudhi::Fake_simplex_tree;
+ using Simplex_tree = Gudhi::Sb_wrapper;
using Filtration_value = Simplex_tree::Filtration_value;
using Rips_complex = Gudhi::rips_complex::Rips_complex<Filtration_value>;
using Point_vector = std::vector<Point>;
@@ -52,7 +54,7 @@ int main(int argc, char **argv) {
end = clock();
std::cout << "Strong witness complex took "<< static_cast<double>(end - start) / CLOCKS_PER_SEC << " s." << std::endl;
- std::cout << "Rips complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() << " simplices." << std::endl;
+ //std::cout << "Rips complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() << " simplices." << std::endl;
return 0;
}
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"
diff --git a/src/Witness_complex/example/example_strong_witness_complex_fvecs.cpp b/src/Witness_complex/example/example_strong_witness_complex_fvecs.cpp
index a8e16fb0..9f5b32c4 100644
--- a/src/Witness_complex/example/example_strong_witness_complex_fvecs.cpp
+++ b/src/Witness_complex/example/example_strong_witness_complex_fvecs.cpp
@@ -22,6 +22,7 @@
#include <gudhi/Simplex_tree.h>
#include <gudhi/Fake_simplex_tree.h>
+#include <gudhi/Sb_wrapper.h>
#include <gudhi/Euclidean_strong_witness_complex.h>
#include <gudhi/pick_n_random_points.h>
#include <gudhi/Points_fvecs_reader.h>
@@ -51,7 +52,8 @@ int main(int argc, char * const argv[]) {
double alpha2 = atof(argv[3]);
clock_t start, end;
//Gudhi::Simplex_tree<> simplex_tree;
- Gudhi::Fake_simplex_tree simplex_tree;
+ //Gudhi::Fake_simplex_tree simplex_tree;
+ Gudhi::Sb_wrapper simplex_tree;
// Read the point file
Point_vector point_vector, landmarks;
@@ -73,7 +75,7 @@ int main(int argc, char * const argv[]) {
end = clock();
std::cout << "Strong witness complex took "
<< static_cast<double>(end - start) / CLOCKS_PER_SEC << " s. \n";
- std::cout << "Number of simplices is: " << simplex_tree.num_simplices() << std::endl;
- std::cout << "Max dimension is : " << simplex_tree.dimension() << std::endl;
+// std::cout << "Number of simplices is: " << simplex_tree.num_simplices() << std::endl;
+ // std::cout << "Max dimension is : " << simplex_tree.dimension() << std::endl;
}
diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h
index d6569f0c..71655824 100644
--- a/src/common/doc/main_page.h
+++ b/src/common/doc/main_page.h
@@ -133,6 +133,23 @@
</td>
</tr>
</table>
+ \subsection ToplexMapDataStructure Toplex Map
+ \image html "map.png" "Toplex map representation"
+<table border="0">
+ <tr>
+ <td width="25%">
+ <b>Author:</b> Fran&ccedil;ois Godi<br>
+ <b>Introduced in:</b> GUDHI 2.1.0<br>
+ <b>Copyright:</b> GPL v3<br>
+ </td>
+ <td width="75%">
+ The Toplex map data structure is composed firstly of a raw storage of toplices (the maximal simplices)
+ and secondly of a map which associate any vertex to a set of pointers toward all toplices
+ containing this vertex.
+ <b>User manual:</b> \ref toplex_map - <b>Reference manual:</b> Gudhi::Toplex_map
+ </td>
+ </tr>
+
\subsection WitnessComplexDataStructure Witness complex
\image html "Witness_complex_representation.png" "Witness complex representation"
<table border="0">