diff options
-rw-r--r-- | src/Collapse/doc/intro_edge_collapse.h | 6 | ||||
-rw-r--r-- | src/Collapse/example/edge_collapse_basic_example.cpp | 12 | ||||
-rw-r--r-- | src/Collapse/example/edge_collapse_conserve_persistence.cpp | 10 | ||||
-rw-r--r-- | src/Collapse/include/gudhi/Flag_complex_edge_collapser.h (renamed from src/Collapse/include/gudhi/Flag_complex_sparse_matrix.h) | 34 | ||||
-rw-r--r-- | src/Collapse/test/collapse_unit_test.cpp | 18 | ||||
-rw-r--r-- | src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp | 10 | ||||
-rw-r--r-- | src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp | 10 |
7 files changed, 50 insertions, 50 deletions
diff --git a/src/Collapse/doc/intro_edge_collapse.h b/src/Collapse/doc/intro_edge_collapse.h index 15f2208c..2b272a9e 100644 --- a/src/Collapse/doc/intro_edge_collapse.h +++ b/src/Collapse/doc/intro_edge_collapse.h @@ -76,9 +76,9 @@ namespace collapse { * * \subsection edgecollapseexample Basic edge collapse * - * This example builds the `Flag_complex_sparse_matrix` from a proximity graph represented as a list of - * `Flag_complex_sparse_matrix::Filtered_edge`. - * Then it collapses edges and displays a new list of `Flag_complex_sparse_matrix::Filtered_edge` (with less edges) + * This example builds the `Flag_complex_edge_collapser` from a proximity graph represented as a list of + * `Flag_complex_edge_collapser::Filtered_edge`. + * Then it collapses edges and displays a new list of `Flag_complex_edge_collapser::Filtered_edge` (with less edges) * that will preserve the persistence homology computation. * * \include Collapse/edge_collapse_basic_example.cpp diff --git a/src/Collapse/example/edge_collapse_basic_example.cpp b/src/Collapse/example/edge_collapse_basic_example.cpp index a154c6bb..333bc231 100644 --- a/src/Collapse/example/edge_collapse_basic_example.cpp +++ b/src/Collapse/example/edge_collapse_basic_example.cpp @@ -1,4 +1,4 @@ -#include <gudhi/Flag_complex_sparse_matrix.h> +#include <gudhi/Flag_complex_edge_collapser.h> #include <iostream> #include <vector> @@ -7,10 +7,10 @@ int main() { // Type definitions using Filtration_value = float; using Vertex_handle = short; - using Flag_complex_sparse_matrix = Gudhi::collapse::Flag_complex_sparse_matrix<Vertex_handle, Filtration_value>; - using Filtered_edge = Flag_complex_sparse_matrix::Filtered_edge; + using Flag_complex_edge_collapser = Gudhi::collapse::Flag_complex_edge_collapser<Vertex_handle, Filtration_value>; + using Filtered_edge = Flag_complex_edge_collapser::Filtered_edge; using Filtered_edge_list = std::vector<Filtered_edge>; - using Edge = Flag_complex_sparse_matrix::Edge; + using Edge = Flag_complex_edge_collapser::Edge; // 1 2 // o---o @@ -26,11 +26,11 @@ int main() { {{0, 2}, 2.}, {{1, 3}, 2.}}; - Flag_complex_sparse_matrix flag_complex_sparse_matrix(graph); + Flag_complex_edge_collapser edge_collapser(graph); Filtered_edge_list collapse_edges; // Retrieve collapse edges from the output iterator - flag_complex_sparse_matrix.filtered_edge_collapse( + edge_collapser.process_edges( [&collapse_edges](std::pair<Vertex_handle, Vertex_handle> edge, Filtration_value filtration) { collapse_edges.push_back({edge, filtration}); }); diff --git a/src/Collapse/example/edge_collapse_conserve_persistence.cpp b/src/Collapse/example/edge_collapse_conserve_persistence.cpp index 9c561efc..701ea1af 100644 --- a/src/Collapse/example/edge_collapse_conserve_persistence.cpp +++ b/src/Collapse/example/edge_collapse_conserve_persistence.cpp @@ -8,7 +8,7 @@ * - YYYY/MM Author: Description of the modification */ -#include <gudhi/Flag_complex_sparse_matrix.h> +#include <gudhi/Flag_complex_edge_collapser.h> #include <gudhi/Simplex_tree.h> #include <gudhi/Persistent_cohomology.h> #include <gudhi/distance_functions.h> @@ -27,8 +27,8 @@ 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 Proximity_graph = Flag_complex_sparse_matrix::Proximity_graph; +using Flag_complex_edge_collapser = Gudhi::collapse::Flag_complex_edge_collapser<Vertex_handle, Filtration_value>; +using Proximity_graph = Flag_complex_edge_collapser::Proximity_graph; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Field_Zp>; @@ -112,14 +112,14 @@ int main(int argc, char* argv[]) { int ambient_dim = point_vector[0].size(); // ***** Simplex tree from a flag complex built after collapse ***** - Flag_complex_sparse_matrix mat_filt_edge_coll(proximity_graph); + Flag_complex_edge_collapser edge_collapser(proximity_graph); Simplex_tree stree_from_collapse; for (Vertex_handle vertex = 0; static_cast<std::size_t>(vertex) < point_vector.size(); vertex++) { // insert the vertex with a 0. filtration value just like a Rips stree_from_collapse.insert_simplex({vertex}, 0.); } - mat_filt_edge_coll.filtered_edge_collapse( + edge_collapser.process_edges( [&stree_from_collapse](const std::vector<Vertex_handle>& edge, Filtration_value filtration) { // insert the edge stree_from_collapse.insert_simplex(edge, filtration); diff --git a/src/Collapse/include/gudhi/Flag_complex_sparse_matrix.h b/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h index 4402523f..32438c3b 100644 --- a/src/Collapse/include/gudhi/Flag_complex_sparse_matrix.h +++ b/src/Collapse/include/gudhi/Flag_complex_edge_collapser.h @@ -9,8 +9,8 @@ * - YYYY/MM Author: Description of the modification */ -#ifndef FLAG_COMPLEX_SPARSE_MATRIX_H_ -#define FLAG_COMPLEX_SPARSE_MATRIX_H_ +#ifndef FLAG_COMPLEX_EDGE_COLLAPSER_H_ +#define FLAG_COMPLEX_EDGE_COLLAPSER_H_ #include <gudhi/graph_simplicial_complex.h> #include <gudhi/Debug_utils.h> @@ -39,7 +39,7 @@ namespace Gudhi { namespace collapse { /** - * \class Flag_complex_sparse_matrix + * \class Flag_complex_edge_collapser * \brief Flag complex sparse matrix data structure. * * \ingroup collapse @@ -52,7 +52,7 @@ namespace collapse { * \tparam Filtration type for the value of the filtration function. Must be comparable with <. */ template<typename Vertex, typename Filtration> -class Flag_complex_sparse_matrix { +class Flag_complex_edge_collapser { public: /** \brief Re-define Vertex as Vertex_handle type to ease the interface with compute_proximity_graph. */ using Vertex_handle = Vertex; @@ -80,8 +80,8 @@ class Flag_complex_sparse_matrix { public: /** \brief Filtered_edge is a type to store an edge with its filtration value. */ using Filtered_edge = std::pair<Edge, Filtration_value>; - /** \brief Proximity_graph is a type that can be used to construct easily a Flag_complex_sparse_matrix. */ - using Proximity_graph = Gudhi::Proximity_graph<Flag_complex_sparse_matrix>; + /** \brief Proximity_graph is a type that can be used to construct easily a Flag_complex_edge_collapser. */ + using Proximity_graph = Gudhi::Proximity_graph<Flag_complex_edge_collapser>; private: // Map from row index to its vertex handle @@ -265,7 +265,7 @@ class Flag_complex_sparse_matrix { // @exception std::invalid_argument In debug mode, if u == v IEdge insert_new_edge(Vertex_handle u, Vertex_handle v, Edge_index idx) { - GUDHI_CHECK((u != v), std::invalid_argument("Flag_complex_sparse_matrix::insert_new_edge with u == v")); + GUDHI_CHECK((u != v), std::invalid_argument("Flag_complex_edge_collapser::insert_new_edge with u == v")); // The edge must not be added before, it should be a new edge. IVertex rw_u = insert_vertex(u); IVertex rw_v = insert_vertex(v); @@ -278,26 +278,26 @@ class Flag_complex_sparse_matrix { } public: - /** \brief Flag_complex_sparse_matrix constructor from a range of filtered edges. + /** \brief Flag_complex_edge_collapser constructor from a range of filtered edges. * * @param[in] filtered_edge_range Range of filtered edges. Filtered edges must be in - * `Flag_complex_sparse_matrix::Filtered_edge`. + * `Flag_complex_edge_collapser::Filtered_edge`. * * There is no need the range to be sorted, as it will be performed in - * `Flag_complex_sparse_matrix::filtered_edge_collapse`. + * `Flag_complex_edge_collapser::process_edges`. */ template<typename Filtered_edge_range> - Flag_complex_sparse_matrix(const Filtered_edge_range& filtered_edge_range) + Flag_complex_edge_collapser(const Filtered_edge_range& filtered_edge_range) : f_edge_vector_(filtered_edge_range.begin(), filtered_edge_range.end()) { } - /** \brief Flag_complex_sparse_matrix constructor from a proximity graph, cf. `Gudhi::compute_proximity_graph`. + /** \brief Flag_complex_edge_collapser constructor from a proximity graph, cf. `Gudhi::compute_proximity_graph`. * * @param[in] one_skeleton_graph The one skeleton graph. The graph must be in - * `Flag_complex_sparse_matrix::Proximity_graph`. + * `Flag_complex_edge_collapser::Proximity_graph`. * - * The constructor is computing and filling a vector of `Flag_complex_sparse_matrix::Filtered_edge` + * The constructor is computing and filling a vector of `Flag_complex_edge_collapser::Filtered_edge` */ - Flag_complex_sparse_matrix(const Proximity_graph& one_skeleton_graph) { + Flag_complex_edge_collapser(const Proximity_graph& one_skeleton_graph) { // Insert all edges for (auto edge_it = boost::edges(one_skeleton_graph); edge_it.first != edge_it.second; ++edge_it.first) { @@ -314,7 +314,7 @@ class Flag_complex_sparse_matrix { * that will get called on the output edges, in non-decreasing order of filtration. */ template<typename FilteredEdgeOutput> - void filtered_edge_collapse(FilteredEdgeOutput filtered_edge_output) { + void process_edges(FilteredEdgeOutput filtered_edge_output) { // Sort edges auto sort_by_filtration = [](const Filtered_edge& edge_a, const Filtered_edge& edge_b) -> bool { @@ -355,4 +355,4 @@ class Flag_complex_sparse_matrix { } // namespace Gudhi -#endif // FLAG_COMPLEX_SPARSE_MATRIX_H_ +#endif // FLAG_COMPLEX_EDGE_COLLAPSER_H_ diff --git a/src/Collapse/test/collapse_unit_test.cpp b/src/Collapse/test/collapse_unit_test.cpp index 1bec3810..e45dc339 100644 --- a/src/Collapse/test/collapse_unit_test.cpp +++ b/src/Collapse/test/collapse_unit_test.cpp @@ -14,7 +14,7 @@ #include <boost/test/unit_test.hpp> #include <boost/mpl/list.hpp> -#include <gudhi/Flag_complex_sparse_matrix.h> +#include <gudhi/Flag_complex_edge_collapser.h> #include <gudhi/distance_functions.h> #include <gudhi/graph_simplicial_complex.h> @@ -26,8 +26,8 @@ using Filtration_value = float; using Vertex_handle = short; -using Flag_complex_sparse_matrix = Gudhi::collapse::Flag_complex_sparse_matrix<Vertex_handle, Filtration_value>; -using Filtered_edge = Flag_complex_sparse_matrix::Filtered_edge; +using Flag_complex_edge_collapser = Gudhi::collapse::Flag_complex_edge_collapser<Vertex_handle, Filtration_value>; +using Filtered_edge = Flag_complex_edge_collapser::Filtered_edge; using Filtered_edge_list = std::vector<Filtered_edge>; template<typename Filtered_edge_range> @@ -49,9 +49,9 @@ void trace_and_check_collapse(const Filtered_edge_range& filtered_edges, const F } std::cout << "COLLAPSE - keep edges: " << std::endl; - Flag_complex_sparse_matrix flag_complex_sparse_matrix(filtered_edges); + Flag_complex_edge_collapser edge_collapser(filtered_edges); Filtered_edge_list collapse_edges; - flag_complex_sparse_matrix.filtered_edge_collapse( + edge_collapser.process_edges( [&collapse_edges](std::pair<Vertex_handle, Vertex_handle> edge, Filtration_value filtration) { std::cout << "f[" << std::get<0>(edge) << ", " << std::get<1>(edge) << "] = " << filtration << std::endl; collapse_edges.push_back({edge, filtration}); @@ -164,13 +164,13 @@ BOOST_AUTO_TEST_CASE(collapse_from_proximity_graph) { {1., 1.} }; Filtration_value threshold = std::numeric_limits<Filtration_value>::infinity(); - using Proximity_graph = Flag_complex_sparse_matrix::Proximity_graph; - Proximity_graph proximity_graph = Gudhi::compute_proximity_graph<Flag_complex_sparse_matrix>(point_cloud, + using Proximity_graph = Flag_complex_edge_collapser::Proximity_graph; + Proximity_graph proximity_graph = Gudhi::compute_proximity_graph<Flag_complex_edge_collapser>(point_cloud, threshold, Gudhi::Euclidean_distance()); - Flag_complex_sparse_matrix flag_complex_sparse_matrix(proximity_graph); + Flag_complex_edge_collapser edge_collapser(proximity_graph); Filtered_edge_list collapse_edges; - flag_complex_sparse_matrix.filtered_edge_collapse( + edge_collapser.process_edges( [&collapse_edges](std::pair<Vertex_handle, Vertex_handle> edge, Filtration_value filtration) { std::cout << "f[" << std::get<0>(edge) << ", " << std::get<1>(edge) << "] = " << filtration << std::endl; collapse_edges.push_back({edge, filtration}); 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 7201a6b4..ae9ff32b 100644 --- a/src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp +++ b/src/Collapse/utilities/distance_matrix_edge_collapse_rips_persistence.cpp @@ -8,7 +8,7 @@ * - YYYY/MM Author: Description of the modification */ -#include <gudhi/Flag_complex_sparse_matrix.h> +#include <gudhi/Flag_complex_edge_collapser.h> #include <gudhi/Simplex_tree.h> #include <gudhi/Persistent_cohomology.h> #include <gudhi/reader_utils.h> @@ -20,8 +20,8 @@ using Simplex_tree = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persis 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 Proximity_graph = Flag_complex_sparse_matrix::Proximity_graph; +using Flag_complex_edge_collapser = Gudhi::collapse::Flag_complex_edge_collapser<Vertex_handle, Filtration_value>; +using Proximity_graph = Flag_complex_edge_collapser::Proximity_graph; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Field_Zp>; @@ -90,14 +90,14 @@ int main(int argc, char* argv[]) { }); // Now we will perform filtered edge collapse to sparsify the edge list edge_t. - Flag_complex_sparse_matrix flag_complex(proximity_graph); + Flag_complex_edge_collapser edge_collapser(proximity_graph); Simplex_tree stree; for (Vertex_handle vertex = 0; static_cast<std::size_t>(vertex) < distances.size(); vertex++) { // insert the vertex with a 0. filtration value just like a Rips stree.insert_simplex({vertex}, 0.); } - flag_complex.filtered_edge_collapse( + edge_collapser.process_edges( [&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.); 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 19f083c4..d2d31013 100644 --- a/src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp +++ b/src/Collapse/utilities/point_cloud_edge_collapse_rips_persistence.cpp @@ -8,7 +8,7 @@ * - YYYY/MM Author: Description of the modification */ -#include <gudhi/Flag_complex_sparse_matrix.h> +#include <gudhi/Flag_complex_edge_collapser.h> #include <gudhi/Simplex_tree.h> #include <gudhi/Persistent_cohomology.h> #include <gudhi/distance_functions.h> @@ -28,8 +28,8 @@ 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 Proximity_graph = Flag_complex_sparse_matrix::Proximity_graph; +using Flag_complex_edge_collapser = Gudhi::collapse::Flag_complex_edge_collapser<Vertex_handle, Filtration_value>; +using Proximity_graph = Flag_complex_edge_collapser::Proximity_graph; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology<Simplex_tree, Field_Zp>; @@ -77,14 +77,14 @@ int main(int argc, char* argv[]) { exit(-1); } - Flag_complex_sparse_matrix mat_filt_edge_coll(proximity_graph); + Flag_complex_edge_collapser edge_collapser(proximity_graph); Simplex_tree stree; for (Vertex_handle vertex = 0; static_cast<std::size_t>(vertex) < point_vector.size(); vertex++) { // insert the vertex with a 0. filtration value just like a Rips stree.insert_simplex({vertex}, 0.); } - mat_filt_edge_coll.filtered_edge_collapse( + edge_collapser.process_edges( [&stree](const 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.); |