summaryrefslogtreecommitdiff
path: root/src/Rips_complex/example
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-09-29 10:56:50 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-09-29 10:56:50 +0000
commit452cf2181433a317fcc4d8c0661df3401073eec9 (patch)
tree02029103949b5f75d6e1930423dc1678f7837716 /src/Rips_complex/example
parentca6b3d72f2114cdd2d0899fd44dba19303dd3bb2 (diff)
New example and texts for doc
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_module@1587 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 332335f6f101f08e246b35de6e3a84c2348fd4ee
Diffstat (limited to 'src/Rips_complex/example')
-rw-r--r--src/Rips_complex/example/CMakeLists.txt6
-rw-r--r--src/Rips_complex/example/example_rips_complex_from_points.cpp69
-rw-r--r--src/Rips_complex/example/rips_points_for_doc_12_2.txt20
-rw-r--r--src/Rips_complex/example/rips_points_for_doc_12_3.txt26
4 files changed, 121 insertions, 0 deletions
diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt
index 6d0deecf..f8dcf94d 100644
--- a/src/Rips_complex/example/CMakeLists.txt
+++ b/src/Rips_complex/example/CMakeLists.txt
@@ -6,3 +6,9 @@ target_link_libraries(ripsoffreader ${Boost_SYSTEM_LIBRARY})
if (TBB_FOUND)
target_link_libraries(ripsoffreader ${TBB_LIBRARIES})
endif()
+
+add_executable ( ripspoints example_rips_complex_from_points.cpp )
+target_link_libraries(ripspoints ${Boost_SYSTEM_LIBRARY})
+if (TBB_FOUND)
+ target_link_libraries(ripspoints ${TBB_LIBRARIES})
+endif()
diff --git a/src/Rips_complex/example/example_rips_complex_from_points.cpp b/src/Rips_complex/example/example_rips_complex_from_points.cpp
new file mode 100644
index 00000000..c241d137
--- /dev/null
+++ b/src/Rips_complex/example/example_rips_complex_from_points.cpp
@@ -0,0 +1,69 @@
+#include <gudhi/Rips_complex.h>
+// to construct Rips_complex from a OFF file of points
+#include <gudhi/Points_off_io.h>
+// to construct a simplex_tree from rips complex
+#include <gudhi/Simplex_tree.h>
+#include <gudhi/distance_functions.h>
+
+#include <iostream>
+#include <string>
+#include <limits> // for std::numeric_limits
+
+void usage(int nbArgs, char * const progName) {
+ std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n";
+ std::cerr << "Usage: " << progName << " dim_max [threshold]\n";
+ std::cerr << " i.e.: " << progName << " 3 12.0\n";
+ exit(-1); // ----- >>
+}
+
+int main(int argc, char **argv) {
+ if ((argc != 2) && (argc != 3)) usage(argc, argv[0]);
+
+ double threshold = std::numeric_limits<double>::infinity();
+ int dim_max = atoi(argv[1]);
+
+ if (argc == 3) {
+ threshold = atof(argv[2]);
+ }
+
+ // Type definitions
+ using Point = std::vector<double>;
+ using Simplex_tree = Gudhi::Simplex_tree<>;
+ using Rips_complex = Gudhi::rips_complex::Rips_complex<Simplex_tree::Filtration_value>;
+
+ std::vector<Point> points;
+ points.push_back({1.0, 1.0});
+ points.push_back({7.0, 0.0});
+ points.push_back({4.0, 6.0});
+ points.push_back({9.0, 6.0});
+ points.push_back({0.0, 14.0});
+ points.push_back({2.0, 19.0});
+ points.push_back({9.0, 17.0});
+
+ // ----------------------------------------------------------------------------
+ // Init of a rips complex from an OFF file
+ // ----------------------------------------------------------------------------
+ Rips_complex rips_complex_from_file(points, threshold, euclidean_distance<Point>);
+
+ Simplex_tree simplex;
+ if (rips_complex_from_file.create_complex(simplex, dim_max)) {
+ // ----------------------------------------------------------------------------
+ // Display information about the rips complex
+ // ----------------------------------------------------------------------------
+ std::cout << "Rips complex is of dimension " << simplex.dimension() <<
+ " - " << simplex.num_simplices() << " simplices - " <<
+ simplex.num_vertices() << " vertices." << std::endl;
+
+ std::cout << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" <<
+ std::endl;
+ for (auto f_simplex : simplex.filtration_simplex_range()) {
+ std::cout << " ( ";
+ for (auto vertex : simplex.simplex_vertex_range(f_simplex)) {
+ std::cout << vertex << " ";
+ }
+ std::cout << ") -> " << "[" << simplex.filtration(f_simplex) << "] ";
+ std::cout << std::endl;
+ }
+ }
+ return 0;
+}
diff --git a/src/Rips_complex/example/rips_points_for_doc_12_2.txt b/src/Rips_complex/example/rips_points_for_doc_12_2.txt
new file mode 100644
index 00000000..b0e25cc5
--- /dev/null
+++ b/src/Rips_complex/example/rips_points_for_doc_12_2.txt
@@ -0,0 +1,20 @@
+Rips complex is of dimension 1 - 18 simplices - 7 vertices.
+Iterator on rips complex simplices in the filtration order, with [filtration value]:
+ ( 0 ) -> [0]
+ ( 1 ) -> [0]
+ ( 2 ) -> [0]
+ ( 3 ) -> [0]
+ ( 4 ) -> [0]
+ ( 5 ) -> [0]
+ ( 6 ) -> [0]
+ ( 3 2 ) -> [5]
+ ( 5 4 ) -> [5.38516]
+ ( 2 0 ) -> [5.83095]
+ ( 1 0 ) -> [6.08276]
+ ( 3 1 ) -> [6.32456]
+ ( 2 1 ) -> [6.7082]
+ ( 6 5 ) -> [7.28011]
+ ( 4 2 ) -> [8.94427]
+ ( 3 0 ) -> [9.43398]
+ ( 6 4 ) -> [9.48683]
+ ( 6 3 ) -> [11]
diff --git a/src/Rips_complex/example/rips_points_for_doc_12_3.txt b/src/Rips_complex/example/rips_points_for_doc_12_3.txt
new file mode 100644
index 00000000..319931e0
--- /dev/null
+++ b/src/Rips_complex/example/rips_points_for_doc_12_3.txt
@@ -0,0 +1,26 @@
+Rips complex is of dimension 3 - 24 simplices - 7 vertices.
+Iterator on rips complex simplices in the filtration order, with [filtration value]:
+ ( 0 ) -> [0]
+ ( 1 ) -> [0]
+ ( 2 ) -> [0]
+ ( 3 ) -> [0]
+ ( 4 ) -> [0]
+ ( 5 ) -> [0]
+ ( 6 ) -> [0]
+ ( 3 2 ) -> [5]
+ ( 5 4 ) -> [5.38516]
+ ( 2 0 ) -> [5.83095]
+ ( 1 0 ) -> [6.08276]
+ ( 3 1 ) -> [6.32456]
+ ( 2 1 ) -> [6.7082]
+ ( 2 1 0 ) -> [6.7082]
+ ( 3 2 1 ) -> [6.7082]
+ ( 6 5 ) -> [7.28011]
+ ( 4 2 ) -> [8.94427]
+ ( 3 0 ) -> [9.43398]
+ ( 3 1 0 ) -> [9.43398]
+ ( 3 2 0 ) -> [9.43398]
+ ( 3 2 1 0 ) -> [9.43398]
+ ( 6 4 ) -> [9.48683]
+ ( 6 5 4 ) -> [9.48683]
+ ( 6 3 ) -> [11]