summaryrefslogtreecommitdiff
path: root/src/Collapse/utilities
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-04-11 09:21:36 +0200
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-04-11 09:21:36 +0200
commitb5bb9fd2a129ab9c429a0c7c67ca4442e6e7b1b0 (patch)
treef5ed48a5263e0f2cd05d2e97085dfb5dfd208d24 /src/Collapse/utilities
parent2acc203de9dcdb55983db29a903ef0ff16e0a597 (diff)
Vertex_handle, Filtration_value and Row_index type
Diffstat (limited to 'src/Collapse/utilities')
-rw-r--r--src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp40
-rw-r--r--src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp31
2 files changed, 17 insertions, 54 deletions
diff --git a/src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp b/src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp
index b937a8ff..56e9bab6 100644
--- a/src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp
+++ b/src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp
@@ -6,16 +6,14 @@
#include <gudhi/reader_utils.h>
#include <gudhi/Points_off_io.h>
-#include <CGAL/Epick_d.h>
-
#include <boost/program_options.hpp>
-// Types definition
-using Point = CGAL::Epick_d<CGAL::Dynamic_dimension_tag>::Point_d;
-using Vector_of_points = std::vector<Point>;
-
using Simplex_tree = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
-using Filtration_value = double;
+using Filtration_value = Simplex_tree::Filtration_value;
+using Vertex_handle = Simplex_tree::Vertex_handle;
+
+using Flag_complex_sparse_matrix = Gudhi::collapse::Flag_complex_sparse_matrix<Vertex_handle, Filtration_value>;
+
using Rips_edge_list = Gudhi::rips_edge_list::Rips_edge_list<Filtration_value>;
using Field_Zp = Gudhi::persistent_cohomology::Field_Zp;
using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Field_Zp>;
@@ -64,17 +62,12 @@ void program_options(int argc, char* argv[], std::string& csv_matrix_file, std::
Filtration_value& threshold, int& dim_max, int& p, Filtration_value& min_persistence);
int main(int argc, char* argv[]) {
- auto the_begin = std::chrono::high_resolution_clock::now();
-
- typedef size_t Vertex_handle;
- typedef std::vector<std::tuple<Filtration_value, Vertex_handle, Vertex_handle>> Filtered_sorted_edge_list;
-
std::string csv_matrix_file;
std::string filediag;
- double threshold;
+ Filtration_value threshold;
int dim_max = 2;
int p;
- double min_persistence;
+ Filtration_value min_persistence;
program_options(argc, argv, csv_matrix_file, filediag, threshold, dim_max, p, min_persistence);
@@ -82,15 +75,12 @@ int main(int argc, char* argv[]) {
Distance_matrix sparse_distances;
distances = Gudhi::read_lower_triangular_matrix_from_csv_file<Filtration_value>(csv_matrix_file);
- std::size_t number_of_points = distances.size();
- std::cout << "Read the distance matrix succesfully, of size: " << number_of_points << std::endl;
+ std::cout << "Read the distance matrix succesfully, of size: " << distances.size() << std::endl;
- Filtered_sorted_edge_list edge_t;
- std::cout << "Computing the one-skeleton for threshold: " << threshold << std::endl;
+ Flag_complex_sparse_matrix::Filtered_sorted_edge_list edge_t;
Rips_edge_list Rips_edge_list_from_file(distances, threshold);
Rips_edge_list_from_file.create_edges(edge_t);
- std::cout<< "Sorted edge list computed" << std::endl;
if (edge_t.size() <= 0) {
std::cerr << "Total number of egdes are zero." << std::endl;
@@ -100,13 +90,11 @@ int main(int argc, char* argv[]) {
std::cout << "Total number of edges before collapse are: " << edge_t.size() << std::endl;
// Now we will perform filtered edge collapse to sparsify the edge list edge_t.
- std::cout << "Filtered edge collapse begins" << std::endl;
- Gudhi::collapse::Flag_complex_sparse_matrix mat_filt_edge_coll(edge_t);
- std::cout << "Matrix instansiated" << std::endl;
+ Flag_complex_sparse_matrix mat_filt_edge_coll(edge_t);
Simplex_tree stree;
mat_filt_edge_coll.filtered_edge_collapse(
- [&stree](std::vector<std::size_t> edge, double filtration) {
+ [&stree](std::vector<Vertex_handle> edge, Filtration_value filtration) {
// insert the 2 vertices with a 0. filtration value just like a Rips
stree.insert_simplex({edge[0]}, 0.);
stree.insert_simplex({edge[1]}, 0.);
@@ -134,12 +122,6 @@ int main(int argc, char* argv[]) {
pcoh.output_diagram(out);
out.close();
}
-
- auto the_end = std::chrono::high_resolution_clock::now();
-
- std::cout << "Total computation time : " << std::chrono::duration<double, std::milli>(the_end - the_begin).count()
- << " ms\n"
- << std::endl;
return 0;
}
diff --git a/src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp b/src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp
index 5fa24306..4b52e4c6 100644
--- a/src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp
+++ b/src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp
@@ -16,10 +16,11 @@
using Simplex_tree = Gudhi::Simplex_tree<>;
using Filtration_value = Simplex_tree::Filtration_value;
-using Vertex_handle = std::size_t; /*Simplex_tree::Vertex_handle;*/
+using Vertex_handle = Simplex_tree::Vertex_handle;
using Point = std::vector<Filtration_value>;
using Vector_of_points = std::vector<Point>;
+using Flag_complex_sparse_matrix = Gudhi::collapse::Flag_complex_sparse_matrix<Vertex_handle, Filtration_value>;
using Field_Zp = Gudhi::persistent_cohomology::Field_Zp;
using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Field_Zp>;
@@ -33,12 +34,6 @@ void program_options(int argc, char* argv[], std::string& off_file_points, std::
Filtration_value& threshold, int& dim_max, int& p, Filtration_value& min_persistence);
int main(int argc, char* argv[]) {
- typedef std::vector<std::tuple<Filtration_value, Vertex_handle, Vertex_handle>> Filtered_sorted_edge_list;
-
- auto the_begin = std::chrono::high_resolution_clock::now();
- std::size_t number_of_points;
-
-
std::string off_file_points;
std::string filediag;
double threshold;
@@ -68,12 +63,8 @@ int main(int argc, char* argv[]) {
exit(-1); // ----- >>
}
- //int dimension = point_vector[0].dimension();
- number_of_points = point_vector.size();
- std::cout << "Successfully read " << number_of_points << " point_vector.\n";
- //std::cout << "Ambient dimension is " << dimension << ".\n";
-
- std::cout << "Point Set Generated." << std::endl;
+ std::cout << "Successfully read " << point_vector.size() << " point_vector.\n";
+ std::cout << "Ambient dimension is " << point_vector[0].size() << ".\n";
Adjacency_list proximity_graph = Gudhi::compute_proximity_graph<Simplex_tree>(off_reader.get_point_cloud(),
threshold,
@@ -84,16 +75,11 @@ int main(int argc, char* argv[]) {
exit(-1);
}
- std::cout << "Filtered edge collapse begins" << std::endl;
- Gudhi::collapse::Flag_complex_sparse_matrix mat_filt_edge_coll(proximity_graph);
-
- std::cout << "Computing the one-skeleton for threshold: " << threshold << std::endl;
-
- std::cout << "Matrix instansiated" << std::endl;
+ Flag_complex_sparse_matrix mat_filt_edge_coll(proximity_graph);
Simplex_tree stree;
mat_filt_edge_coll.filtered_edge_collapse(
- [&stree](std::vector<std::size_t> edge, double filtration) {
+ [&stree](std::vector<Vertex_handle> edge, Filtration_value filtration) {
// insert the 2 vertices with a 0. filtration value just like a Rips
stree.insert_simplex({edge[0]}, 0.);
stree.insert_simplex({edge[1]}, 0.);
@@ -122,11 +108,6 @@ int main(int argc, char* argv[]) {
out.close();
}
- auto the_end = std::chrono::high_resolution_clock::now();
-
- std::cout << "Total computation time : " << std::chrono::duration<double, std::milli>(the_end - the_begin).count()
- << " ms\n"
- << std::endl;
return 0;
}