diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/doc/file_formats.h | 83 | ||||
-rw-r--r-- | src/common/doc/main_page.h | 165 | ||||
-rw-r--r-- | src/common/include/gudhi/graph_simplicial_complex.h | 63 | ||||
-rw-r--r-- | src/common/include/gudhi/reader_utils.h | 4 | ||||
-rw-r--r-- | src/common/test/test_distance_matrix_reader.cpp | 4 | ||||
-rw-r--r-- | src/common/test/test_persistence_intervals_reader.cpp | 37 | ||||
-rw-r--r-- | src/common/utilities/README | 26 | ||||
-rw-r--r-- | src/common/utilities/off_file_from_shape_generator.cpp | 2 |
8 files changed, 293 insertions, 91 deletions
diff --git a/src/common/doc/file_formats.h b/src/common/doc/file_formats.h index c145b271..d06b81f5 100644 --- a/src/common/doc/file_formats.h +++ b/src/common/doc/file_formats.h @@ -2,7 +2,7 @@ * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * -* Author(s): Clément Jamin +* Author(s): Clément Jamin * * Copyright (C) 2017 INRIA * @@ -26,7 +26,7 @@ namespace Gudhi { /*! \page fileformats File formats - + \tableofcontents \section FileFormatsPers Persistence Diagram @@ -34,20 +34,89 @@ namespace Gudhi { Such a file, whose extension is usually `.pers`, contains a list of persistence intervals.<br> Lines starting with `#` are ignored (comments).<br> Other lines might contain 2, 3 or 4 values (the number of values on each line must be the same for all lines): - \code{.unparsed} + \verbatim [[field] dimension] birth death - \endcode + \endverbatim Here is a simple sample file: - \code{.unparsed} - # Beautiful persistence diagram + \verbatim + # Persistence diagram example 2 2.7 3.7 2 9.6 14. + # Some comments 3 34.2 34.974 4 3. inf - \endcode + \endverbatim Other sample files can be found in the `data/persistence_diagram` folder. + + Such files can be generated with `Gudhi::persistent_cohomology::Persistent_cohomology::output_diagram()` and read with + `Gudhi::read_persistence_intervals_and_dimension()`, `Gudhi::read_persistence_intervals_grouped_by_dimension()` or + `Gudhi::read_persistence_intervals_in_dimension()`. + + + \section FileFormatsIsoCuboid Iso-cuboid + + Such a file describes an iso-oriented cuboid with diagonal opposite vertices (min_x, min_y, min_z,...) and (max_x, max_y, max_z, ...). The format is:<br> + \verbatim + min_x min_y [min_z ...] + max_x max_y [max_z ...] + \endverbatim + + Here is a simple sample file in the 3D case: + \verbatim + -1. -1. -1. + 1. 1. 1. + \endverbatim + + + \section FileFormatsPerseus Perseus + + This file format is the format used by the Perseus software + (http://www.sas.upenn.edu/~vnanda/perseus/) by Vidit Nanda. + The first line contains a number d begin the dimension of the + bitmap (2 in the example below). Next d lines are the numbers of top dimensional cubes in each dimensions (3 and 3 + in the example below). Next, in lexicographical order, the filtration of top dimensional cubes is given (1 4 6 8 + 20 4 7 6 5 in the example below). + + \image html "exampleBitmap.png" "Example of a input data." + + The input file for the following complex is: + \verbatim + 2 + 3 + 3 + 1 + 4 + 6 + 8 + 20 + 4 + 7 + 6 + 5 + \endverbatim + + To indicate periodic boundary conditions in a + given direction, then number of top dimensional cells in this direction have to be multiplied by -1. For instance: + + \verbatim + 2 + -3 + 3 + 1 + 4 + 6 + 8 + 20 + 4 + 7 + 6 + 5 + \endverbatim + + Indicate that we have imposed periodic boundary conditions in the direction x, but not in the direction y. + */ } // namespace Gudhi diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index e5f135db..108cf6e3 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -93,6 +93,24 @@ </td> </tr> </table> + \subsection CoverComplexDataStructure Cover Complexes: Nerves and Graph Induced Complexes + \image html "gicvisu.jpg" "Graph Induced Complex of a point cloud." +<table border="0"> + <tr> + <td width="25%"> + <b>Author:</b> Mathieu Carrière<br> + <b>Introduced in:</b> GUDHI 2.0.1<br> + <b>Copyright:</b> GPL v3<br> + </td> + <td width="75%"> + Nerves and Graph Induced Complexes are cover complexes, i.e. simplicial complexes that provably contain + topological information about the input data. They can be computed with a cover of the + data, that comes i.e. from the preimage of a family of intervals covering the image + of a scalar-valued function defined on the data. <br> + <b>User manual:</b> \ref cover_complex - <b>Reference manual:</b> Gudhi::cover_complex::Cover_complex + </td> + </tr> +</table> \subsection SkeletonBlockerDataStructure Skeleton blocker \image html "ds_representation.png" "Skeleton blocker representation" <table border="0"> @@ -161,7 +179,7 @@ <b>Author:</b> François Godi<br> <b>Introduced in:</b> GUDHI 2.0.0<br> <b>Copyright:</b> GPL v3<br> - <b>Requires:</b> \ref cgal ≥ 4.8.1 and \ref eigen3 + <b>Requires:</b> \ref cgal ≥ 4.8.1 </td> <td width="75%"> Bottleneck distance measures the similarity between two persistence diagrams. @@ -288,30 +306,38 @@ make doxygen * Having CGAL version 4.4.0 or higher installed is recommended. The procedure to install this library according to * your operating system is detailed here http://doc.cgal.org/latest/Manual/installation.html * - * The following examples require the <a target="_blank" href="http://www.cgal.org/">Computational Geometry Algorithms + * The following examples/utilities require the <a target="_blank" href="http://www.cgal.org/">Computational Geometry Algorithms * Library</a> (CGAL \cite cgal:eb-15b) and will not be built if CGAL is not installed: - * \li <a href="_persistent_cohomology_2alpha_complex_3d_persistence_8cpp-example.html"> - * Persistent_cohomology/alpha_complex_3d_persistence.cpp</a> - * \li <a href="_persistent_cohomology_2exact_alpha_complex_3d_persistence_8cpp-example.html"> - * Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp</a> - * \li <a href="_persistent_cohomology_2weighted_alpha_complex_3d_persistence_8cpp-example.html"> - * Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp</a> + * \li <a href="_alpha_complex_2alpha_complex_3d_persistence_8cpp-example.html"> + * Alpha_complex/alpha_complex_3d_persistence.cpp</a> + * \li <a href="_alpha_complex_2exact_alpha_complex_3d_persistence_8cpp-example.html"> + * Alpha_complex/exact_alpha_complex_3d_persistence.cpp</a> + * \li <a href="_alpha_complex_2weighted_alpha_complex_3d_persistence_8cpp-example.html"> + * Alpha_complex/weighted_alpha_complex_3d_persistence.cpp</a> * \li <a href="_simplex_tree_2example_alpha_shapes_3_simplex_tree_from_off_file_8cpp-example.html"> * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp</a> * - * The following example requires CGAL version ≥ 4.6.0: - * \li <a href="_witness_complex_2witness_complex_sphere_8cpp-example.html"> - * Witness_complex/witness_complex_sphere.cpp</a> - * + * The following examples/utilities require CGAL version ≥ 4.6.0: + * \li <a href="_witness_complex_2strong_witness_persistence_8cpp-example.html"> + * Witness_complex/strong_witness_persistence.cpp</a> + * \li <a href="_witness_complex_2weak_witness_persistence_8cpp-example.html"> + * Witness_complex/weak_witness_persistence.cpp</a> + * \li <a href="_witness_complex_2example_strong_witness_complex_off_8cpp-example.html"> + * Witness_complex/example_strong_witness_complex_off.cpp</a> + * \li <a href="_witness_complex_2example_witness_complex_off_8cpp-example.html"> + * Witness_complex/example_witness_complex_off.cpp</a> + * \li <a href="_witness_complex_2example_witness_complex_sphere_8cpp-example.html"> + * Witness_complex/example_witness_complex_sphere.cpp</a> + * * The following example requires CGAL version ≥ 4.7.0: * \li <a href="_alpha_complex_2_alpha_complex_from_off_8cpp-example.html"> * Alpha_complex/Alpha_complex_from_off.cpp</a> * \li <a href="_alpha_complex_2_alpha_complex_from_points_8cpp-example.html"> * Alpha_complex/Alpha_complex_from_points.cpp</a> - * \li <a href="_persistent_cohomology_2alpha_complex_persistence_8cpp-example.html"> - * Persistent_cohomology/alpha_complex_persistence.cpp</a> - * \li <a href="_persistent_cohomology_2periodic_alpha_complex_3d_persistence_8cpp-example.html"> - * Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp</a> + * \li <a href="_alpha_complex_2alpha_complex_persistence_8cpp-example.html"> + * Alpha_complex/alpha_complex_persistence.cpp</a> + * \li <a href="_alpha_complex_2periodic_alpha_complex_3d_persistence_8cpp-example.html"> + * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp</a> * \li <a href="_persistent_cohomology_2custom_persistence_sort_8cpp-example.html"> * Persistent_cohomology/custom_persistence_sort.cpp</a> * @@ -320,8 +346,8 @@ make doxygen * Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp</a> * \li <a href="_bottleneck_distance_2bottleneck_basic_example_8cpp-example.html"> * Bottleneck_distance/bottleneck_basic_example.cpp</a> - * \li <a href="_bottleneck_distance_2bottleneck_read_file_example_8cpp-example.html"> - * Bottleneck_distance/bottleneck_read_file_example.cpp</a> + * \li <a href="_bottleneck_distance_2bottleneck_read_file_8cpp-example.html"> + * Bottleneck_distance/bottleneck_distance.cpp</a> * \li <a href="_spatial_searching_2example_spatial_searching_8cpp-example.html"> * Spatial_searching/example_spatial_searching.cpp</a> * \li <a href="_subsampling_2example_choose_n_farthest_points_8cpp-example.html"> @@ -342,19 +368,45 @@ make doxygen * <a target="_blank" href="http://eigen.tuxfamily.org/">Eigen3</a> is a C++ template library for linear algebra: * matrices, vectors, numerical solvers, and related algorithms. * - * The following example requires the <a target="_blank" href="http://eigen.tuxfamily.org/">Eigen3</a> and will not be + * The following examples/utilities require the <a target="_blank" href="http://eigen.tuxfamily.org/">Eigen3</a> and will not be * built if Eigen3 is not installed: * \li <a href="_alpha_complex_2_alpha_complex_from_off_8cpp-example.html"> * Alpha_complex/Alpha_complex_from_off.cpp</a> * \li <a href="_alpha_complex_2_alpha_complex_from_points_8cpp-example.html"> * Alpha_complex/Alpha_complex_from_points.cpp</a> - * \li <a href="_persistent_cohomology_2alpha_complex_persistence_8cpp-example.html"> - * Persistent_cohomology/alpha_complex_persistence.cpp</a> - * \li <a href="_persistent_cohomology_2periodic_alpha_complex_3d_persistence_8cpp-example.html"> - * Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp</a> + * \li <a href="_alpha_complex_2alpha_complex_persistence_8cpp-example.html"> + * Alpha_complex/alpha_complex_persistence.cpp</a> + * \li <a href="_alpha_complex_2periodic_alpha_complex_3d_persistence_8cpp-example.html"> + * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp</a> + * \li <a href="_bottleneck_distance_2alpha_rips_persistence_bottleneck_distance_8cpp-example.html"> + * Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp</a> * \li <a href="_persistent_cohomology_2custom_persistence_sort_8cpp-example.html"> * Persistent_cohomology/custom_persistence_sort.cpp</a> - * + * \li <a href="_spatial_searching_2example_spatial_searching_8cpp-example.html"> + * Spatial_searching/example_spatial_searching.cpp</a> + * \li <a href="_subsampling_2example_choose_n_farthest_points_8cpp-example.html"> + * Subsampling/example_choose_n_farthest_points.cpp</a> + * \li <a href="_subsampling_2example_custom_kernel_8cpp-example.html"> + * Subsampling/example_custom_kernel.cpp</a> + * \li <a href="_subsampling_2example_pick_n_random_points_8cpp-example.html"> + * Subsampling/example_pick_n_random_points.cpp</a> + * \li <a href="_subsampling_2example_sparsify_point_set_8cpp-example.html"> + * Subsampling/example_sparsify_point_set.cpp</a> + * \li <a href="_tangential_complex_2example_basic_8cpp-example.html"> + * Tangential_complex/example_basic.cpp</a> + * \li <a href="_tangential_complex_2example_with_perturb_8cpp-example.html"> + * Tangential_complex/example_with_perturb.cpp</a> + * \li <a href="_witness_complex_2strong_witness_persistence_8cpp-example.html"> + * Witness_complex/strong_witness_persistence.cpp</a> + * \li <a href="_witness_complex_2weak_witness_persistence_8cpp-example.html"> + * Witness_complex/weak_witness_persistence.cpp</a> + * \li <a href="_witness_complex_2example_strong_witness_complex_off_8cpp-example.html"> + * Witness_complex/example_strong_witness_complex_off.cpp</a> + * \li <a href="_witness_complex_2example_witness_complex_off_8cpp-example.html"> + * Witness_complex/example_witness_complex_off.cpp</a> + * \li <a href="_witness_complex_2example_witness_complex_sphere_8cpp-example.html"> + * Witness_complex/example_witness_complex_sphere.cpp</a> + * * \subsection tbb Threading Building Blocks * <a target="_blank" href="https://www.threadingbuildingblocks.org/">Intel® TBB</a> lets you easily write parallel * C++ programs that take full advantage of multicore performance, that are portable and composable, and that have @@ -362,27 +414,35 @@ make doxygen * * Having Intel® TBB installed is recommended to parallelize and accelerate some GUDHI computations. * - * The following examples are using Intel® TBB if installed: + * The following examples/utilities are using Intel® TBB if installed: * \li <a href="_alpha_complex_2_alpha_complex_from_off_8cpp-example.html"> * Alpha_complex/Alpha_complex_from_off.cpp</a> * \li <a href="_alpha_complex_2_alpha_complex_from_points_8cpp-example.html"> * Alpha_complex/Alpha_complex_from_points.cpp</a> + * \li <a href="_alpha_complex_2alpha_complex_3d_persistence_8cpp-example.html"> + * Alpha_complex/alpha_complex_3d_persistence.cpp</a> + * \li <a href="_alpha_complex_2alpha_complex_persistence_8cpp-example.html"> + * Alpha_complex/alpha_complex_persistence.cpp</a> + * \li <a href="_alpha_complex_2exact_alpha_complex_3d_persistence_8cpp-example.html"> + * Alpha_complex/exact_alpha_complex_3d_persistence.cpp</a> + * \li <a href="_alpha_complex_2periodic_alpha_complex_3d_persistence_8cpp-example.html"> + * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp</a> + * \li <a href="_alpha_complex_2weighted_alpha_complex_3d_persistence_8cpp-example.html"> + * Alpha_complex/weighted_alpha_complex_3d_persistence.cpp</a> * \li <a href="_bitmap_cubical_complex_2_bitmap_cubical_complex_8cpp-example.html"> - * Bitmap_cubical_complex/Bitmap_cubical_complex.cpp</a> + * Bitmap_cubical_complex/cubical_complex_persistence.cpp</a> * \li <a href="_bitmap_cubical_complex_2_bitmap_cubical_complex_periodic_boundary_conditions_8cpp-example.html"> - * Bitmap_cubical_complex/Bitmap_cubical_complex_periodic_boundary_conditions.cpp</a> + * Bitmap_cubical_complex/periodic_cubical_complex_persistence.cpp</a> * \li <a href="_bitmap_cubical_complex_2_random_bitmap_cubical_complex_8cpp-example.html"> * Bitmap_cubical_complex/Random_bitmap_cubical_complex.cpp</a> - * \li <a href="_persistent_cohomology_2alpha_complex_3d_persistence_8cpp-example.html"> - * Persistent_cohomology/alpha_complex_3d_persistence.cpp</a> - * \li <a href="_persistent_cohomology_2alpha_complex_persistence_8cpp-example.html"> - * Persistent_cohomology/alpha_complex_persistence.cpp</a> * \li <a href="_simplex_tree_2simple_simplex_tree_8cpp-example.html"> * Simplex_tree/simple_simplex_tree.cpp</a> * \li <a href="_simplex_tree_2example_alpha_shapes_3_simplex_tree_from_off_file_8cpp-example.html"> * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp</a> * \li <a href="_simplex_tree_2simplex_tree_from_cliques_of_graph_8cpp-example.html"> * Simplex_tree/simplex_tree_from_cliques_of_graph.cpp</a> + * \li <a href="_simplex_tree_2graph_expansion_with_blocker_8cpp-example.html"> + * Simplex_tree/graph_expansion_with_blocker.cpp</a> * \li <a href="_persistent_cohomology_2alpha_complex_3d_persistence_8cpp-example.html"> * Persistent_cohomology/alpha_complex_3d_persistence.cpp</a> * \li <a href="_persistent_cohomology_2alpha_complex_persistence_8cpp-example.html"> @@ -395,27 +455,31 @@ make doxygen * Persistent_cohomology/persistence_from_simple_simplex_tree.cpp</a> * \li <a href="_persistent_cohomology_2plain_homology_8cpp-example.html"> * Persistent_cohomology/plain_homology.cpp</a> - * \li <a href="_persistent_cohomology_2rips_distance_matrix_persistence_8cpp-example.html"> - * Persistent_cohomology/rips_distance_matrix_persistence.cpp</a> * \li <a href="_persistent_cohomology_2rips_multifield_persistence_8cpp-example.html"> * Persistent_cohomology/rips_multifield_persistence.cpp</a> - * \li <a href="_persistent_cohomology_2rips_persistence_8cpp-example.html"> - * Persistent_cohomology/rips_persistence.cpp</a> * \li <a href="_persistent_cohomology_2rips_persistence_step_by_step_8cpp-example.html"> * Persistent_cohomology/rips_persistence_step_by_step.cpp</a> * \li <a href="_persistent_cohomology_2exact_alpha_complex_3d_persistence_8cpp-example.html"> * Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp</a> * \li <a href="_persistent_cohomology_2weighted_alpha_complex_3d_persistence_8cpp-example.html"> * Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp</a> - * \li <a href="_persistent_cohomology_2periodic_alpha_complex_3d_persistence_8cpp-example.html"> - * Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp</a> * \li <a href="_persistent_cohomology_2custom_persistence_sort_8cpp-example.html"> * Persistent_cohomology/custom_persistence_sort.cpp</a> * \li <a href="_rips_complex_2example_one_skeleton_rips_from_points_8cpp-example.html"> * Rips_complex/example_one_skeleton_rips_from_points.cpp</a> * \li <a href="_rips_complex_2example_rips_complex_from_off_file_8cpp-example.html"> * Rips_complex/example_rips_complex_from_off_file.cpp</a> - * + * \li <a href="_rips_complex_2rips_distance_matrix_persistence_8cpp-example.html"> + * Rips_complex/rips_distance_matrix_persistence.cpp</a> + * \li <a href="_rips_complex_2rips_persistence_8cpp-example.html"> + * Rips_complex/rips_persistence.cpp</a> + * \li <a href="_witness_complex_2strong_witness_persistence_8cpp-example.html"> + * Witness_complex/strong_witness_persistence.cpp</a> + * \li <a href="_witness_complex_2weak_witness_persistence_8cpp-example.html"> + * Witness_complex/weak_witness_persistence.cpp</a> + * \li <a href="_witness_complex_2example_nearest_landmark_table_8cpp-example.html"> + * Witness_complex/example_nearest_landmark_table.cpp</a> + * * \section Contributions Bug reports and contributions * Please help us improving the quality of the GUDHI library. You may report bugs or suggestions to: * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim @@ -439,36 +503,37 @@ make doxygen /*! @file Examples * @example Alpha_complex/Alpha_complex_from_off.cpp * @example Alpha_complex/Alpha_complex_from_points.cpp + * @example Alpha_complex/alpha_complex_3d_persistence.cpp + * @example Alpha_complex/alpha_complex_persistence.cpp + * @example Alpha_complex/exact_alpha_complex_3d_persistence.cpp + * @example Alpha_complex/periodic_alpha_complex_3d_persistence.cpp + * @example Alpha_complex/weighted_alpha_complex_3d_persistence.cpp * @example Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp * @example Bottleneck_distance/bottleneck_basic_example.cpp - * @example Bottleneck_distance/bottleneck_read_file_example.cpp - * @example Bitmap_cubical_complex/Bitmap_cubical_complex.cpp - * @example Bitmap_cubical_complex/Bitmap_cubical_complex_periodic_boundary_conditions.cpp + * @example Bottleneck_distance/bottleneck_distance.cpp + * @example Bitmap_cubical_complex/cubical_complex_persistence.cpp + * @example Bitmap_cubical_complex/periodic_cubical_complex_persistence.cpp * @example Bitmap_cubical_complex/Random_bitmap_cubical_complex.cpp * @example common/example_CGAL_3D_points_off_reader.cpp * @example common/example_CGAL_points_off_reader.cpp * @example Contraction/Garland_heckbert.cpp * @example Contraction/Rips_contraction.cpp - * @example Persistent_cohomology/alpha_complex_3d_persistence.cpp - * @example Persistent_cohomology/alpha_complex_persistence.cpp * @example Persistent_cohomology/rips_persistence_via_boundary_matrix.cpp - * @example Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp - * @example Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp - * @example Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp * @example Persistent_cohomology/persistence_from_file.cpp * @example Persistent_cohomology/persistence_from_simple_simplex_tree.cpp * @example Persistent_cohomology/plain_homology.cpp * @example Persistent_cohomology/rips_multifield_persistence.cpp - * @example Persistent_cohomology/rips_distance_matrix_persistence.cpp - * @example Persistent_cohomology/rips_persistence.cpp * @example Persistent_cohomology/custom_persistence_sort.cpp * @example Persistent_cohomology/rips_persistence_step_by_step.cpp * @example Rips_complex/example_one_skeleton_rips_from_points.cpp * @example Rips_complex/example_rips_complex_from_off_file.cpp + * @example Rips_complex/rips_persistence.cpp + * @example Rips_complex/rips_distance_matrix_persistence.cpp * @example Simplex_tree/mini_simplex_tree.cpp * @example Simplex_tree/simple_simplex_tree.cpp * @example Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp * @example Simplex_tree/simplex_tree_from_cliques_of_graph.cpp + * @example Simplex_tree/graph_expansion_with_blocker.cpp * @example Skeleton_blocker/Skeleton_blocker_from_simplices.cpp * @example Skeleton_blocker/Skeleton_blocker_iteration.cpp * @example Skeleton_blocker/Skeleton_blocker_link.cpp @@ -481,9 +546,9 @@ make doxygen * @example Tangential_complex/example_with_perturb.cpp * @example Witness_complex/example_nearest_landmark_table.cpp * @example Witness_complex/example_strong_witness_complex_off.cpp - * @example Witness_complex/example_strong_witness_persistence.cpp * @example Witness_complex/example_witness_complex_off.cpp - * @example Witness_complex/example_witness_complex_persistence.cpp * @example Witness_complex/example_witness_complex_sphere.cpp + * @example Witness_complex/weak_witness_persistence.cpp + * @example Witness_complex/strong_witness_persistence.cpp */
\ No newline at end of file diff --git a/src/common/include/gudhi/graph_simplicial_complex.h b/src/common/include/gudhi/graph_simplicial_complex.h index 5fe7c826..d84421b2 100644 --- a/src/common/include/gudhi/graph_simplicial_complex.h +++ b/src/common/include/gudhi/graph_simplicial_complex.h @@ -28,6 +28,9 @@ #include <utility> // for pair<> #include <vector> #include <map> +#include <tuple> // for std::tie + +namespace Gudhi { /* Edge tag for Boost PropertyGraph. */ struct edge_filtration_t { @@ -39,4 +42,64 @@ struct vertex_filtration_t { typedef boost::vertex_property_tag kind; }; +template <typename SimplicialComplexForProximityGraph> +using Proximity_graph = typename boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS +, boost::property < vertex_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value > +, boost::property < edge_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value >>; + +/** \brief Computes the proximity graph of the points. + * + * If points contains n elements, the proximity graph is the graph with n vertices, and an edge [u,v] iff the + * distance function between points u and v is smaller than threshold. + * + * \tparam ForwardPointRange furnishes `.begin()` and `.end()` methods. + * + * \tparam Distance furnishes `operator()(const Point& p1, const Point& p2)`, where + * `Point` is a point from the `ForwardPointRange`, and that returns a `Filtration_value`. + */ +template< typename SimplicialComplexForProximityGraph + , typename ForwardPointRange + , typename Distance > +Proximity_graph<SimplicialComplexForProximityGraph> compute_proximity_graph( + const ForwardPointRange& points, + typename SimplicialComplexForProximityGraph::Filtration_value threshold, + Distance distance) { + using Vertex_handle = typename SimplicialComplexForProximityGraph::Vertex_handle; + using Filtration_value = typename SimplicialComplexForProximityGraph::Filtration_value; + + std::vector<std::pair< Vertex_handle, Vertex_handle >> edges; + std::vector< Filtration_value > edges_fil; + std::map< Vertex_handle, Filtration_value > vertices; + + Vertex_handle idx_u, idx_v; + Filtration_value fil; + idx_u = 0; + for (auto it_u = points.begin(); it_u != points.end(); ++it_u) { + idx_v = idx_u + 1; + for (auto it_v = it_u + 1; it_v != points.end(); ++it_v, ++idx_v) { + fil = distance(*it_u, *it_v); + if (fil <= threshold) { + edges.emplace_back(idx_u, idx_v); + edges_fil.push_back(fil); + } + } + ++idx_u; + } + + // Points are labeled from 0 to idx_u-1 + Proximity_graph<SimplicialComplexForProximityGraph> skel_graph(edges.begin(), edges.end(), edges_fil.begin(), idx_u); + + auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph); + + typename boost::graph_traits<Proximity_graph<SimplicialComplexForProximityGraph>>::vertex_iterator vi, vi_end; + for (std::tie(vi, vi_end) = boost::vertices(skel_graph); + vi != vi_end; ++vi) { + boost::put(vertex_prop, *vi, 0.); + } + + return skel_graph; +} + +} // namespace Gudhi + #endif // GRAPH_SIMPLICIAL_COMPLEX_H_ diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index bda93f4f..90be4fc7 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -38,6 +38,8 @@ #include <utility> // for pair #include <tuple> // for std::make_tuple +namespace Gudhi { + // Keep this file tag for Doxygen to parse the code, otherwise, functions are not documented. // It is required for global functions and variables. @@ -362,4 +364,6 @@ inline std::vector<std::pair<double, double>> read_persistence_intervals_in_dime return ret; } +} // namespace Gudhi + #endif // READER_UTILS_H_ diff --git a/src/common/test/test_distance_matrix_reader.cpp b/src/common/test/test_distance_matrix_reader.cpp index 95a73bd9..656e6f2e 100644 --- a/src/common/test/test_distance_matrix_reader.cpp +++ b/src/common/test/test_distance_matrix_reader.cpp @@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE( lower_triangular_distance_matrix ) { Distance_matrix from_lower_triangular; // Read lower_triangular_distance_matrix.csv file where the separator is a ',' - from_lower_triangular = read_lower_triangular_matrix_from_csv_file<double>("lower_triangular_distance_matrix.csv", + from_lower_triangular = Gudhi::read_lower_triangular_matrix_from_csv_file<double>("lower_triangular_distance_matrix.csv", ','); for (auto& i : from_lower_triangular) { for (auto j : i) { @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE( full_square_distance_matrix ) { Distance_matrix from_full_square; // Read full_square_distance_matrix.csv file where the separator is the default one ';' - from_full_square = read_lower_triangular_matrix_from_csv_file<double>("full_square_distance_matrix.csv"); + from_full_square = Gudhi::read_lower_triangular_matrix_from_csv_file<double>("full_square_distance_matrix.csv"); for (auto& i : from_full_square) { for (auto j : i) { std::cout << j << " "; diff --git a/src/common/test/test_persistence_intervals_reader.cpp b/src/common/test/test_persistence_intervals_reader.cpp index a06fff1e..be299376 100644 --- a/src/common/test/test_persistence_intervals_reader.cpp +++ b/src/common/test/test_persistence_intervals_reader.cpp @@ -27,6 +27,7 @@ #include <utility> // for pair #include <tuple> #include <limits> // for inf +#include <map> #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE "persistence_intervals_reader" @@ -44,7 +45,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_without_dimension ) expected_intervals_by_dimension[-1].push_back(std::make_pair(3., std::numeric_limits<double>::infinity())); Persistence_intervals_by_dimension persistence_intervals_by_dimension = - read_persistence_intervals_grouped_by_dimension("persistence_intervals_without_dimension.pers"); + Gudhi::read_persistence_intervals_grouped_by_dimension("persistence_intervals_without_dimension.pers"); std::cout << "\nread_persistence_intervals_grouped_by_dimension - expected\n"; for (auto map_iter : expected_intervals_by_dimension) { @@ -69,7 +70,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_without_dimension ) expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits<double>::infinity())); Persistence_intervals persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers"); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers"); std::cout << "\nread_persistence_intervals_in_dimension - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -83,22 +84,22 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_without_dimension ) expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 0); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 0); BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 1); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 1); BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 2); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 2); BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 3); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_without_dimension.pers", 3); BOOST_CHECK(persistence_intervals_in_dimension == expected_intervals_in_dimension); } @@ -112,7 +113,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_by_dimension[1].push_back(std::make_pair(3., std::numeric_limits<double>::infinity())); Persistence_intervals_by_dimension persistence_intervals_by_dimension = - read_persistence_intervals_grouped_by_dimension("persistence_intervals_with_dimension.pers"); + Gudhi::read_persistence_intervals_grouped_by_dimension("persistence_intervals_with_dimension.pers"); std::cout << "\nread_persistence_intervals_grouped_by_dimension - expected\n"; for (auto map_iter : expected_intervals_by_dimension) { @@ -137,7 +138,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits<double>::infinity())); Persistence_intervals persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers"); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers"); std::cout << "\nread_persistence_intervals_in_dimension - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -152,7 +153,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_in_dimension.clear(); expected_intervals_in_dimension.push_back(std::make_pair(2.7, 3.7)); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 0); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 0); std::cout << "\nread_persistence_intervals_in_dimension 0 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -168,7 +169,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_in_dimension.push_back(std::make_pair(9.6, 14.)); expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits<double>::infinity())); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 1); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 1); std::cout << "\nread_persistence_intervals_in_dimension 1 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -182,7 +183,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 2); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 2); std::cout << "\nread_persistence_intervals_in_dimension 2 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -197,7 +198,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_dimension ) expected_intervals_in_dimension.clear(); expected_intervals_in_dimension.push_back(std::make_pair(34.2, 34.974)); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 3); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_dimension.pers", 3); std::cout << "\nread_persistence_intervals_in_dimension 3 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -221,7 +222,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_by_dimension[1].push_back(std::make_pair(3., std::numeric_limits<double>::infinity())); Persistence_intervals_by_dimension persistence_intervals_by_dimension = - read_persistence_intervals_grouped_by_dimension("persistence_intervals_with_field.pers"); + Gudhi::read_persistence_intervals_grouped_by_dimension("persistence_intervals_with_field.pers"); std::cout << "\nread_persistence_intervals_grouped_by_dimension - expected\n"; for (auto map_iter : expected_intervals_by_dimension) { @@ -246,7 +247,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits<double>::infinity())); Persistence_intervals persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers"); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers"); std::cout << "\nread_persistence_intervals_in_dimension - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -261,7 +262,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_in_dimension.clear(); expected_intervals_in_dimension.push_back(std::make_pair(2.7, 3.7)); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 0); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 0); std::cout << "\nread_persistence_intervals_in_dimension 0 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -277,7 +278,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_in_dimension.push_back(std::make_pair(9.6, 14.)); expected_intervals_in_dimension.push_back(std::make_pair(3., std::numeric_limits<double>::infinity())); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 1); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 1); std::cout << "\nread_persistence_intervals_in_dimension 1 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -291,7 +292,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_in_dimension.clear(); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 2); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 2); std::cout << "\nread_persistence_intervals_in_dimension 2 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) @@ -306,7 +307,7 @@ BOOST_AUTO_TEST_CASE( persistence_intervals_with_field ) expected_intervals_in_dimension.clear(); expected_intervals_in_dimension.push_back(std::make_pair(34.2, 34.974)); persistence_intervals_in_dimension = - read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 3); + Gudhi::read_persistence_intervals_in_dimension("persistence_intervals_with_field.pers", 3); std::cout << "\nread_persistence_intervals_in_dimension 3 - expected\n"; for (auto vec_iter : expected_intervals_in_dimension) diff --git a/src/common/utilities/README b/src/common/utilities/README index dc841521..18fa8cc4 100644 --- a/src/common/utilities/README +++ b/src/common/utilities/README @@ -1,19 +1,19 @@ -======================= off_file_from_shape_generator ================================== +# Pointset generator # -Example of use : +## `off_file_from_shape_generator` ## -*** on|in sphere|cube|curve|torus|klein generator +Generates a pointset and save it in an OFF file. Command-line is: +`off_file_from_shape_generator on|in sphere|cube|curve|torus|klein <filename> <num_points> <dimension> <parameter1> <parameter2>...` -./off_file_from_shape_generator on sphere onSphere.off 1000 3 15.2 +Warning: "on cube" generator is not available! - => generates a onSphere.off file with 1000 points randomized on a sphere of dimension 3 and radius 15.2 +Examples: -./off_file_from_shape_generator in sphere inSphere.off 100 2 +* Generate an onSphere.off file with 1000 points randomized on a sphere of dimension 3 and radius 15.2: +`off_file_from_shape_generator on sphere onSphere.off 1000 3 15.2` + +* Generate an inSphere.off file with 100 points randomized in a sphere of dimension 2 (circle) and radius 1.0 (default): +`off_file_from_shape_generator in sphere inSphere.off 100 2` - => generates a inSphere.off file with 100 points randomized in a sphere of dimension 2 (circle) and radius 1.0 (default) - -./off_file_from_shape_generator in cube inCube.off 10000 3 5.8 - - => generates a inCube.off file with 10000 points randomized in a cube of dimension 3 and side 5.8 - -!! Warning: hypegenerator on cube is not available !! +* Generates a inCube.off file with 10000 points randomized in a cube of dimension 3 and side 5.8: +`off_file_from_shape_generator in cube inCube.off 10000 3 5.8` diff --git a/src/common/utilities/off_file_from_shape_generator.cpp b/src/common/utilities/off_file_from_shape_generator.cpp index 0f310a13..afcd558c 100644 --- a/src/common/utilities/off_file_from_shape_generator.cpp +++ b/src/common/utilities/off_file_from_shape_generator.cpp @@ -77,7 +77,7 @@ int main(int argc, char **argv) { usage(argv[0]); } - enum class Data_shape { sphere, cube, curve, torus, klein, undefined } ; + enum class Data_shape { sphere, cube, curve, torus, klein, undefined}; Data_shape shape = Data_shape::undefined; if (memcmp(argv[2], "sphere", sizeof("sphere")) == 0) { |