From ca6b3d72f2114cdd2d0899fd44dba19303dd3bb2 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 28 Sep 2016 11:15:34 +0000 Subject: Add rips complex module and first modification step git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_module@1577 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fc949570c6cffa4756f84a15c41fadc8c45b2af2 --- .../concept/Simplicial_complex_for_rips.h | 53 ++++ src/Rips_complex/doc/Intro_rips_complex.h | 104 +++++++ .../doc/rips_complex_representation.ipe | 326 +++++++++++++++++++++ .../doc/rips_complex_representation.png | Bin 0 -> 15677 bytes src/Rips_complex/doc/rips_one_skeleton.ipe | 326 +++++++++++++++++++++ src/Rips_complex/doc/rips_one_skeleton.png | Bin 0 -> 47651 bytes src/Rips_complex/example/CMakeLists.txt | 8 + .../example/example_rips_complex_from_off_file.cpp | 71 +++++ src/Rips_complex/include/gudhi/Rips_complex.h | 154 ++++++++++ 9 files changed, 1042 insertions(+) create mode 100644 src/Rips_complex/concept/Simplicial_complex_for_rips.h create mode 100644 src/Rips_complex/doc/Intro_rips_complex.h create mode 100644 src/Rips_complex/doc/rips_complex_representation.ipe create mode 100644 src/Rips_complex/doc/rips_complex_representation.png create mode 100644 src/Rips_complex/doc/rips_one_skeleton.ipe create mode 100644 src/Rips_complex/doc/rips_one_skeleton.png create mode 100644 src/Rips_complex/example/CMakeLists.txt create mode 100644 src/Rips_complex/example/example_rips_complex_from_off_file.cpp create mode 100644 src/Rips_complex/include/gudhi/Rips_complex.h (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/concept/Simplicial_complex_for_rips.h b/src/Rips_complex/concept/Simplicial_complex_for_rips.h new file mode 100644 index 00000000..470860e9 --- /dev/null +++ b/src/Rips_complex/concept/Simplicial_complex_for_rips.h @@ -0,0 +1,53 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2016 INRIA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ +#define CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ + +namespace Gudhi { + +namespace rips_complex { + +/** \brief The concept SimplicialComplexForRips describes the requirements for a type to implement a simplicial + * complex, that can be created from a `Rips_complex`. + */ +struct SimplicialComplexForRips { + /** Handle to specify the simplex filtration value. */ + typedef unspecified Filtration_value; + + /** Returns the number of vertices in the simplicial complex. */ + std::size_t num_vertices(); + + /** \brief Inserts a a given range 'OneSkeletonGraph' in the simplicial complex. */ + template + void insert_graph(const OneSkeletonGraph& skel_graph); + + /** \brief Expands the simplicial complex containing only its one skeleton until a given maximal dimension. */ + void expansion(int max_dim); + +}; + +} // namespace rips_complex + +} // namespace Gudhi + +#endif // CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h new file mode 100644 index 00000000..85108168 --- /dev/null +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -0,0 +1,104 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Clément Maria & Vincent Rouvreau + * + * Copyright (C) 2015 INRIA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef DOC_RIPS_COMPLEX_INTRO_RIPS_COMPLEX_H_ +#define DOC_RIPS_COMPLEX_INTRO_RIPS_COMPLEX_H_ + +namespace Gudhi { + +namespace rips_complex { + +/** \defgroup rips_complex Rips complex + * + * \author Clément Maria & Vincent Rouvreau + * + * @{ + * + * \section definition Definition + * + * Rips_complex + * (Wikipedia) is a + * simplicial complex + * constructed from a one skeleton graph. + * + * The filtration value of each edge is computed from a user-given distance function. + * + * All edges that have a filtration value strictly greater than a given threshold value are not inserted into + * the complex. + * + * When creating a simplicial complex from this one skeleton graph, rips inserts the one skeleton graph into the data + * structure, and then expands the simplicial when required. + * + * \image html "rips_complex_representation.png" "Rips-complex one skeleton graph representation" + * + * On this example, as edges (4,5), (4,6) and (5,6) are in the complex, simplex (4,5,6) is added with the filtration + * value set with \f$max(filtration(4,5), filtration(4,6), filtration(5,6))\f$. + * And so on for simplex (0,1,2,3). + * + * \section ripspointsexample Example from points + * + * This example builds the one skeleton graph from the given points, threshold value, and distance function. + * Then it creates a `Simplex_tree` with it. + * + * Then, it is asked to display information about the simplicial complex. + * + * \include Rips_complex/example_rips_complex_from_points.cpp + * + * When launching: + * + * \code $> ./ripspoints + * \endcode + * + * the program output is: + * + * \include Rips_complex/rips_points_for_doc_12_2.txt + * + * \section offexample Example from OFF file + * + * This example builds the one skeleton graph from the given points in an OFF file, threshold value, and distance + * function. + * Then it creates a `Simplex_tree` with it. + * + * + * Then, it is asked to display information about the rips complex. + * + * \include Rips_complex/example_rips_complex_from_off_file.cpp + * + * When launching: + * + * \code $> ./ripsoffreader ../../data/points/alphacomplexdoc.off 12.0 3 + * \endcode + * + * the program output is: + * + * \include Rips_complex/rips_points_for_doc_12_3.txt + * + * \copyright GNU General Public License v3. + * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim + */ +/** @} */ // end defgroup rips_complex + +} // namespace rips_complex + +} // namespace Gudhi + +#endif // DOC_RIPS_COMPLEX_INTRO_RIPS_COMPLEX_H_ diff --git a/src/Rips_complex/doc/rips_complex_representation.ipe b/src/Rips_complex/doc/rips_complex_representation.ipe new file mode 100644 index 00000000..7f6028f4 --- /dev/null +++ b/src/Rips_complex/doc/rips_complex_representation.ipe @@ -0,0 +1,326 @@ + + + + + + + +0 0 m +-1 0.333 l +-1 -0.333 l +h + + + + +0 0 m +-1 0.333 l +-1 -0.333 l +h + + + + +0.6 0 0 0.6 0 0 e +0.4 0 0 0.4 0 0 e + + + + +0.6 0 0 0.6 0 0 e + + + + + +0.5 0 0 0.5 0 0 e + + +0.6 0 0 0.6 0 0 e +0.4 0 0 0.4 0 0 e + + + + + +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h +-0.4 -0.4 m +0.4 -0.4 l +0.4 0.4 l +-0.4 0.4 l +h + + + + +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h + + + + + +-0.5 -0.5 m +0.5 -0.5 l +0.5 0.5 l +-0.5 0.5 l +h + + +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h +-0.4 -0.4 m +0.4 -0.4 l +0.4 0.4 l +-0.4 0.4 l +h + + + + + + +-0.43 -0.57 m +0.57 0.43 l +0.43 0.57 l +-0.57 -0.43 l +h + + +-0.43 0.57 m +0.57 -0.43 l +0.43 -0.57 l +-0.57 0.43 l +h + + + + + +0 0 m +-1 0.333 l +-1 -0.333 l +h + + + + +0 0 m +-1 0.333 l +-0.8 0 l +-1 -0.333 l +h + + + + +0 0 m +-1 0.333 l +-0.8 0 l +-1 -0.333 l +h + + + + +-1 0.333 m +0 0 l +-1 -0.333 l + + + + +0 0 m +-1 0.333 l +-1 -0.333 l +h +-1 0 m +-2 0.333 l +-2 -0.333 l +h + + + + +0 0 m +-1 0.333 l +-1 -0.333 l +h +-1 0 m +-2 0.333 l +-2 -0.333 l +h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +109.771 601.912 m +159.595 601.797 l +140.058 541.915 l +h + + +79.8776 552.169 m +109.756 601.699 l +139.812 542.209 l +h + + +69.8453 682.419 m +159.925 712.208 l +90.12 732.039 l +h + +Rips complex +0 +1 +2 +3 +4 +5 +6 + +60 710 m +40 660 l + + +40 660 m +130 690 l + + +130 690 m +60 710 l + + +40 660 m +80 580 l + + +80 580 m +130 580 l +130 580 l + + +130 580 m +110 520 l + + +110 520 m +50 530 l +50 530 l +50 530 l + + +50 530 m +80 580 l + + +130 580 m +130 690 l + + + + + + + +150.038 609.9 m +179.929 549.727 l + + + + +158.7 593.269 m +81.4925 544.805 l + + +256.324 639.958 m +370.055 639.958 l + + +56.8567 0 0 56.8567 313.217 639.756 e + + + +Rips threshold + + diff --git a/src/Rips_complex/doc/rips_complex_representation.png b/src/Rips_complex/doc/rips_complex_representation.png new file mode 100644 index 00000000..e901d92e Binary files /dev/null and b/src/Rips_complex/doc/rips_complex_representation.png differ diff --git a/src/Rips_complex/doc/rips_one_skeleton.ipe b/src/Rips_complex/doc/rips_one_skeleton.ipe new file mode 100644 index 00000000..3a35970c --- /dev/null +++ b/src/Rips_complex/doc/rips_one_skeleton.ipe @@ -0,0 +1,326 @@ + + + + + + + +0 0 m +-1 0.333 l +-1 -0.333 l +h + + + + +0 0 m +-1 0.333 l +-1 -0.333 l +h + + + + +0.6 0 0 0.6 0 0 e +0.4 0 0 0.4 0 0 e + + + + +0.6 0 0 0.6 0 0 e + + + + + +0.5 0 0 0.5 0 0 e + + +0.6 0 0 0.6 0 0 e +0.4 0 0 0.4 0 0 e + + + + + +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h +-0.4 -0.4 m +0.4 -0.4 l +0.4 0.4 l +-0.4 0.4 l +h + + + + +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h + + + + + +-0.5 -0.5 m +0.5 -0.5 l +0.5 0.5 l +-0.5 0.5 l +h + + +-0.6 -0.6 m +0.6 -0.6 l +0.6 0.6 l +-0.6 0.6 l +h +-0.4 -0.4 m +0.4 -0.4 l +0.4 0.4 l +-0.4 0.4 l +h + + + + + + +-0.43 -0.57 m +0.57 0.43 l +0.43 0.57 l +-0.57 -0.43 l +h + + +-0.43 0.57 m +0.57 -0.43 l +0.43 -0.57 l +-0.57 0.43 l +h + + + + + +0 0 m +-1 0.333 l +-1 -0.333 l +h + + + + +0 0 m +-1 0.333 l +-0.8 0 l +-1 -0.333 l +h + + + + +0 0 m +-1 0.333 l +-0.8 0 l +-1 -0.333 l +h + + + + +-1 0.333 m +0 0 l +-1 -0.333 l + + + + +0 0 m +-1 0.333 l +-1 -0.333 l +h +-1 0 m +-2 0.333 l +-2 -0.333 l +h + + + + +0 0 m +-1 0.333 l +-1 -0.333 l +h +-1 0 m +-2 0.333 l +-2 -0.333 l +h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +109.771 601.912 m +159.595 601.797 l +140.058 541.915 l +h + + +79.8776 552.169 m +109.756 601.699 l +139.812 542.209 l +h + + +69.8453 682.419 m +159.925 712.208 l +90.12 732.039 l +h + +One skeleton graph +0 +1 +2 +3 +4 +5 +6 + +60 710 m +40 660 l + + +40 660 m +130 690 l + + +130 690 m +60 710 l + + +40 660 m +80 580 l + + +80 580 m +130 580 l +130 580 l + + +130 580 m +110 520 l + + +110 520 m +50 530 l +50 530 l +50 530 l + + +50 530 m +80 580 l + + +130 580 m +130 690 l + + + + + + + +150.038 609.9 m +179.929 549.727 l + + + + +158.7 593.269 m +81.4925 544.805 l + + +256.324 639.958 m +370.055 639.958 l + + +56.8567 0 0 56.8567 313.217 639.756 e + + + +Rips threshold + + diff --git a/src/Rips_complex/doc/rips_one_skeleton.png b/src/Rips_complex/doc/rips_one_skeleton.png new file mode 100644 index 00000000..1028770e Binary files /dev/null and b/src/Rips_complex/doc/rips_one_skeleton.png differ diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt new file mode 100644 index 00000000..6d0deecf --- /dev/null +++ b/src/Rips_complex/example/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.6) +project(Rips_complex_examples) + +add_executable ( ripsoffreader example_rips_complex_from_off_file.cpp ) +target_link_libraries(ripsoffreader ${Boost_SYSTEM_LIBRARY}) +if (TBB_FOUND) + target_link_libraries(ripsoffreader ${TBB_LIBRARIES}) +endif() diff --git a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp new file mode 100644 index 00000000..82baa68e --- /dev/null +++ b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp @@ -0,0 +1,71 @@ +#include +// to construct Rips_complex from a OFF file of points +#include +// to construct a simplex_tree from rips complex +#include +#include + +#include +#include + +void usage(int nbArgs, char * const progName) { + std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; + std::cerr << "Usage: " << progName << " filename.off threshold dim_max [ouput_file.txt]\n"; + std::cerr << " i.e.: " << progName << " ../../data/points/alphacomplexdoc.off 60.0\n"; + exit(-1); // ----- >> +} + +int main(int argc, char **argv) { + if ((argc != 4) && (argc != 5)) usage(argc, (argv[0] - 1)); + + std::string off_file_name(argv[1]); + double threshold = atof(argv[2]); + int dim_max = atoi(argv[3]); + + // Type definitions + using Point = std::vector; + using Simplex_tree = Gudhi::Simplex_tree<>; + using Rips_complex = Gudhi::rips_complex::Rips_complex; + + // ---------------------------------------------------------------------------- + // Init of a rips complex from an OFF file + // ---------------------------------------------------------------------------- + Gudhi::Points_off_reader off_reader(off_file_name); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, + euclidean_distance); + + std::streambuf* streambufffer; + std::ofstream ouput_file_stream; + + if (argc == 5) { + ouput_file_stream.open(std::string(argv[4])); + streambufffer = ouput_file_stream.rdbuf(); + } else { + streambufffer = std::cout.rdbuf(); + } + + Simplex_tree simplex; + if (rips_complex_from_file.create_complex(simplex, dim_max)) { + std::ostream output_stream(streambufffer); + + // ---------------------------------------------------------------------------- + // Display information about the rips complex + // ---------------------------------------------------------------------------- + output_stream << "Rips complex is of dimension " << simplex.dimension() << + " - " << simplex.num_simplices() << " simplices - " << + simplex.num_vertices() << " vertices." << std::endl; + + output_stream << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << + std::endl; + for (auto f_simplex : simplex.filtration_simplex_range()) { + output_stream << " ( "; + for (auto vertex : simplex.simplex_vertex_range(f_simplex)) { + output_stream << vertex << " "; + } + output_stream << ") -> " << "[" << simplex.filtration(f_simplex) << "] "; + output_stream << std::endl; + } + } + ouput_file_stream.close(); + return 0; +} diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h new file mode 100644 index 00000000..10f674e5 --- /dev/null +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -0,0 +1,154 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Clément Maria & Vincent Rouvreau + * + * Copyright (C) 2016 INRIA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef RIPS_COMPLEX_H_ +#define RIPS_COMPLEX_H_ + +#include +#include + +#include + +#include +#include +#include +#include +#include // for numeric_limits +#include // for pair<> + + +namespace Gudhi { + +namespace rips_complex { + +/** + * \class Rips_complex + * \brief Rips complex data structure. + * + * \ingroup rips_complex + * + * \details + * The data structure is a 1-skeleton graph constructed from a point cloud, containing edges when the edge length is + * less or equal to a given threshold. Edge length is computed from a user given function. + * + * The complex is a template class requiring a Filtration_value type. + * + * \remark When Alpha_complex is constructed with an infinite value of alpha, the complex is a Delaunay complex. + * + * \tparam Filtration_value must meet `SimplicialComplexForRips` concept. + */ +template +class Rips_complex { + private: + typedef typename boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS + , boost::property < vertex_filtration_t, Filtration_value > + , boost::property < edge_filtration_t, Filtration_value >> Graph_t; + + typedef int Vertex_handle; + + public: + /** \brief Rips_complex constructor from a list of points. + * + * @param[in] points Range of points. + * @param[in] threshold rips value. + * @param[in] distance distance function that returns a Filtration_value from 2 given points. + * + * The type InputPointRange must be a range for which std::begin and std::end return input iterators on a point. + */ + template + Rips_complex(const InputPointRange& points, Filtration_value threshold, + Filtration_value distance(const Point_d& p1,const Point_d& p2)) { + std::vector< std::pair< Vertex_handle, Vertex_handle > > edges; + std::vector< Filtration_value > edges_fil; + std::map< Vertex_handle, Filtration_value > vertices; + + // Compute 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. + // -------------------------------------------------------------------------------------------- + // Creates the vector of edges and its filtration values (returned by distance function) + Vertex_handle idx_u, idx_v; + Filtration_value fil; + idx_u = 0; + for (auto it_u = std::begin(points); it_u != std::end(points); ++it_u) { + idx_v = idx_u + 1; + for (auto it_v = it_u + 1; it_v != std::end(points); ++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; + } + + // -------------------------------------------------------------------------------------------- + // Creates the proximity graph from edges and sets the property with the filtration value. + // Number of points is labeled from 0 to idx_u-1 + rips_skeleton_graph_ = Graph_t(edges.begin() , edges.end() , edges_fil.begin() , idx_u); + + auto vertex_prop = boost::get(vertex_filtration_t(), rips_skeleton_graph_); + + using vertex_iterator = typename boost::graph_traits::vertex_iterator; + vertex_iterator vi, vi_end; + for (std::tie(vi, vi_end) = boost::vertices(rips_skeleton_graph_); + vi != vi_end; ++vi) { + boost::put(vertex_prop, *vi, 0.); + } + + } + + /** \brief Initializes the simplicial complex from the 1-skeleton graph and expands it until a given maximal + * dimension. + * + * \tparam SimplicialComplexForRips must meet `SimplicialComplexForRips` concept. + * + * @param[in] complex SimplicialComplexForRips to be created. + * @param[in] dim_max graph expansion for rips until this given maximal dimension. + * + * @return true if creation succeeds, false otherwise. + * + */ + template + bool create_complex(SimplicialComplexForRips& complex, int dim_max) { + if (complex.num_vertices() > 0) { + std::cerr << "Rips_complex create_complex - complex is not empty\n"; + return false; // ----- >> + } + + // insert the proximity graph in the simplicial complex + complex.insert_graph(rips_skeleton_graph_); + // expand the graph until dimension dim_max + complex.expansion(dim_max); + + // -------------------------------------------------------------------------------------------- + return true; + } + private: + Graph_t rips_skeleton_graph_; +}; + +} // namespace rips_complex + +} // namespace Gudhi + +#endif // RIPS_COMPLEX_H_ -- cgit v1.2.3 From 452cf2181433a317fcc4d8c0661df3401073eec9 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 29 Sep 2016 10:56:50 +0000 Subject: 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 --- src/Rips_complex/example/CMakeLists.txt | 6 ++ .../example/example_rips_complex_from_points.cpp | 69 ++++++++++++++++++++++ .../example/rips_points_for_doc_12_2.txt | 20 +++++++ .../example/rips_points_for_doc_12_3.txt | 26 ++++++++ 4 files changed, 121 insertions(+) create mode 100644 src/Rips_complex/example/example_rips_complex_from_points.cpp create mode 100644 src/Rips_complex/example/rips_points_for_doc_12_2.txt create mode 100644 src/Rips_complex/example/rips_points_for_doc_12_3.txt (limited to 'src/Rips_complex') 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 +// to construct Rips_complex from a OFF file of points +#include +// to construct a simplex_tree from rips complex +#include +#include + +#include +#include +#include // 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::infinity(); + int dim_max = atoi(argv[1]); + + if (argc == 3) { + threshold = atof(argv[2]); + } + + // Type definitions + using Point = std::vector; + using Simplex_tree = Gudhi::Simplex_tree<>; + using Rips_complex = Gudhi::rips_complex::Rips_complex; + + std::vector 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); + + 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] -- cgit v1.2.3 From 62281451e55ab65a693118527337eb10ef369ae0 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 29 Sep 2016 11:08:01 +0000 Subject: rename files git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_module@1588 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 1d94b1a511d11cdb824bc3f4fbe58f365bb772bf --- .../example/rips_points_for_doc_12_1.txt | 20 ++++++++++++++++++++ .../example/rips_points_for_doc_12_2.txt | 20 -------------------- 2 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 src/Rips_complex/example/rips_points_for_doc_12_1.txt delete mode 100644 src/Rips_complex/example/rips_points_for_doc_12_2.txt (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/example/rips_points_for_doc_12_1.txt b/src/Rips_complex/example/rips_points_for_doc_12_1.txt new file mode 100644 index 00000000..b0e25cc5 --- /dev/null +++ b/src/Rips_complex/example/rips_points_for_doc_12_1.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_2.txt b/src/Rips_complex/example/rips_points_for_doc_12_2.txt deleted file mode 100644 index b0e25cc5..00000000 --- a/src/Rips_complex/example/rips_points_for_doc_12_2.txt +++ /dev/null @@ -1,20 +0,0 @@ -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] -- cgit v1.2.3 From 1c1c3073e0612ee401a941008a6b13438b3429e2 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 29 Sep 2016 12:34:19 +0000 Subject: Fix doxygen Add tests git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_module@1589 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3b03e969f43f4f41c7bca1b2de96a71688475742 --- CMakeLists.txt | 1 + src/CMakeLists.txt | 1 + src/Doxyfile | 3 +- src/Rips_complex/doc/Intro_rips_complex.h | 17 +- src/Rips_complex/example/CMakeLists.txt | 21 +- .../example_one_skeleton_rips_from_points.cpp | 64 ++++++ .../example/example_rips_complex_from_points.cpp | 69 ------ .../example/full_skeleton_rips_points_for_doc.txt | 26 +++ .../example/one_skeleton_rips_points_for_doc.txt | 20 ++ .../example/rips_points_for_doc_12_1.txt | 20 -- .../example/rips_points_for_doc_12_3.txt | 26 --- src/Rips_complex/test/CMakeLists.txt | 24 +++ src/Rips_complex/test/README | 12 ++ src/Rips_complex/test/test_rips_complex.cpp | 231 +++++++++++++++++++++ src/cmake/modules/GUDHI_user_version_target.txt | 2 +- src/common/doc/main_page.h | 23 ++ 16 files changed, 431 insertions(+), 129 deletions(-) create mode 100644 src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp delete mode 100644 src/Rips_complex/example/example_rips_complex_from_points.cpp create mode 100644 src/Rips_complex/example/full_skeleton_rips_points_for_doc.txt create mode 100644 src/Rips_complex/example/one_skeleton_rips_points_for_doc.txt delete mode 100644 src/Rips_complex/example/rips_points_for_doc_12_1.txt delete mode 100644 src/Rips_complex/example/rips_points_for_doc_12_3.txt create mode 100644 src/Rips_complex/test/CMakeLists.txt create mode 100644 src/Rips_complex/test/README create mode 100644 src/Rips_complex/test/test_rips_complex.cpp (limited to 'src/Rips_complex') diff --git a/CMakeLists.txt b/CMakeLists.txt index 89e130f4..972df204 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,6 +144,7 @@ else() add_subdirectory(src/Alpha_complex/example) add_subdirectory(src/Alpha_complex/test) add_subdirectory(src/Rips_complex/example) + add_subdirectory(src/Rips_complex/test) # data points generator add_subdirectory(data/points/generator) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c7744c49..7973ae39 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -108,6 +108,7 @@ else() add_subdirectory(example/Bitmap_cubical_complex) add_subdirectory(example/Witness_complex) add_subdirectory(example/Alpha_complex) + add_subdirectory(example/Rips_complex) # data points generator add_subdirectory(data/points/generator) diff --git a/src/Doxyfile b/src/Doxyfile index dd9a33fb..40d07049 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -845,7 +845,8 @@ IMAGE_PATH = doc/Skeleton_blocker/ \ doc/Simplex_tree/ \ doc/Persistent_cohomology/ \ doc/Witness_complex/ \ - doc/Bitmap_cubical_complex/ + doc/Bitmap_cubical_complex/ \ + doc/Rips_complex/ # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index 85108168..bd9f5fad 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -29,11 +29,11 @@ namespace rips_complex { /** \defgroup rips_complex Rips complex * - * \author Clément Maria & Vincent Rouvreau + * \author Clément Maria and Vincent Rouvreau * * @{ * - * \section definition Definition + * \section ripsdefinition Definition * * Rips_complex * (Wikipedia) is a @@ -61,18 +61,19 @@ namespace rips_complex { * * Then, it is asked to display information about the simplicial complex. * - * \include Rips_complex/example_rips_complex_from_points.cpp + * \include Rips_complex/example_one_skeleton_rips_from_points.cpp * - * When launching: + * When launching (rips maximal distance between 2 points is 12.0, is expanded until dimension 1 - one skeleton graph + * with other words): * - * \code $> ./ripspoints + * \code $> ./oneskeletonripspoints 12.0 * \endcode * * the program output is: * - * \include Rips_complex/rips_points_for_doc_12_2.txt + * \include Rips_complex/one_skeleton_rips_points_for_doc.txt * - * \section offexample Example from OFF file + * \section ripsoffexample Example from OFF file * * This example builds the one skeleton graph from the given points in an OFF file, threshold value, and distance * function. @@ -90,7 +91,7 @@ namespace rips_complex { * * the program output is: * - * \include Rips_complex/rips_points_for_doc_12_3.txt + * \include Rips_complex/full_skeleton_rips_points_for_doc.txt * * \copyright GNU General Public License v3. * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt index f8dcf94d..3962b15e 100644 --- a/src/Rips_complex/example/CMakeLists.txt +++ b/src/Rips_complex/example/CMakeLists.txt @@ -3,12 +3,25 @@ project(Rips_complex_examples) add_executable ( ripsoffreader example_rips_complex_from_off_file.cpp ) target_link_libraries(ripsoffreader ${Boost_SYSTEM_LIBRARY}) + +add_executable ( oneskeletonripspoints example_one_skeleton_rips_from_points.cpp ) +target_link_libraries(oneskeletonripspoints ${Boost_SYSTEM_LIBRARY}) + if (TBB_FOUND) target_link_libraries(ripsoffreader ${TBB_LIBRARIES}) + target_link_libraries(oneskeletonripspoints ${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}) +add_test(oneskeletonripspoints ${CMAKE_CURRENT_BINARY_DIR}/oneskeletonripspoints 12.0) +# Do not forget to copy test files in current binary dir +file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) +add_test(ripsoffreader_doc_12_1 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader alphacomplexdoc.off 12.0 1 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_1.txt) +add_test(ripsoffreader_doc_12_3 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader alphacomplexdoc.off 12.0 3 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_3.txt) +if (DIFF_PATH) + # Do not forget to copy test results files in current binary dir + file(COPY "one_skeleton_rips_points_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + file(COPY "full_skeleton_rips_points_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + + add_test(ripsoffreader_doc_12_1_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_1.txt ${CMAKE_CURRENT_BINARY_DIR}/one_skeleton_rips_points_for_doc.txt) + add_test(ripsoffreader_doc_12_3_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_points_for_doc.txt) endif() diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp new file mode 100644 index 00000000..db41b425 --- /dev/null +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp @@ -0,0 +1,64 @@ +#include +// to construct Rips_complex from a OFF file of points +#include +// to construct a simplex_tree from rips complex +#include +#include + +#include +#include +#include // 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 << " threshold\n"; + std::cerr << " i.e.: " << progName << " 12.0\n"; + exit(-1); // ----- >> +} + +int main(int argc, char **argv) { + if (argc != 2) usage(argc, argv[0]); + + double threshold = atof(argv[1]); + + // Type definitions + using Point = std::vector; + using Simplex_tree = Gudhi::Simplex_tree<>; + using Rips_complex = Gudhi::rips_complex::Rips_complex; + + std::vector 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 points + // ---------------------------------------------------------------------------- + Rips_complex rips_complex_from_file(points, threshold, euclidean_distance); + + Simplex_tree simplex; + if (rips_complex_from_file.create_complex(simplex, 1)) { + // ---------------------------------------------------------------------------- + // Display information about the one skeleton 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/example_rips_complex_from_points.cpp b/src/Rips_complex/example/example_rips_complex_from_points.cpp deleted file mode 100644 index c241d137..00000000 --- a/src/Rips_complex/example/example_rips_complex_from_points.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include -// to construct Rips_complex from a OFF file of points -#include -// to construct a simplex_tree from rips complex -#include -#include - -#include -#include -#include // 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::infinity(); - int dim_max = atoi(argv[1]); - - if (argc == 3) { - threshold = atof(argv[2]); - } - - // Type definitions - using Point = std::vector; - using Simplex_tree = Gudhi::Simplex_tree<>; - using Rips_complex = Gudhi::rips_complex::Rips_complex; - - std::vector 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); - - 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/full_skeleton_rips_points_for_doc.txt b/src/Rips_complex/example/full_skeleton_rips_points_for_doc.txt new file mode 100644 index 00000000..319931e0 --- /dev/null +++ b/src/Rips_complex/example/full_skeleton_rips_points_for_doc.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] diff --git a/src/Rips_complex/example/one_skeleton_rips_points_for_doc.txt b/src/Rips_complex/example/one_skeleton_rips_points_for_doc.txt new file mode 100644 index 00000000..b0e25cc5 --- /dev/null +++ b/src/Rips_complex/example/one_skeleton_rips_points_for_doc.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_1.txt b/src/Rips_complex/example/rips_points_for_doc_12_1.txt deleted file mode 100644 index b0e25cc5..00000000 --- a/src/Rips_complex/example/rips_points_for_doc_12_1.txt +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 319931e0..00000000 --- a/src/Rips_complex/example/rips_points_for_doc_12_3.txt +++ /dev/null @@ -1,26 +0,0 @@ -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] diff --git a/src/Rips_complex/test/CMakeLists.txt b/src/Rips_complex/test/CMakeLists.txt new file mode 100644 index 00000000..3972e9fc --- /dev/null +++ b/src/Rips_complex/test/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.6) +project(Rips_complex_tests) + +if (GCOVR_PATH) + # for gcovr to make coverage reports - Corbera Jenkins plugin + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") +endif() +if (GPROF_PATH) + # for gprof to make coverage reports - Jenkins + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") +endif() + +add_executable ( rips_complex_UT test_rips_complex.cpp ) +target_link_libraries(rips_complex_UT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +if (TBB_FOUND) + target_link_libraries(rips_complex_UT ${TBB_LIBRARIES}) +endif() + +# Do not forget to copy test files in current binary dir +file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + +add_test(rips_complex_UT ${CMAKE_CURRENT_BINARY_DIR}/rips_complex_UT + # XML format for Jenkins xUnit plugin + --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/rips_complex_UT.xml --log_level=test_suite --report_level=no) diff --git a/src/Rips_complex/test/README b/src/Rips_complex/test/README new file mode 100644 index 00000000..28236b52 --- /dev/null +++ b/src/Rips_complex/test/README @@ -0,0 +1,12 @@ +To compile: +*********** + +cmake . +make + +To launch with details: +*********************** + +./rips_complex_UT --report_level=detailed --log_level=all + + ==> echo $? returns 0 in case of success (non-zero otherwise) diff --git a/src/Rips_complex/test/test_rips_complex.cpp b/src/Rips_complex/test/test_rips_complex.cpp new file mode 100644 index 00000000..5f129160 --- /dev/null +++ b/src/Rips_complex/test/test_rips_complex.cpp @@ -0,0 +1,231 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2016 INRIA Saclay (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "rips_complex" +#include + +#include // float comparison +#include +#include +#include +#include // std::max + +#include +// to construct Rips_complex from a OFF file of points +#include +// to construct a simplex_tree from rips complex +#include +#include + +// Type definitions +using Point = std::vector; +using Simplex_tree = Gudhi::Simplex_tree<>; +using Rips_complex = Gudhi::rips_complex::Rips_complex; + +bool are_almost_the_same(float a, float b) { + return std::fabs(a - b) < std::numeric_limits::epsilon(); +} + +BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { + // ---------------------------------------------------------------------------- + // + // Init of a rips complex from a OFF file + // + // ---------------------------------------------------------------------------- + std::string off_file_name("alphacomplexdoc.off"); + double rips_threshold = 12.0; + std::cout << "========== OFF FILE NAME = " << off_file_name << " - rips threshold=" << + rips_threshold << "==========" << std::endl; + + Gudhi::Points_off_reader off_reader(off_file_name); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), rips_threshold, euclidean_distance); + + const int DIMENSION_1 = 1; + Simplex_tree st; + BOOST_CHECK(rips_complex_from_file.create_complex(st, DIMENSION_1)); + std::cout << "st.dimension()=" << st.dimension() << std::endl; + BOOST_CHECK(st.dimension() == DIMENSION_1); + + const int NUMBER_OF_VERTICES = 7; + std::cout << "st.num_vertices()=" << st.num_vertices() << std::endl; + BOOST_CHECK(st.num_vertices() == NUMBER_OF_VERTICES); + + std::cout << "st.num_simplices()=" << st.num_simplices() << std::endl; + BOOST_CHECK(st.num_simplices() == 18); + + // Check filtration values of vertices is 0.0 + for (auto f_simplex : st.skeleton_simplex_range(0)) { + BOOST_CHECK(st.filtration(f_simplex) == 0.0); + } + + // Check filtration values of edges + for (auto f_simplex : st.skeleton_simplex_range(DIMENSION_1)) { + if (DIMENSION_1 == st.dimension(f_simplex)) { + std::vector vp; + std::cout << "vertex = ("; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::cout << vertex << ","; + vp.push_back(off_reader.get_point_cloud().at(vertex)); + } + std::cout << ") - distance =" << euclidean_distance(vp.at(0), vp.at(1)) << + " - filtration =" << st.filtration(f_simplex) << std::endl; + BOOST_CHECK(vp.size() == 2); + BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), euclidean_distance(vp.at(0), vp.at(1)))); + } + } + + const int DIMENSION_2 = 2; + Simplex_tree st2; + BOOST_CHECK(rips_complex_from_file.create_complex(st2, DIMENSION_2)); + std::cout << "st2.dimension()=" << st2.dimension() << std::endl; + BOOST_CHECK(st2.dimension() == DIMENSION_2); + + std::cout << "st2.num_vertices()=" << st2.num_vertices() << std::endl; + BOOST_CHECK(st2.num_vertices() == NUMBER_OF_VERTICES); + + std::cout << "st2.num_simplices()=" << st2.num_simplices() << std::endl; + BOOST_CHECK(st2.num_simplices() == 23); + + Simplex_tree::Filtration_value f01 = st2.filtration(st2.find({0, 1})); + Simplex_tree::Filtration_value f02 = st2.filtration(st2.find({0, 2})); + Simplex_tree::Filtration_value f12 = st2.filtration(st2.find({1, 2})); + Simplex_tree::Filtration_value f012 = st2.filtration(st2.find({0, 1, 2})); + std::cout << "f012= " << f012 << " | f01= " << f01 << " - f02= " << f02 << " - f12= " << f12 << std::endl; + BOOST_CHECK(are_almost_the_same(f012, std::max(f01, std::max(f02,f12)))); + + Simplex_tree::Filtration_value f45 = st2.filtration(st2.find({4, 5})); + Simplex_tree::Filtration_value f56 = st2.filtration(st2.find({5, 6})); + Simplex_tree::Filtration_value f46 = st2.filtration(st2.find({4, 6})); + Simplex_tree::Filtration_value f456 = st2.filtration(st2.find({4, 5, 6})); + std::cout << "f456= " << f456 << " | f45= " << f45 << " - f56= " << f56 << " - f46= " << f46 << std::endl; + BOOST_CHECK(are_almost_the_same(f456, std::max(f45, std::max(f56,f46)))); + + const int DIMENSION_3 = 3; + Simplex_tree st3; + BOOST_CHECK(rips_complex_from_file.create_complex(st3, DIMENSION_3)); + std::cout << "st3.dimension()=" << st3.dimension() << std::endl; + BOOST_CHECK(st3.dimension() == DIMENSION_3); + + std::cout << "st3.num_vertices()=" << st3.num_vertices() << std::endl; + BOOST_CHECK(st3.num_vertices() == NUMBER_OF_VERTICES); + + std::cout << "st3.num_simplices()=" << st3.num_simplices() << std::endl; + BOOST_CHECK(st3.num_simplices() == 24); + + Simplex_tree::Filtration_value f123 = st3.filtration(st3.find({1, 2, 3})); + Simplex_tree::Filtration_value f013 = st3.filtration(st3.find({0, 1, 3})); + Simplex_tree::Filtration_value f023 = st3.filtration(st3.find({0, 2, 3})); + Simplex_tree::Filtration_value f0123 = st3.filtration(st3.find({0, 1, 2, 3})); + std::cout << "f0123= " << f0123 << " | f012= " << f012 << " - f123= " << f123 << " - f013= " << f013 << + " - f023= " << f023 << std::endl; + BOOST_CHECK(are_almost_the_same(f0123, std::max(f012, std::max(f123, std::max(f013, f023))))); + +} + +using Vector_of_points = std::vector; + +bool is_point_in_list(Vector_of_points points_list, Point point) { + for (auto& point_in_list : points_list) { + if (point_in_list == point) { + return true; // point found + } + } + return false; // point not found +} + +/* Compute the square value of Euclidean distance between two Points given by a range of coordinates. + * The points are assumed to have the same dimension. */ +template< typename Point > +double custom_square_euclidean_distance(const Point &p1,const Point &p2) { + double dist = 0.; + auto it1 = p1.begin(); + auto it2 = p2.begin(); + for (; it1 != p1.end(); ++it1, ++it2) { + double tmp = *it1 - *it2; + dist += tmp*tmp; + } + return dist; +} + +BOOST_AUTO_TEST_CASE(Rips_complex_from_points) { + // ---------------------------------------------------------------------------- + // Init of a list of points + // ---------------------------------------------------------------------------- + Vector_of_points points; + std::vector coords = { 0.0, 0.0, 0.0, 1.0 }; + points.push_back(Point(coords.begin(), coords.end())); + coords = { 0.0, 0.0, 1.0, 0.0 }; + points.push_back(Point(coords.begin(), coords.end())); + coords = { 0.0, 1.0, 0.0, 0.0 }; + points.push_back(Point(coords.begin(), coords.end())); + coords = { 1.0, 0.0, 0.0, 0.0 }; + points.push_back(Point(coords.begin(), coords.end())); + + // ---------------------------------------------------------------------------- + // Init of a rips complex from the list of points + // ---------------------------------------------------------------------------- + Rips_complex rips_complex_from_points(points, 2.0, custom_square_euclidean_distance); + + std::cout << "========== Rips_complex_from_points ==========" << std::endl; + Simplex_tree st; + const int DIMENSION = 3; + BOOST_CHECK(rips_complex_from_points.create_complex(st, DIMENSION)); + + // Another way to check num_simplices + std::cout << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << std::endl; + int num_simplices = 0; + for (auto f_simplex : st.filtration_simplex_range()) { + num_simplices++; + std::cout << " ( "; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::cout << vertex << " "; + } + std::cout << ") -> " << "[" << st.filtration(f_simplex) << "] "; + std::cout << std::endl; + } + BOOST_CHECK(num_simplices == 15); + std::cout << "st.num_simplices()=" << st.num_simplices() << std::endl; + BOOST_CHECK(st.num_simplices() == 15); + + std::cout << "st.dimension()=" << st.dimension() << std::endl; + BOOST_CHECK(st.dimension() == DIMENSION); + std::cout << "st.num_vertices()=" << st.num_vertices() << std::endl; + BOOST_CHECK(st.num_vertices() == 4); + + for (auto f_simplex : st.filtration_simplex_range()) { + std::cout << "dimension(" << st.dimension(f_simplex) << ") - f = " << st.filtration(f_simplex) << std::endl; + switch (st.dimension(f_simplex)) { + case 0: + BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), 0.0)); + break; + case 1: + case 2: + case 3: + BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), 2.0)); + break; + default: + BOOST_CHECK(false); // Shall not happen + break; + } + } +} diff --git a/src/cmake/modules/GUDHI_user_version_target.txt b/src/cmake/modules/GUDHI_user_version_target.txt index 805f0a83..78d3092f 100644 --- a/src/cmake/modules/GUDHI_user_version_target.txt +++ b/src/cmake/modules/GUDHI_user_version_target.txt @@ -48,7 +48,7 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.11) add_custom_command(TARGET user_version PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/src/GudhUI ${GUDHI_USER_VERSION_DIR}/GudhUI) - set(GUDHI_MODULES "common;Alpha_complex;Bitmap_cubical_complex;Contraction;Hasse_complex;Persistent_cohomology;Simplex_tree;Skeleton_blocker;Witness_complex") + set(GUDHI_MODULES "common;Alpha_complex;Bitmap_cubical_complex;Contraction;Hasse_complex;Persistent_cohomology;Rips_complex;Simplex_tree;Skeleton_blocker;Witness_complex") foreach(GUDHI_MODULE ${GUDHI_MODULES}) # doc files diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index 21cf6925..a38dbcdf 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -55,6 +55,23 @@ User manual: \ref cubical_complex - Reference manual: Gudhi::cubical_complex::Bitmap_cubical_complex + \subsection RipsComplexDataStructure Rips complex + \image html "rips_complex_representation.png" "Rips complex representation" + + + + + +
+ Author: Clément Maria
+ Introduced in: GUDHI 1.4.0
+ Copyright: GPL v3
+
+ Rips_complex is a simplicial complex constructed from a one skeleton graph.
+ The filtration value of each edge is computed from a user-given distance function and is inserted until a + user-given threshold value.
+ User manual: \ref rips_complex - Reference manual: Gudhi::rips_complex::Rips_complex +
\subsection SimplexTreeDataStructure Simplex tree \image html "Simplex_tree_representation.png" "Simplex tree representation" @@ -288,6 +305,10 @@ make \endverbatim * Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp * \li * Persistent_cohomology/custom_persistence_sort.cpp + * \li + * Rips_complex/example_one_skeleton_rips_from_points.cpp + * \li + * Rips_complex/example_rips_complex_from_off_file.cpp * * \section Contributions Bug reports and contributions * Please help us improving the quality of the GUDHI library. You may report bugs or suggestions to: @@ -330,6 +351,8 @@ make \endverbatim * @example Persistent_cohomology/rips_multifield_persistence.cpp * @example Persistent_cohomology/rips_persistence.cpp * @example Persistent_cohomology/custom_persistence_sort.cpp + * @example Rips_complex/example_one_skeleton_rips_from_points.cpp + * @example Rips_complex/example_rips_complex_from_off_file.cpp * @example Simplex_tree/mini_simplex_tree.cpp * @example Simplex_tree/simple_simplex_tree.cpp * @example Simplex_tree/simplex_tree_from_alpha_shapes_3.cpp -- cgit v1.2.3 From 29499b02d1b6eafcc6419a0b6b4469152ea20a09 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 30 Sep 2016 14:24:41 +0000 Subject: Fix compilation issues git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_module@1596 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 343308ef914e6a6617890f49a55eb0bb8db15ee9 --- CMakeLists.txt | 1 + src/GudhUI/utils/Persistence_compute.h | 35 ++-- src/Persistent_cohomology/benchmark/CMakeLists.txt | 14 ++ .../benchmark/performance_rips_persistence.cpp | 217 +++++++++++++++++++++ src/Persistent_cohomology/example/CMakeLists.txt | 4 - .../example/alpha_complex_3d_persistence.cpp | 3 +- .../example/alpha_complex_persistence.cpp | 2 + .../example/performance_rips_persistence.cpp | 214 -------------------- .../periodic_alpha_complex_3d_persistence.cpp | 1 + .../persistence_from_simple_simplex_tree.cpp | 17 +- .../example/rips_multifield_persistence.cpp | 21 +- .../example/rips_persistence.cpp | 20 +- .../rips_persistence_via_boundary_matrix.cpp | 50 +++-- ...persistent_cohomology_unit_test_multi_field.cpp | 4 +- src/Rips_complex/include/gudhi/Rips_complex.h | 2 +- src/Simplex_tree/example/simple_simplex_tree.cpp | 13 +- .../example/simplex_tree_from_cliques_of_graph.cpp | 9 +- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 69 +++---- .../example/witness_complex_from_file.cpp | 2 +- .../include/gudhi/Witness_complex.h | 2 +- .../test/simple_witness_complex.cpp | 2 +- .../test/witness_complex_points.cpp | 2 +- src/common/include/gudhi/reader_utils.h | 3 +- 24 files changed, 376 insertions(+), 333 deletions(-) create mode 100644 src/Persistent_cohomology/benchmark/CMakeLists.txt create mode 100644 src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp delete mode 100644 src/Persistent_cohomology/example/performance_rips_persistence.cpp (limited to 'src/Rips_complex') diff --git a/CMakeLists.txt b/CMakeLists.txt index 972df204..cecad3e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,6 +134,7 @@ else() add_subdirectory(src/Simplex_tree/example) add_subdirectory(src/Persistent_cohomology/test) add_subdirectory(src/Persistent_cohomology/example) + add_subdirectory(src/Persistent_cohomology/benchmark) add_subdirectory(src/Skeleton_blocker/test) add_subdirectory(src/Skeleton_blocker/example) add_subdirectory(src/Contraction/example) diff --git a/src/GudhUI/utils/Persistence_compute.h b/src/GudhUI/utils/Persistence_compute.h index 97165490..fa5bafc1 100644 --- a/src/GudhUI/utils/Persistence_compute.h +++ b/src/GudhUI/utils/Persistence_compute.h @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -69,22 +70,26 @@ template class Persistence_compute { points.emplace_back(std::move(pt_to_add)); } + using Simplex_tree = Gudhi::Simplex_tree<>; + using Filtration_value = Simplex_tree::Filtration_value; + using Rips_complex = Gudhi::rips_complex::Rips_complex; + using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; + using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; + + Rips_complex rips_complex(points, params.threshold, euclidean_distance); - Graph_t prox_graph = compute_proximity_graph(points, params.threshold, euclidean_distance); - Gudhi::Simplex_tree<> st; - st.insert_graph(prox_graph); - st.expansion(params.max_dim); - - Gudhi::persistent_cohomology::Persistent_cohomology< Gudhi::Simplex_tree<>, - Gudhi::persistent_cohomology::Field_Zp > pcoh(st); - // initializes the coefficient field for homology - pcoh.init_coefficients(params.p); - // put params.min_pers - pcoh.compute_persistent_cohomology(params.min_pers); - stream << "persistence: \n"; - stream << "p dimension birth death: \n"; - - pcoh.output_diagram(stream); + Simplex_tree st; + if (rips_complex.create_complex(st, params.max_dim)) { + Persistent_cohomology pcoh(st); + // initializes the coefficient field for homology + pcoh.init_coefficients(params.p); + // put params.min_pers + pcoh.compute_persistent_cohomology(params.min_pers); + stream << "persistence: \n"; + stream << "p dimension birth death: \n"; + + pcoh.output_diagram(stream); + } } }; diff --git a/src/Persistent_cohomology/benchmark/CMakeLists.txt b/src/Persistent_cohomology/benchmark/CMakeLists.txt new file mode 100644 index 00000000..ea792c89 --- /dev/null +++ b/src/Persistent_cohomology/benchmark/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 2.6) +project(Persistent_cohomology_benchmark) + + +if(GMP_FOUND) + if(GMPXX_FOUND) + add_executable ( performance_rips_persistence EXCLUDE_FROM_ALL performance_rips_persistence.cpp ) + target_link_libraries(performance_rips_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) + if (TBB_FOUND) + target_link_libraries(performance_rips_persistence ${TBB_LIBRARIES}) + endif(TBB_FOUND) + file(COPY "${CMAKE_SOURCE_DIR}/data/points/Kl.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + endif(GMPXX_FOUND) +endif(GMP_FOUND) diff --git a/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp b/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp new file mode 100644 index 00000000..99fcad41 --- /dev/null +++ b/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp @@ -0,0 +1,217 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Clément Maria + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +// Types definition +using Simplex_tree = Gudhi::Simplex_tree; +using Filtration_value = Simplex_tree::Filtration_value; +using Rips_complex = Gudhi::rips_complex::Rips_complex; +using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; +using Multi_field = Gudhi::persistent_cohomology::Multi_field; +using Point = std::vector; +using Points_off_reader = Gudhi::Points_off_reader; + +/* Compute the persistent homology of the complex cpx with coefficients in Z/pZ. */ +template< typename FilteredComplex> +void timing_persistence(FilteredComplex & cpx + , int p); + +/* Compute multi-field persistent homology of the complex cpx with coefficients in + * Z/rZ for all prime number r in [p;q].*/ +template< typename FilteredComplex> +void timing_persistence(FilteredComplex & cpx + , int p + , int q); + +/* Timings for the computation of persistent homology with different + * representations of a Rips complex and different coefficient fields. The + * Rips complex is built on a set of 10000 points sampling a Klein bottle embedded + * in dimension 5. + * We represent complexes with a simplex tree and + * with a Hasse diagram. The Hasse diagram represents explicitly all + * codimension 1 incidence relations in the complex, and hence leads to + * a faster computation of persistence because boundaries are precomputed. + * Hovewer, the simplex tree may be constructed directly from a point cloud and + * is more compact. + * We compute persistent homology with coefficient fields Z/2Z and Z/1223Z. + * We present also timings for the computation of multi-field persistent + * homology in all fields Z/rZ for r prime between 2 and 1223. + */ +int main(int argc, char * argv[]) { + std::chrono::time_point start, end; + int elapsed_sec; + { + + std::string off_file_points = "Kl.off"; + Filtration_value threshold = 0.27; + int dim_max = 3; + int p = 2; + int q = 1223; + + // Extract the points from the file off_file_points + Points_off_reader off_reader(off_file_points); + + // Compute the proximity graph of the points + start = std::chrono::system_clock::now(); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, + euclidean_distance); + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << "Compute Rips graph in " << elapsed_sec << " ms.\n"; + + // Construct the Rips complex in a Simplex Tree + Simplex_tree st; + start = std::chrono::system_clock::now(); + + // insert the proximity graph in the simplex tree + // expand the graph until dimension dim_max + rips_complex_from_file.create_complex(st, dim_max); + + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << "Compute Rips complex in " << elapsed_sec << " ms.\n"; + std::cout << " - dimension = " << st.dimension() << std::endl; + std::cout << " - number of simplices = " << st.num_simplices() << std::endl; + + // Sort the simplices in the order of the filtration + start = std::chrono::system_clock::now(); + st.initialize_filtration(); + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << "Order the simplices of the filtration in " << elapsed_sec << " ms.\n"; + + // Copy the keys inside the simplices + start = std::chrono::system_clock::now(); + { + int count = 0; + for (auto sh : st.filtration_simplex_range()) + st.assign_key(sh, count++); + } + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << "Copied the keys inside the simplices in " << elapsed_sec << " ms.\n"; + + // Convert the simplex tree into a hasse diagram + start = std::chrono::system_clock::now(); + Gudhi::Hasse_complex<> hcpx(st); + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << "Convert the simplex tree into a Hasse diagram in " << elapsed_sec << " ms.\n"; + + + std::cout << "Timings when using a simplex tree: \n"; + timing_persistence(st, p); + timing_persistence(st, q); + timing_persistence(st, p, q); + + std::cout << "Timings when using a Hasse complex: \n"; + timing_persistence(hcpx, p); + timing_persistence(hcpx, q); + timing_persistence(hcpx, p, q); + + start = std::chrono::system_clock::now(); + } + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << "Running the complex destructors in " << elapsed_sec << " ms.\n"; + return 0; +} + +template< typename FilteredComplex> +void +timing_persistence(FilteredComplex & cpx + , int p) { + std::chrono::time_point start, end; + int elapsed_sec; + { + start = std::chrono::system_clock::now(); + Gudhi::persistent_cohomology::Persistent_cohomology< FilteredComplex, Field_Zp > pcoh(cpx); + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << " Initialize pcoh in " << elapsed_sec << " ms.\n"; + // initializes the coefficient field for homology + start = std::chrono::system_clock::now(); + pcoh.init_coefficients(p); + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << " Initialize the coefficient field in " << elapsed_sec << " ms.\n"; + + start = std::chrono::system_clock::now(); + + pcoh.compute_persistent_cohomology(INFINITY); + + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << " Compute persistent homology in Z/" << p << "Z in " << elapsed_sec << " ms.\n"; + start = std::chrono::system_clock::now(); + } + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << " Run the persistence destructors in " << elapsed_sec << " ms.\n"; +} + +template< typename FilteredComplex> +void +timing_persistence(FilteredComplex & cpx + , int p + , int q) { + std::chrono::time_point start, end; + int elapsed_sec; + { + start = std::chrono::system_clock::now(); + Gudhi::persistent_cohomology::Persistent_cohomology< FilteredComplex, Multi_field > pcoh(cpx); + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << " Initialize pcoh in " << elapsed_sec << " ms.\n"; + // initializes the coefficient field for homology + start = std::chrono::system_clock::now(); + pcoh.init_coefficients(p, q); + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << " Initialize the coefficient field in " << elapsed_sec << " ms.\n"; + // compute persistent homology, disgarding persistent features of life shorter than min_persistence + + start = std::chrono::system_clock::now(); + + pcoh.compute_persistent_cohomology(INFINITY); + + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << " Compute multi-field persistent homology in all coefficient fields Z/pZ " + << "with p in [" << p << ";" << q << "] in " << elapsed_sec << " ms.\n"; + start = std::chrono::system_clock::now(); + } + end = std::chrono::system_clock::now(); + elapsed_sec = std::chrono::duration_cast(end - start).count(); + std::cout << " Run the persistence destructors in " << elapsed_sec << " ms.\n"; +} diff --git a/src/Persistent_cohomology/example/CMakeLists.txt b/src/Persistent_cohomology/example/CMakeLists.txt index d97d1b63..75f3c5d4 100644 --- a/src/Persistent_cohomology/example/CMakeLists.txt +++ b/src/Persistent_cohomology/example/CMakeLists.txt @@ -39,13 +39,9 @@ if(GMP_FOUND) if(GMPXX_FOUND) add_executable(rips_multifield_persistence rips_multifield_persistence.cpp ) target_link_libraries(rips_multifield_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) - add_executable ( performance_rips_persistence performance_rips_persistence.cpp ) - target_link_libraries(performance_rips_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES}) if (TBB_FOUND) target_link_libraries(rips_multifield_persistence ${TBB_LIBRARIES}) - target_link_libraries(performance_rips_persistence ${TBB_LIBRARIES}) endif(TBB_FOUND) - add_test(rips_multifield_persistence_2_71 ${CMAKE_CURRENT_BINARY_DIR}/rips_multifield_persistence ${CMAKE_SOURCE_DIR}/data/points/Kl.txt -r 0.2 -d 3 -p 2 -q 71 -m 100) endif(GMPXX_FOUND) endif(GMP_FOUND) diff --git a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp index 48fbb91a..f7e8f800 100644 --- a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp @@ -64,6 +64,7 @@ typedef std::list Vertex_list; // gudhi type definition typedef Gudhi::Simplex_tree ST; +typedef ST::Filtration_value Filtration_value; typedef ST::Vertex_handle Simplex_tree_vertex; typedef std::map Alpha_shape_simplex_tree_map; typedef std::pair Alpha_shape_simplex_tree_pair; @@ -132,7 +133,7 @@ int main(int argc, char * const argv[]) { int coeff_field_characteristic = atoi(argv[2]); Filtration_value min_persistence = 0.0; - int returnedScanValue = sscanf(argv[3], "%lf", &min_persistence); + int returnedScanValue = sscanf(argv[3], "%f", &min_persistence); if ((returnedScanValue == EOF) || (min_persistence < -1.0)) { std::cerr << "Error: " << argv[3] << " is not correct\n"; usage(argv[0]); diff --git a/src/Persistent_cohomology/example/alpha_complex_persistence.cpp b/src/Persistent_cohomology/example/alpha_complex_persistence.cpp index cb181936..24315144 100644 --- a/src/Persistent_cohomology/example/alpha_complex_persistence.cpp +++ b/src/Persistent_cohomology/example/alpha_complex_persistence.cpp @@ -9,6 +9,8 @@ #include #include // for numeric_limits +using Filtration_value = double; + void program_options(int argc, char * argv[] , std::string & off_file_points , std::string & output_file_diag diff --git a/src/Persistent_cohomology/example/performance_rips_persistence.cpp b/src/Persistent_cohomology/example/performance_rips_persistence.cpp deleted file mode 100644 index b4d282ac..00000000 --- a/src/Persistent_cohomology/example/performance_rips_persistence.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ - * library for computational topology. - * - * Author(s): Clément Maria - * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -using namespace Gudhi; -using namespace Gudhi::persistent_cohomology; - -/* Compute the persistent homology of the complex cpx with coefficients in Z/pZ. */ -template< typename FilteredComplex> -void timing_persistence(FilteredComplex & cpx - , int p); - -/* Compute multi-field persistent homology of the complex cpx with coefficients in - * Z/rZ for all prime number r in [p;q].*/ -template< typename FilteredComplex> -void timing_persistence(FilteredComplex & cpx - , int p - , int q); - -/* Timings for the computation of persistent homology with different - * representations of a Rips complex and different coefficient fields. The - * Rips complex is built on a set of 10000 points sampling a Klein bottle embedded - * in dimension 5. - * We represent complexes with a simplex tree and - * with a Hasse diagram. The Hasse diagram represents explicitly all - * codimension 1 incidence relations in the complex, and hence leads to - * a faster computation of persistence because boundaries are precomputed. - * Hovewer, the simplex tree may be constructed directly from a point cloud and - * is more compact. - * We compute persistent homology with coefficient fields Z/2Z and Z/1223Z. - * We present also timings for the computation of multi-field persistent - * homology in all fields Z/rZ for r prime between 2 and 1223. - */ -int main(int argc, char * argv[]) { - std::chrono::time_point start, end; - int elapsed_sec; - { - - std::string filepoints = "../../../data/points/Kl.txt"; - Filtration_value threshold = 0.27; - int dim_max = 3; - int p = 2; - int q = 1223; - - // Extract the points from the file filepoints - typedef std::vector Point_t; - std::vector< Point_t > points; - read_points(filepoints, points); - - // Compute the proximity graph of the points - start = std::chrono::system_clock::now(); - Graph_t prox_graph = compute_proximity_graph(points, threshold - , euclidean_distance); - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << "Compute Rips graph in " << elapsed_sec << " ms.\n"; - - // Construct the Rips complex in a Simplex Tree - Simplex_tree st; - start = std::chrono::system_clock::now(); - - // insert the proximity graph in the simplex tree - st.insert_graph(prox_graph); - // expand the graph until dimension dim_max - st.expansion(dim_max); - - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << "Compute Rips complex in " << elapsed_sec << " ms.\n"; - std::cout << " - dimension = " << st.dimension() << std::endl; - std::cout << " - number of simplices = " << st.num_simplices() << std::endl; - - // Sort the simplices in the order of the filtration - start = std::chrono::system_clock::now(); - st.initialize_filtration(); - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << "Order the simplices of the filtration in " << elapsed_sec << " ms.\n"; - - // Copy the keys inside the simplices - start = std::chrono::system_clock::now(); - { - int count = 0; - for (auto sh : st.filtration_simplex_range()) - st.assign_key(sh, count++); - } - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << "Copied the keys inside the simplices in " << elapsed_sec << " ms.\n"; - - // Convert the simplex tree into a hasse diagram - start = std::chrono::system_clock::now(); - Hasse_complex<> hcpx(st); - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << "Convert the simplex tree into a Hasse diagram in " << elapsed_sec << " ms.\n"; - - - std::cout << "Timings when using a simplex tree: \n"; - timing_persistence(st, p); - timing_persistence(st, q); - timing_persistence(st, p, q); - - std::cout << "Timings when using a Hasse complex: \n"; - timing_persistence(hcpx, p); - timing_persistence(hcpx, q); - timing_persistence(hcpx, p, q); - - start = std::chrono::system_clock::now(); - } - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << "Running the complex destructors in " << elapsed_sec << " ms.\n"; - return 0; -} - -template< typename FilteredComplex> -void -timing_persistence(FilteredComplex & cpx - , int p) { - std::chrono::time_point start, end; - int elapsed_sec; - { - start = std::chrono::system_clock::now(); - Persistent_cohomology< FilteredComplex, Field_Zp > pcoh(cpx); - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << " Initialize pcoh in " << elapsed_sec << " ms.\n"; - // initializes the coefficient field for homology - start = std::chrono::system_clock::now(); - pcoh.init_coefficients(p); - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << " Initialize the coefficient field in " << elapsed_sec << " ms.\n"; - - start = std::chrono::system_clock::now(); - - pcoh.compute_persistent_cohomology(INFINITY); - - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << " Compute persistent homology in Z/" << p << "Z in " << elapsed_sec << " ms.\n"; - start = std::chrono::system_clock::now(); - } - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << " Run the persistence destructors in " << elapsed_sec << " ms.\n"; -} - -template< typename FilteredComplex> -void -timing_persistence(FilteredComplex & cpx - , int p - , int q) { - std::chrono::time_point start, end; - int elapsed_sec; - { - start = std::chrono::system_clock::now(); - Persistent_cohomology< FilteredComplex, Multi_field > pcoh(cpx); - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << " Initialize pcoh in " << elapsed_sec << " ms.\n"; - // initializes the coefficient field for homology - start = std::chrono::system_clock::now(); - pcoh.init_coefficients(p, q); - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << " Initialize the coefficient field in " << elapsed_sec << " ms.\n"; - // compute persistent homology, disgarding persistent features of life shorter than min_persistence - - start = std::chrono::system_clock::now(); - - pcoh.compute_persistent_cohomology(INFINITY); - - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << " Compute multi-field persistent homology in all coefficient fields Z/pZ " - << "with p in [" << p << ";" << q << "] in " << elapsed_sec << " ms.\n"; - start = std::chrono::system_clock::now(); - } - end = std::chrono::system_clock::now(); - elapsed_sec = std::chrono::duration_cast(end - start).count(); - std::cout << " Run the persistence destructors in " << elapsed_sec << " ms.\n"; -} diff --git a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp index a199fea1..5184ef52 100644 --- a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp @@ -70,6 +70,7 @@ using Vertex_list = std::list; // gudhi type definition using ST = Gudhi::Simplex_tree; +using Filtration_value = ST::Filtration_value; using Simplex_tree_vertex = ST::Vertex_handle; using Alpha_shape_simplex_tree_map = std::map; using Alpha_shape_simplex_tree_pair = std::pair; diff --git a/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp b/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp index ba772f04..817aac4d 100644 --- a/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp +++ b/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp @@ -29,13 +29,12 @@ #include #include -using namespace Gudhi; -using namespace Gudhi::persistent_cohomology; - -typedef std::vector< Vertex_handle > typeVectorVertex; -typedef std::pair typeSimplex; -typedef std::pair< Simplex_tree<>::Simplex_handle, bool > typePairSimplexBool; -typedef Simplex_tree<> typeST; +// Types definition +using Simplex_tree = Gudhi::Simplex_tree; +using Filtration_value = Simplex_tree::Filtration_value; +using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; +using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; +using typeVectorVertex = std::vector< Simplex_tree::Vertex_handle >; void usage(char * const progName) { std::cerr << "Usage: " << progName << " coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n"; @@ -66,7 +65,7 @@ int main(int argc, char * const argv[]) { // TEST OF INSERTION std::cout << "********************************************************************" << std::endl; std::cout << "TEST OF INSERTION" << std::endl; - typeST st; + Simplex_tree st; // ++ FIRST std::cout << " - INSERT (0,1,2)" << std::endl; @@ -166,7 +165,7 @@ int main(int argc, char * const argv[]) { std::cout << "**************************************************************" << std::endl; // Compute the persistence diagram of the complex - persistent_cohomology::Persistent_cohomology< Simplex_tree<>, Field_Zp > pcoh(st); + Persistent_cohomology pcoh(st); // initializes the coefficient field for homology pcoh.init_coefficients(coeff_field_characteristic); diff --git a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp index d4a07bb6..f4adc7a9 100644 --- a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp @@ -25,14 +25,21 @@ #include #include #include +#include #include #include #include - -typedef double Filtration_value; +// Types definition +using Simplex_tree = Gudhi::Simplex_tree; +using Filtration_value = Simplex_tree::Filtration_value; +using Rips_complex = Gudhi::rips_complex::Rips_complex; +using Multi_field = Gudhi::persistent_cohomology::Multi_field; +using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; +using Point = std::vector; +using Points_off_reader = Gudhi::Points_off_reader; void program_options(int argc, char * argv[] , std::string & off_file_points @@ -54,22 +61,22 @@ int main(int argc, char * argv[]) { program_options(argc, argv, off_file_points, filediag, threshold, dim_max, min_p, max_p, min_persistence); - Gudhi::rips_complex::Rips_complex<> rips_complex_from_file(off_file_points); + Points_off_reader off_reader(off_file_points); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, + euclidean_distance); // Construct the Rips complex in a Simplex Tree - using Simplex_tree = Gudhi::Simplex_tree; Simplex_tree simplex_tree; - if (rips_complex_from_file.create_complex(simplex_tree, threshold, dim_max, euclidean_distance>)) { + if (rips_complex_from_file.create_complex(simplex_tree, dim_max)) { std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n"; std::cout << " and has dimension " << simplex_tree.dimension() << " \n"; // Sort the simplices in the order of the filtration simplex_tree.initialize_filtration(); - using Multi_field = Gudhi::persistent_cohomology::Multi_field; // Compute the persistence diagram of the complex - Gudhi::persistent_cohomology::Persistent_cohomology pcoh(simplex_tree); + Persistent_cohomology pcoh(simplex_tree); // initializes the coefficient field for homology pcoh.init_coefficients(min_p, max_p); diff --git a/src/Persistent_cohomology/example/rips_persistence.cpp b/src/Persistent_cohomology/example/rips_persistence.cpp index e3ab5927..97bab14c 100644 --- a/src/Persistent_cohomology/example/rips_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_persistence.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -32,7 +33,14 @@ #include #include // infinity -typedef double Filtration_value; +// Types definition +using Simplex_tree = Gudhi::Simplex_tree; +using Filtration_value = Simplex_tree::Filtration_value; +using Rips_complex = Gudhi::rips_complex::Rips_complex; +using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; +using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; +using Point = std::vector; +using Points_off_reader = Gudhi::Points_off_reader; void program_options(int argc, char * argv[] , std::string & off_file_points @@ -52,22 +60,22 @@ int main(int argc, char * argv[]) { program_options(argc, argv, off_file_points, filediag, threshold, dim_max, p, min_persistence); - Gudhi::rips_complex::Rips_complex<> rips_complex_from_file(off_file_points); + Points_off_reader off_reader(off_file_points); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, + euclidean_distance); // Construct the Rips complex in a Simplex Tree - using Simplex_tree = Gudhi::Simplex_tree; Simplex_tree simplex_tree; - if (rips_complex_from_file.create_complex(simplex_tree, threshold, dim_max, euclidean_distance>)) { + if (rips_complex_from_file.create_complex(simplex_tree, dim_max)) { std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n"; std::cout << " and has dimension " << simplex_tree.dimension() << " \n"; // Sort the simplices in the order of the filtration simplex_tree.initialize_filtration(); - using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; // Compute the persistence diagram of the complex - Gudhi::persistent_cohomology::Persistent_cohomology pcoh(simplex_tree); + Persistent_cohomology pcoh(simplex_tree); // initializes the coefficient field for homology pcoh.init_coefficients(p); diff --git a/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp b/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp index 4c6656f5..991ed4f0 100644 --- a/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp +++ b/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp @@ -21,12 +21,12 @@ * along with this program. If not, see . */ -#include -#include -#include #include #include +#include #include +#include +#include #include @@ -44,14 +44,16 @@ // // //////////////////////////////////////////////////////////////// -using namespace Gudhi; -using namespace Gudhi::persistent_cohomology; - -typedef int Vertex_handle; -typedef double Filtration_value; +// Types definition +using Simplex_tree = Gudhi::Simplex_tree<>; +using Filtration_value = Simplex_tree::Filtration_value; +using Rips_complex = Gudhi::rips_complex::Rips_complex; +using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; +using Point = std::vector; +using Points_off_reader = Gudhi::Points_off_reader; void program_options(int argc, char * argv[] - , std::string & filepoints + , std::string & off_file_points , std::string & filediag , Filtration_value & threshold , int & dim_max @@ -59,30 +61,22 @@ void program_options(int argc, char * argv[] , Filtration_value & min_persistence); int main(int argc, char * argv[]) { - std::string filepoints; + std::string off_file_points; std::string filediag; Filtration_value threshold; int dim_max; int p; Filtration_value min_persistence; - program_options(argc, argv, filepoints, filediag, threshold, dim_max, p, min_persistence); - - // Extract the points from the file filepoints - typedef std::vector Point_t; - std::vector< Point_t > points; - read_points(filepoints, points); + program_options(argc, argv, off_file_points, filediag, threshold, dim_max, p, min_persistence); - // Compute the proximity graph of the points - Graph_t prox_graph = compute_proximity_graph(points, threshold - , euclidean_distance); + Points_off_reader off_reader(off_file_points); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, + euclidean_distance); // Construct the Rips complex in a Simplex Tree - Simplex_tree<>& st = *new Simplex_tree<>; - // insert the proximity graph in the simplex tree - st.insert_graph(prox_graph); - // expand the graph until dimension dim_max - st.expansion(dim_max); + Simplex_tree& st = *new Simplex_tree; + rips_complex_from_file.create_complex(st, dim_max); std::cout << "The complex contains " << st.num_simplices() << " simplices \n"; std::cout << " and has dimension " << st.dimension() << " \n"; @@ -99,7 +93,7 @@ int main(int argc, char * argv[]) { st.assign_key(sh, count++); // Convert to a more convenient representation. - Hasse_complex<> hcpx(st); + Gudhi::Hasse_complex<> hcpx(st); #ifdef GUDHI_USE_TBB ts.terminate(); @@ -109,7 +103,7 @@ int main(int argc, char * argv[]) { delete &st; // Compute the persistence diagram of the complex - persistent_cohomology::Persistent_cohomology< Hasse_complex<>, Field_Zp > pcoh(hcpx); + Gudhi::persistent_cohomology::Persistent_cohomology< Gudhi::Hasse_complex<>, Field_Zp > pcoh(hcpx); // initializes the coefficient field for homology pcoh.init_coefficients(p); @@ -126,7 +120,7 @@ int main(int argc, char * argv[]) { } void program_options(int argc, char * argv[] - , std::string & filepoints + , std::string & off_file_points , std::string & filediag , Filtration_value & threshold , int & dim_max @@ -135,7 +129,7 @@ void program_options(int argc, char * argv[] namespace po = boost::program_options; po::options_description hidden("Hidden options"); hidden.add_options() - ("input-file", po::value(&filepoints), + ("input-file", po::value(&off_file_points), "Name of file containing a point set. Format is one point per line: X1 ... Xd "); po::options_description visible("Allowed options", 100); diff --git a/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp b/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp index 703682e1..1a6e3296 100644 --- a/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp +++ b/src/Persistent_cohomology/test/persistent_cohomology_unit_test_multi_field.cpp @@ -21,7 +21,7 @@ using namespace boost::unit_test; typedef Simplex_tree<> typeST; -std::string test_rips_persistence(int min_coefficient, int max_coefficient, int min_persistence) { +std::string test_rips_persistence(int min_coefficient, int max_coefficient, double min_persistence) { // file name is given as parameter from CMakeLists.txt const std::string inputFile(framework::master_test_suite().argv[1]); @@ -74,7 +74,7 @@ void test_rips_persistence_in_dimension(int min_dimension, int max_dimension) { std::cout << "********************************************************************" << std::endl; std::cout << "TEST OF RIPS_PERSISTENT_COHOMOLOGY_MULTI_FIELD MIN_DIM=" << min_dimension << " MAX_DIM=" << max_dimension << " MIN_PERS=0" << std::endl; - std::string str_rips_persistence = test_rips_persistence(min_dimension, max_dimension, static_cast (0.0)); + std::string str_rips_persistence = test_rips_persistence(min_dimension, max_dimension, 0.0); std::cout << "str_rips_persistence=" << str_rips_persistence << std::endl; BOOST_CHECK(str_rips_persistence.find(value0) != std::string::npos); // Check found diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index 10f674e5..9eb22d03 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -47,7 +47,7 @@ namespace rips_complex { * \ingroup rips_complex * * \details - * The data structure is a 1-skeleton graph constructed from a point cloud, containing edges when the edge length is + * The data structure is a one skeleton graph constructed from a point cloud, containing edges when the edge length is * less or equal to a given threshold. Edge length is computed from a user given function. * * The complex is a template class requiring a Filtration_value type. diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index 5146b906..bf6dc470 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -27,10 +27,11 @@ #include // for pair #include -using namespace Gudhi; - -typedef std::vector< Vertex_handle > typeVectorVertex; -typedef std::pair< Simplex_tree<>::Simplex_handle, bool > typePairSimplexBool; +using Simplex_tree = Gudhi::Simplex_tree<>; +using Vertex_handle = Simplex_tree::Vertex_handle; +using Filtration_value = Simplex_tree::Filtration_value; +using typeVectorVertex = std::vector< Vertex_handle >; +using typePairSimplexBool = std::pair< Simplex_tree::Simplex_handle, bool >; int main(int argc, char * const argv[]) { const Filtration_value FIRST_FILTRATION_VALUE = 0.1; @@ -42,7 +43,7 @@ int main(int argc, char * const argv[]) { std::cout << "********************************************************************" << std::endl; std::cout << "EXAMPLE OF SIMPLE INSERTION" << std::endl; // Construct the Simplex Tree - Simplex_tree<> simplexTree; + Simplex_tree simplexTree; /* Simplex to be inserted: */ /* 1 */ @@ -212,7 +213,7 @@ int main(int argc, char * const argv[]) { // ------------------------------------------------------------------------------------------------------------------ // Find in the simplex_tree // ------------------------------------------------------------------------------------------------------------------ - Simplex_tree<>::Simplex_handle simplexFound = simplexTree.find(secondSimplexVector); + Simplex_tree::Simplex_handle simplexFound = simplexTree.find(secondSimplexVector); std::cout << "**************IS THE SIMPLEX {1} IN THE SIMPLEX TREE ?\n"; if (simplexFound != simplexTree.null_simplex()) std::cout << "***+ YES IT IS!\n"; diff --git a/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp b/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp index 58085014..8d729c56 100644 --- a/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp +++ b/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp @@ -29,6 +29,13 @@ using namespace Gudhi; +typedef int Vertex_handle; +typedef double Filtration_value; +typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS, + boost::property < vertex_filtration_t, Filtration_value >, + boost::property < edge_filtration_t, Filtration_value > > Graph_t; +typedef std::pair< Vertex_handle, Vertex_handle > Edge_t; + int main(int argc, char * const argv[]) { if (argc != 3) { std::cerr << "Usage: " << argv[0] @@ -43,7 +50,7 @@ int main(int argc, char * const argv[]) { Simplex_tree<> st; start = clock(); - auto g = read_graph(filegraph); + auto g = read_graph(filegraph); // insert the graph in the simplex tree as 1-skeleton st.insert_graph(g); end = clock(); diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 206b2fba..63e3f0e5 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -28,7 +28,7 @@ #include #include -//#include +#include #include #include diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index 28bf202b..b06d7ec9 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include // std::pair, std::make_pair @@ -19,19 +20,19 @@ using namespace Gudhi; typedef boost::mpl::list, Simplex_tree> list_of_tested_variants; -const Vertex_handle DEFAULT_VERTEX_HANDLE = (const Vertex_handle) - 1; -const Filtration_value DEFAULT_FILTRATION_VALUE = (const Filtration_value) 0.0; template void test_empty_simplex_tree(typeST& tst) { - BOOST_CHECK(tst.null_vertex() == DEFAULT_VERTEX_HANDLE); - BOOST_CHECK(tst.filtration() == DEFAULT_FILTRATION_VALUE); + typedef typename typeST::Vertex_handle Vertex_handle; + const Vertex_handle DEFAULT_VERTEX_VALUE = Vertex_handle(- 1); + BOOST_CHECK(tst.null_vertex() == DEFAULT_VERTEX_VALUE); + BOOST_CHECK(tst.filtration() == 0.0); BOOST_CHECK(tst.num_vertices() == (size_t) 0); BOOST_CHECK(tst.num_simplices() == (size_t) 0); typename typeST::Siblings* STRoot = tst.root(); BOOST_CHECK(STRoot != nullptr); BOOST_CHECK(STRoot->oncles() == nullptr); - BOOST_CHECK(STRoot->parent() == DEFAULT_VERTEX_HANDLE); + BOOST_CHECK(STRoot->parent() == DEFAULT_VERTEX_VALUE); BOOST_CHECK(tst.dimension() == -1); } @@ -59,7 +60,7 @@ void test_iterators_on_empty_simplex_tree(typeST& tst) { BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_when_empty, typeST, list_of_tested_variants) { typedef std::pair typePairSimplexBool; - typedef std::vector typeVectorVertex; + typedef std::vector typeVectorVertex; std::cout << "********************************************************************" << std::endl; std::cout << "TEST OF DEFAULT CONSTRUCTOR" << std::endl; @@ -72,8 +73,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_when_empty, typeST, list_of_tested_va std::cout << "TEST OF EMPTY INSERTION" << std::endl; typeVectorVertex simplexVectorEmpty; BOOST_CHECK(simplexVectorEmpty.empty() == true); - typePairSimplexBool returnEmptyValue = st.insert_simplex(simplexVectorEmpty, - DEFAULT_FILTRATION_VALUE); + typePairSimplexBool returnEmptyValue = st.insert_simplex(simplexVectorEmpty, 0.0); BOOST_CHECK(returnEmptyValue.first == typename typeST::Simplex_handle(nullptr)); BOOST_CHECK(returnEmptyValue.second == true); @@ -141,12 +141,13 @@ void test_simplex_tree_contains(typeST& simplexTree, typeSimplex& simplex, int p template void test_simplex_tree_insert_returns_true(const typePairSimplexBool& returnValue) { BOOST_CHECK(returnValue.second == true); - typename typeST::Simplex_handle shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator + // Simplex_handle = boost::container::flat_map< typeST::Vertex_handle, Node >::iterator + typename typeST::Simplex_handle shReturned = returnValue.first; BOOST_CHECK(shReturned != typename typeST::Simplex_handle(nullptr)); } // Global variables -Filtration_value max_fil = DEFAULT_FILTRATION_VALUE; +double max_fil = 0.0; int dim_max = -1; template @@ -179,8 +180,9 @@ void set_and_test_simplex_tree_dim_fil(typeST& simplexTree, int vectorSize, cons } BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_variants) { + typedef typename typeST::Filtration_value Filtration_value; typedef std::pair typePairSimplexBool; - typedef std::vector typeVectorVertex; + typedef std::vector typeVectorVertex; typedef std::pair typeSimplex; const Filtration_value FIRST_FILTRATION_VALUE = 0.1; const Filtration_value SECOND_FILTRATION_VALUE = 0.2; @@ -188,7 +190,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var const Filtration_value FOURTH_FILTRATION_VALUE = 0.4; // reset since we run the test several times dim_max = -1; - max_fil = DEFAULT_FILTRATION_VALUE; + max_fil = 0.0; // TEST OF INSERTION std::cout << "********************************************************************" << std::endl; @@ -303,7 +305,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var returnValue = st.insert_simplex(tenthSimplex.first, tenthSimplex.second); BOOST_CHECK(returnValue.second == false); - typename typeST::Simplex_handle shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator + // Simplex_handle = boost::container::flat_map< typeST::Vertex_handle, Node >::iterator + typename typeST::Simplex_handle shReturned = returnValue.first; BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr)); BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !! BOOST_CHECK(st.dimension() == dim_max); @@ -317,7 +320,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var returnValue = st.insert_simplex(eleventhSimplex.first, eleventhSimplex.second); BOOST_CHECK(returnValue.second == false); - shReturned = returnValue.first; // Simplex_handle = boost::container::flat_map< Vertex_handle, Node >::iterator + // Simplex_handle = boost::container::flat_map< typeST::Vertex_handle, Node >::iterator + shReturned = returnValue.first; BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr)); BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !! BOOST_CHECK(st.dimension() == dim_max); @@ -375,8 +379,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var BOOST_AUTO_TEST_CASE_TEMPLATE(NSimplexAndSubfaces_tree_insertion, typeST, list_of_tested_variants) { typedef std::pair typePairSimplexBool; - typedef std::vector typeVectorVertex; - typedef std::pair typeSimplex; + typedef std::vector typeVectorVertex; + typedef std::pair typeSimplex; std::cout << "********************************************************************" << std::endl; std::cout << "TEST OF RECURSIVE INSERTION" << std::endl; typeST st; @@ -394,7 +398,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(NSimplexAndSubfaces_tree_insertion, typeST, list_o // Check it is well inserted BOOST_CHECK(true == returnValue.second); position = 0; - std::sort(SimplexVector1.begin(), SimplexVector1.end(), std::greater()); + std::sort(SimplexVector1.begin(), SimplexVector1.end(), std::greater()); for (auto vertex : st.simplex_vertex_range(returnValue.first)) { // Check returned Simplex_handle std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector1[position] << std::endl; @@ -413,7 +417,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(NSimplexAndSubfaces_tree_insertion, typeST, list_o // Check it is well inserted BOOST_CHECK(true == returnValue.second); position = 0; - std::sort(SimplexVector2.begin(), SimplexVector2.end(), std::greater()); + std::sort(SimplexVector2.begin(), SimplexVector2.end(), std::greater()); for (auto vertex : st.simplex_vertex_range(returnValue.first)) { // Check returned Simplex_handle std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector2[position] << std::endl; @@ -432,7 +436,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(NSimplexAndSubfaces_tree_insertion, typeST, list_o // Check it is well inserted BOOST_CHECK(true == returnValue.second); position = 0; - std::sort(SimplexVector3.begin(), SimplexVector3.end(), std::greater()); + std::sort(SimplexVector3.begin(), SimplexVector3.end(), std::greater()); for (auto vertex : st.simplex_vertex_range(returnValue.first)) { // Check returned Simplex_handle std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector3[position] << std::endl; @@ -462,7 +466,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(NSimplexAndSubfaces_tree_insertion, typeST, list_o // Check it is well inserted BOOST_CHECK(true == returnValue.second); position = 0; - std::sort(SimplexVector5.begin(), SimplexVector5.end(), std::greater()); + std::sort(SimplexVector5.begin(), SimplexVector5.end(), std::greater()); for (auto vertex : st.simplex_vertex_range(returnValue.first)) { // Check returned Simplex_handle std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector5[position] << std::endl; @@ -481,7 +485,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(NSimplexAndSubfaces_tree_insertion, typeST, list_o // Check it is well inserted BOOST_CHECK(true == returnValue.second); position = 0; - std::sort(SimplexVector6.begin(), SimplexVector6.end(), std::greater()); + std::sort(SimplexVector6.begin(), SimplexVector6.end(), std::greater()); for (auto vertex : st.simplex_vertex_range(returnValue.first)) { // Check returned Simplex_handle std::cout << "vertex = " << vertex << " | vector[" << position << "] = " << SimplexVector6[position] << std::endl; @@ -504,12 +508,12 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(NSimplexAndSubfaces_tree_insertion, typeST, list_o /* A facet [3,4,5] */ /* A cell [0,1,6,7] */ - typeSimplex simplexPair1 = std::make_pair(SimplexVector1, DEFAULT_FILTRATION_VALUE); - typeSimplex simplexPair2 = std::make_pair(SimplexVector2, DEFAULT_FILTRATION_VALUE); - typeSimplex simplexPair3 = std::make_pair(SimplexVector3, DEFAULT_FILTRATION_VALUE); - typeSimplex simplexPair4 = std::make_pair(SimplexVector4, DEFAULT_FILTRATION_VALUE); - typeSimplex simplexPair5 = std::make_pair(SimplexVector5, DEFAULT_FILTRATION_VALUE); - typeSimplex simplexPair6 = std::make_pair(SimplexVector6, DEFAULT_FILTRATION_VALUE); + typeSimplex simplexPair1 = std::make_pair(SimplexVector1, 0.0); + typeSimplex simplexPair2 = std::make_pair(SimplexVector2, 0.0); + typeSimplex simplexPair3 = std::make_pair(SimplexVector3, 0.0); + typeSimplex simplexPair4 = std::make_pair(SimplexVector4, 0.0); + typeSimplex simplexPair5 = std::make_pair(SimplexVector5, 0.0); + typeSimplex simplexPair6 = std::make_pair(SimplexVector6, 0.0); test_simplex_tree_contains(st, simplexPair1, 6); // (2,1,0) is in position 6 test_simplex_tree_contains(st, simplexPair2, 7); // (3) is in position 7 test_simplex_tree_contains(st, simplexPair3, 8); // (3,0) is in position 8 @@ -600,7 +604,7 @@ void test_cofaces(typeST& st, const std::vector& expected, int di } BOOST_AUTO_TEST_CASE_TEMPLATE(coface_on_simplex_tree, typeST, list_of_tested_variants) { - typedef std::vector typeVectorVertex; + typedef std::vector typeVectorVertex; std::cout << "********************************************************************" << std::endl; std::cout << "TEST COFACE ALGORITHM" << std::endl; typeST st; @@ -629,7 +633,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(coface_on_simplex_tree, typeST, list_of_tested_var // FIXME st.set_dimension(3); - std::vector simplex_result; + std::vector simplex_result; std::vector result; std::cout << "First test - Star of (3):" << std::endl; @@ -649,7 +653,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(coface_on_simplex_tree, typeST, list_of_tested_var result.push_back(st.find(simplex_result)); simplex_result.clear(); - std::vector vertex = {3}; + std::vector vertex = {3}; test_cofaces(st, vertex, 0, result); vertex.clear(); result.clear(); @@ -699,7 +703,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(coface_on_simplex_tree, typeST, list_of_tested_var } BOOST_AUTO_TEST_CASE_TEMPLATE(copy_move_on_simplex_tree, typeST, list_of_tested_variants) { - typedef std::vector typeVectorVertex; + typedef std::vector typeVectorVertex; std::cout << "********************************************************************" << std::endl; std::cout << "TEST COPY MOVE CONSTRUCTORS" << std::endl; typeST st; @@ -771,12 +775,11 @@ void test_simplex_is_vertex(typeST& st, typename typeST::Simplex_handle sh, type BOOST_AUTO_TEST_CASE(non_contiguous) { typedef Simplex_tree<> typeST; - typedef typeST::Vertex_handle Vertex_handle; typedef typeST::Simplex_handle Simplex_handle; std::cout << "********************************************************************" << std::endl; std::cout << "TEST NON-CONTIGUOUS VERTICES" << std::endl; typeST st; - Vertex_handle e[] = {3,-7}; + typeST::Vertex_handle e[] = {3,-7}; std::cout << "Insert" << std::endl; st.insert_simplex_and_subfaces(e); BOOST_CHECK(st.num_vertices() == 2); diff --git a/src/Witness_complex/example/witness_complex_from_file.cpp b/src/Witness_complex/example/witness_complex_from_file.cpp index 53207ad2..392ad55d 100644 --- a/src/Witness_complex/example/witness_complex_from_file.cpp +++ b/src/Witness_complex/example/witness_complex_from_file.cpp @@ -34,7 +34,7 @@ #include #include -typedef std::vector< Vertex_handle > typeVectorVertex; +typedef std::vector< int > typeVectorVertex; typedef std::vector< std::vector > Point_Vector; /** diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index 489cdf11..2cec921a 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -72,7 +72,7 @@ class Witness_complex { typedef std::vector< Point_t > Point_Vector; typedef std::vector< Vertex_handle > typeVectorVertex; - typedef std::pair< typeVectorVertex, Filtration_value> typeSimplex; + //typedef std::pair< typeVectorVertex, Filtration_value> typeSimplex; typedef std::pair< Simplex_handle, bool > typePairSimplexBool; typedef int Witness_id; diff --git a/src/Witness_complex/test/simple_witness_complex.cpp b/src/Witness_complex/test/simple_witness_complex.cpp index 03df78ee..adaadfb0 100644 --- a/src/Witness_complex/test/simple_witness_complex.cpp +++ b/src/Witness_complex/test/simple_witness_complex.cpp @@ -33,7 +33,7 @@ #include typedef Gudhi::Simplex_tree<> Simplex_tree; -typedef std::vector< Vertex_handle > typeVectorVertex; +typedef std::vector< int > typeVectorVertex; typedef Gudhi::witness_complex::Witness_complex WitnessComplex; BOOST_AUTO_TEST_CASE(simple_witness_complex) { diff --git a/src/Witness_complex/test/witness_complex_points.cpp b/src/Witness_complex/test/witness_complex_points.cpp index bd3df604..03c9adc0 100644 --- a/src/Witness_complex/test/witness_complex_points.cpp +++ b/src/Witness_complex/test/witness_complex_points.cpp @@ -34,7 +34,7 @@ #include typedef std::vector Point; -typedef std::vector< Vertex_handle > typeVectorVertex; +typedef std::vector< int > typeVectorVertex; typedef Gudhi::Simplex_tree<> Simplex_tree; typedef Gudhi::witness_complex::Witness_complex WitnessComplex; diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 899f9df6..4154acc9 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -77,6 +77,7 @@ inline void read_points(std::string file_name, std::vector< std::vector< double * Every simplex must appear exactly once. * Simplices of dimension more than 1 are ignored. */ +template< typename Graph_t, typename Edge_t, typename Filtration_value, typename Vertex_handle > inline Graph_t read_graph(std::string file_name) { std::ifstream in_(file_name.c_str(), std::ios::in); if (!in_.is_open()) { @@ -130,7 +131,7 @@ inline Graph_t read_graph(std::string file_name) { Graph_t skel_graph(edges.begin(), edges.end(), edges_fil.begin(), vertices.size()); auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph); - boost::graph_traits::vertex_iterator vi, vi_end; + typename boost::graph_traits::vertex_iterator vi, vi_end; auto v_it = vertices.begin(); for (std::tie(vi, vi_end) = boost::vertices(skel_graph); vi != vi_end; ++vi, ++v_it) { boost::put(vertex_prop, *vi, v_it->second); -- cgit v1.2.3 From 5ce7c7c8ec1378439cdc02dc94ac2a7e14e9ca04 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 3 Oct 2016 15:17:04 +0000 Subject: Fix euclidean distance for rips git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_module@1610 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a07dfd4ffe3f17bf242ffb5b57058e99171a8016 --- src/GudhUI/utils/Persistence_compute.h | 2 +- .../benchmark/performance_rips_persistence.cpp | 4 ++-- .../example/rips_multifield_persistence.cpp | 4 ++-- src/Persistent_cohomology/example/rips_persistence.cpp | 4 ++-- .../example/rips_persistence_via_boundary_matrix.cpp | 2 +- .../example/example_one_skeleton_rips_from_points.cpp | 9 +++++---- src/Rips_complex/example/example_rips_complex_from_off_file.cpp | 5 +++-- src/Rips_complex/test/test_rips_complex.cpp | 8 +++++--- .../include/gudhi/Landmark_choice_by_furthest_point.h | 2 +- .../include/gudhi/Landmark_choice_by_random_point.h | 2 +- src/common/include/gudhi/distance_functions.h | 8 ++++---- 11 files changed, 27 insertions(+), 23 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/GudhUI/utils/Persistence_compute.h b/src/GudhUI/utils/Persistence_compute.h index fa5bafc1..f7048c28 100644 --- a/src/GudhUI/utils/Persistence_compute.h +++ b/src/GudhUI/utils/Persistence_compute.h @@ -76,7 +76,7 @@ template class Persistence_compute { using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; - Rips_complex rips_complex(points, params.threshold, euclidean_distance); + Rips_complex rips_complex(points, params.threshold, euclidean_distance); Simplex_tree st; if (rips_complex.create_complex(st, params.max_dim)) { diff --git a/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp b/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp index 99fcad41..a9eab5dd 100644 --- a/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp +++ b/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp @@ -33,7 +33,7 @@ #include // Types definition -using Simplex_tree = Gudhi::Simplex_tree; +using Simplex_tree = Gudhi::Simplex_tree; using Filtration_value = Simplex_tree::Filtration_value; using Rips_complex = Gudhi::rips_complex::Rips_complex; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; @@ -84,7 +84,7 @@ int main(int argc, char * argv[]) { // Compute the proximity graph of the points start = std::chrono::system_clock::now(); Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, - euclidean_distance); + euclidean_distance); end = std::chrono::system_clock::now(); elapsed_sec = std::chrono::duration_cast(end - start).count(); std::cout << "Compute Rips graph in " << elapsed_sec << " ms.\n"; diff --git a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp index f4adc7a9..8e5c83a1 100644 --- a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp @@ -33,7 +33,7 @@ #include // Types definition -using Simplex_tree = Gudhi::Simplex_tree; +using Simplex_tree = Gudhi::Simplex_tree; using Filtration_value = Simplex_tree::Filtration_value; using Rips_complex = Gudhi::rips_complex::Rips_complex; using Multi_field = Gudhi::persistent_cohomology::Multi_field; @@ -63,7 +63,7 @@ int main(int argc, char * argv[]) { Points_off_reader off_reader(off_file_points); Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, - euclidean_distance); + euclidean_distance); // Construct the Rips complex in a Simplex Tree Simplex_tree simplex_tree; diff --git a/src/Persistent_cohomology/example/rips_persistence.cpp b/src/Persistent_cohomology/example/rips_persistence.cpp index 97bab14c..b74d0094 100644 --- a/src/Persistent_cohomology/example/rips_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_persistence.cpp @@ -34,7 +34,7 @@ #include // infinity // Types definition -using Simplex_tree = Gudhi::Simplex_tree; +using Simplex_tree = Gudhi::Simplex_tree; using Filtration_value = Simplex_tree::Filtration_value; using Rips_complex = Gudhi::rips_complex::Rips_complex; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; @@ -62,7 +62,7 @@ int main(int argc, char * argv[]) { Points_off_reader off_reader(off_file_points); Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, - euclidean_distance); + euclidean_distance); // Construct the Rips complex in a Simplex Tree Simplex_tree simplex_tree; diff --git a/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp b/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp index 991ed4f0..ee6577f4 100644 --- a/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp +++ b/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp @@ -72,7 +72,7 @@ int main(int argc, char * argv[]) { Points_off_reader off_reader(off_file_points); Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, - euclidean_distance); + euclidean_distance); // Construct the Rips complex in a Simplex Tree Simplex_tree& st = *new Simplex_tree; diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp index db41b425..2e63d9a6 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp @@ -23,8 +23,9 @@ int main(int argc, char **argv) { // Type definitions using Point = std::vector; - using Simplex_tree = Gudhi::Simplex_tree<>; - using Rips_complex = Gudhi::rips_complex::Rips_complex; + using Simplex_tree = Gudhi::Simplex_tree; + using Filtration_value = Simplex_tree::Filtration_value; + using Rips_complex = Gudhi::rips_complex::Rips_complex; std::vector points; points.push_back({1.0, 1.0}); @@ -38,10 +39,10 @@ int main(int argc, char **argv) { // ---------------------------------------------------------------------------- // Init of a rips complex from points // ---------------------------------------------------------------------------- - Rips_complex rips_complex_from_file(points, threshold, euclidean_distance); + Rips_complex rips_complex_from_points(points, threshold, euclidean_distance); Simplex_tree simplex; - if (rips_complex_from_file.create_complex(simplex, 1)) { + if (rips_complex_from_points.create_complex(simplex, 1)) { // ---------------------------------------------------------------------------- // Display information about the one skeleton rips complex // ---------------------------------------------------------------------------- diff --git a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp index 82baa68e..60050cea 100644 --- a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp @@ -25,14 +25,15 @@ int main(int argc, char **argv) { // Type definitions using Point = std::vector; using Simplex_tree = Gudhi::Simplex_tree<>; - using Rips_complex = Gudhi::rips_complex::Rips_complex; + using Filtration_value = Simplex_tree::Filtration_value; + using Rips_complex = Gudhi::rips_complex::Rips_complex; // ---------------------------------------------------------------------------- // Init of a rips complex from an OFF file // ---------------------------------------------------------------------------- Gudhi::Points_off_reader off_reader(off_file_name); Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, - euclidean_distance); + euclidean_distance); std::streambuf* streambufffer; std::ofstream ouput_file_stream; diff --git a/src/Rips_complex/test/test_rips_complex.cpp b/src/Rips_complex/test/test_rips_complex.cpp index 5f129160..f8be9748 100644 --- a/src/Rips_complex/test/test_rips_complex.cpp +++ b/src/Rips_complex/test/test_rips_complex.cpp @@ -40,6 +40,7 @@ // Type definitions using Point = std::vector; using Simplex_tree = Gudhi::Simplex_tree<>; +using Filtration_value = Simplex_tree::Filtration_value; using Rips_complex = Gudhi::rips_complex::Rips_complex; bool are_almost_the_same(float a, float b) { @@ -58,7 +59,8 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { rips_threshold << "==========" << std::endl; Gudhi::Points_off_reader off_reader(off_file_name); - Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), rips_threshold, euclidean_distance); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), rips_threshold, + euclidean_distance); const int DIMENSION_1 = 1; Simplex_tree st; @@ -87,10 +89,10 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { std::cout << vertex << ","; vp.push_back(off_reader.get_point_cloud().at(vertex)); } - std::cout << ") - distance =" << euclidean_distance(vp.at(0), vp.at(1)) << + std::cout << ") - distance =" << euclidean_distance(vp.at(0), vp.at(1)) << " - filtration =" << st.filtration(f_simplex) << std::endl; BOOST_CHECK(vp.size() == 2); - BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), euclidean_distance(vp.at(0), vp.at(1)))); + BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), euclidean_distance(vp.at(0), vp.at(1)))); } } diff --git a/src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h b/src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h index df93155b..bcb89e00 100644 --- a/src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h +++ b/src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h @@ -77,7 +77,7 @@ namespace witness_complex { chosen_landmarks.push_back(curr_max_w); unsigned i = 0; for (auto& p : points) { - double curr_dist = euclidean_distance(p, *(std::begin(points) + chosen_landmarks[current_number_of_landmarks])); + double curr_dist = euclidean_distance(p, *(std::begin(points) + chosen_landmarks[current_number_of_landmarks])); wit_land_dist[i].push_back(curr_dist); knn[i].push_back(current_number_of_landmarks); if (curr_dist < dist_to_L[i]) diff --git a/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h b/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h index ebf6aad1..b5aab9d5 100644 --- a/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h +++ b/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h @@ -78,7 +78,7 @@ namespace witness_complex { int landmarks_i = 0; for (landmarks_it = landmarks.begin(), landmarks_i = 0; landmarks_it != landmarks.end(); ++landmarks_it, landmarks_i++) { - dist_i dist = std::make_pair(euclidean_distance(points[points_i], points[*landmarks_it]), landmarks_i); + dist_i dist = std::make_pair(euclidean_distance(points[points_i], points[*landmarks_it]), landmarks_i); l_heap.push(dist); } for (int i = 0; i < dim + 1; i++) { diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index b2726ba8..006df275 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -28,13 +28,13 @@ /* Compute the Euclidean distance between two Points given * by a range of coordinates. The points are assumed to have * the same dimension. */ -template< typename Point > -double euclidean_distance(const Point &p1,const Point &p2) { - double dist = 0.; +template< typename Filtration_value, typename Point > +Filtration_value euclidean_distance(const Point &p1,const Point &p2) { + Filtration_value dist = 0.; auto it1 = p1.begin(); auto it2 = p2.begin(); for (; it1 != p1.end(); ++it1, ++it2) { - double tmp = *it1 - *it2; + Filtration_value tmp = (double)(*it1) - (double)(*it2); dist += tmp*tmp; } return std::sqrt(dist); -- cgit v1.2.3 From 4f229573f2e52a9385d05a2ce6235d77841f2368 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 3 Oct 2016 15:29:03 +0000 Subject: Fix doc issue git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_module@1611 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ed254b9a2b953723aa1a10623f688613f3a0c408 --- src/Rips_complex/include/gudhi/Rips_complex.h | 2 -- src/common/doc/main_page.h | 5 ----- 2 files changed, 7 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index 9eb22d03..aee6c969 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -52,8 +52,6 @@ namespace rips_complex { * * The complex is a template class requiring a Filtration_value type. * - * \remark When Alpha_complex is constructed with an infinite value of alpha, the complex is a Delaunay complex. - * * \tparam Filtration_value must meet `SimplicialComplexForRips` concept. */ template diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index a38dbcdf..1d2b99df 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -200,8 +200,6 @@ make \endverbatim * * The following example requires the GNU Multiple Precision Arithmetic * Library (GMP) and will not be built if GMP is not installed: - * \li - * Persistent_cohomology/performance_rips_persistence.cpp * \li * Persistent_cohomology/rips_multifield_persistence.cpp * @@ -289,8 +287,6 @@ make \endverbatim * Persistent_cohomology/alpha_complex_persistence.cpp * \li * Persistent_cohomology/rips_persistence_via_boundary_matrix.cpp - * \li - * Persistent_cohomology/performance_rips_persistence.cpp * \li * Persistent_cohomology/persistence_from_file.cpp * \li @@ -343,7 +339,6 @@ make \endverbatim * @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/performance_rips_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 -- cgit v1.2.3 From ede6f875e8340fb72d114ad9db3b54862566594f Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 17 Nov 2016 09:52:03 +0000 Subject: Modify examples git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_module@1757 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4b6f26947ad16f440ea4d4b7cb5e145a58f28dcb --- .../example/alpha_complex_3d_persistence.cpp | 2 +- .../example/alpha_complex_persistence.cpp | 7 +- .../periodic_alpha_complex_3d_persistence.cpp | 2 +- .../persistence_from_simple_simplex_tree.cpp | 4 +- .../example/rips_multifield_persistence.cpp | 2 +- .../example/rips_persistence.cpp | 2 +- .../rips_persistence_via_boundary_matrix.cpp | 3 +- src/Rips_complex/doc/Intro_rips_complex.h | 6 +- src/Rips_complex/include/gudhi/Rips_complex.h | 2 +- src/Simplex_tree/example/simple_simplex_tree.cpp | 2 +- .../example/simplex_tree_from_cliques_of_graph.cpp | 2 +- .../example/witness_complex_from_file.cpp | 6 +- .../example/witness_complex_sphere.cpp | 2 +- .../gudhi/Construct_closest_landmark_table.h | 2 +- .../gudhi/Landmark_choice_by_furthest_point.h | 105 --------------------- .../gudhi/Landmark_choice_by_random_point.h | 96 ------------------- .../include/gudhi/Witness_complex.h | 1 - .../test/simple_witness_complex.cpp | 2 +- .../test/witness_complex_points.cpp | 2 +- .../include/gudhi/graph_simplicial_complex.h | 57 ----------- 20 files changed, 24 insertions(+), 283 deletions(-) delete mode 100644 src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h delete mode 100644 src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h (limited to 'src/Rips_complex') diff --git a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp index f7e8f800..978dc942 100644 --- a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2014 INRIA Saclay (France) + * Copyright (C) 2014 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Persistent_cohomology/example/alpha_complex_persistence.cpp b/src/Persistent_cohomology/example/alpha_complex_persistence.cpp index bca4b66c..9e84e91f 100644 --- a/src/Persistent_cohomology/example/alpha_complex_persistence.cpp +++ b/src/Persistent_cohomology/example/alpha_complex_persistence.cpp @@ -11,7 +11,8 @@ #include #include // for numeric_limits -using Filtration_value = double; +using Simplex_tree = Gudhi::Simplex_tree<>; +using Filtration_value = Simplex_tree::Filtration_value; void program_options(int argc, char * argv[] , std::string & off_file_points @@ -36,7 +37,7 @@ int main(int argc, char **argv) { using Kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; Gudhi::alpha_complex::Alpha_complex alpha_complex_from_file(off_file_points); - Gudhi::Simplex_tree<> simplex; + Simplex_tree simplex; if (alpha_complex_from_file.create_complex(simplex, alpha_square_max_value)) { // ---------------------------------------------------------------------------- // Display information about the alpha complex @@ -50,7 +51,7 @@ int main(int argc, char **argv) { std::cout << "Simplex_tree dim: " << simplex.dimension() << std::endl; // Compute the persistence diagram of the complex - Gudhi::persistent_cohomology::Persistent_cohomology< Gudhi::Simplex_tree<>, + Gudhi::persistent_cohomology::Persistent_cohomology< Simplex_tree, Gudhi::persistent_cohomology::Field_Zp > pcoh(simplex); // initializes the coefficient field for homology pcoh.init_coefficients(coeff_field_characteristic); diff --git a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp index 5184ef52..6c03afce 100644 --- a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2014 INRIA Saclay (France) + * Copyright (C) 2014 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp b/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp index 817aac4d..7ca9410a 100644 --- a/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp +++ b/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2014 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ #include // Types definition -using Simplex_tree = Gudhi::Simplex_tree; +using Simplex_tree = Gudhi::Simplex_tree<>; using Filtration_value = Simplex_tree::Filtration_value; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; diff --git a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp index 8e5c83a1..6db85d16 100644 --- a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp @@ -4,7 +4,7 @@ * * Author(s): Clément Maria * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2014 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Persistent_cohomology/example/rips_persistence.cpp b/src/Persistent_cohomology/example/rips_persistence.cpp index b74d0094..709c2eab 100644 --- a/src/Persistent_cohomology/example/rips_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_persistence.cpp @@ -4,7 +4,7 @@ * * Author(s): Clément Maria * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2014 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp b/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp index ee6577f4..b7daf6ae 100644 --- a/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp +++ b/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp @@ -4,8 +4,7 @@ * * Author(s): Clément Maria, Marc Glisse * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France), - * 2015 INRIA Saclay Île de France) + * Copyright (C) 2014 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index bd9f5fad..a71946b5 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -2,9 +2,9 @@ * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * - * Author(s): Clément Maria & Vincent Rouvreau + * Author(s): Clément Maria, Vincent Rouvreau * - * Copyright (C) 2015 INRIA + * Copyright (C) 2016 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ namespace rips_complex { /** \defgroup rips_complex Rips complex * - * \author Clément Maria and Vincent Rouvreau + * \author Clément Maria, Vincent Rouvreau * * @{ * diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index aee6c969..da755b7c 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -2,7 +2,7 @@ * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * - * Author(s): Clément Maria & Vincent Rouvreau + * Author(s): Clément Maria, Vincent Rouvreau * * Copyright (C) 2016 INRIA * diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index bf6dc470..60f9a35e 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2014 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp b/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp index 8d729c56..13c700c6 100644 --- a/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp +++ b/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp @@ -4,7 +4,7 @@ * * Author(s): Clément Maria * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2014 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Witness_complex/example/witness_complex_from_file.cpp b/src/Witness_complex/example/witness_complex_from_file.cpp index 59dd28e0..5dd18d0a 100644 --- a/src/Witness_complex/example/witness_complex_from_file.cpp +++ b/src/Witness_complex/example/witness_complex_from_file.cpp @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2015 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2015 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,9 +36,9 @@ #include #include -typedef std::vector< int > typeVectorVertex; -typedef std::vector< std::vector > Point_Vector; typedef Gudhi::Simplex_tree<> Simplex_tree; +typedef std::vector< Simplex_tree::Vertex_handle > typeVectorVertex; +typedef std::vector< std::vector > Point_Vector; int main(int argc, char * const argv[]) { if (argc != 3) { diff --git a/src/Witness_complex/example/witness_complex_sphere.cpp b/src/Witness_complex/example/witness_complex_sphere.cpp index 7ab86cc0..60e02225 100644 --- a/src/Witness_complex/example/witness_complex_sphere.cpp +++ b/src/Witness_complex/example/witness_complex_sphere.cpp @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2015 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2015 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Witness_complex/include/gudhi/Construct_closest_landmark_table.h b/src/Witness_complex/include/gudhi/Construct_closest_landmark_table.h index ec93ae71..1ae2e393 100644 --- a/src/Witness_complex/include/gudhi/Construct_closest_landmark_table.h +++ b/src/Witness_complex/include/gudhi/Construct_closest_landmark_table.h @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2015 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2015 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h b/src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h deleted file mode 100644 index bcb89e00..00000000 --- a/src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h +++ /dev/null @@ -1,105 +0,0 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ - * library for computational topology. - * - * Author(s): Siargey Kachanovich - * - * Copyright (C) 2015 INRIA Sophia Antipolis-Méditerranée (France) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef LANDMARK_CHOICE_BY_FURTHEST_POINT_H_ -#define LANDMARK_CHOICE_BY_FURTHEST_POINT_H_ - -#include - -#include // for numeric_limits<> -#include -#include // for sort -#include - -namespace Gudhi { - -namespace witness_complex { - - typedef std::vector typeVectorVertex; - - /** - * \ingroup witness_complex - * \brief Landmark choice strategy by iteratively adding the furthest witness from the - * current landmark set as the new landmark. - * \details It chooses nbL landmarks from a random access range `points` and - * writes {witness}*{closest landmarks} matrix in `knn`. - * - * The type KNearestNeighbors can be seen as - * Witness_range>, where - * Witness_range and Closest_landmark_range are random access ranges - * - */ - - template - void landmark_choice_by_furthest_point(Point_random_access_range const &points, - int nbL, - KNearestNeighbours &knn) { - int nb_points = boost::size(points); - assert(nb_points >= nbL); - // distance matrix witness x landmarks - std::vector> wit_land_dist(nb_points, std::vector()); - // landmark list - typeVectorVertex chosen_landmarks; - - knn = KNearestNeighbours(nb_points, std::vector()); - int current_number_of_landmarks = 0; // counter for landmarks - double curr_max_dist = 0; // used for defining the furhest point from L - const double infty = std::numeric_limits::infinity(); // infinity (see next entry) - std::vector< double > dist_to_L(nb_points, infty); // vector of current distances to L from points - - // TODO(SK) Consider using rand_r(...) instead of rand(...) for improved thread safety - // or better yet std::uniform_int_distribution - int rand_int = rand() % nb_points; - int curr_max_w = rand_int; // For testing purposes a pseudo-random number is used here - - for (current_number_of_landmarks = 0; current_number_of_landmarks != nbL; current_number_of_landmarks++) { - // curr_max_w at this point is the next landmark - chosen_landmarks.push_back(curr_max_w); - unsigned i = 0; - for (auto& p : points) { - double curr_dist = euclidean_distance(p, *(std::begin(points) + chosen_landmarks[current_number_of_landmarks])); - wit_land_dist[i].push_back(curr_dist); - knn[i].push_back(current_number_of_landmarks); - if (curr_dist < dist_to_L[i]) - dist_to_L[i] = curr_dist; - ++i; - } - curr_max_dist = 0; - for (i = 0; i < dist_to_L.size(); i++) - if (dist_to_L[i] > curr_max_dist) { - curr_max_dist = dist_to_L[i]; - curr_max_w = i; - } - } - for (int i = 0; i < nb_points; ++i) - std::sort(std::begin(knn[i]), - std::end(knn[i]), - [&wit_land_dist, i](int a, int b) { - return wit_land_dist[i][a] < wit_land_dist[i][b]; }); - } - -} // namespace witness_complex - -} // namespace Gudhi - -#endif // LANDMARK_CHOICE_BY_FURTHEST_POINT_H_ diff --git a/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h b/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h deleted file mode 100644 index b5aab9d5..00000000 --- a/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h +++ /dev/null @@ -1,96 +0,0 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ - * library for computational topology. - * - * Author(s): Siargey Kachanovich - * - * Copyright (C) 2015 INRIA Sophia Antipolis-Méditerranée (France) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef LANDMARK_CHOICE_BY_RANDOM_POINT_H_ -#define LANDMARK_CHOICE_BY_RANDOM_POINT_H_ - -#include - -#include // for priority_queue<> -#include // for pair<> -#include -#include -#include - -namespace Gudhi { - -namespace witness_complex { - - /** - * \ingroup witness_complex - * \brief Landmark choice strategy by taking random vertices for landmarks. - * \details It chooses nbL distinct landmarks from a random access range `points` - * and outputs a matrix {witness}*{closest landmarks} in knn. - * - * The type KNearestNeighbors can be seen as - * Witness_range>, where - * Witness_range and Closest_landmark_range are random access ranges and - * Vertex_handle is the label type of a vertex in a simplicial complex. - * Closest_landmark_range needs to have push_back operation. - */ - - template - void landmark_choice_by_random_point(Point_random_access_range const &points, - int nbL, - KNearestNeighbours &knn) { - int nbP = boost::size(points); - assert(nbP >= nbL); - std::set landmarks; - int current_number_of_landmarks = 0; // counter for landmarks - - // TODO(SK) Consider using rand_r(...) instead of rand(...) for improved thread safety - int chosen_landmark = rand() % nbP; - for (current_number_of_landmarks = 0; current_number_of_landmarks != nbL; current_number_of_landmarks++) { - while (landmarks.find(chosen_landmark) != landmarks.end()) - chosen_landmark = rand() % nbP; - landmarks.insert(chosen_landmark); - } - - int dim = boost::size(*std::begin(points)); - typedef std::pair dist_i; - typedef bool (*comp)(dist_i, dist_i); - knn = KNearestNeighbours(nbP); - for (int points_i = 0; points_i < nbP; points_i++) { - std::priority_queue, comp> l_heap([](dist_i j1, dist_i j2) { - return j1.first > j2.first; - }); - std::set::iterator landmarks_it; - int landmarks_i = 0; - for (landmarks_it = landmarks.begin(), landmarks_i = 0; landmarks_it != landmarks.end(); - ++landmarks_it, landmarks_i++) { - dist_i dist = std::make_pair(euclidean_distance(points[points_i], points[*landmarks_it]), landmarks_i); - l_heap.push(dist); - } - for (int i = 0; i < dim + 1; i++) { - dist_i dist = l_heap.top(); - knn[points_i].push_back(dist.second); - l_heap.pop(); - } - } - } - -} // namespace witness_complex - -} // namespace Gudhi - -#endif // LANDMARK_CHOICE_BY_RANDOM_POINT_H_ diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index 2cec921a..1eb126f1 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -72,7 +72,6 @@ class Witness_complex { typedef std::vector< Point_t > Point_Vector; typedef std::vector< Vertex_handle > typeVectorVertex; - //typedef std::pair< typeVectorVertex, Filtration_value> typeSimplex; typedef std::pair< Simplex_handle, bool > typePairSimplexBool; typedef int Witness_id; diff --git a/src/Witness_complex/test/simple_witness_complex.cpp b/src/Witness_complex/test/simple_witness_complex.cpp index adaadfb0..6be39f58 100644 --- a/src/Witness_complex/test/simple_witness_complex.cpp +++ b/src/Witness_complex/test/simple_witness_complex.cpp @@ -33,7 +33,7 @@ #include typedef Gudhi::Simplex_tree<> Simplex_tree; -typedef std::vector< int > typeVectorVertex; +typedef std::vector< Simplex_tree::Vertex_handle > typeVectorVertex; typedef Gudhi::witness_complex::Witness_complex WitnessComplex; BOOST_AUTO_TEST_CASE(simple_witness_complex) { diff --git a/src/Witness_complex/test/witness_complex_points.cpp b/src/Witness_complex/test/witness_complex_points.cpp index b7067f87..92f53417 100644 --- a/src/Witness_complex/test/witness_complex_points.cpp +++ b/src/Witness_complex/test/witness_complex_points.cpp @@ -34,8 +34,8 @@ #include typedef std::vector Point; -typedef std::vector< int > typeVectorVertex; typedef Gudhi::Simplex_tree<> Simplex_tree; +typedef std::vector< Simplex_tree::Vertex_handle > typeVectorVertex; typedef Gudhi::witness_complex::Witness_complex WitnessComplex; BOOST_AUTO_TEST_CASE(witness_complex_points) { diff --git a/src/common/include/gudhi/graph_simplicial_complex.h b/src/common/include/gudhi/graph_simplicial_complex.h index 773889d9..9dbcd891 100644 --- a/src/common/include/gudhi/graph_simplicial_complex.h +++ b/src/common/include/gudhi/graph_simplicial_complex.h @@ -39,61 +39,4 @@ struct vertex_filtration_t { typedef boost::vertex_property_tag kind; }; -/*typedef int Vertex_handle; -typedef double Filtration_value; -typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS -, boost::property < vertex_filtration_t, Filtration_value > -, boost::property < edge_filtration_t, Filtration_value > -> Graph_t; -typedef std::pair< Vertex_handle, Vertex_handle > Edge_t; -*/ -/** \brief Output 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. - * - * The type PointCloud furnishes .begin() and .end() methods, that return - * iterators with value_type Point. - */ -/*template< typename PointCloud -, typename Point > -Graph_t compute_proximity_graph(PointCloud &points - , Filtration_value threshold - , Filtration_value distance(Point p1, Point p2)) { - std::vector< Edge_t > 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; - } - - Graph_t skel_graph(edges.begin() - , edges.end() - , edges_fil.begin() - , idx_u); // number of points labeled from 0 to idx_u-1 - - auto vertex_prop = boost::get(vertex_filtration_t(), skel_graph); - - boost::graph_traits::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; -}*/ - #endif // GRAPH_SIMPLICIAL_COMPLEX_H_ -- cgit v1.2.3 From c6ab4a62da2572b51032995266c109df7fe76dfd Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 18 Nov 2016 17:21:46 +0000 Subject: Add distance matrix read from csv files Distance template instead of Point_d for distance matrices git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1762 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 695bead714228c57e1be1650048125aa0b841683 --- src/Rips_complex/include/gudhi/Rips_complex.h | 89 +++++++++++++++---------- src/common/include/gudhi/reader_utils.h | 95 ++++++++++++++++++++++++++- 2 files changed, 146 insertions(+), 38 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index da755b7c..6f947f41 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -2,7 +2,7 @@ * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * - * Author(s): Clément Maria, Vincent Rouvreau + * Author(s): Clément Maria, Pawel Dlotko, Vincent Rouvreau * * Copyright (C) 2016 INRIA * @@ -58,12 +58,13 @@ template class Rips_complex { private: typedef typename boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS - , boost::property < vertex_filtration_t, Filtration_value > - , boost::property < edge_filtration_t, Filtration_value >> Graph_t; - + , boost::property < vertex_filtration_t, Filtration_value > + , boost::property < edge_filtration_t, Filtration_value >> Graph_t; + typedef int Vertex_handle; - + public: + /** \brief Rips_complex constructor from a list of points. * * @param[in] points Range of points. @@ -72,9 +73,51 @@ class Rips_complex { * * The type InputPointRange must be a range for which std::begin and std::end return input iterators on a point. */ - template - Rips_complex(const InputPointRange& points, Filtration_value threshold, - Filtration_value distance(const Point_d& p1,const Point_d& p2)) { + template + Rips_complex(const InputPointRange& points, Filtration_value threshold, Distance distance) { + compute_proximity_graph(points, threshold, distance); + } + + /** \brief Initializes the simplicial complex from the 1-skeleton graph and expands it until a given maximal + * dimension. + * + * \tparam SimplicialComplexForRips must meet `SimplicialComplexForRips` concept. + * + * @param[in] complex SimplicialComplexForRips to be created. + * @param[in] dim_max graph expansion for rips until this given maximal dimension. + * + * @return true if creation succeeds, false otherwise. + * + */ + template + bool create_complex(SimplicialComplexForRips& complex, int dim_max) { + if (complex.num_vertices() > 0) { + std::cerr << "Rips_complex create_complex - complex is not empty\n"; + return false; // ----- >> + } + + // insert the proximity graph in the simplicial complex + complex.insert_graph(rips_skeleton_graph_); + // expand the graph until dimension dim_max + complex.expansion(dim_max); + + // -------------------------------------------------------------------------------------------- + return true; + } + + public: + /** \brief Output 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. + * + * The type PointCloud furnishes .begin() and .end() methods, that return + * iterators with value_type Point. + */ + template< typename InputPointRange, typename Distance > + void compute_proximity_graph(const InputPointRange& points, Filtration_value threshold, + Distance distance) { std::vector< std::pair< Vertex_handle, Vertex_handle > > edges; std::vector< Filtration_value > edges_fil; std::map< Vertex_handle, Filtration_value > vertices; @@ -102,7 +145,7 @@ class Rips_complex { // -------------------------------------------------------------------------------------------- // Creates the proximity graph from edges and sets the property with the filtration value. // Number of points is labeled from 0 to idx_u-1 - rips_skeleton_graph_ = Graph_t(edges.begin() , edges.end() , edges_fil.begin() , idx_u); + rips_skeleton_graph_ = Graph_t(edges.begin(), edges.end(), edges_fil.begin(), idx_u); auto vertex_prop = boost::get(vertex_filtration_t(), rips_skeleton_graph_); @@ -112,37 +155,11 @@ class Rips_complex { vi != vi_end; ++vi) { boost::put(vertex_prop, *vi, 0.); } - } - /** \brief Initializes the simplicial complex from the 1-skeleton graph and expands it until a given maximal - * dimension. - * - * \tparam SimplicialComplexForRips must meet `SimplicialComplexForRips` concept. - * - * @param[in] complex SimplicialComplexForRips to be created. - * @param[in] dim_max graph expansion for rips until this given maximal dimension. - * - * @return true if creation succeeds, false otherwise. - * - */ - template - bool create_complex(SimplicialComplexForRips& complex, int dim_max) { - if (complex.num_vertices() > 0) { - std::cerr << "Rips_complex create_complex - complex is not empty\n"; - return false; // ----- >> - } - - // insert the proximity graph in the simplicial complex - complex.insert_graph(rips_skeleton_graph_); - // expand the graph until dimension dim_max - complex.expansion(dim_max); - - // -------------------------------------------------------------------------------------------- - return true; - } private: Graph_t rips_skeleton_graph_; + }; } // namespace rips_complex diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 4154acc9..5897030f 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -2,9 +2,9 @@ * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * - * Author(s): Clément Maria + * Author(s): Clement Maria, Pawel Dlotko * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2014 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -196,4 +196,95 @@ bool read_hasse_simplex(std::istream & in_, std::vector< Simplex_key > & boundar return true; } +/** + * \brief Read a lower triangular distance matrix from a csv file. We assume that the .csv store the whole + * (square) matrix. + * + * \author Pawel Dlotko + * + * Square matrix file format: + * 0;D12;...;D1j + * D21;0;...;D2j + * ... + * Dj1;Dj2;...;0 + * + * lower matrix file format: + * 0 + * D21; + * D31;D32; + * ... + * Dj1;Dj2;...;Dj(j-1); + * + **/ +template< typename Filtration_value > +std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from_csv_file(std::string filename, + const char separator=';') { + bool dbg = true; + if (dbg) { + std::cerr << "Using procedure read_lower_triangular_matrix_from_csv_file \n"; + } + std::vector< std::vector< Filtration_value > > result; + std::ifstream in; + in.open(filename.c_str()); + if (!in.is_open()) { + return result; + } + + std::string line; + + // the first line is emtpy, so we ignore it: + std::getline(in, line); + std::vector< Filtration_value > values_in_this_line; + result.push_back(values_in_this_line); + + int number_of_line = 0; + + // first, read the file line by line to a string: + while (std::getline(in, line)) { + // if line is empty, break + if (line.size() == 0) + break; + + // if the last element of a string is comma: + if (line[ line.size() - 1 ] == separator) { + // then shrink the string by one + line.pop_back(); + } + + // replace all commas with spaces + std::replace(line.begin(), line.end(), separator, ' '); + + // put the new line to a stream + std::istringstream iss(line); + // and now read the doubles. + + int number_of_entry = 0; + std::vector< Filtration_value > values_in_this_line; + while (iss.good()) { + double entry; + iss >> entry; + if (number_of_entry <= number_of_line) { + values_in_this_line.push_back(entry); + } + ++number_of_entry; + } + if (!values_in_this_line.empty())result.push_back(values_in_this_line); + ++number_of_line; + + } + in.close(); + + if (dbg) { + std::cerr << "Here is the matrix we read : \n"; + for (size_t i = 0; i != result.size(); ++i) { + for (size_t j = 0; j != result[i].size(); ++j) { + std::cerr << result[i][j] << " "; + } + std::cerr << std::endl; + } + } + + return result; +} // read_lower_triangular_matrix_from_csv_file + #endif // READER_UTILS_H_ -- cgit v1.2.3 From 1a728400187d89db914e865a979c85c7260b0b02 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 21 Nov 2016 16:24:15 +0000 Subject: Add distance matrix rips construction (doc, code, test) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1766 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6b9bdecbaf0aca12facb023e66bdea71e8e8cd38 --- biblio/how_to_cite_gudhi.bib | 9 +++ src/Doxyfile | 6 +- src/Rips_complex/doc/Intro_rips_complex.h | 52 ++++++++++++-- src/Rips_complex/example/CMakeLists.txt | 23 ++++++ ...mple_one_skeleton_rips_from_distance_matrix.cpp | 68 ++++++++++++++++++ .../example_one_skeleton_rips_from_points.cpp | 2 - ..._rips_complex_from_csv_distance_matrix_file.cpp | 72 +++++++++++++++++++ .../full_skeleton_rips_distance_for_doc.txt | 32 +++++++++ .../example/one_skeleton_rips_distance_for_doc.txt | 17 +++++ src/Rips_complex/include/gudhi/Rips_complex.h | 13 ++++ src/common/doc/main_page.h | 3 +- src/common/include/gudhi/distance_functions.h | 11 +-- .../include/gudhi/graph_simplicial_complex.h | 2 +- src/common/include/gudhi/reader_utils.h | 84 +++++++++++----------- src/common/test/test_distance_matrix_reader.cpp | 16 ++--- 15 files changed, 347 insertions(+), 63 deletions(-) create mode 100644 src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp create mode 100644 src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp create mode 100644 src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt create mode 100644 src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt (limited to 'src/Rips_complex') diff --git a/biblio/how_to_cite_gudhi.bib b/biblio/how_to_cite_gudhi.bib index 03c05728..77b6e284 100644 --- a/biblio/how_to_cite_gudhi.bib +++ b/biblio/how_to_cite_gudhi.bib @@ -94,4 +94,13 @@ , booktitle = "{GUDHI} User and Reference Manual" , url = "http://gudhi.gforge.inria.fr/doc/latest/group__tangential__complex.html" , year = 2016 +} + +@incollection{gudhi:RipsComplex +, author = "Cl\'ement Maria, Pawel Dlotko, Vincent Rouvreau" +, title = "Rips complex" +, publisher = "{GUDHI Editorial Board}" +, booktitle = "{GUDHI} User and Reference Manual" +, url = "http://gudhi.gforge.inria.fr/doc/latest/group__rips__complex.html" +, year = 2016 } \ No newline at end of file diff --git a/src/Doxyfile b/src/Doxyfile index e7c1a0e1..cf79755f 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -500,7 +500,7 @@ HIDE_SCOPE_NAMES = NO # the files that are included by a file in the documentation of that file. # The default value is: YES. -SHOW_INCLUDE_FILES = YES +SHOW_INCLUDE_FILES = NO # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each # grouped member an include statement to the documentation, telling the reader @@ -2151,7 +2151,7 @@ TEMPLATE_RELATIONS = YES # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -INCLUDE_GRAPH = YES +INCLUDE_GRAPH = NO # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are # set to YES then doxygen will generate a graph for each documented file showing @@ -2160,7 +2160,7 @@ INCLUDE_GRAPH = YES # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. -INCLUDED_BY_GRAPH = YES +INCLUDED_BY_GRAPH = NO # If the CALL_GRAPH tag is set to YES then doxygen will generate a call # dependency graph for every global function or class method. diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index a71946b5..d01b14bb 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -2,7 +2,7 @@ * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * - * Author(s): Clément Maria, Vincent Rouvreau + * Author(s): Clément Maria, Pawel Dlotko, Vincent Rouvreau * * Copyright (C) 2016 INRIA * @@ -29,7 +29,7 @@ namespace rips_complex { /** \defgroup rips_complex Rips complex * - * \author Clément Maria, Vincent Rouvreau + * \author Clément Maria, Pawel Dlotko, Vincent Rouvreau * * @{ * @@ -54,7 +54,9 @@ namespace rips_complex { * value set with \f$max(filtration(4,5), filtration(4,6), filtration(5,6))\f$. * And so on for simplex (0,1,2,3). * - * \section ripspointsexample Example from points + * \section ripspointsdistance Point cloud and distance function + * + * \subsection ripspointscloudexample Example from a point cloud and a distance function * * This example builds the one skeleton graph from the given points, threshold value, and distance function. * Then it creates a `Simplex_tree` with it. @@ -73,7 +75,7 @@ namespace rips_complex { * * \include Rips_complex/one_skeleton_rips_points_for_doc.txt * - * \section ripsoffexample Example from OFF file + * \subsection ripsoffexample Example from OFF file * * This example builds the one skeleton graph from the given points in an OFF file, threshold value, and distance * function. @@ -93,6 +95,48 @@ namespace rips_complex { * * \include Rips_complex/full_skeleton_rips_points_for_doc.txt * + * + * + * \section ripsdistancematrix Distance matrix + * + * \subsection ripsdistancematrixexample Example from a distance matrix + * + * This example builds the one skeleton graph from the given distance matrix and threshold value. + * Then it creates a `Simplex_tree` with it. + * + * Then, it is asked to display information about the simplicial complex. + * + * \include Rips_complex/example_one_skeleton_rips_from_distance_matrix.cpp + * + * When launching (rips maximal distance between 2 points is 1.0, is expanded until dimension 1 - one skeleton graph + * with other words): + * + * \code $> ./oneskeletonripsdistance 1.0 + * \endcode + * + * the program output is: + * + * \include Rips_complex/one_skeleton_rips_distance_for_doc.txt + * + * \subsection ripscsvdistanceexample Example from a distance matrix read in a csv file + * + * This example builds the one skeleton graph from the given distance matrix read in a csv file and threshold value. + * Then it creates a `Simplex_tree` with it. + * + * + * Then, it is asked to display information about the rips complex. + * + * \include Rips_complex/example_rips_complex_from_csv_distance_matrix_file.cpp + * + * When launching: + * + * \code $> ./ripscsvdistancereader ../../data/distance_matrix/full_square_distance_matrix.csv 1.0 3 + * \endcode + * + * the program output is: + * + * \include Rips_complex/full_skeleton_rips_distance_for_doc.txt + * * \copyright GNU General Public License v3. * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim */ diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt index 3962b15e..9ba9d941 100644 --- a/src/Rips_complex/example/CMakeLists.txt +++ b/src/Rips_complex/example/CMakeLists.txt @@ -1,27 +1,50 @@ cmake_minimum_required(VERSION 2.6) project(Rips_complex_examples) +# Point cloud add_executable ( ripsoffreader example_rips_complex_from_off_file.cpp ) target_link_libraries(ripsoffreader ${Boost_SYSTEM_LIBRARY}) add_executable ( oneskeletonripspoints example_one_skeleton_rips_from_points.cpp ) target_link_libraries(oneskeletonripspoints ${Boost_SYSTEM_LIBRARY}) +# Distance matrix +add_executable ( oneskeletonripsdistance example_one_skeleton_rips_from_distance_matrix.cpp ) +target_link_libraries(oneskeletonripsdistance ${Boost_SYSTEM_LIBRARY}) + +add_executable ( ripscsvdistancereader example_rips_complex_from_csv_distance_matrix_file.cpp ) +target_link_libraries(ripscsvdistancereader ${Boost_SYSTEM_LIBRARY}) + if (TBB_FOUND) target_link_libraries(ripsoffreader ${TBB_LIBRARIES}) target_link_libraries(oneskeletonripspoints ${TBB_LIBRARIES}) + target_link_libraries(oneskeletonripsdistance ${TBB_LIBRARIES}) + target_link_libraries(ripscsvdistancereader ${TBB_LIBRARIES}) endif() add_test(oneskeletonripspoints ${CMAKE_CURRENT_BINARY_DIR}/oneskeletonripspoints 12.0) + +add_test(oneskeletonripsdistance ${CMAKE_CURRENT_BINARY_DIR}/oneskeletonripspoints 1.0) + # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_test(ripsoffreader_doc_12_1 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader alphacomplexdoc.off 12.0 1 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_1.txt) add_test(ripsoffreader_doc_12_3 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader alphacomplexdoc.off 12.0 3 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_3.txt) + +file(COPY "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) +add_test(ripscsvdistancereader_doc_1_1 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvdistancereader full_square_distance_matrix.csv 1.0 1 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_1.txt) +add_test(ripscsvdistancereader_doc_1_3 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvdistancereader full_square_distance_matrix.csv 1.0 3 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_3.txt) + + if (DIFF_PATH) # Do not forget to copy test results files in current binary dir file(COPY "one_skeleton_rips_points_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) file(COPY "full_skeleton_rips_points_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + file(COPY "one_skeleton_rips_distance_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + file(COPY "full_skeleton_rips_distance_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_test(ripsoffreader_doc_12_1_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_1.txt ${CMAKE_CURRENT_BINARY_DIR}/one_skeleton_rips_points_for_doc.txt) add_test(ripsoffreader_doc_12_3_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_points_for_doc.txt) + add_test(ripscsvreader_doc_1_1_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_1.txt ${CMAKE_CURRENT_BINARY_DIR}/one_skeleton_rips_distance_for_doc.txt) + add_test(ripscsvreader_doc_1_3_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_distance_for_doc.txt) endif() diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp new file mode 100644 index 00000000..54fa3aa1 --- /dev/null +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp @@ -0,0 +1,68 @@ +#include +// to construct a simplex_tree from rips complex +#include +#include + +#include +#include +#include // 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 << " threshold\n"; + std::cerr << " i.e.: " << progName << " 12.0\n"; + exit(-1); // ----- >> +} + +int main(int argc, char **argv) { + if (argc != 2) usage(argc, argv[0]); + + double threshold = atof(argv[1]); + + // Type definitions + using Simplex_tree = Gudhi::Simplex_tree; + using Filtration_value = Simplex_tree::Filtration_value; + using Rips_complex = Gudhi::rips_complex::Rips_complex; + using Distance_matrix = std::vector>; + + // User defined distance matrix is: + // | 0 0.94 0.77 0.99 0.11 | + // | 0.94 0 0.26 0.99 0.39 | + // | 0.77 0.26 0 0.28 0.97 | + // | 0.99 0.99 0.28 0 0.30 | + // | 0.11 0.39 0.97 0.30 0 | + + Distance_matrix distances; + distances.push_back({}); + distances.push_back({0.94}); + distances.push_back({0.77, 0.26}); + distances.push_back({0.99, 0.99, 0.28}); + distances.push_back({0.11, 0.39, 0.97, 0.30}); + + // ---------------------------------------------------------------------------- + // Init of a rips complex from points + // ---------------------------------------------------------------------------- + Rips_complex rips_complex_from_points(distances, threshold); + + Simplex_tree simplex; + if (rips_complex_from_points.create_complex(simplex, 1)) { + // ---------------------------------------------------------------------------- + // Display information about the one skeleton 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/example_one_skeleton_rips_from_points.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp index 2e63d9a6..26517876 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp @@ -1,6 +1,4 @@ #include -// to construct Rips_complex from a OFF file of points -#include // to construct a simplex_tree from rips complex #include #include diff --git a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp new file mode 100644 index 00000000..cfada84a --- /dev/null +++ b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp @@ -0,0 +1,72 @@ +#include +// to construct Rips_complex from a OFF file of points +#include +// to construct a simplex_tree from rips complex +#include +#include + +#include +#include + +void usage(int nbArgs, char * const progName) { + std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; + std::cerr << "Usage: " << progName << " filename.csv threshold dim_max [ouput_file.txt]\n"; + std::cerr << " i.e.: " << progName << " ../../data/distance_matrix/full_square_distance_matrix.csv 1.0 3\n"; + exit(-1); // ----- >> +} + +int main(int argc, char **argv) { + if ((argc != 4) && (argc != 5)) usage(argc, (argv[0] - 1)); + + std::string csv_file_name(argv[1]); + double threshold = atof(argv[2]); + int dim_max = atoi(argv[3]); + + // Type definitions + using Simplex_tree = Gudhi::Simplex_tree<>; + using Filtration_value = Simplex_tree::Filtration_value; + using Rips_complex = Gudhi::rips_complex::Rips_complex; + using Distance_matrix = std::vector>; + + // ---------------------------------------------------------------------------- + // Init of a rips complex from a distance matrix in a csv file + // Default separator is ';' + // ---------------------------------------------------------------------------- + Distance_matrix distances = read_lower_triangular_matrix_from_csv_file(csv_file_name); + Rips_complex rips_complex_from_file(distances, threshold); + + std::streambuf* streambufffer; + std::ofstream ouput_file_stream; + + if (argc == 5) { + ouput_file_stream.open(std::string(argv[4])); + streambufffer = ouput_file_stream.rdbuf(); + } else { + streambufffer = std::cout.rdbuf(); + } + + Simplex_tree simplex; + if (rips_complex_from_file.create_complex(simplex, dim_max)) { + std::ostream output_stream(streambufffer); + + // ---------------------------------------------------------------------------- + // Display information about the rips complex + // ---------------------------------------------------------------------------- + output_stream << "Rips complex is of dimension " << simplex.dimension() << + " - " << simplex.num_simplices() << " simplices - " << + simplex.num_vertices() << " vertices." << std::endl; + + output_stream << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << + std::endl; + for (auto f_simplex : simplex.filtration_simplex_range()) { + output_stream << " ( "; + for (auto vertex : simplex.simplex_vertex_range(f_simplex)) { + output_stream << vertex << " "; + } + output_stream << ") -> " << "[" << simplex.filtration(f_simplex) << "] "; + output_stream << std::endl; + } + } + ouput_file_stream.close(); + return 0; +} diff --git a/src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt b/src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt new file mode 100644 index 00000000..6744532d --- /dev/null +++ b/src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt @@ -0,0 +1,32 @@ +Rips complex is of dimension 3 - 30 simplices - 5 vertices. +Iterator on rips complex simplices in the filtration order, with [filtration value]: + ( 0 ) -> [0] + ( 1 ) -> [0] + ( 2 ) -> [0] + ( 3 ) -> [0] + ( 4 ) -> [0] + ( 4 0 ) -> [0.11] + ( 2 1 ) -> [0.26] + ( 3 2 ) -> [0.28] + ( 4 3 ) -> [0.3] + ( 4 1 ) -> [0.39] + ( 2 0 ) -> [0.77] + ( 1 0 ) -> [0.94] + ( 2 1 0 ) -> [0.94] + ( 4 1 0 ) -> [0.94] + ( 4 2 ) -> [0.97] + ( 4 2 0 ) -> [0.97] + ( 4 2 1 ) -> [0.97] + ( 4 2 1 0 ) -> [0.97] + ( 4 3 2 ) -> [0.97] + ( 3 0 ) -> [0.99] + ( 3 1 ) -> [0.99] + ( 3 1 0 ) -> [0.99] + ( 3 2 0 ) -> [0.99] + ( 3 2 1 ) -> [0.99] + ( 3 2 1 0 ) -> [0.99] + ( 4 3 0 ) -> [0.99] + ( 4 3 1 ) -> [0.99] + ( 4 3 1 0 ) -> [0.99] + ( 4 3 2 0 ) -> [0.99] + ( 4 3 2 1 ) -> [0.99] diff --git a/src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt b/src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt new file mode 100644 index 00000000..9bb1a7ab --- /dev/null +++ b/src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt @@ -0,0 +1,17 @@ +Rips complex is of dimension 1 - 15 simplices - 5 vertices. +Iterator on rips complex simplices in the filtration order, with [filtration value]: + ( 0 ) -> [0] + ( 1 ) -> [0] + ( 2 ) -> [0] + ( 3 ) -> [0] + ( 4 ) -> [0] + ( 4 0 ) -> [0.11] + ( 2 1 ) -> [0.26] + ( 3 2 ) -> [0.28] + ( 4 3 ) -> [0.3] + ( 4 1 ) -> [0.39] + ( 2 0 ) -> [0.77] + ( 1 0 ) -> [0.94] + ( 4 2 ) -> [0.97] + ( 3 0 ) -> [0.99] + ( 3 1 ) -> [0.99] diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index 6f947f41..63207892 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -78,6 +78,19 @@ class Rips_complex { compute_proximity_graph(points, threshold, distance); } + /** \brief Rips_complex constructor from a distance matrix. + * + * @param[in] distance_matrix Range of distances. + * @param[in] threshold rips value. + * + * The type InputDistanceRange must be a range for which std::begin and std::end return input iterators on a point. + */ + template + Rips_complex(const InputDistanceRange& distance_matrix, Filtration_value threshold) { + compute_proximity_graph(boost::irange((size_t)0,distance_matrix.size()), threshold, + [&](size_t i, size_t j){return distance_matrix[j][i];}); + } + /** \brief Initializes the simplicial complex from the 1-skeleton graph and expands it until a given maximal * dimension. * diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index 85310f66..85ae8679 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -60,7 +60,7 @@ @@ -68,6 +68,7 @@ Rips_complex is a simplicial complex constructed from a one skeleton graph.
The filtration value of each edge is computed from a user-given distance function and is inserted until a user-given threshold value.
+ This complex can be built from a point cloud and a distance function, or from a distance matrix.
User manual: \ref rips_complex - Reference manual: Gudhi::rips_complex::Rips_complex diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 006df275..ed2c1f5d 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -4,7 +4,7 @@ * * Author(s): Clément Maria * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2014 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,9 +25,12 @@ #include // for std::sqrt -/* Compute the Euclidean distance between two Points given - * by a range of coordinates. The points are assumed to have - * the same dimension. */ +/** @file + * @brief Global distance functions + */ + +/** @brief Compute the Euclidean distance between two Points given by a range of coordinates. The points are assumed to + * have the same dimension. */ template< typename Filtration_value, typename Point > Filtration_value euclidean_distance(const Point &p1,const Point &p2) { Filtration_value dist = 0.; diff --git a/src/common/include/gudhi/graph_simplicial_complex.h b/src/common/include/gudhi/graph_simplicial_complex.h index 9dbcd891..5fe7c826 100644 --- a/src/common/include/gudhi/graph_simplicial_complex.h +++ b/src/common/include/gudhi/graph_simplicial_complex.h @@ -4,7 +4,7 @@ * * Author(s): Clément Maria * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2014 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 40d566d8..3799e583 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -34,14 +34,20 @@ #include #include +// Keep this file tag for Doxygen to parse the code, otherwise, functions are not documented. +// It is required for global functions and variables. + +/** @file + * @brief This file includes common file reader for GUDHI + */ + /** - * \brief Read a set of points to turn it - * into a vector< vector > by filling points + * @brief Read a set of points to turn it into a vector< vector > by filling points. * - * File format: 1 point per line - * X11 X12 ... X1d - * X21 X22 ... X2d - * etc + * File format: 1 point per line
+ * X11 X12 ... X1d
+ * X21 X22 ... X2d
+ * etc
*/ inline void read_points(std::string file_name, std::vector< std::vector< double > > & points) { std::ifstream in_file(file_name.c_str(), std::ios::in); @@ -66,12 +72,12 @@ inline void read_points(std::string file_name, std::vector< std::vector< double } /** - * \brief Read a graph from a file. + * @brief Read a graph from a file. * - * File format: 1 simplex per line - * Dim1 X11 X12 ... X1d Fil1 - * Dim2 X21 X22 ... X2d Fil2 - * etc + * File format: 1 simplex per line
+ * Dim1 X11 X12 ... X1d Fil1
+ * Dim2 X21 X22 ... X2d Fil2
+ * etc
* * The vertices must be labeled from 0 to n-1. * Every simplex must appear exactly once. @@ -141,12 +147,12 @@ inline Graph_t read_graph(std::string file_name) { } /** - * \brief Read a face from a file. + * @brief Read a face from a file. * - * File format: 1 simplex per line - * Dim1 X11 X12 ... X1d Fil1 - * Dim2 X21 X22 ... X2d Fil2 - * etc + * File format: 1 simplex per line
+ * Dim1 X11 X12 ... X1d Fil1
+ * Dim2 X21 X22 ... X2d Fil2
+ * etc
* * The vertices must be labeled from 0 to n-1. * Every simplex must appear exactly once. @@ -167,18 +173,16 @@ bool read_simplex(std::istream & in_, std::vector< Vertex_handle > & simplex, Fi } /** - * \brief Read a hasse simplex from a file. + * @brief Read a hasse simplex from a file. * - * File format: 1 simplex per line - * Dim1 k11 k12 ... k1Dim1 Fil1 - * Dim2 k21 k22 ... k2Dim2 Fil2 - * etc + * File format: 1 simplex per line
+ * Dim1 k11 k12 ... k1Dim1 Fil1
+ * Dim2 k21 k22 ... k2Dim2 Fil2
+ * etc
* - * The key of a simplex is its position in the filtration order - * and also the number of its row in the file. - * Dimi ki1 ki2 ... kiDimi Fili means that the ith simplex in the - * filtration has dimension Dimi, filtration value fil1 and simplices with - * key ki1 ... kiDimi in its boundary.*/ + * The key of a simplex is its position in the filtration order and also the number of its row in the file. + * Dimi ki1 ki2 ... kiDimi Fili means that the ith simplex in the filtration has dimension Dimi, filtration value + * fil1 and simplices with key ki1 ... kiDimi in its boundary.*/ template< typename Simplex_key, typename Filtration_value > bool read_hasse_simplex(std::istream & in_, std::vector< Simplex_key > & boundary, Filtration_value & fil) { int dim; @@ -197,27 +201,27 @@ bool read_hasse_simplex(std::istream & in_, std::vector< Simplex_key > & boundar } /** - * \brief Read a lower triangular distance matrix from a csv file. We assume that the .csv store the whole + * @brief Read a lower triangular distance matrix from a csv file. We assume that the .csv store the whole * (square) matrix. * - * \author Pawel Dlotko + * @author Pawel Dlotko * - * Square matrix file format: - * 0;D12;...;D1j - * D21;0;...;D2j - * ... - * Dj1;Dj2;...;0 + * Square matrix file format:
+ * 0;D12;...;D1j
+ * D21;0;...;D2j
+ * ...
+ * Dj1;Dj2;...;0
* - * lower matrix file format: - * 0 - * D21; - * D31;D32; - * ... - * Dj1;Dj2;...;Dj(j-1); + * lower matrix file format:
+ * 0
+ * D21;
+ * D31;D32;
+ * ...
+ * Dj1;Dj2;...;Dj(j-1);
* **/ template< typename Filtration_value > -std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from_csv_file(std::string filename, +std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from_csv_file(const std::string& filename, const char separator=';') { bool dbg = false; if (dbg) { diff --git a/src/common/test/test_distance_matrix_reader.cpp b/src/common/test/test_distance_matrix_reader.cpp index 7eb7e846..a4c46bb1 100644 --- a/src/common/test/test_distance_matrix_reader.cpp +++ b/src/common/test/test_distance_matrix_reader.cpp @@ -47,21 +47,21 @@ BOOST_AUTO_TEST_CASE( lower_triangular_distance_matrix ) std::cout << "from_lower_triangular size = " << from_lower_triangular.size() << std::endl; BOOST_CHECK(from_lower_triangular.size() == 5); - for (int i = 0; i < from_lower_triangular.size(); i++) { + for (std::size_t i = 0; i < from_lower_triangular.size(); i++) { std::cout << "from_lower_triangular[" << i << "] size = " << from_lower_triangular[i].size() << std::endl; BOOST_CHECK(from_lower_triangular[i].size() == i); } std::vector expected = {1}; - BOOST_CHECK(from_lower_triangular[0] == expected); + BOOST_CHECK(from_lower_triangular[1] == expected); expected = {2,3}; - BOOST_CHECK(from_lower_triangular[0] == expected); + BOOST_CHECK(from_lower_triangular[2] == expected); expected = {4,5,6}; - BOOST_CHECK(from_lower_triangular[0] == expected); + BOOST_CHECK(from_lower_triangular[3] == expected); expected = {7,8,9,10}; - BOOST_CHECK(from_lower_triangular[0] == expected); + BOOST_CHECK(from_lower_triangular[4] == expected); } @@ -78,8 +78,8 @@ BOOST_AUTO_TEST_CASE( full_square_distance_matrix ) } std::cout << "from_full_square size = " << from_full_square.size() << std::endl; BOOST_CHECK(from_full_square.size() == 5); - for (int i = 0; i < from_lower_triangular.size(); i++) { - std::cout << "from_lower_triangular[" << i << "] size = " << from_lower_triangular[i].size() << std::endl; - BOOST_CHECK(from_lower_triangular[i].size() == i); + for (std::size_t i = 0; i < from_full_square.size(); i++) { + std::cout << "from_full_square[" << i << "] size = " << from_full_square[i].size() << std::endl; + BOOST_CHECK(from_full_square[i].size() == i); } } -- cgit v1.2.3 From 71f9bed6df48dedc0d4e8ef620496af9c494eccc Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 22 Nov 2016 13:29:59 +0000 Subject: Fix examples and tests git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1767 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4a1c78aec05d443e0525bf24a0cc7f7b5c628629 --- .../full_square_distance_matrix.csv | 12 +- src/Persistent_cohomology/example/CMakeLists.txt | 9 +- src/Persistent_cohomology/example/README | 50 ++++--- .../example/rips_distance_matrix_persistence.cpp | 145 +++++++++++++++++++++ .../example/rips_persistence.cpp | 5 +- src/Rips_complex/doc/Intro_rips_complex.h | 8 +- src/Rips_complex/example/CMakeLists.txt | 20 ++- .../full_skeleton_rips_distance_for_doc.txt | 32 ----- .../example/full_skeleton_rips_for_doc.txt | 26 ++++ .../example/full_skeleton_rips_points_for_doc.txt | 26 ---- .../example/one_skeleton_rips_distance_for_doc.txt | 17 --- .../example/one_skeleton_rips_for_doc.txt | 20 +++ .../example/one_skeleton_rips_points_for_doc.txt | 20 --- src/common/include/gudhi/reader_utils.h | 21 ++- src/common/test/test_distance_matrix_reader.cpp | 2 +- 15 files changed, 264 insertions(+), 149 deletions(-) create mode 100644 src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp delete mode 100644 src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt create mode 100644 src/Rips_complex/example/full_skeleton_rips_for_doc.txt delete mode 100644 src/Rips_complex/example/full_skeleton_rips_points_for_doc.txt delete mode 100644 src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt create mode 100644 src/Rips_complex/example/one_skeleton_rips_for_doc.txt delete mode 100644 src/Rips_complex/example/one_skeleton_rips_points_for_doc.txt (limited to 'src/Rips_complex') diff --git a/data/distance_matrix/full_square_distance_matrix.csv b/data/distance_matrix/full_square_distance_matrix.csv index 7225a5fd..51512b03 100644 --- a/data/distance_matrix/full_square_distance_matrix.csv +++ b/data/distance_matrix/full_square_distance_matrix.csv @@ -1,5 +1,7 @@ -0;0.94;0.77;0.99;0.11; -0.94;0;0.26;0.99;0.39; -0.77;0.26;0;0.28;0.97; -0.99;0.99;0.28;0;0.30; -0.11;0.39;0.97;0.30;0; +0;6.0827625303;5.8309518948;9.4339811321;13.0384048104;18.0277563773;17.88854382; +6.0827625303;0;6.7082039325;6.3245553203;15.6524758425;19.6468827044;17.1172427686; +5.8309518948;6.7082039325;0;5;8.94427191;13.152946438;12.0830459736; +9.4339811321;6.3245553203;5;0;12.0415945788;14.7648230602;11; +13.0384048104;15.6524758425;8.94427191;12.0415945788;0;5.3851648071;9.4868329805; +18.0277563773;19.6468827044;13.152946438;14.7648230602;5.3851648071;0;7.2801098893; +17.88854382;17.1172427686;12.0830459736;11;9.4868329805;7.2801098893;0; \ No newline at end of file diff --git a/src/Persistent_cohomology/example/CMakeLists.txt b/src/Persistent_cohomology/example/CMakeLists.txt index e50e8ca9..b2ac9736 100644 --- a/src/Persistent_cohomology/example/CMakeLists.txt +++ b/src/Persistent_cohomology/example/CMakeLists.txt @@ -11,6 +11,9 @@ target_link_libraries(plain_homology ${Boost_SYSTEM_LIBRARY}) add_executable(persistence_from_simple_simplex_tree persistence_from_simple_simplex_tree.cpp) target_link_libraries(persistence_from_simple_simplex_tree ${Boost_SYSTEM_LIBRARY}) +add_executable(rips_distance_matrix_persistence rips_distance_matrix_persistence.cpp) +target_link_libraries(rips_distance_matrix_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) + add_executable(rips_persistence rips_persistence.cpp) target_link_libraries(rips_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) @@ -23,6 +26,7 @@ target_link_libraries(persistence_from_file ${Boost_SYSTEM_LIBRARY} ${Boost_PROG if (TBB_FOUND) target_link_libraries(plain_homology ${TBB_LIBRARIES}) target_link_libraries(persistence_from_simple_simplex_tree ${TBB_LIBRARIES}) + target_link_libraries(rips_distance_matrix_persistence ${TBB_LIBRARIES}) target_link_libraries(rips_persistence ${TBB_LIBRARIES}) target_link_libraries(rips_persistence_via_boundary_matrix ${TBB_LIBRARIES}) target_link_libraries(persistence_from_file ${TBB_LIBRARIES}) @@ -30,7 +34,8 @@ endif() add_test(plain_homology ${CMAKE_CURRENT_BINARY_DIR}/plain_homology) add_test(persistence_from_simple_simplex_tree ${CMAKE_CURRENT_BINARY_DIR}/persistence_from_simple_simplex_tree 1 0) -add_test(rips_persistence_3 ${CMAKE_CURRENT_BINARY_DIR}/rips_persistence ${CMAKE_SOURCE_DIR}/data/points/Kl.txt -r 0.16 -d 3 -p 3 -m 100) +add_test(rips_distance_matrix ${CMAKE_CURRENT_BINARY_DIR}/rips_distance_matrix_persistence ${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv -r 1.0 -d 3 -p 3 -m 0) +add_test(rips_persistence_3 ${CMAKE_CURRENT_BINARY_DIR}/rips_persistence ${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3) add_test(rips_persistence_via_boundary_matrix_3 ${CMAKE_CURRENT_BINARY_DIR}/rips_persistence_via_boundary_matrix ${CMAKE_SOURCE_DIR}/data/points/Kl.txt -r 0.16 -d 3 -p 3 -m 100) add_test(persistence_from_file_3_2_0 ${CMAKE_CURRENT_BINARY_DIR}/persistence_from_file ${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/bunny_5000_complex.fsc -p 2 -m 0) add_test(persistence_from_file_3_3_100 ${CMAKE_CURRENT_BINARY_DIR}/persistence_from_file ${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/bunny_5000_complex.fsc -p 3 -m 100) @@ -42,7 +47,7 @@ if(GMP_FOUND) if (TBB_FOUND) target_link_libraries(rips_multifield_persistence ${TBB_LIBRARIES}) endif(TBB_FOUND) - add_test(rips_multifield_persistence_2_71 ${CMAKE_CURRENT_BINARY_DIR}/rips_multifield_persistence ${CMAKE_SOURCE_DIR}/data/points/Kl.txt -r 0.2 -d 3 -p 2 -q 71 -m 100) + add_test(rips_multifield_persistence_2_71 ${CMAKE_CURRENT_BINARY_DIR}/rips_multifield_persistence ${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 2 -q 71) endif(GMPXX_FOUND) endif(GMP_FOUND) diff --git a/src/Persistent_cohomology/example/README b/src/Persistent_cohomology/example/README index 7803e5ab..1063ea41 100644 --- a/src/Persistent_cohomology/example/README +++ b/src/Persistent_cohomology/example/README @@ -10,13 +10,13 @@ Example of use of RIPS: Computation of the persistent homology with Z/2Z coefficients of the Rips complex on points sampling a Klein bottle: -./rips_persistence ../../data/points/Kl.txt -r 0.25 -d 3 -p 2 -m 100 +./rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 2 output: -210 0 0 inf -210 1 0.0702103 inf -2 1 0.0702103 inf -2 2 0.159992 inf +2 0 0 inf +2 1 0.0983494 inf +2 1 0.104347 inf +2 2 0.138335 inf Every line is of this format: p1*...*pr dim b d @@ -29,31 +29,45 @@ where with Z/3Z coefficients: -./rips_persistence ../../data/points/Kl.txt -r 0.25 -d 3 -p 3 -m 100 +./rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3 output: -3 0 0 inf -3 1 0.0702103 inf +3 0 0 inf +3 1 0.0983494 inf +3 1 0.104347 inf +3 2 0.138335 inf and the computation with Z/2Z and Z/3Z coefficients simultaneously: -./rips_multifield_persistence ../../data/points/Kl.txt -r 0.25 -d 3 -p 2 -q 3 -m 100 +./rips_multifield_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.12 -d 3 -p 2 -q 3 output: -6 0 0 inf -6 1 0.0702103 inf -2 1 0.0702103 inf -2 2 0.159992 inf +6 0 0 inf +6 1 0.0983494 inf +6 1 0.104347 inf +6 2 0.138335 inf +6 0 0 0.122545 +6 0 0 0.121171 +6 0 0 0.120964 +6 0 0 0.12057 +6 0 0 0.12047 +6 0 0 0.120414 and finally the computation with all Z/pZ for 2 <= p <= 71 (20 first prime numbers): - ./rips_multifield_persistence ../../data/points/Kl.txt -r 0.25 -d 3 -p 2 -q 71 -m 100 + ./rips_multifield_persistence ../../data/points/Kl.txt -r 0.25 -m 0.5 -d 3 -p 2 -q 71 output: -557940830126698960967415390 0 0 inf -557940830126698960967415390 1 0.0702103 inf -2 1 0.0702103 inf -2 2 0.159992 inf +557940830126698960967415390 0 0 inf +557940830126698960967415390 1 0.0983494 inf +557940830126698960967415390 1 0.104347 inf +557940830126698960967415390 2 0.138335 inf +557940830126698960967415390 0 0 0.122545 +557940830126698960967415390 0 0 0.121171 +557940830126698960967415390 0 0 0.120964 +557940830126698960967415390 0 0 0.12057 +557940830126698960967415390 0 0 0.12047 +557940830126698960967415390 0 0 0.120414 *********************************************************************************************************************** Example of use of ALPHA: diff --git a/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp b/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp new file mode 100644 index 00000000..7a9e9c8b --- /dev/null +++ b/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp @@ -0,0 +1,145 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Pawel Dlotko, Vincent Rouvreau + * + * Copyright (C) 2016 INRIA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include + +#include + +#include +#include +#include // infinity + +// Types definition +using Simplex_tree = Gudhi::Simplex_tree; +using Filtration_value = Simplex_tree::Filtration_value; +using Rips_complex = Gudhi::rips_complex::Rips_complex; +using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; +using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; +using Distance_matrix = std::vector>; + +void program_options(int argc, char * argv[] + , std::string & csv_matrix_file + , std::string & filediag + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence); + +int main(int argc, char * argv[]) { + std::string csv_matrix_file; + std::string filediag; + Filtration_value threshold; + int dim_max; + int p; + Filtration_value min_persistence; + + program_options(argc, argv, csv_matrix_file, filediag, threshold, dim_max, p, min_persistence); + + Distance_matrix distances = read_lower_triangular_matrix_from_csv_file(csv_matrix_file); + Rips_complex rips_complex_from_file(distances, threshold); + + // Construct the Rips complex in a Simplex Tree + Simplex_tree simplex_tree; + + if (rips_complex_from_file.create_complex(simplex_tree, dim_max)) { + std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n"; + std::cout << " and has dimension " << simplex_tree.dimension() << " \n"; + + // Sort the simplices in the order of the filtration + simplex_tree.initialize_filtration(); + + // Compute the persistence diagram of the complex + Persistent_cohomology pcoh(simplex_tree); + // initializes the coefficient field for homology + pcoh.init_coefficients(p); + + pcoh.compute_persistent_cohomology(min_persistence); + + // Output the diagram in filediag + if (filediag.empty()) { + pcoh.output_diagram(); + } else { + std::ofstream out(filediag); + pcoh.output_diagram(out); + out.close(); + } + } + return 0; +} + +void program_options(int argc, char * argv[] + , std::string & csv_matrix_file + , std::string & filediag + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options() + ("input-file", po::value(&csv_matrix_file), + "Name of file containing a distance matrix. Can be square or lower triangular matrix. Separator is ';'."); + + po::options_description visible("Allowed options", 100); + visible.add_options() + ("help,h", "produce help message") + ("output-file,o", po::value(&filediag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout") + ("max-edge-length,r", + po::value(&threshold)->default_value(std::numeric_limits::infinity()), + "Maximal length of an edge for the Rips complex construction.") + ("cpx-dimension,d", po::value(&dim_max)->default_value(1), + "Maximal dimension of the Rips complex we want to compute.") + ("field-charac,p", po::value(&p)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.") + ("min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals"); + + po::positional_options_description pos; + pos.add("input-file", 1); + + po::options_description all; + all.add(visible).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv). + options(all).positional(pos).run(), vm); + po::notify(vm); + + if (vm.count("help") || !vm.count("input-file")) { + std::cout << std::endl; + std::cout << "Compute the persistent homology with coefficient field Z/pZ \n"; + std::cout << "of a Rips complex defined on a set of distance matrix.\n \n"; + std::cout << "The output diagram contains one bar per line, written with the convention: \n"; + std::cout << " p dim b d \n"; + std::cout << "where dim is the dimension of the homological feature,\n"; + std::cout << "b and d are respectively the birth and death of the feature and \n"; + std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl; + + std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} diff --git a/src/Persistent_cohomology/example/rips_persistence.cpp b/src/Persistent_cohomology/example/rips_persistence.cpp index 709c2eab..3fa8aa30 100644 --- a/src/Persistent_cohomology/example/rips_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_persistence.cpp @@ -104,14 +104,15 @@ void program_options(int argc, char * argv[] po::options_description hidden("Hidden options"); hidden.add_options() ("input-file", po::value(&off_file_points), - "Name of file containing a point set. Format is one point per line: X1 ... Xd "); + "Name of an OFF file containing a point set.\n"); po::options_description visible("Allowed options", 100); visible.add_options() ("help,h", "produce help message") ("output-file,o", po::value(&filediag)->default_value(std::string()), "Name of file in which the persistence diagram is written. Default print in std::cout") - ("max-edge-length,r", po::value(&threshold)->default_value(std::numeric_limits::infinity()), + ("max-edge-length,r", + po::value(&threshold)->default_value(std::numeric_limits::infinity()), "Maximal length of an edge for the Rips complex construction.") ("cpx-dimension,d", po::value(&dim_max)->default_value(1), "Maximal dimension of the Rips complex we want to compute.") diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index d01b14bb..0ae89ffc 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -73,7 +73,7 @@ namespace rips_complex { * * the program output is: * - * \include Rips_complex/one_skeleton_rips_points_for_doc.txt + * \include Rips_complex/one_skeleton_rips_for_doc.txt * * \subsection ripsoffexample Example from OFF file * @@ -93,7 +93,7 @@ namespace rips_complex { * * the program output is: * - * \include Rips_complex/full_skeleton_rips_points_for_doc.txt + * \include Rips_complex/full_skeleton_rips_for_doc.txt * * * @@ -116,7 +116,7 @@ namespace rips_complex { * * the program output is: * - * \include Rips_complex/one_skeleton_rips_distance_for_doc.txt + * \include Rips_complex/one_skeleton_rips_for_doc.txt * * \subsection ripscsvdistanceexample Example from a distance matrix read in a csv file * @@ -135,7 +135,7 @@ namespace rips_complex { * * the program output is: * - * \include Rips_complex/full_skeleton_rips_distance_for_doc.txt + * \include Rips_complex/full_skeleton_rips_for_doc.txt * * \copyright GNU General Public License v3. * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt index 9ba9d941..c15a13d0 100644 --- a/src/Rips_complex/example/CMakeLists.txt +++ b/src/Rips_complex/example/CMakeLists.txt @@ -32,19 +32,17 @@ add_test(ripsoffreader_doc_12_1 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader alphac add_test(ripsoffreader_doc_12_3 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader alphacomplexdoc.off 12.0 3 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_3.txt) file(COPY "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -add_test(ripscsvdistancereader_doc_1_1 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvdistancereader full_square_distance_matrix.csv 1.0 1 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_1.txt) -add_test(ripscsvdistancereader_doc_1_3 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvdistancereader full_square_distance_matrix.csv 1.0 3 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_3.txt) +add_test(ripscsvdistancereader_doc_12_1 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvdistancereader full_square_distance_matrix.csv 12.0 1 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_12_1.txt) +add_test(ripscsvdistancereader_doc_12_3 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvdistancereader full_square_distance_matrix.csv 12.0 3 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_12_3.txt) if (DIFF_PATH) # Do not forget to copy test results files in current binary dir - file(COPY "one_skeleton_rips_points_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - file(COPY "full_skeleton_rips_points_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - file(COPY "one_skeleton_rips_distance_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - file(COPY "full_skeleton_rips_distance_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - - add_test(ripsoffreader_doc_12_1_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_1.txt ${CMAKE_CURRENT_BINARY_DIR}/one_skeleton_rips_points_for_doc.txt) - add_test(ripsoffreader_doc_12_3_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_points_for_doc.txt) - add_test(ripscsvreader_doc_1_1_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_1.txt ${CMAKE_CURRENT_BINARY_DIR}/one_skeleton_rips_distance_for_doc.txt) - add_test(ripscsvreader_doc_1_3_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_distance_for_doc.txt) + file(COPY "one_skeleton_rips_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + file(COPY "full_skeleton_rips_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + + add_test(ripsoffreader_doc_12_1_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_1.txt ${CMAKE_CURRENT_BINARY_DIR}/one_skeleton_rips_for_doc.txt) + add_test(ripsoffreader_doc_12_3_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_for_doc.txt) + add_test(ripscsvreader_doc_12_1_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_12_1.txt ${CMAKE_CURRENT_BINARY_DIR}/one_skeleton_rips_for_doc.txt) + add_test(ripscsvreader_doc_12_3_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_12_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_for_doc.txt) endif() diff --git a/src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt b/src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt deleted file mode 100644 index 6744532d..00000000 --- a/src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt +++ /dev/null @@ -1,32 +0,0 @@ -Rips complex is of dimension 3 - 30 simplices - 5 vertices. -Iterator on rips complex simplices in the filtration order, with [filtration value]: - ( 0 ) -> [0] - ( 1 ) -> [0] - ( 2 ) -> [0] - ( 3 ) -> [0] - ( 4 ) -> [0] - ( 4 0 ) -> [0.11] - ( 2 1 ) -> [0.26] - ( 3 2 ) -> [0.28] - ( 4 3 ) -> [0.3] - ( 4 1 ) -> [0.39] - ( 2 0 ) -> [0.77] - ( 1 0 ) -> [0.94] - ( 2 1 0 ) -> [0.94] - ( 4 1 0 ) -> [0.94] - ( 4 2 ) -> [0.97] - ( 4 2 0 ) -> [0.97] - ( 4 2 1 ) -> [0.97] - ( 4 2 1 0 ) -> [0.97] - ( 4 3 2 ) -> [0.97] - ( 3 0 ) -> [0.99] - ( 3 1 ) -> [0.99] - ( 3 1 0 ) -> [0.99] - ( 3 2 0 ) -> [0.99] - ( 3 2 1 ) -> [0.99] - ( 3 2 1 0 ) -> [0.99] - ( 4 3 0 ) -> [0.99] - ( 4 3 1 ) -> [0.99] - ( 4 3 1 0 ) -> [0.99] - ( 4 3 2 0 ) -> [0.99] - ( 4 3 2 1 ) -> [0.99] diff --git a/src/Rips_complex/example/full_skeleton_rips_for_doc.txt b/src/Rips_complex/example/full_skeleton_rips_for_doc.txt new file mode 100644 index 00000000..319931e0 --- /dev/null +++ b/src/Rips_complex/example/full_skeleton_rips_for_doc.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] diff --git a/src/Rips_complex/example/full_skeleton_rips_points_for_doc.txt b/src/Rips_complex/example/full_skeleton_rips_points_for_doc.txt deleted file mode 100644 index 319931e0..00000000 --- a/src/Rips_complex/example/full_skeleton_rips_points_for_doc.txt +++ /dev/null @@ -1,26 +0,0 @@ -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] diff --git a/src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt b/src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt deleted file mode 100644 index 9bb1a7ab..00000000 --- a/src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt +++ /dev/null @@ -1,17 +0,0 @@ -Rips complex is of dimension 1 - 15 simplices - 5 vertices. -Iterator on rips complex simplices in the filtration order, with [filtration value]: - ( 0 ) -> [0] - ( 1 ) -> [0] - ( 2 ) -> [0] - ( 3 ) -> [0] - ( 4 ) -> [0] - ( 4 0 ) -> [0.11] - ( 2 1 ) -> [0.26] - ( 3 2 ) -> [0.28] - ( 4 3 ) -> [0.3] - ( 4 1 ) -> [0.39] - ( 2 0 ) -> [0.77] - ( 1 0 ) -> [0.94] - ( 4 2 ) -> [0.97] - ( 3 0 ) -> [0.99] - ( 3 1 ) -> [0.99] diff --git a/src/Rips_complex/example/one_skeleton_rips_for_doc.txt b/src/Rips_complex/example/one_skeleton_rips_for_doc.txt new file mode 100644 index 00000000..b0e25cc5 --- /dev/null +++ b/src/Rips_complex/example/one_skeleton_rips_for_doc.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/one_skeleton_rips_points_for_doc.txt b/src/Rips_complex/example/one_skeleton_rips_points_for_doc.txt deleted file mode 100644 index b0e25cc5..00000000 --- a/src/Rips_complex/example/one_skeleton_rips_points_for_doc.txt +++ /dev/null @@ -1,20 +0,0 @@ -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/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 3799e583..ddec5ba7 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -223,10 +223,9 @@ bool read_hasse_simplex(std::istream & in_, std::vector< Simplex_key > & boundar template< typename Filtration_value > std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from_csv_file(const std::string& filename, const char separator=';') { - bool dbg = false; - if (dbg) { - std::cerr << "Using procedure read_lower_triangular_matrix_from_csv_file \n"; - } +#ifdef DEBUG_TRACES + std::cout << "Using procedure read_lower_triangular_matrix_from_csv_file \n"; +#endif // DEBUG_TRACES std::vector< std::vector< Filtration_value > > result; std::ifstream in; in.open(filename.c_str()); @@ -278,15 +277,15 @@ std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from } in.close(); - if (dbg) { - std::cerr << "Here is the matrix we read : \n"; - for (size_t i = 0; i != result.size(); ++i) { - for (size_t j = 0; j != result[i].size(); ++j) { - std::cerr << result[i][j] << " "; - } - std::cerr << std::endl; +#ifdef DEBUG_TRACES + std::cerr << "Here is the matrix we read : \n"; + for (size_t i = 0; i != result.size(); ++i) { + for (size_t j = 0; j != result[i].size(); ++j) { + std::cerr << result[i][j] << " "; } + std::cerr << std::endl; } +#endif // DEBUG_TRACES return result; } // read_lower_triangular_matrix_from_csv_file diff --git a/src/common/test/test_distance_matrix_reader.cpp b/src/common/test/test_distance_matrix_reader.cpp index a4c46bb1..95a73bd9 100644 --- a/src/common/test/test_distance_matrix_reader.cpp +++ b/src/common/test/test_distance_matrix_reader.cpp @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE( full_square_distance_matrix ) std::cout << std::endl; } std::cout << "from_full_square size = " << from_full_square.size() << std::endl; - BOOST_CHECK(from_full_square.size() == 5); + BOOST_CHECK(from_full_square.size() == 7); for (std::size_t i = 0; i < from_full_square.size(); i++) { std::cout << "from_full_square[" << i << "] size = " << from_full_square[i].size() << std::endl; BOOST_CHECK(from_full_square[i].size() == i); -- cgit v1.2.3 From 759b7d6fd92fa8666c41fb3acdb3158d744134c3 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 22 Nov 2016 14:22:16 +0000 Subject: Add distance matrix Unitary test git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1768 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 566a69cf00976360c07084ce5df48fcc02f6653f --- src/Rips_complex/test/CMakeLists.txt | 1 + src/Rips_complex/test/test_rips_complex.cpp | 97 +++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/test/CMakeLists.txt b/src/Rips_complex/test/CMakeLists.txt index 3972e9fc..87bad2ed 100644 --- a/src/Rips_complex/test/CMakeLists.txt +++ b/src/Rips_complex/test/CMakeLists.txt @@ -18,6 +18,7 @@ endif() # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) +file(COPY "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_test(rips_complex_UT ${CMAKE_CURRENT_BINARY_DIR}/rips_complex_UT # XML format for Jenkins xUnit plugin diff --git a/src/Rips_complex/test/test_rips_complex.cpp b/src/Rips_complex/test/test_rips_complex.cpp index f8be9748..faedbf4a 100644 --- a/src/Rips_complex/test/test_rips_complex.cpp +++ b/src/Rips_complex/test/test_rips_complex.cpp @@ -36,12 +36,14 @@ // to construct a simplex_tree from rips complex #include #include +#include // Type definitions using Point = std::vector; using Simplex_tree = Gudhi::Simplex_tree<>; using Filtration_value = Simplex_tree::Filtration_value; using Rips_complex = Gudhi::rips_complex::Rips_complex; +using Distance_matrix = std::vector>; bool are_almost_the_same(float a, float b) { return std::fabs(a - b) < std::numeric_limits::epsilon(); @@ -231,3 +233,98 @@ BOOST_AUTO_TEST_CASE(Rips_complex_from_points) { } } } + +BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { + // ---------------------------------------------------------------------------- + // + // Init of a rips complex from a OFF file + // + // ---------------------------------------------------------------------------- + std::string csv_file_name("full_square_distance_matrix.csv"); + double rips_threshold = 12.0; + std::cout << "========== CSV FILE NAME = " << csv_file_name << " - rips threshold=" << + rips_threshold << "==========" << std::endl; + + Distance_matrix distances = read_lower_triangular_matrix_from_csv_file(csv_file_name); + Rips_complex rips_complex_from_file(distances, rips_threshold); + + const int DIMENSION_1 = 1; + Simplex_tree st; + BOOST_CHECK(rips_complex_from_file.create_complex(st, DIMENSION_1)); + std::cout << "st.dimension()=" << st.dimension() << std::endl; + BOOST_CHECK(st.dimension() == DIMENSION_1); + + const int NUMBER_OF_VERTICES = 7; + std::cout << "st.num_vertices()=" << st.num_vertices() << std::endl; + BOOST_CHECK(st.num_vertices() == NUMBER_OF_VERTICES); + + std::cout << "st.num_simplices()=" << st.num_simplices() << std::endl; + BOOST_CHECK(st.num_simplices() == 18); + + // Check filtration values of vertices is 0.0 + for (auto f_simplex : st.skeleton_simplex_range(0)) { + BOOST_CHECK(st.filtration(f_simplex) == 0.0); + } + + // Check filtration values of edges + for (auto f_simplex : st.skeleton_simplex_range(DIMENSION_1)) { + if (DIMENSION_1 == st.dimension(f_simplex)) { + std::vector vvh; + std::cout << "vertex = ("; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::cout << vertex << ","; + vvh.push_back(vertex); + } + std::cout << ") - filtration =" << st.filtration(f_simplex) << std::endl; + BOOST_CHECK(vvh.size() == 2); + BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), distances[vvh.at(0)][vvh.at(1)])); + } + } + + const int DIMENSION_2 = 2; + Simplex_tree st2; + BOOST_CHECK(rips_complex_from_file.create_complex(st2, DIMENSION_2)); + std::cout << "st2.dimension()=" << st2.dimension() << std::endl; + BOOST_CHECK(st2.dimension() == DIMENSION_2); + + std::cout << "st2.num_vertices()=" << st2.num_vertices() << std::endl; + BOOST_CHECK(st2.num_vertices() == NUMBER_OF_VERTICES); + + std::cout << "st2.num_simplices()=" << st2.num_simplices() << std::endl; + BOOST_CHECK(st2.num_simplices() == 23); + + Simplex_tree::Filtration_value f01 = st2.filtration(st2.find({0, 1})); + Simplex_tree::Filtration_value f02 = st2.filtration(st2.find({0, 2})); + Simplex_tree::Filtration_value f12 = st2.filtration(st2.find({1, 2})); + Simplex_tree::Filtration_value f012 = st2.filtration(st2.find({0, 1, 2})); + std::cout << "f012= " << f012 << " | f01= " << f01 << " - f02= " << f02 << " - f12= " << f12 << std::endl; + BOOST_CHECK(are_almost_the_same(f012, std::max(f01, std::max(f02,f12)))); + + Simplex_tree::Filtration_value f45 = st2.filtration(st2.find({4, 5})); + Simplex_tree::Filtration_value f56 = st2.filtration(st2.find({5, 6})); + Simplex_tree::Filtration_value f46 = st2.filtration(st2.find({4, 6})); + Simplex_tree::Filtration_value f456 = st2.filtration(st2.find({4, 5, 6})); + std::cout << "f456= " << f456 << " | f45= " << f45 << " - f56= " << f56 << " - f46= " << f46 << std::endl; + BOOST_CHECK(are_almost_the_same(f456, std::max(f45, std::max(f56,f46)))); + + const int DIMENSION_3 = 3; + Simplex_tree st3; + BOOST_CHECK(rips_complex_from_file.create_complex(st3, DIMENSION_3)); + std::cout << "st3.dimension()=" << st3.dimension() << std::endl; + BOOST_CHECK(st3.dimension() == DIMENSION_3); + + std::cout << "st3.num_vertices()=" << st3.num_vertices() << std::endl; + BOOST_CHECK(st3.num_vertices() == NUMBER_OF_VERTICES); + + std::cout << "st3.num_simplices()=" << st3.num_simplices() << std::endl; + BOOST_CHECK(st3.num_simplices() == 24); + + Simplex_tree::Filtration_value f123 = st3.filtration(st3.find({1, 2, 3})); + Simplex_tree::Filtration_value f013 = st3.filtration(st3.find({0, 1, 3})); + Simplex_tree::Filtration_value f023 = st3.filtration(st3.find({0, 2, 3})); + Simplex_tree::Filtration_value f0123 = st3.filtration(st3.find({0, 1, 2, 3})); + std::cout << "f0123= " << f0123 << " | f012= " << f012 << " - f123= " << f123 << " - f013= " << f013 << + " - f023= " << f023 << std::endl; + BOOST_CHECK(are_almost_the_same(f0123, std::max(f012, std::max(f123, std::max(f013, f023))))); + +} \ No newline at end of file -- cgit v1.2.3 From 69907a03283337e76d7763f82250b4e2a6b8f631 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 23 Nov 2016 07:35:46 +0000 Subject: Fix cpplint git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1771 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 994e3bf769d236d230ac2f7e751aa310dabb74bb --- src/GudhUI/utils/Persistence_compute.h | 3 +-- .../example/rips_distance_matrix_persistence.cpp | 8 ++++---- .../example/rips_multifield_persistence.cpp | 8 ++++---- .../example/rips_persistence.cpp | 8 ++++---- ...ample_one_skeleton_rips_from_distance_matrix.cpp | 3 ++- .../example_one_skeleton_rips_from_points.cpp | 3 ++- ...e_rips_complex_from_csv_distance_matrix_file.cpp | 1 + .../example/example_rips_complex_from_off_file.cpp | 1 + src/Rips_complex/include/gudhi/Rips_complex.h | 21 ++++++++------------- .../example/simplex_tree_from_cliques_of_graph.cpp | 1 + src/common/include/gudhi/distance_functions.h | 4 ++-- src/common/include/gudhi/reader_utils.h | 3 +-- 12 files changed, 31 insertions(+), 33 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/GudhUI/utils/Persistence_compute.h b/src/GudhUI/utils/Persistence_compute.h index f7048c28..d2973d84 100644 --- a/src/GudhUI/utils/Persistence_compute.h +++ b/src/GudhUI/utils/Persistence_compute.h @@ -75,7 +75,7 @@ template class Persistence_compute { using Rips_complex = Gudhi::rips_complex::Rips_complex; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; - + Rips_complex rips_complex(points, params.threshold, euclidean_distance); Simplex_tree st; @@ -87,7 +87,6 @@ template class Persistence_compute { pcoh.compute_persistent_cohomology(params.min_pers); stream << "persistence: \n"; stream << "p dimension birth death: \n"; - pcoh.output_diagram(stream); } } diff --git a/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp b/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp index 7a9e9c8b..ee236d61 100644 --- a/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp @@ -66,17 +66,17 @@ int main(int argc, char * argv[]) { if (rips_complex_from_file.create_complex(simplex_tree, dim_max)) { std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n"; std::cout << " and has dimension " << simplex_tree.dimension() << " \n"; - + // Sort the simplices in the order of the filtration simplex_tree.initialize_filtration(); - + // Compute the persistence diagram of the complex Persistent_cohomology pcoh(simplex_tree); // initializes the coefficient field for homology pcoh.init_coefficients(p); - + pcoh.compute_persistent_cohomology(min_persistence); - + // Output the diagram in filediag if (filediag.empty()) { pcoh.output_diagram(); diff --git a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp index 6db85d16..aaa71db9 100644 --- a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp @@ -71,17 +71,17 @@ int main(int argc, char * argv[]) { if (rips_complex_from_file.create_complex(simplex_tree, dim_max)) { std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n"; std::cout << " and has dimension " << simplex_tree.dimension() << " \n"; - + // Sort the simplices in the order of the filtration simplex_tree.initialize_filtration(); - + // Compute the persistence diagram of the complex Persistent_cohomology pcoh(simplex_tree); // initializes the coefficient field for homology pcoh.init_coefficients(min_p, max_p); - + pcoh.compute_persistent_cohomology(min_persistence); - + // Output the diagram in filediag if (filediag.empty()) { pcoh.output_diagram(); diff --git a/src/Persistent_cohomology/example/rips_persistence.cpp b/src/Persistent_cohomology/example/rips_persistence.cpp index 3fa8aa30..0b1873d4 100644 --- a/src/Persistent_cohomology/example/rips_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_persistence.cpp @@ -70,17 +70,17 @@ int main(int argc, char * argv[]) { if (rips_complex_from_file.create_complex(simplex_tree, dim_max)) { std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n"; std::cout << " and has dimension " << simplex_tree.dimension() << " \n"; - + // Sort the simplices in the order of the filtration simplex_tree.initialize_filtration(); - + // Compute the persistence diagram of the complex Persistent_cohomology pcoh(simplex_tree); // initializes the coefficient field for homology pcoh.init_coefficients(p); - + pcoh.compute_persistent_cohomology(min_persistence); - + // Output the diagram in filediag if (filediag.empty()) { pcoh.output_diagram(); diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp index 54fa3aa1..b1ba494e 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp @@ -5,6 +5,7 @@ #include #include +#include #include // for std::numeric_limits void usage(int nbArgs, char * const progName) { @@ -38,7 +39,7 @@ int main(int argc, char **argv) { distances.push_back({0.77, 0.26}); distances.push_back({0.99, 0.99, 0.28}); distances.push_back({0.11, 0.39, 0.97, 0.30}); - + // ---------------------------------------------------------------------------- // Init of a rips complex from points // ---------------------------------------------------------------------------- diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp index 26517876..68fc3629 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp @@ -5,6 +5,7 @@ #include #include +#include #include // for std::numeric_limits void usage(int nbArgs, char * const progName) { @@ -33,7 +34,7 @@ int main(int argc, char **argv) { 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 points // ---------------------------------------------------------------------------- diff --git a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp index cfada84a..730bfc7c 100644 --- a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp @@ -7,6 +7,7 @@ #include #include +#include void usage(int nbArgs, char * const progName) { std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; diff --git a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp index 60050cea..469de403 100644 --- a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp @@ -7,6 +7,7 @@ #include #include +#include void usage(int nbArgs, char * const progName) { std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index 63207892..f98a6993 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -64,7 +64,6 @@ class Rips_complex { typedef int Vertex_handle; public: - /** \brief Rips_complex constructor from a list of points. * * @param[in] points Range of points. @@ -87,7 +86,7 @@ class Rips_complex { */ template Rips_complex(const InputDistanceRange& distance_matrix, Filtration_value threshold) { - compute_proximity_graph(boost::irange((size_t)0,distance_matrix.size()), threshold, + compute_proximity_graph(boost::irange((size_t)0, distance_matrix.size()), threshold, [&](size_t i, size_t j){return distance_matrix[j][i];}); } @@ -106,7 +105,7 @@ class Rips_complex { bool create_complex(SimplicialComplexForRips& complex, int dim_max) { if (complex.num_vertices() > 0) { std::cerr << "Rips_complex create_complex - complex is not empty\n"; - return false; // ----- >> + return false; // ----- >> } // insert the proximity graph in the simplicial complex @@ -118,7 +117,7 @@ class Rips_complex { return true; } - public: + private: /** \brief Output the proximity graph of the points. * * If points contains n elements, the proximity graph is the graph @@ -133,20 +132,17 @@ class Rips_complex { Distance distance) { std::vector< std::pair< Vertex_handle, Vertex_handle > > edges; std::vector< Filtration_value > edges_fil; - std::map< Vertex_handle, Filtration_value > vertices; // Compute 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. // -------------------------------------------------------------------------------------------- // Creates the vector of edges and its filtration values (returned by distance function) - Vertex_handle idx_u, idx_v; - Filtration_value fil; - idx_u = 0; + Vertex_handle idx_u = 0; for (auto it_u = std::begin(points); it_u != std::end(points); ++it_u) { - idx_v = idx_u + 1; + Vertex_handle idx_v = idx_u + 1; for (auto it_v = it_u + 1; it_v != std::end(points); ++it_v, ++idx_v) { - fil = distance(*it_u, *it_v); + Filtration_value fil = distance(*it_u, *it_v); if (fil <= threshold) { edges.emplace_back(idx_u, idx_v); edges_fil.push_back(fil); @@ -172,11 +168,10 @@ class Rips_complex { private: Graph_t rips_skeleton_graph_; - }; -} // namespace rips_complex +} // namespace rips_complex -} // namespace Gudhi +} // namespace Gudhi #endif // RIPS_COMPLEX_H_ diff --git a/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp b/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp index 13c700c6..1dff4529 100644 --- a/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp +++ b/src/Simplex_tree/example/simplex_tree_from_cliques_of_graph.cpp @@ -26,6 +26,7 @@ #include #include #include +#include // for std::pair using namespace Gudhi; diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index ed2c1f5d..58a513e7 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -32,12 +32,12 @@ /** @brief Compute the Euclidean distance between two Points given by a range of coordinates. The points are assumed to * have the same dimension. */ template< typename Filtration_value, typename Point > -Filtration_value euclidean_distance(const Point &p1,const Point &p2) { +Filtration_value euclidean_distance(const Point &p1, const Point &p2) { Filtration_value dist = 0.; auto it1 = p1.begin(); auto it2 = p2.begin(); for (; it1 != p1.end(); ++it1, ++it2) { - Filtration_value tmp = (double)(*it1) - (double)(*it2); + Filtration_value tmp = static_cast(*it1) - static_cast(*it2); dist += tmp*tmp; } return std::sqrt(dist); diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index ddec5ba7..2d774d4d 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -222,7 +222,7 @@ bool read_hasse_simplex(std::istream & in_, std::vector< Simplex_key > & boundar **/ template< typename Filtration_value > std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from_csv_file(const std::string& filename, - const char separator=';') { + const char separator = ';') { #ifdef DEBUG_TRACES std::cout << "Using procedure read_lower_triangular_matrix_from_csv_file \n"; #endif // DEBUG_TRACES @@ -273,7 +273,6 @@ std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from } if (!values_in_this_line.empty())result.push_back(values_in_this_line); ++number_of_line; - } in.close(); -- cgit v1.2.3 From b41fb07d4dbaf4e12c31b952cc2bc24e30c55384 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 8 Dec 2016 22:17:04 +0000 Subject: replace euclidean_distance with a class Euclidean_distance containing an operator() git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1840 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b1619401ac0ef978257709c5deeb7e19fbcff32c --- src/GudhUI/utils/Persistence_compute.h | 2 +- .../benchmark/performance_rips_persistence.cpp | 3 +- .../example/rips_multifield_persistence.cpp | 3 +- .../example/rips_persistence.cpp | 3 +- .../rips_persistence_via_boundary_matrix.cpp | 3 +- .../example_one_skeleton_rips_from_points.cpp | 2 +- .../example/example_rips_complex_from_off_file.cpp | 3 +- src/Rips_complex/test/test_rips_complex.cpp | 36 +++++++++++----------- .../gudhi/Construct_closest_landmark_table.h | 2 +- src/common/include/gudhi/distance_functions.h | 23 ++++++++------ 10 files changed, 39 insertions(+), 41 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/GudhUI/utils/Persistence_compute.h b/src/GudhUI/utils/Persistence_compute.h index d2973d84..12283cbe 100644 --- a/src/GudhUI/utils/Persistence_compute.h +++ b/src/GudhUI/utils/Persistence_compute.h @@ -76,7 +76,7 @@ template class Persistence_compute { using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; - Rips_complex rips_complex(points, params.threshold, euclidean_distance); + Rips_complex rips_complex(points, params.threshold, Euclidean_distance()); Simplex_tree st; if (rips_complex.create_complex(st, params.max_dim)) { diff --git a/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp b/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp index a9eab5dd..ba752999 100644 --- a/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp +++ b/src/Persistent_cohomology/benchmark/performance_rips_persistence.cpp @@ -83,8 +83,7 @@ int main(int argc, char * argv[]) { // Compute the proximity graph of the points start = std::chrono::system_clock::now(); - Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, - euclidean_distance); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, Euclidean_distance()); end = std::chrono::system_clock::now(); elapsed_sec = std::chrono::duration_cast(end - start).count(); std::cout << "Compute Rips graph in " << elapsed_sec << " ms.\n"; diff --git a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp index aaa71db9..3389d8e1 100644 --- a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp @@ -62,8 +62,7 @@ int main(int argc, char * argv[]) { program_options(argc, argv, off_file_points, filediag, threshold, dim_max, min_p, max_p, min_persistence); Points_off_reader off_reader(off_file_points); - Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, - euclidean_distance); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, Euclidean_distance()); // Construct the Rips complex in a Simplex Tree Simplex_tree simplex_tree; diff --git a/src/Persistent_cohomology/example/rips_persistence.cpp b/src/Persistent_cohomology/example/rips_persistence.cpp index 0b1873d4..bc62b736 100644 --- a/src/Persistent_cohomology/example/rips_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_persistence.cpp @@ -61,8 +61,7 @@ int main(int argc, char * argv[]) { program_options(argc, argv, off_file_points, filediag, threshold, dim_max, p, min_persistence); Points_off_reader off_reader(off_file_points); - Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, - euclidean_distance); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, Euclidean_distance()); // Construct the Rips complex in a Simplex Tree Simplex_tree simplex_tree; diff --git a/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp b/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp index b7daf6ae..63da9847 100644 --- a/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp +++ b/src/Persistent_cohomology/example/rips_persistence_via_boundary_matrix.cpp @@ -70,8 +70,7 @@ int main(int argc, char * argv[]) { program_options(argc, argv, off_file_points, filediag, threshold, dim_max, p, min_persistence); Points_off_reader off_reader(off_file_points); - Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, - euclidean_distance); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, Euclidean_distance()); // Construct the Rips complex in a Simplex Tree Simplex_tree& st = *new Simplex_tree; diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp index 68fc3629..e9e7ecd4 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp @@ -38,7 +38,7 @@ int main(int argc, char **argv) { // ---------------------------------------------------------------------------- // Init of a rips complex from points // ---------------------------------------------------------------------------- - Rips_complex rips_complex_from_points(points, threshold, euclidean_distance); + Rips_complex rips_complex_from_points(points, threshold, Euclidean_distance()); Simplex_tree simplex; if (rips_complex_from_points.create_complex(simplex, 1)) { diff --git a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp index 469de403..af2c7029 100644 --- a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp @@ -33,8 +33,7 @@ int main(int argc, char **argv) { // Init of a rips complex from an OFF file // ---------------------------------------------------------------------------- Gudhi::Points_off_reader off_reader(off_file_name); - Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, - euclidean_distance); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, Euclidean_distance()); std::streambuf* streambufffer; std::ofstream ouput_file_stream; diff --git a/src/Rips_complex/test/test_rips_complex.cpp b/src/Rips_complex/test/test_rips_complex.cpp index faedbf4a..2db1554d 100644 --- a/src/Rips_complex/test/test_rips_complex.cpp +++ b/src/Rips_complex/test/test_rips_complex.cpp @@ -61,8 +61,7 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { rips_threshold << "==========" << std::endl; Gudhi::Points_off_reader off_reader(off_file_name); - Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), rips_threshold, - euclidean_distance); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), rips_threshold, Euclidean_distance()); const int DIMENSION_1 = 1; Simplex_tree st; @@ -91,10 +90,10 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { std::cout << vertex << ","; vp.push_back(off_reader.get_point_cloud().at(vertex)); } - std::cout << ") - distance =" << euclidean_distance(vp.at(0), vp.at(1)) << + std::cout << ") - distance =" << Euclidean_distance()(vp.at(0), vp.at(1)) << " - filtration =" << st.filtration(f_simplex) << std::endl; BOOST_CHECK(vp.size() == 2); - BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), euclidean_distance(vp.at(0), vp.at(1)))); + BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), Euclidean_distance()(vp.at(0), vp.at(1)))); } } @@ -157,19 +156,20 @@ bool is_point_in_list(Vector_of_points points_list, Point point) { return false; // point not found } -/* Compute the square value of Euclidean distance between two Points given by a range of coordinates. - * The points are assumed to have the same dimension. */ -template< typename Point > -double custom_square_euclidean_distance(const Point &p1,const Point &p2) { - double dist = 0.; - auto it1 = p1.begin(); - auto it2 = p2.begin(); - for (; it1 != p1.end(); ++it1, ++it2) { - double tmp = *it1 - *it2; - dist += tmp*tmp; +class Custom_square_euclidean_distance { + public: + template< typename Point > + auto operator()(const Point& p1, const Point& p2) -> typename Point::value_type { + auto it1 = p1.begin(); + auto it2 = p2.begin(); + typename Point::value_type dist = 0.; + for (; it1 != p1.end(); ++it1, ++it2) { + typename Point::value_type tmp = (*it1) - (*it2); + dist += tmp*tmp; + } + return dist; } - return dist; -} +}; BOOST_AUTO_TEST_CASE(Rips_complex_from_points) { // ---------------------------------------------------------------------------- @@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(Rips_complex_from_points) { // ---------------------------------------------------------------------------- // Init of a rips complex from the list of points // ---------------------------------------------------------------------------- - Rips_complex rips_complex_from_points(points, 2.0, custom_square_euclidean_distance); + Rips_complex rips_complex_from_points(points, 2.0, Custom_square_euclidean_distance()); std::cout << "========== Rips_complex_from_points ==========" << std::endl; Simplex_tree st; @@ -327,4 +327,4 @@ BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { " - f023= " << f023 << std::endl; BOOST_CHECK(are_almost_the_same(f0123, std::max(f012, std::max(f123, std::max(f013, f023))))); -} \ No newline at end of file +} diff --git a/src/Witness_complex/include/gudhi/Construct_closest_landmark_table.h b/src/Witness_complex/include/gudhi/Construct_closest_landmark_table.h index 1ae2e393..a8cdd096 100644 --- a/src/Witness_complex/include/gudhi/Construct_closest_landmark_table.h +++ b/src/Witness_complex/include/gudhi/Construct_closest_landmark_table.h @@ -73,7 +73,7 @@ namespace witness_complex { int landmarks_i = 0; for (landmarks_it = landmarks.begin(), landmarks_i = 0; landmarks_it != landmarks.end(); ++landmarks_it, landmarks_i++) { - dist_i dist = std::make_pair(euclidean_distance(points[points_i], *landmarks_it), + dist_i dist = std::make_pair(Euclidean_distance()(points[points_i], *landmarks_it), landmarks_i); l_heap.push(dist); } diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 58a513e7..5c7f3d55 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -31,16 +31,19 @@ /** @brief Compute the Euclidean distance between two Points given by a range of coordinates. The points are assumed to * have the same dimension. */ -template< typename Filtration_value, typename Point > -Filtration_value euclidean_distance(const Point &p1, const Point &p2) { - Filtration_value dist = 0.; - auto it1 = p1.begin(); - auto it2 = p2.begin(); - for (; it1 != p1.end(); ++it1, ++it2) { - Filtration_value tmp = static_cast(*it1) - static_cast(*it2); - dist += tmp*tmp; +class Euclidean_distance { + public: + template< typename Point > + auto operator()(const Point& p1, const Point& p2) -> typename Point::value_type { + auto it1 = p1.begin(); + auto it2 = p2.begin(); + typename Point::value_type dist = 0.; + for (; it1 != p1.end(); ++it1, ++it2) { + typename Point::value_type tmp = (*it1) - (*it2); + dist += tmp*tmp; + } + return std::sqrt(dist); } - return std::sqrt(dist); -} +}; #endif // DISTANCE_FUNCTIONS_H_ -- cgit v1.2.3 From fc454f6135bc6f63a6eb859f58835fe653eb073d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 12 Dec 2016 13:33:29 +0000 Subject: Remove comment // to construct a simplex_tree from rips complex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1855 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2be10c7952457b0f6210c4bbbce82eaa250498a7 --- .../example/example_one_skeleton_rips_from_distance_matrix.cpp | 1 - src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp | 1 - .../example/example_rips_complex_from_csv_distance_matrix_file.cpp | 1 - src/Rips_complex/example/example_rips_complex_from_off_file.cpp | 1 - src/Rips_complex/test/test_rips_complex.cpp | 1 - 5 files changed, 5 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp index b1ba494e..4d577822 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp @@ -1,5 +1,4 @@ #include -// to construct a simplex_tree from rips complex #include #include diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp index e9e7ecd4..9e90c72e 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp @@ -1,5 +1,4 @@ #include -// to construct a simplex_tree from rips complex #include #include diff --git a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp index 730bfc7c..93160b1b 100644 --- a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp @@ -1,7 +1,6 @@ #include // to construct Rips_complex from a OFF file of points #include -// to construct a simplex_tree from rips complex #include #include diff --git a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp index af2c7029..23e49add 100644 --- a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp @@ -1,7 +1,6 @@ #include // to construct Rips_complex from a OFF file of points #include -// to construct a simplex_tree from rips complex #include #include diff --git a/src/Rips_complex/test/test_rips_complex.cpp b/src/Rips_complex/test/test_rips_complex.cpp index 2db1554d..7e0473d9 100644 --- a/src/Rips_complex/test/test_rips_complex.cpp +++ b/src/Rips_complex/test/test_rips_complex.cpp @@ -33,7 +33,6 @@ #include // to construct Rips_complex from a OFF file of points #include -// to construct a simplex_tree from rips complex #include #include #include -- cgit v1.2.3 From 911370db9608601cce5aaf9ec91f2a0ca08eb9d7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 12 Dec 2016 15:36:28 +0000 Subject: rename simplex_tree variable names git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1856 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: aa283b26d5c31577698dcec271e7b0ef95b4bd0f --- .../example_one_skeleton_rips_from_distance_matrix.cpp | 16 ++++++++-------- .../example/example_one_skeleton_rips_from_points.cpp | 16 ++++++++-------- ...xample_rips_complex_from_csv_distance_matrix_file.cpp | 16 ++++++++-------- .../example/example_rips_complex_from_off_file.cpp | 16 ++++++++-------- 4 files changed, 32 insertions(+), 32 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp index 4d577822..02bffe0d 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp @@ -44,23 +44,23 @@ int main(int argc, char **argv) { // ---------------------------------------------------------------------------- Rips_complex rips_complex_from_points(distances, threshold); - Simplex_tree simplex; - if (rips_complex_from_points.create_complex(simplex, 1)) { + Simplex_tree stree; + if (rips_complex_from_points.create_complex(stree, 1)) { // ---------------------------------------------------------------------------- // Display information about the one skeleton rips complex // ---------------------------------------------------------------------------- - std::cout << "Rips complex is of dimension " << simplex.dimension() << - " - " << simplex.num_simplices() << " simplices - " << - simplex.num_vertices() << " vertices." << std::endl; + std::cout << "Rips complex is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.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()) { + for (auto f_simplex : stree.filtration_simplex_range()) { std::cout << " ( "; - for (auto vertex : simplex.simplex_vertex_range(f_simplex)) { + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { std::cout << vertex << " "; } - std::cout << ") -> " << "[" << simplex.filtration(f_simplex) << "] "; + std::cout << ") -> " << "[" << stree.filtration(f_simplex) << "] "; std::cout << std::endl; } } diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp index 9e90c72e..efbcd88e 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp @@ -39,23 +39,23 @@ int main(int argc, char **argv) { // ---------------------------------------------------------------------------- Rips_complex rips_complex_from_points(points, threshold, Euclidean_distance()); - Simplex_tree simplex; - if (rips_complex_from_points.create_complex(simplex, 1)) { + Simplex_tree stree; + if (rips_complex_from_points.create_complex(stree, 1)) { // ---------------------------------------------------------------------------- // Display information about the one skeleton rips complex // ---------------------------------------------------------------------------- - std::cout << "Rips complex is of dimension " << simplex.dimension() << - " - " << simplex.num_simplices() << " simplices - " << - simplex.num_vertices() << " vertices." << std::endl; + std::cout << "Rips complex is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.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()) { + for (auto f_simplex : stree.filtration_simplex_range()) { std::cout << " ( "; - for (auto vertex : simplex.simplex_vertex_range(f_simplex)) { + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { std::cout << vertex << " "; } - std::cout << ") -> " << "[" << simplex.filtration(f_simplex) << "] "; + std::cout << ") -> " << "[" << stree.filtration(f_simplex) << "] "; std::cout << std::endl; } } diff --git a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp index 93160b1b..7cdaffdf 100644 --- a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp @@ -45,25 +45,25 @@ int main(int argc, char **argv) { streambufffer = std::cout.rdbuf(); } - Simplex_tree simplex; - if (rips_complex_from_file.create_complex(simplex, dim_max)) { + Simplex_tree stree; + if (rips_complex_from_file.create_complex(stree, dim_max)) { std::ostream output_stream(streambufffer); // ---------------------------------------------------------------------------- // Display information about the rips complex // ---------------------------------------------------------------------------- - output_stream << "Rips complex is of dimension " << simplex.dimension() << - " - " << simplex.num_simplices() << " simplices - " << - simplex.num_vertices() << " vertices." << std::endl; + output_stream << "Rips complex is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.num_vertices() << " vertices." << std::endl; output_stream << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << std::endl; - for (auto f_simplex : simplex.filtration_simplex_range()) { + for (auto f_simplex : stree.filtration_simplex_range()) { output_stream << " ( "; - for (auto vertex : simplex.simplex_vertex_range(f_simplex)) { + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { output_stream << vertex << " "; } - output_stream << ") -> " << "[" << simplex.filtration(f_simplex) << "] "; + output_stream << ") -> " << "[" << stree.filtration(f_simplex) << "] "; output_stream << std::endl; } } diff --git a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp index 23e49add..8849d784 100644 --- a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp @@ -44,25 +44,25 @@ int main(int argc, char **argv) { streambufffer = std::cout.rdbuf(); } - Simplex_tree simplex; - if (rips_complex_from_file.create_complex(simplex, dim_max)) { + Simplex_tree stree; + if (rips_complex_from_file.create_complex(stree, dim_max)) { std::ostream output_stream(streambufffer); // ---------------------------------------------------------------------------- // Display information about the rips complex // ---------------------------------------------------------------------------- - output_stream << "Rips complex is of dimension " << simplex.dimension() << - " - " << simplex.num_simplices() << " simplices - " << - simplex.num_vertices() << " vertices." << std::endl; + output_stream << "Rips complex is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.num_vertices() << " vertices." << std::endl; output_stream << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << std::endl; - for (auto f_simplex : simplex.filtration_simplex_range()) { + for (auto f_simplex : stree.filtration_simplex_range()) { output_stream << " ( "; - for (auto vertex : simplex.simplex_vertex_range(f_simplex)) { + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { output_stream << vertex << " "; } - output_stream << ") -> " << "[" << simplex.filtration(f_simplex) << "] "; + output_stream << ") -> " << "[" << stree.filtration(f_simplex) << "] "; output_stream << std::endl; } } -- cgit v1.2.3 From 04e1b011959f93de8a7a252cdc9fa1f4aed0c12e Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 12 Dec 2016 16:52:02 +0000 Subject: Doc fix from review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1857 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 88619abff993bd776310f18034d2ab5fa0b41944 --- src/Rips_complex/doc/Intro_rips_complex.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index 0ae89ffc..5b424a26 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -37,10 +37,13 @@ namespace rips_complex { * * Rips_complex * (Wikipedia) is a + * one skeleton graph that allows to construct a * simplicial complex - * constructed from a one skeleton graph. + * from it. + * The input can be a point cloud with a given distance function, or a distance matrix. * - * The filtration value of each edge is computed from a user-given distance function. + * The filtration value of each edge is computed from a user-given distance function, or directly from the distance + * matrix. * * All edges that have a filtration value strictly greater than a given threshold value are not inserted into * the complex. @@ -77,7 +80,7 @@ namespace rips_complex { * * \subsection ripsoffexample Example from OFF file * - * This example builds the one skeleton graph from the given points in an OFF file, threshold value, and distance + * This example builds the Rips_complex from the given points in an OFF file, threshold value, and distance * function. * Then it creates a `Simplex_tree` with it. * -- cgit v1.2.3 From 1569573662fe88c82ceb0846beb19701a95ac935 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 12 Dec 2016 16:54:49 +0000 Subject: Doc changed for review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1858 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2b70b619233362adebdc3046c923090fac53a660 --- src/Rips_complex/include/gudhi/Rips_complex.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index f98a6993..3260e500 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -118,14 +118,13 @@ class Rips_complex { } private: - /** \brief Output the proximity graph of the points. + /** \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. + * 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. * - * The type PointCloud furnishes .begin() and .end() methods, that return - * iterators with value_type Point. + * \tparam The type InputPointRange furnishes .begin() and .end() methods, that return iterators with + * value_type Point. */ template< typename InputPointRange, typename Distance > void compute_proximity_graph(const InputPointRange& points, Filtration_value threshold, -- cgit v1.2.3 From dc8731b3e43c9289004b474dcb0b97b2e03527c6 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 12 Dec 2016 16:56:47 +0000 Subject: Fix for doc review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1859 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3460f25024dc952a3313322111ffb1b3eef5abda --- src/Rips_complex/include/gudhi/Rips_complex.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index 3260e500..d00372d8 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -47,8 +47,8 @@ namespace rips_complex { * \ingroup rips_complex * * \details - * The data structure is a one skeleton graph constructed from a point cloud, containing edges when the edge length is - * less or equal to a given threshold. Edge length is computed from a user given function. + * The data structure is a one skeleton graph, or Rips graph, constructed from a point cloud, containing edges when + * the edge length is less or equal to a given threshold. Edge length is computed from a user given function. * * The complex is a template class requiring a Filtration_value type. * @@ -90,7 +90,7 @@ class Rips_complex { [&](size_t i, size_t j){return distance_matrix[j][i];}); } - /** \brief Initializes the simplicial complex from the 1-skeleton graph and expands it until a given maximal + /** \brief Initializes the simplicial complex from the Rips graph and expands it until a given maximal * dimension. * * \tparam SimplicialComplexForRips must meet `SimplicialComplexForRips` concept. -- cgit v1.2.3 From d9895d13cecf61de78a1c812bfb80bbc2778e7a6 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 13 Dec 2016 19:09:18 +0000 Subject: Use of a pointer for the rips skeleton graph member variable to avoid deep copy of the structure. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1865 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fe745c7c61d9149689521c1cb9e750b2682179b5 --- src/Rips_complex/include/gudhi/Rips_complex.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index d00372d8..5ac46071 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -73,7 +73,8 @@ class Rips_complex { * The type InputPointRange must be a range for which std::begin and std::end return input iterators on a point. */ template - Rips_complex(const InputPointRange& points, Filtration_value threshold, Distance distance) { + Rips_complex(const InputPointRange& points, Filtration_value threshold, Distance distance) + : rips_skeleton_graph_(nullptr) { compute_proximity_graph(points, threshold, distance); } @@ -82,10 +83,13 @@ class Rips_complex { * @param[in] distance_matrix Range of distances. * @param[in] threshold rips value. * - * The type InputDistanceRange must be a range for which std::begin and std::end return input iterators on a point. + * The type InputDistanceRange must have a \code size() \endcode method and on which distance_matrix[i][j] returns + * the distance between points \f$i\f$ and \f$j\f$ as long as \f$ 0 \subseteq i \subseteq j \subseteq + * distance_matrix.size().\f$ */ template - Rips_complex(const InputDistanceRange& distance_matrix, Filtration_value threshold) { + Rips_complex(const InputDistanceRange& distance_matrix, Filtration_value threshold) + : rips_skeleton_graph_(nullptr) { compute_proximity_graph(boost::irange((size_t)0, distance_matrix.size()), threshold, [&](size_t i, size_t j){return distance_matrix[j][i];}); } @@ -107,9 +111,13 @@ class Rips_complex { std::cerr << "Rips_complex create_complex - complex is not empty\n"; return false; // ----- >> } + if (rips_skeleton_graph_ == nullptr) { + std::cerr << "Rips Skeleton Graph is not defined\n"; + return false; // ----- >> + } // insert the proximity graph in the simplicial complex - complex.insert_graph(rips_skeleton_graph_); + complex.insert_graph(*rips_skeleton_graph_); // expand the graph until dimension dim_max complex.expansion(dim_max); @@ -153,20 +161,20 @@ class Rips_complex { // -------------------------------------------------------------------------------------------- // Creates the proximity graph from edges and sets the property with the filtration value. // Number of points is labeled from 0 to idx_u-1 - rips_skeleton_graph_ = Graph_t(edges.begin(), edges.end(), edges_fil.begin(), idx_u); + rips_skeleton_graph_ = new Graph_t(edges.begin(), edges.end(), edges_fil.begin(), idx_u); - auto vertex_prop = boost::get(vertex_filtration_t(), rips_skeleton_graph_); + auto vertex_prop = boost::get(vertex_filtration_t(), *rips_skeleton_graph_); using vertex_iterator = typename boost::graph_traits::vertex_iterator; vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = boost::vertices(rips_skeleton_graph_); + for (std::tie(vi, vi_end) = boost::vertices(*rips_skeleton_graph_); vi != vi_end; ++vi) { boost::put(vertex_prop, *vi, 0.); } } private: - Graph_t rips_skeleton_graph_; + Graph_t* rips_skeleton_graph_; }; } // namespace rips_complex -- cgit v1.2.3 From de2573cf2b2eb92cff628d9690a067b50b4ca145 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 14 Dec 2016 13:27:02 +0000 Subject: Rollback pointer modification, and use of of a hack for no deep copy of boost graph "voidification" of create_complex method git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1868 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3667c8f57388dec0300d1fed8bf1b063843727dd --- ...mple_one_skeleton_rips_from_distance_matrix.cpp | 32 +++++++++--------- .../example_one_skeleton_rips_from_points.cpp | 33 +++++++++--------- ..._rips_complex_from_csv_distance_matrix_file.cpp | 34 +++++++++---------- .../example/example_rips_complex_from_off_file.cpp | 34 +++++++++---------- src/Rips_complex/include/gudhi/Rips_complex.h | 39 +++++++++------------- src/Rips_complex/test/test_rips_complex.cpp | 38 +++++++++++++++++---- 6 files changed, 112 insertions(+), 98 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp index 02bffe0d..326ad52f 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp @@ -45,24 +45,24 @@ int main(int argc, char **argv) { Rips_complex rips_complex_from_points(distances, threshold); Simplex_tree stree; - if (rips_complex_from_points.create_complex(stree, 1)) { - // ---------------------------------------------------------------------------- - // Display information about the one skeleton rips complex - // ---------------------------------------------------------------------------- - std::cout << "Rips complex is of dimension " << stree.dimension() << - " - " << stree.num_simplices() << " simplices - " << - stree.num_vertices() << " vertices." << std::endl; + rips_complex_from_points.create_complex(stree, 1); + // ---------------------------------------------------------------------------- + // Display information about the one skeleton rips complex + // ---------------------------------------------------------------------------- + std::cout << "Rips complex is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.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 : stree.filtration_simplex_range()) { - std::cout << " ( "; - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - std::cout << vertex << " "; - } - std::cout << ") -> " << "[" << stree.filtration(f_simplex) << "] "; - std::cout << std::endl; + std::cout << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << + std::endl; + for (auto f_simplex : stree.filtration_simplex_range()) { + std::cout << " ( "; + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { + std::cout << vertex << " "; } + std::cout << ") -> " << "[" << stree.filtration(f_simplex) << "] "; + std::cout << std::endl; } + return 0; } diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp index efbcd88e..6e8dee27 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp @@ -40,24 +40,23 @@ int main(int argc, char **argv) { Rips_complex rips_complex_from_points(points, threshold, Euclidean_distance()); Simplex_tree stree; - if (rips_complex_from_points.create_complex(stree, 1)) { - // ---------------------------------------------------------------------------- - // Display information about the one skeleton rips complex - // ---------------------------------------------------------------------------- - std::cout << "Rips complex is of dimension " << stree.dimension() << - " - " << stree.num_simplices() << " simplices - " << - stree.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 : stree.filtration_simplex_range()) { - std::cout << " ( "; - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - std::cout << vertex << " "; - } - std::cout << ") -> " << "[" << stree.filtration(f_simplex) << "] "; - std::cout << std::endl; + rips_complex_from_points.create_complex(stree, 1); + // ---------------------------------------------------------------------------- + // Display information about the one skeleton rips complex + // ---------------------------------------------------------------------------- + std::cout << "Rips complex is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.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 : stree.filtration_simplex_range()) { + std::cout << " ( "; + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { + std::cout << vertex << " "; } + std::cout << ") -> " << "[" << stree.filtration(f_simplex) << "] "; + std::cout << std::endl; } return 0; } diff --git a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp index 7cdaffdf..cc6c3a33 100644 --- a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp @@ -46,27 +46,27 @@ int main(int argc, char **argv) { } Simplex_tree stree; - if (rips_complex_from_file.create_complex(stree, dim_max)) { - std::ostream output_stream(streambufffer); + rips_complex_from_file.create_complex(stree, dim_max); + std::ostream output_stream(streambufffer); - // ---------------------------------------------------------------------------- - // Display information about the rips complex - // ---------------------------------------------------------------------------- - output_stream << "Rips complex is of dimension " << stree.dimension() << - " - " << stree.num_simplices() << " simplices - " << - stree.num_vertices() << " vertices." << std::endl; + // ---------------------------------------------------------------------------- + // Display information about the rips complex + // ---------------------------------------------------------------------------- + output_stream << "Rips complex is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.num_vertices() << " vertices." << std::endl; - output_stream << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << - std::endl; - for (auto f_simplex : stree.filtration_simplex_range()) { - output_stream << " ( "; - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - output_stream << vertex << " "; - } - output_stream << ") -> " << "[" << stree.filtration(f_simplex) << "] "; - output_stream << std::endl; + output_stream << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << + std::endl; + for (auto f_simplex : stree.filtration_simplex_range()) { + output_stream << " ( "; + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { + output_stream << vertex << " "; } + output_stream << ") -> " << "[" << stree.filtration(f_simplex) << "] "; + output_stream << std::endl; } + ouput_file_stream.close(); return 0; } diff --git a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp index 8849d784..b6c961d0 100644 --- a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp @@ -45,27 +45,27 @@ int main(int argc, char **argv) { } Simplex_tree stree; - if (rips_complex_from_file.create_complex(stree, dim_max)) { - std::ostream output_stream(streambufffer); + rips_complex_from_file.create_complex(stree, dim_max); + std::ostream output_stream(streambufffer); - // ---------------------------------------------------------------------------- - // Display information about the rips complex - // ---------------------------------------------------------------------------- - output_stream << "Rips complex is of dimension " << stree.dimension() << - " - " << stree.num_simplices() << " simplices - " << - stree.num_vertices() << " vertices." << std::endl; + // ---------------------------------------------------------------------------- + // Display information about the rips complex + // ---------------------------------------------------------------------------- + output_stream << "Rips complex is of dimension " << stree.dimension() << + " - " << stree.num_simplices() << " simplices - " << + stree.num_vertices() << " vertices." << std::endl; - output_stream << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << - std::endl; - for (auto f_simplex : stree.filtration_simplex_range()) { - output_stream << " ( "; - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - output_stream << vertex << " "; - } - output_stream << ") -> " << "[" << stree.filtration(f_simplex) << "] "; - output_stream << std::endl; + output_stream << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << + std::endl; + for (auto f_simplex : stree.filtration_simplex_range()) { + output_stream << " ( "; + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { + output_stream << vertex << " "; } + output_stream << ") -> " << "[" << stree.filtration(f_simplex) << "] "; + output_stream << std::endl; } + ouput_file_stream.close(); return 0; } diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index 5ac46071..1061de73 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -73,8 +73,7 @@ class Rips_complex { * The type InputPointRange must be a range for which std::begin and std::end return input iterators on a point. */ template - Rips_complex(const InputPointRange& points, Filtration_value threshold, Distance distance) - : rips_skeleton_graph_(nullptr) { + Rips_complex(const InputPointRange& points, Filtration_value threshold, Distance distance) { compute_proximity_graph(points, threshold, distance); } @@ -88,8 +87,7 @@ class Rips_complex { * distance_matrix.size().\f$ */ template - Rips_complex(const InputDistanceRange& distance_matrix, Filtration_value threshold) - : rips_skeleton_graph_(nullptr) { + Rips_complex(const InputDistanceRange& distance_matrix, Filtration_value threshold) { compute_proximity_graph(boost::irange((size_t)0, distance_matrix.size()), threshold, [&](size_t i, size_t j){return distance_matrix[j][i];}); } @@ -101,28 +99,18 @@ class Rips_complex { * * @param[in] complex SimplicialComplexForRips to be created. * @param[in] dim_max graph expansion for rips until this given maximal dimension. - * - * @return true if creation succeeds, false otherwise. - * + * @exception std::invalid_argument In debug mode, if \code complex.num_vertices() \endcode does not return 0. + * */ template - bool create_complex(SimplicialComplexForRips& complex, int dim_max) { - if (complex.num_vertices() > 0) { - std::cerr << "Rips_complex create_complex - complex is not empty\n"; - return false; // ----- >> - } - if (rips_skeleton_graph_ == nullptr) { - std::cerr << "Rips Skeleton Graph is not defined\n"; - return false; // ----- >> - } + void create_complex(SimplicialComplexForRips& complex, int dim_max) { + GUDHI_CHECK(complex.num_vertices() == 0, + std::invalid_argument("Rips_complex::create_complex - simplicial complex is not empty")); // insert the proximity graph in the simplicial complex - complex.insert_graph(*rips_skeleton_graph_); + complex.insert_graph(rips_skeleton_graph_); // expand the graph until dimension dim_max complex.expansion(dim_max); - - // -------------------------------------------------------------------------------------------- - return true; } private: @@ -161,20 +149,23 @@ class Rips_complex { // -------------------------------------------------------------------------------------------- // Creates the proximity graph from edges and sets the property with the filtration value. // Number of points is labeled from 0 to idx_u-1 - rips_skeleton_graph_ = new Graph_t(edges.begin(), edges.end(), edges_fil.begin(), idx_u); + // -------------------------------------------------------------------------------------------- + // Do not use : rips_skeleton_graph_ = Graph_t(...) -> deep copy of the graph (boost graph is not move-enabled) + rips_skeleton_graph_.~Graph_t(); + new(&rips_skeleton_graph_)Graph_t(edges.begin(), edges.end(), edges_fil.begin(), idx_u); - auto vertex_prop = boost::get(vertex_filtration_t(), *rips_skeleton_graph_); + auto vertex_prop = boost::get(vertex_filtration_t(), rips_skeleton_graph_); using vertex_iterator = typename boost::graph_traits::vertex_iterator; vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = boost::vertices(*rips_skeleton_graph_); + for (std::tie(vi, vi_end) = boost::vertices(rips_skeleton_graph_); vi != vi_end; ++vi) { boost::put(vertex_prop, *vi, 0.); } } private: - Graph_t* rips_skeleton_graph_; + Graph_t rips_skeleton_graph_; }; } // namespace rips_complex diff --git a/src/Rips_complex/test/test_rips_complex.cpp b/src/Rips_complex/test/test_rips_complex.cpp index 7e0473d9..1bdd0512 100644 --- a/src/Rips_complex/test/test_rips_complex.cpp +++ b/src/Rips_complex/test/test_rips_complex.cpp @@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { const int DIMENSION_1 = 1; Simplex_tree st; - BOOST_CHECK(rips_complex_from_file.create_complex(st, DIMENSION_1)); + rips_complex_from_file.create_complex(st, DIMENSION_1); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == DIMENSION_1); @@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { const int DIMENSION_2 = 2; Simplex_tree st2; - BOOST_CHECK(rips_complex_from_file.create_complex(st2, DIMENSION_2)); + rips_complex_from_file.create_complex(st2, DIMENSION_2); std::cout << "st2.dimension()=" << st2.dimension() << std::endl; BOOST_CHECK(st2.dimension() == DIMENSION_2); @@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { const int DIMENSION_3 = 3; Simplex_tree st3; - BOOST_CHECK(rips_complex_from_file.create_complex(st3, DIMENSION_3)); + rips_complex_from_file.create_complex(st3, DIMENSION_3); std::cout << "st3.dimension()=" << st3.dimension() << std::endl; BOOST_CHECK(st3.dimension() == DIMENSION_3); @@ -192,7 +192,7 @@ BOOST_AUTO_TEST_CASE(Rips_complex_from_points) { std::cout << "========== Rips_complex_from_points ==========" << std::endl; Simplex_tree st; const int DIMENSION = 3; - BOOST_CHECK(rips_complex_from_points.create_complex(st, DIMENSION)); + rips_complex_from_points.create_complex(st, DIMENSION); // Another way to check num_simplices std::cout << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << std::endl; @@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { const int DIMENSION_1 = 1; Simplex_tree st; - BOOST_CHECK(rips_complex_from_file.create_complex(st, DIMENSION_1)); + rips_complex_from_file.create_complex(st, DIMENSION_1); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == DIMENSION_1); @@ -282,7 +282,7 @@ BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { const int DIMENSION_2 = 2; Simplex_tree st2; - BOOST_CHECK(rips_complex_from_file.create_complex(st2, DIMENSION_2)); + rips_complex_from_file.create_complex(st2, DIMENSION_2); std::cout << "st2.dimension()=" << st2.dimension() << std::endl; BOOST_CHECK(st2.dimension() == DIMENSION_2); @@ -308,7 +308,7 @@ BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { const int DIMENSION_3 = 3; Simplex_tree st3; - BOOST_CHECK(rips_complex_from_file.create_complex(st3, DIMENSION_3)); + rips_complex_from_file.create_complex(st3, DIMENSION_3); std::cout << "st3.dimension()=" << st3.dimension() << std::endl; BOOST_CHECK(st3.dimension() == DIMENSION_3); @@ -327,3 +327,27 @@ BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { BOOST_CHECK(are_almost_the_same(f0123, std::max(f012, std::max(f123, std::max(f013, f023))))); } + +#ifdef GUDHI_DEBUG +BOOST_AUTO_TEST_CASE(Rips_create_complex_throw) { + // ---------------------------------------------------------------------------- + // + // Init of a rips complex from a OFF file + // + // ---------------------------------------------------------------------------- + std::string off_file_name("alphacomplexdoc.off"); + double rips_threshold = 12.0; + std::cout << "========== OFF FILE NAME = " << off_file_name << " - rips threshold=" << + rips_threshold << "==========" << std::endl; + + Gudhi::Points_off_reader off_reader(off_file_name); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), rips_threshold, Euclidean_distance()); + + Simplex_tree stree; + std::vector simplex = {0, 1, 2}; + stree.insert_simplex_and_subfaces(simplex); + std::cout << "Check exception throw in debug mode" << std::endl; + // throw excpt because stree is not empty + BOOST_CHECK_THROW (rips_complex_from_file.create_complex(stree, 1), std::invalid_argument); +} +#endif -- cgit v1.2.3 From 08bfe7735e33efbd81b3fd58e8bc34e3228baa3b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 16 Dec 2016 10:10:55 +0000 Subject: Modify doc after review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1893 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 03cb7169f4b5454de0d7ce0f9946fbaa26d74356 --- .../concept/Simplicial_complex_for_rips.h | 10 ++--- src/Rips_complex/include/gudhi/Rips_complex.h | 48 +++++++++++++--------- 2 files changed, 34 insertions(+), 24 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/concept/Simplicial_complex_for_rips.h b/src/Rips_complex/concept/Simplicial_complex_for_rips.h index 470860e9..ba9a2f5e 100644 --- a/src/Rips_complex/concept/Simplicial_complex_for_rips.h +++ b/src/Rips_complex/concept/Simplicial_complex_for_rips.h @@ -31,19 +31,19 @@ namespace rips_complex { * complex, that can be created from a `Rips_complex`. */ struct SimplicialComplexForRips { - /** Handle to specify the simplex filtration value. */ + /** \brief Handle to specify the simplex filtration value. */ typedef unspecified Filtration_value; - /** Returns the number of vertices in the simplicial complex. */ - std::size_t num_vertices(); - - /** \brief Inserts a a given range 'OneSkeletonGraph' in the simplicial complex. */ + /** \brief Inserts a given range `Gudhi::rips_complex::Rips_complex::OneSkeletonGraph` in the simplicial complex. */ template void insert_graph(const OneSkeletonGraph& skel_graph); /** \brief Expands the simplicial complex containing only its one skeleton until a given maximal dimension. */ void expansion(int max_dim); + /** \brief Returns the number of vertices in the simplicial complex. */ + std::size_t num_vertices(); + }; } // namespace rips_complex diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index 1061de73..c7bec34f 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -47,20 +47,23 @@ namespace rips_complex { * \ingroup rips_complex * * \details - * The data structure is a one skeleton graph, or Rips graph, constructed from a point cloud, containing edges when - * the edge length is less or equal to a given threshold. Edge length is computed from a user given function. - * - * The complex is a template class requiring a Filtration_value type. + * The data structure is a one skeleton graph, or Rips graph, containing edges when the edge length is less or equal + * to a given threshold. Edge length is computed from a user given point cloud with a given distance function, or a + * distance matrix. * * \tparam Filtration_value must meet `SimplicialComplexForRips` concept. */ template class Rips_complex { - private: + public: + /** + * \brief Type of the one skeleton graph stored inside the Rips complex structure. + */ typedef typename boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS , boost::property < vertex_filtration_t, Filtration_value > - , boost::property < edge_filtration_t, Filtration_value >> Graph_t; + , boost::property < edge_filtration_t, Filtration_value >> OneSkeletonGraph; + private: typedef int Vertex_handle; public: @@ -68,9 +71,13 @@ class Rips_complex { * * @param[in] points Range of points. * @param[in] threshold rips value. - * @param[in] distance distance function that returns a Filtration_value from 2 given points. + * @param[in] distance distance function that returns a `Filtration_value` from 2 given points. * - * The type InputPointRange must be a range for which std::begin and std::end return input iterators on a point. + * \tparam InputPointRange must be a range for which `std::begin` and `std::end` return input iterators on a + * point. + * + * \tparam Distance furnishes `operator()(const Point& p1, const Point& p2)`, where + * `Point` is a point from the `InputPointRange`, and that returns a `Filtration_value`. */ template Rips_complex(const InputPointRange& points, Filtration_value threshold, Distance distance) { @@ -82,9 +89,9 @@ class Rips_complex { * @param[in] distance_matrix Range of distances. * @param[in] threshold rips value. * - * The type InputDistanceRange must have a \code size() \endcode method and on which distance_matrix[i][j] returns - * the distance between points \f$i\f$ and \f$j\f$ as long as \f$ 0 \subseteq i \subseteq j \subseteq - * distance_matrix.size().\f$ + * \tparam InputDistanceRange must have a `size()` method and on which `distance_matrix[i][j]` returns + * the distance between points \f$i\f$ and \f$j\f$ as long as \f$ 0 \leqslant i \leqslant j \leqslant + * distance\_matrix.size().\f$ */ template Rips_complex(const InputDistanceRange& distance_matrix, Filtration_value threshold) { @@ -99,7 +106,7 @@ class Rips_complex { * * @param[in] complex SimplicialComplexForRips to be created. * @param[in] dim_max graph expansion for rips until this given maximal dimension. - * @exception std::invalid_argument In debug mode, if \code complex.num_vertices() \endcode does not return 0. + * @exception std::invalid_argument In debug mode, if `complex.num_vertices()` does not return 0. * */ template @@ -119,8 +126,11 @@ class Rips_complex { * 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 The type InputPointRange furnishes .begin() and .end() methods, that return iterators with - * value_type Point. + * \tparam InputPointRange furnishes `.begin()` and `.end()` + * methods. + * + * \tparam Distance furnishes `operator()(const Point& p1, const Point& p2)`, where + * `Point` is a point from the `InputPointRange`, and that returns a `Filtration_value`. */ template< typename InputPointRange, typename Distance > void compute_proximity_graph(const InputPointRange& points, Filtration_value threshold, @@ -150,13 +160,13 @@ class Rips_complex { // Creates the proximity graph from edges and sets the property with the filtration value. // Number of points is labeled from 0 to idx_u-1 // -------------------------------------------------------------------------------------------- - // Do not use : rips_skeleton_graph_ = Graph_t(...) -> deep copy of the graph (boost graph is not move-enabled) - rips_skeleton_graph_.~Graph_t(); - new(&rips_skeleton_graph_)Graph_t(edges.begin(), edges.end(), edges_fil.begin(), idx_u); + // Do not use : rips_skeleton_graph_ = OneSkeletonGraph(...) -> deep copy of the graph (boost graph is not move-enabled) + rips_skeleton_graph_.~OneSkeletonGraph(); + new(&rips_skeleton_graph_)OneSkeletonGraph(edges.begin(), edges.end(), edges_fil.begin(), idx_u); auto vertex_prop = boost::get(vertex_filtration_t(), rips_skeleton_graph_); - using vertex_iterator = typename boost::graph_traits::vertex_iterator; + using vertex_iterator = typename boost::graph_traits::vertex_iterator; vertex_iterator vi, vi_end; for (std::tie(vi, vi_end) = boost::vertices(rips_skeleton_graph_); vi != vi_end; ++vi) { @@ -165,7 +175,7 @@ class Rips_complex { } private: - Graph_t rips_skeleton_graph_; + OneSkeletonGraph rips_skeleton_graph_; }; } // namespace rips_complex -- cgit v1.2.3 From 8340ca1acd568c93d115fcd46a996749a8cc295d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 16 Dec 2016 10:22:49 +0000 Subject: Modify documentatin after review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1894 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4bd2b575d6f58aab2ea1d03b20d3e06693bec182 --- src/Rips_complex/concept/Simplicial_complex_for_rips.h | 6 ++++-- src/Rips_complex/doc/Intro_rips_complex.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/concept/Simplicial_complex_for_rips.h b/src/Rips_complex/concept/Simplicial_complex_for_rips.h index ba9a2f5e..08173289 100644 --- a/src/Rips_complex/concept/Simplicial_complex_for_rips.h +++ b/src/Rips_complex/concept/Simplicial_complex_for_rips.h @@ -34,11 +34,13 @@ struct SimplicialComplexForRips { /** \brief Handle to specify the simplex filtration value. */ typedef unspecified Filtration_value; - /** \brief Inserts a given range `Gudhi::rips_complex::Rips_complex::OneSkeletonGraph` in the simplicial complex. */ + /** \brief Inserts a given range `Gudhi::rips_complex::Rips_complex::OneSkeletonGraph` in the simplicial + * complex. */ template void insert_graph(const OneSkeletonGraph& skel_graph); - /** \brief Expands the simplicial complex containing only its one skeleton until a given maximal dimension. */ + /** \brief Expands the simplicial complex containing only its one skeleton until a given maximal dimension as + * defined in \ref ripsdefinition. */ void expansion(int max_dim); /** \brief Returns the number of vertices in the simplicial complex. */ diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index 5b424a26..8bacd0e7 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -33,7 +33,7 @@ namespace rips_complex { * * @{ * - * \section ripsdefinition Definition + * \section ripsdefinition Rips complex definition * * Rips_complex * (Wikipedia) is a -- cgit v1.2.3 From a2977f4038b8cfc375f037de7c5c805a9079f9f7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 16 Dec 2016 12:59:04 +0000 Subject: Doc modification git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1901 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 503d38af6ee04b19ffc2feec6ee2bfd05429e9ef --- src/Rips_complex/concept/Simplicial_complex_for_rips.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/concept/Simplicial_complex_for_rips.h b/src/Rips_complex/concept/Simplicial_complex_for_rips.h index 08173289..c233a50a 100644 --- a/src/Rips_complex/concept/Simplicial_complex_for_rips.h +++ b/src/Rips_complex/concept/Simplicial_complex_for_rips.h @@ -40,7 +40,7 @@ struct SimplicialComplexForRips { void insert_graph(const OneSkeletonGraph& skel_graph); /** \brief Expands the simplicial complex containing only its one skeleton until a given maximal dimension as - * defined in \ref ripsdefinition. */ + * explained in \ref ripsdefinition. */ void expansion(int max_dim); /** \brief Returns the number of vertices in the simplicial complex. */ -- cgit v1.2.3 From b987fc9acca83d8a0dca40647cfe804edfcee2a7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 16 Jan 2017 09:43:21 +0000 Subject: Remove the usage functions and modified the doc for oneskeletonripspoints and oneskeletonripsdistance. No added value as distance matrix and points set is hard defined. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1939 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 13142245f95995a13c5bf484a6f8bf5d4bf53b58 --- src/Rips_complex/doc/Intro_rips_complex.h | 6 +++--- src/Rips_complex/example/CMakeLists.txt | 5 ++--- .../example_one_skeleton_rips_from_distance_matrix.cpp | 14 ++------------ .../example/example_one_skeleton_rips_from_points.cpp | 14 ++------------ 4 files changed, 9 insertions(+), 30 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index 8bacd0e7..64fd34bc 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -69,9 +69,9 @@ namespace rips_complex { * \include Rips_complex/example_one_skeleton_rips_from_points.cpp * * When launching (rips maximal distance between 2 points is 12.0, is expanded until dimension 1 - one skeleton graph - * with other words): + * in other words): * - * \code $> ./oneskeletonripspoints 12.0 + * \code $> ./oneskeletonripspoints * \endcode * * the program output is: @@ -114,7 +114,7 @@ namespace rips_complex { * When launching (rips maximal distance between 2 points is 1.0, is expanded until dimension 1 - one skeleton graph * with other words): * - * \code $> ./oneskeletonripsdistance 1.0 + * \code $> ./oneskeletonripsdistance * \endcode * * the program output is: diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt index c15a13d0..070ac710 100644 --- a/src/Rips_complex/example/CMakeLists.txt +++ b/src/Rips_complex/example/CMakeLists.txt @@ -22,9 +22,8 @@ if (TBB_FOUND) target_link_libraries(ripscsvdistancereader ${TBB_LIBRARIES}) endif() -add_test(oneskeletonripspoints ${CMAKE_CURRENT_BINARY_DIR}/oneskeletonripspoints 12.0) - -add_test(oneskeletonripsdistance ${CMAKE_CURRENT_BINARY_DIR}/oneskeletonripspoints 1.0) +add_test(oneskeletonripspoints ${CMAKE_CURRENT_BINARY_DIR}/oneskeletonripspoints) +add_test(oneskeletonripsdistance ${CMAKE_CURRENT_BINARY_DIR}/oneskeletonripsdistance) # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp index 326ad52f..765d65ea 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp @@ -7,18 +7,7 @@ #include #include // 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 << " threshold\n"; - std::cerr << " i.e.: " << progName << " 12.0\n"; - exit(-1); // ----- >> -} - -int main(int argc, char **argv) { - if (argc != 2) usage(argc, argv[0]); - - double threshold = atof(argv[1]); - +int main() { // Type definitions using Simplex_tree = Gudhi::Simplex_tree; using Filtration_value = Simplex_tree::Filtration_value; @@ -42,6 +31,7 @@ int main(int argc, char **argv) { // ---------------------------------------------------------------------------- // Init of a rips complex from points // ---------------------------------------------------------------------------- + double threshold = 1.0; Rips_complex rips_complex_from_points(distances, threshold); Simplex_tree stree; diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp index 6e8dee27..5d1216a0 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp @@ -7,18 +7,7 @@ #include #include // 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 << " threshold\n"; - std::cerr << " i.e.: " << progName << " 12.0\n"; - exit(-1); // ----- >> -} - -int main(int argc, char **argv) { - if (argc != 2) usage(argc, argv[0]); - - double threshold = atof(argv[1]); - +int main() { // Type definitions using Point = std::vector; using Simplex_tree = Gudhi::Simplex_tree; @@ -37,6 +26,7 @@ int main(int argc, char **argv) { // ---------------------------------------------------------------------------- // Init of a rips complex from points // ---------------------------------------------------------------------------- + double threshold = 12.0; Rips_complex rips_complex_from_points(points, threshold, Euclidean_distance()); Simplex_tree stree; -- cgit v1.2.3 From ea39d06f10ef0fd4256dcd4552d0434d9ac0a6ad Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 17 Jan 2017 16:02:07 +0000 Subject: using double for filtration value type instead of float (error on windows) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1942 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 796ab5c933f1d0eb18685a0f2f1626b0fa9aa76b --- .../example/example_one_skeleton_rips_from_distance_matrix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp index 765d65ea..90bd8e38 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp @@ -9,7 +9,7 @@ int main() { // Type definitions - using Simplex_tree = Gudhi::Simplex_tree; + using Simplex_tree = Gudhi::Simplex_tree<>; using Filtration_value = Simplex_tree::Filtration_value; using Rips_complex = Gudhi::rips_complex::Rips_complex; using Distance_matrix = std::vector>; -- cgit v1.2.3 From 2023ca9110cbc8638f28640f35505041c01566a9 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 19 Jan 2017 08:58:37 +0000 Subject: Fix ccplint issue git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1956 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 01ffb1d403c65a90d081cf17fe8f595c11a34bab --- src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp | 3 ++- src/Rips_complex/include/gudhi/Rips_complex.h | 3 ++- src/common/include/gudhi/reader_utils.h | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp b/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp index 1d9377df..c8f0921a 100644 --- a/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp +++ b/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp @@ -31,6 +31,8 @@ #include #include #include // infinity +#include // for pair +#include // Types definition using Simplex_tree = Gudhi::Simplex_tree; @@ -175,7 +177,6 @@ template< typename InputPointRange, typename Distance > Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold, Distance distance) { std::vector< Edge_t > edges; std::vector< Filtration_value > edges_fil; - std::map< Vertex_handle, Filtration_value > vertices; Vertex_handle idx_u, idx_v; Filtration_value fil; diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index c7bec34f..f0f39db8 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -160,7 +160,8 @@ class Rips_complex { // Creates the proximity graph from edges and sets the property with the filtration value. // Number of points is labeled from 0 to idx_u-1 // -------------------------------------------------------------------------------------------- - // Do not use : rips_skeleton_graph_ = OneSkeletonGraph(...) -> deep copy of the graph (boost graph is not move-enabled) + // Do not use : rips_skeleton_graph_ = OneSkeletonGraph(...) -> deep copy of the graph (boost graph is not + // move-enabled) rips_skeleton_graph_.~OneSkeletonGraph(); new(&rips_skeleton_graph_)OneSkeletonGraph(edges.begin(), edges.end(), edges_fil.begin(), idx_u); diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 4c8d85cd..97a87edd 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -30,9 +30,10 @@ #include #include #include -#include // for numeric_limits<> +#include // for numeric_limits #include #include +#include // for pair // Keep this file tag for Doxygen to parse the code, otherwise, functions are not documented. // It is required for global functions and variables. -- cgit v1.2.3 From 7ba68a39361109d872bfa284e68d13ad5c8c6231 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 20 Jan 2017 10:04:01 +0000 Subject: Fix code review Remove unused include git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1968 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: dc983a4be66296869cbeddd66b9d48e25a24b5ef --- src/Persistent_cohomology/example/rips_persistence.cpp | 1 - src/Rips_complex/concept/Simplicial_complex_for_rips.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Persistent_cohomology/example/rips_persistence.cpp b/src/Persistent_cohomology/example/rips_persistence.cpp index b70d0283..c6378de7 100644 --- a/src/Persistent_cohomology/example/rips_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_persistence.cpp @@ -21,7 +21,6 @@ */ #include -#include #include #include #include diff --git a/src/Rips_complex/concept/Simplicial_complex_for_rips.h b/src/Rips_complex/concept/Simplicial_complex_for_rips.h index c233a50a..dc871177 100644 --- a/src/Rips_complex/concept/Simplicial_complex_for_rips.h +++ b/src/Rips_complex/concept/Simplicial_complex_for_rips.h @@ -28,7 +28,7 @@ namespace Gudhi { namespace rips_complex { /** \brief The concept SimplicialComplexForRips describes the requirements for a type to implement a simplicial - * complex, that can be created from a `Rips_complex`. + * complex, that can be created from a `Rips_complex`. The only available model for the moment is the `Simplex_tree`. */ struct SimplicialComplexForRips { /** \brief Handle to specify the simplex filtration value. */ -- cgit v1.2.3 From 5f292d2580219097e53753885b02a4cdaba9c798 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 25 Jan 2017 09:58:36 +0000 Subject: Fix code review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_doc_fixes@2008 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d742fb816e1c83a85400d2f0c187e045dcea362f --- .../concept/Simplicial_complex_for_rips.h | 5 ++--- src/Rips_complex/doc/Intro_rips_complex.h | 10 +++++----- ...ample_one_skeleton_rips_from_distance_matrix.cpp | 6 +++--- .../example_one_skeleton_rips_from_points.cpp | 6 +++--- ...e_rips_complex_from_csv_distance_matrix_file.cpp | 6 +++--- .../example/example_rips_complex_from_off_file.cpp | 6 +++--- .../example/full_skeleton_rips_for_doc.txt | 2 +- .../example/one_skeleton_rips_for_doc.txt | 2 +- src/Rips_complex/include/gudhi/Rips_complex.h | 21 ++++++++++----------- src/Rips_complex/test/test_rips_complex.cpp | 16 ++++++++-------- 10 files changed, 39 insertions(+), 41 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/concept/Simplicial_complex_for_rips.h b/src/Rips_complex/concept/Simplicial_complex_for_rips.h index dc871177..7dab0615 100644 --- a/src/Rips_complex/concept/Simplicial_complex_for_rips.h +++ b/src/Rips_complex/concept/Simplicial_complex_for_rips.h @@ -31,11 +31,10 @@ namespace rips_complex { * complex, that can be created from a `Rips_complex`. The only available model for the moment is the `Simplex_tree`. */ struct SimplicialComplexForRips { - /** \brief Handle to specify the simplex filtration value. */ + /** \brief Type used to store the filtration values of the simplicial complex. */ typedef unspecified Filtration_value; - /** \brief Inserts a given range `Gudhi::rips_complex::Rips_complex::OneSkeletonGraph` in the simplicial - * complex. */ + /** \brief Inserts a given `Gudhi::rips_complex::Rips_complex::OneSkeletonGraph` in the simplicial complex. */ template void insert_graph(const OneSkeletonGraph& skel_graph); diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index 64fd34bc..ceecfa7b 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -48,7 +48,7 @@ namespace rips_complex { * All edges that have a filtration value strictly greater than a given threshold value are not inserted into * the complex. * - * When creating a simplicial complex from this one skeleton graph, rips inserts the one skeleton graph into the data + * When creating a simplicial complex from this one skeleton graph, Rips inserts the one skeleton graph into the data * structure, and then expands the simplicial when required. * * \image html "rips_complex_representation.png" "Rips-complex one skeleton graph representation" @@ -68,7 +68,7 @@ namespace rips_complex { * * \include Rips_complex/example_one_skeleton_rips_from_points.cpp * - * When launching (rips maximal distance between 2 points is 12.0, is expanded until dimension 1 - one skeleton graph + * When launching (Rips maximal distance between 2 points is 12.0, is expanded until dimension 1 - one skeleton graph * in other words): * * \code $> ./oneskeletonripspoints @@ -85,7 +85,7 @@ namespace rips_complex { * Then it creates a `Simplex_tree` with it. * * - * Then, it is asked to display information about the rips complex. + * Then, it is asked to display information about the Rips complex. * * \include Rips_complex/example_rips_complex_from_off_file.cpp * @@ -111,7 +111,7 @@ namespace rips_complex { * * \include Rips_complex/example_one_skeleton_rips_from_distance_matrix.cpp * - * When launching (rips maximal distance between 2 points is 1.0, is expanded until dimension 1 - one skeleton graph + * When launching (Rips maximal distance between 2 points is 1.0, is expanded until dimension 1 - one skeleton graph * with other words): * * \code $> ./oneskeletonripsdistance @@ -127,7 +127,7 @@ namespace rips_complex { * Then it creates a `Simplex_tree` with it. * * - * Then, it is asked to display information about the rips complex. + * Then, it is asked to display information about the Rips complex. * * \include Rips_complex/example_rips_complex_from_csv_distance_matrix_file.cpp * diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp index 90bd8e38..bbc3c755 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_distance_matrix.cpp @@ -29,7 +29,7 @@ int main() { distances.push_back({0.11, 0.39, 0.97, 0.30}); // ---------------------------------------------------------------------------- - // Init of a rips complex from points + // Init of a Rips complex from points // ---------------------------------------------------------------------------- double threshold = 1.0; Rips_complex rips_complex_from_points(distances, threshold); @@ -37,13 +37,13 @@ int main() { Simplex_tree stree; rips_complex_from_points.create_complex(stree, 1); // ---------------------------------------------------------------------------- - // Display information about the one skeleton rips complex + // Display information about the one skeleton Rips complex // ---------------------------------------------------------------------------- std::cout << "Rips complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() << " simplices - " << stree.num_vertices() << " vertices." << std::endl; - std::cout << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << + std::cout << "Iterator on Rips complex simplices in the filtration order, with [filtration value]:" << std::endl; for (auto f_simplex : stree.filtration_simplex_range()) { std::cout << " ( "; diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp index 5d1216a0..3fd69ebc 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp @@ -24,7 +24,7 @@ int main() { points.push_back({9.0, 17.0}); // ---------------------------------------------------------------------------- - // Init of a rips complex from points + // Init of a Rips complex from points // ---------------------------------------------------------------------------- double threshold = 12.0; Rips_complex rips_complex_from_points(points, threshold, Euclidean_distance()); @@ -32,13 +32,13 @@ int main() { Simplex_tree stree; rips_complex_from_points.create_complex(stree, 1); // ---------------------------------------------------------------------------- - // Display information about the one skeleton rips complex + // Display information about the one skeleton Rips complex // ---------------------------------------------------------------------------- std::cout << "Rips complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() << " simplices - " << stree.num_vertices() << " vertices." << std::endl; - std::cout << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << + std::cout << "Iterator on Rips complex simplices in the filtration order, with [filtration value]:" << std::endl; for (auto f_simplex : stree.filtration_simplex_range()) { std::cout << " ( "; diff --git a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp index cc6c3a33..ef3a9d13 100644 --- a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp @@ -29,7 +29,7 @@ int main(int argc, char **argv) { using Distance_matrix = std::vector>; // ---------------------------------------------------------------------------- - // Init of a rips complex from a distance matrix in a csv file + // Init of a Rips complex from a distance matrix in a csv file // Default separator is ';' // ---------------------------------------------------------------------------- Distance_matrix distances = read_lower_triangular_matrix_from_csv_file(csv_file_name); @@ -50,13 +50,13 @@ int main(int argc, char **argv) { std::ostream output_stream(streambufffer); // ---------------------------------------------------------------------------- - // Display information about the rips complex + // Display information about the Rips complex // ---------------------------------------------------------------------------- output_stream << "Rips complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() << " simplices - " << stree.num_vertices() << " vertices." << std::endl; - output_stream << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << + output_stream << "Iterator on Rips complex simplices in the filtration order, with [filtration value]:" << std::endl; for (auto f_simplex : stree.filtration_simplex_range()) { output_stream << " ( "; diff --git a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp index b6c961d0..a1e4e255 100644 --- a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp @@ -29,7 +29,7 @@ int main(int argc, char **argv) { using Rips_complex = Gudhi::rips_complex::Rips_complex; // ---------------------------------------------------------------------------- - // Init of a rips complex from an OFF file + // Init of a Rips complex from an OFF file // ---------------------------------------------------------------------------- Gudhi::Points_off_reader off_reader(off_file_name); Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, Euclidean_distance()); @@ -49,13 +49,13 @@ int main(int argc, char **argv) { std::ostream output_stream(streambufffer); // ---------------------------------------------------------------------------- - // Display information about the rips complex + // Display information about the Rips complex // ---------------------------------------------------------------------------- output_stream << "Rips complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() << " simplices - " << stree.num_vertices() << " vertices." << std::endl; - output_stream << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << + output_stream << "Iterator on Rips complex simplices in the filtration order, with [filtration value]:" << std::endl; for (auto f_simplex : stree.filtration_simplex_range()) { output_stream << " ( "; diff --git a/src/Rips_complex/example/full_skeleton_rips_for_doc.txt b/src/Rips_complex/example/full_skeleton_rips_for_doc.txt index 319931e0..55de4ab8 100644 --- a/src/Rips_complex/example/full_skeleton_rips_for_doc.txt +++ b/src/Rips_complex/example/full_skeleton_rips_for_doc.txt @@ -1,5 +1,5 @@ Rips complex is of dimension 3 - 24 simplices - 7 vertices. -Iterator on rips complex simplices in the filtration order, with [filtration value]: +Iterator on Rips complex simplices in the filtration order, with [filtration value]: ( 0 ) -> [0] ( 1 ) -> [0] ( 2 ) -> [0] diff --git a/src/Rips_complex/example/one_skeleton_rips_for_doc.txt b/src/Rips_complex/example/one_skeleton_rips_for_doc.txt index b0e25cc5..706512a5 100644 --- a/src/Rips_complex/example/one_skeleton_rips_for_doc.txt +++ b/src/Rips_complex/example/one_skeleton_rips_for_doc.txt @@ -1,5 +1,5 @@ Rips complex is of dimension 1 - 18 simplices - 7 vertices. -Iterator on rips complex simplices in the filtration order, with [filtration value]: +Iterator on Rips complex simplices in the filtration order, with [filtration value]: ( 0 ) -> [0] ( 1 ) -> [0] ( 2 ) -> [0] diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index f0f39db8..65e742ce 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -51,7 +51,7 @@ namespace rips_complex { * to a given threshold. Edge length is computed from a user given point cloud with a given distance function, or a * distance matrix. * - * \tparam Filtration_value must meet `SimplicialComplexForRips` concept. + * \tparam Filtration_value is the type used to store the filtration values of the simplicial complex. */ template class Rips_complex { @@ -70,7 +70,7 @@ class Rips_complex { /** \brief Rips_complex constructor from a list of points. * * @param[in] points Range of points. - * @param[in] threshold rips value. + * @param[in] threshold Rips value. * @param[in] distance distance function that returns a `Filtration_value` from 2 given points. * * \tparam InputPointRange must be a range for which `std::begin` and `std::end` return input iterators on a @@ -81,20 +81,20 @@ class Rips_complex { */ template Rips_complex(const InputPointRange& points, Filtration_value threshold, Distance distance) { - compute_proximity_graph(points, threshold, distance); + compute_proximity_graph(points, threshold, distance); } /** \brief Rips_complex constructor from a distance matrix. * * @param[in] distance_matrix Range of distances. - * @param[in] threshold rips value. + * @param[in] threshold Rips value. * - * \tparam InputDistanceRange must have a `size()` method and on which `distance_matrix[i][j]` returns - * the distance between points \f$i\f$ and \f$j\f$ as long as \f$ 0 \leqslant i \leqslant j \leqslant + * \tparam DistanceMatrix must have a `size()` method and on which `distance_matrix[i][j]` returns + * the distance between points \f$i\f$ and \f$j\f$ as long as \f$ 0 \leqslant i < j \leqslant * distance\_matrix.size().\f$ */ - template - Rips_complex(const InputDistanceRange& distance_matrix, Filtration_value threshold) { + template + Rips_complex(const DistanceMatrix& distance_matrix, Filtration_value threshold) { compute_proximity_graph(boost::irange((size_t)0, distance_matrix.size()), threshold, [&](size_t i, size_t j){return distance_matrix[j][i];}); } @@ -105,7 +105,7 @@ class Rips_complex { * \tparam SimplicialComplexForRips must meet `SimplicialComplexForRips` concept. * * @param[in] complex SimplicialComplexForRips to be created. - * @param[in] dim_max graph expansion for rips until this given maximal dimension. + * @param[in] dim_max graph expansion for Rips until this given maximal dimension. * @exception std::invalid_argument In debug mode, if `complex.num_vertices()` does not return 0. * */ @@ -144,7 +144,7 @@ class Rips_complex { // -------------------------------------------------------------------------------------------- // Creates the vector of edges and its filtration values (returned by distance function) Vertex_handle idx_u = 0; - for (auto it_u = std::begin(points); it_u != std::end(points); ++it_u) { + for (auto it_u = std::begin(points); it_u != std::end(points); ++it_u, ++idx_u) { Vertex_handle idx_v = idx_u + 1; for (auto it_v = it_u + 1; it_v != std::end(points); ++it_v, ++idx_v) { Filtration_value fil = distance(*it_u, *it_v); @@ -153,7 +153,6 @@ class Rips_complex { edges_fil.push_back(fil); } } - ++idx_u; } // -------------------------------------------------------------------------------------------- diff --git a/src/Rips_complex/test/test_rips_complex.cpp b/src/Rips_complex/test/test_rips_complex.cpp index 1bdd0512..ae68ba0d 100644 --- a/src/Rips_complex/test/test_rips_complex.cpp +++ b/src/Rips_complex/test/test_rips_complex.cpp @@ -51,12 +51,12 @@ bool are_almost_the_same(float a, float b) { BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { // ---------------------------------------------------------------------------- // - // Init of a rips complex from a OFF file + // Init of a Rips complex from a OFF file // // ---------------------------------------------------------------------------- std::string off_file_name("alphacomplexdoc.off"); double rips_threshold = 12.0; - std::cout << "========== OFF FILE NAME = " << off_file_name << " - rips threshold=" << + std::cout << "========== OFF FILE NAME = " << off_file_name << " - Rips threshold=" << rips_threshold << "==========" << std::endl; Gudhi::Points_off_reader off_reader(off_file_name); @@ -185,7 +185,7 @@ BOOST_AUTO_TEST_CASE(Rips_complex_from_points) { points.push_back(Point(coords.begin(), coords.end())); // ---------------------------------------------------------------------------- - // Init of a rips complex from the list of points + // Init of a Rips complex from the list of points // ---------------------------------------------------------------------------- Rips_complex rips_complex_from_points(points, 2.0, Custom_square_euclidean_distance()); @@ -195,7 +195,7 @@ BOOST_AUTO_TEST_CASE(Rips_complex_from_points) { rips_complex_from_points.create_complex(st, DIMENSION); // Another way to check num_simplices - std::cout << "Iterator on rips complex simplices in the filtration order, with [filtration value]:" << std::endl; + std::cout << "Iterator on Rips complex simplices in the filtration order, with [filtration value]:" << std::endl; int num_simplices = 0; for (auto f_simplex : st.filtration_simplex_range()) { num_simplices++; @@ -236,12 +236,12 @@ BOOST_AUTO_TEST_CASE(Rips_complex_from_points) { BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { // ---------------------------------------------------------------------------- // - // Init of a rips complex from a OFF file + // Init of a Rips complex from a OFF file // // ---------------------------------------------------------------------------- std::string csv_file_name("full_square_distance_matrix.csv"); double rips_threshold = 12.0; - std::cout << "========== CSV FILE NAME = " << csv_file_name << " - rips threshold=" << + std::cout << "========== CSV FILE NAME = " << csv_file_name << " - Rips threshold=" << rips_threshold << "==========" << std::endl; Distance_matrix distances = read_lower_triangular_matrix_from_csv_file(csv_file_name); @@ -332,12 +332,12 @@ BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { BOOST_AUTO_TEST_CASE(Rips_create_complex_throw) { // ---------------------------------------------------------------------------- // - // Init of a rips complex from a OFF file + // Init of a Rips complex from a OFF file // // ---------------------------------------------------------------------------- std::string off_file_name("alphacomplexdoc.off"); double rips_threshold = 12.0; - std::cout << "========== OFF FILE NAME = " << off_file_name << " - rips threshold=" << + std::cout << "========== OFF FILE NAME = " << off_file_name << " - Rips threshold=" << rips_threshold << "==========" << std::endl; Gudhi::Points_off_reader off_reader(off_file_name); -- cgit v1.2.3 From d698708b81548a885aeb035cde9af7b270a16dd7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 25 Jan 2017 10:12:29 +0000 Subject: Fix code review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_doc_fixes@2009 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e002ed07e5dd559690ddef60cac4d5941ba4def3 --- src/Rips_complex/include/gudhi/Rips_complex.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index 65e742ce..1e4b76a7 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -51,7 +51,7 @@ namespace rips_complex { * to a given threshold. Edge length is computed from a user given point cloud with a given distance function, or a * distance matrix. * - * \tparam Filtration_value is the type used to store the filtration values of the simplicial complex. + * \tparam Filtration_value is the type used to store the filtration values of the simplicial complex. */ template class Rips_complex { @@ -73,14 +73,14 @@ class Rips_complex { * @param[in] threshold Rips value. * @param[in] distance distance function that returns a `Filtration_value` from 2 given points. * - * \tparam InputPointRange must be a range for which `std::begin` and `std::end` return input iterators on a + * \tparam ForwardPointRange must be a range for which `std::begin` and `std::end` return input iterators on a * point. * * \tparam Distance furnishes `operator()(const Point& p1, const Point& p2)`, where - * `Point` is a point from the `InputPointRange`, and that returns a `Filtration_value`. + * `Point` is a point from the `ForwardPointRange`, and that returns a `Filtration_value`. */ - template - Rips_complex(const InputPointRange& points, Filtration_value threshold, Distance distance) { + template + Rips_complex(const ForwardPointRange& points, Filtration_value threshold, Distance distance) { compute_proximity_graph(points, threshold, distance); } @@ -126,14 +126,14 @@ class Rips_complex { * 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 InputPointRange furnishes `.begin()` and `.end()` + * \tparam ForwardPointRange furnishes `.begin()` and `.end()` * methods. * * \tparam Distance furnishes `operator()(const Point& p1, const Point& p2)`, where - * `Point` is a point from the `InputPointRange`, and that returns a `Filtration_value`. + * `Point` is a point from the `ForwardPointRange`, and that returns a `Filtration_value`. */ - template< typename InputPointRange, typename Distance > - void compute_proximity_graph(const InputPointRange& points, Filtration_value threshold, + template< typename ForwardPointRange, typename Distance > + void compute_proximity_graph(const ForwardPointRange& points, Filtration_value threshold, Distance distance) { std::vector< std::pair< Vertex_handle, Vertex_handle > > edges; std::vector< Filtration_value > edges_fil; -- cgit v1.2.3 From dea1b04f72b5e77f61320e7a328d85ffbe088aa0 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 25 Jan 2017 10:21:32 +0000 Subject: Fix code review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_doc_fixes@2010 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 939e4bc3fb8af5cb0b00ab2e011b4de4b2b4b41e --- src/Rips_complex/doc/Intro_rips_complex.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index ceecfa7b..945027dc 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -50,6 +50,8 @@ namespace rips_complex { * * When creating a simplicial complex from this one skeleton graph, Rips inserts the one skeleton graph into the data * structure, and then expands the simplicial when required. + * + * Vertex name correspond to the index of the point in the given range (aka. the point cloud). * * \image html "rips_complex_representation.png" "Rips-complex one skeleton graph representation" * -- cgit v1.2.3 From d674c67bdfdee94bc23a720865834ef22088679b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 25 Jan 2017 11:54:08 +0000 Subject: Code review fix git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_doc_fixes@2011 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0f2751802f4a6f4e75dfd3dbea08d57fe081e8f9 --- .../example/rips_persistence_step_by_step.cpp | 7 +++++++ src/Rips_complex/doc/Intro_rips_complex.h | 4 ++++ 2 files changed, 11 insertions(+) (limited to 'src/Rips_complex') diff --git a/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp b/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp index c8f0921a..b159c62e 100644 --- a/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp +++ b/src/Persistent_cohomology/example/rips_persistence_step_by_step.cpp @@ -34,6 +34,13 @@ #include // for pair #include +// ---------------------------------------------------------------------------- +// rips_persistence_step_by_step is an example of each step that is required to +// build a Rips over a Simplex_tree. Please refer to rips_persistence to see +// how to do the same thing with the Rips_complex wrapper for less detailed +// steps. +// ---------------------------------------------------------------------------- + // Types definition using Simplex_tree = Gudhi::Simplex_tree; using Vertex_handle = Simplex_tree::Vertex_handle; diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index 945027dc..4318e5da 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -59,6 +59,10 @@ namespace rips_complex { * value set with \f$max(filtration(4,5), filtration(4,6), filtration(5,6))\f$. * And so on for simplex (0,1,2,3). * + * If the Rips_complex interfaces are not detailed enough for your need, please refer to + * + * rips_persistence_step_by_step.cpp example, where the graph construction over the Simplex_tree is more detailed. + * * \section ripspointsdistance Point cloud and distance function * * \subsection ripspointscloudexample Example from a point cloud and a distance function -- cgit v1.2.3 From ee78c169e19a75c180a27e7a9a29242e445533f9 Mon Sep 17 00:00:00 2001 From: cjamin Date: Mon, 30 Jan 2017 14:35:47 +0000 Subject: Missing word git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2029 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6260e9a89d40c8930ae723d80baef2a507ea41b6 --- src/Rips_complex/doc/Intro_rips_complex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index 64fd34bc..884a4eff 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -49,7 +49,7 @@ namespace rips_complex { * the complex. * * When creating a simplicial complex from this one skeleton graph, rips inserts the one skeleton graph into the data - * structure, and then expands the simplicial when required. + * structure, and then expands the simplicial complex when required. * * \image html "rips_complex_representation.png" "Rips-complex one skeleton graph representation" * -- cgit v1.2.3 From a424f92e94783648422edbd639da19d92a94cf90 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 31 Jan 2017 21:35:37 +0000 Subject: Rename Rips and Alpha concept file names GUDHI version 2.0.0 git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_doc_2.0.0@2038 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: be93fae5a69b15de05bfabe75a2d84ef606b589f --- CMakeGUDHIVersion.txt | 6 +- .../concept/SimplicialComplexForAlpha.h | 89 ++++++++++++++++++++++ .../concept/Simplicial_complex_for_alpha.h | 89 ---------------------- .../concept/SimplicialComplexForRips.h | 54 +++++++++++++ .../concept/Simplicial_complex_for_rips.h | 54 ------------- src/common/doc/main_page.h | 6 +- 6 files changed, 149 insertions(+), 149 deletions(-) create mode 100644 src/Alpha_complex/concept/SimplicialComplexForAlpha.h delete mode 100644 src/Alpha_complex/concept/Simplicial_complex_for_alpha.h create mode 100644 src/Rips_complex/concept/SimplicialComplexForRips.h delete mode 100644 src/Rips_complex/concept/Simplicial_complex_for_rips.h (limited to 'src/Rips_complex') diff --git a/CMakeGUDHIVersion.txt b/CMakeGUDHIVersion.txt index a00ae1b2..bd0c57ac 100644 --- a/CMakeGUDHIVersion.txt +++ b/CMakeGUDHIVersion.txt @@ -1,6 +1,6 @@ -set (GUDHI_MAJOR_VERSION 1) -set (GUDHI_MINOR_VERSION 3) -set (GUDHI_PATCH_VERSION 1) +set (GUDHI_MAJOR_VERSION 2) +set (GUDHI_MINOR_VERSION 0) +set (GUDHI_PATCH_VERSION 0) set(GUDHI_VERSION ${GUDHI_MAJOR_VERSION}.${GUDHI_MINOR_VERSION}.${GUDHI_PATCH_VERSION}) message(STATUS "GUDHI version : ${GUDHI_VERSION}") diff --git a/src/Alpha_complex/concept/SimplicialComplexForAlpha.h b/src/Alpha_complex/concept/SimplicialComplexForAlpha.h new file mode 100644 index 00000000..2b8bff94 --- /dev/null +++ b/src/Alpha_complex/concept/SimplicialComplexForAlpha.h @@ -0,0 +1,89 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2016 INRIA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ +#define CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ + +namespace Gudhi { + +namespace alpha_complex { + +/** \brief The concept SimplicialComplexForAlpha describes the requirements for a type to implement a simplicial + * complex, that can be created from a `Alpha_complex`. + */ +struct SimplicialComplexForAlpha { + /** Handle to specify a simplex. */ + typedef unspecified Simplex_handle; + /** Handle to specify a vertex. Must be a non-negative integer. */ + typedef unspecified Vertex_handle; + /** Handle to specify the simplex filtration value. */ + typedef unspecified Filtration_value; + + /** Returns the number of vertices in the simplicial complex. */ + std::size_t num_vertices(); + + /** Sets the simplicial complex dimension. */ + void set_dimension(int dimension); + + /** Gets the 'simplex' dimension. */ + int dimension(Simplex_handle simplex); + + /** Assigns the 'simplex' with the given 'filtration' value. */ + int assign_filtration(Simplex_handle simplex, Filtration_value filtration); + + /** \brief Inserts a simplex with vertices from a given simplex (represented by a vector of Vertex_handle) in the + * simplicial complex with the given 'filtration' value. */ + void insert_simplex_and_subfaces(std::vector const & vertex_range, Filtration_value filtration); + + /** Browses the simplicial complex to make the filtration non-decreasing. */ + void make_filtration_non_decreasing(); + + /** Prune the simplicial complex above 'filtration' value given as parameter. */ + void prune_above_filtration(Filtration_value filtration); + + /** \brief Iterator over vertices of a simplex. + * + * 'value type' must be 'Vertex_handle'.*/ + typedef unspecified Simplex_vertex_range; + + /** \brief Returns a range over vertices of a given + * simplex. */ + Simplex_vertex_range simplex_vertex_range(Simplex_handle const & simplex); + + /** \brief Iterator over the boundaries of the complex, in an arbitrary order. + * + * 'value_type' must be 'Simplex_handle'.*/ + typedef unspecified Boundary_simplex_range; + + /** \brief Returns a range over boundaries of a given simplex. */ + Boundary_simplex_range boundary_simplex_range(Simplex_handle const & simplex); + + /** \brief Return type of an insertion of a simplex + */ + typedef unspecified Insertion_result_type; +}; + +} // namespace alpha_complex + +} // namespace Gudhi + +#endif // CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ diff --git a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h deleted file mode 100644 index 2b8bff94..00000000 --- a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h +++ /dev/null @@ -1,89 +0,0 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ - * library for computational topology. - * - * Author(s): Vincent Rouvreau - * - * Copyright (C) 2016 INRIA - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ -#define CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ - -namespace Gudhi { - -namespace alpha_complex { - -/** \brief The concept SimplicialComplexForAlpha describes the requirements for a type to implement a simplicial - * complex, that can be created from a `Alpha_complex`. - */ -struct SimplicialComplexForAlpha { - /** Handle to specify a simplex. */ - typedef unspecified Simplex_handle; - /** Handle to specify a vertex. Must be a non-negative integer. */ - typedef unspecified Vertex_handle; - /** Handle to specify the simplex filtration value. */ - typedef unspecified Filtration_value; - - /** Returns the number of vertices in the simplicial complex. */ - std::size_t num_vertices(); - - /** Sets the simplicial complex dimension. */ - void set_dimension(int dimension); - - /** Gets the 'simplex' dimension. */ - int dimension(Simplex_handle simplex); - - /** Assigns the 'simplex' with the given 'filtration' value. */ - int assign_filtration(Simplex_handle simplex, Filtration_value filtration); - - /** \brief Inserts a simplex with vertices from a given simplex (represented by a vector of Vertex_handle) in the - * simplicial complex with the given 'filtration' value. */ - void insert_simplex_and_subfaces(std::vector const & vertex_range, Filtration_value filtration); - - /** Browses the simplicial complex to make the filtration non-decreasing. */ - void make_filtration_non_decreasing(); - - /** Prune the simplicial complex above 'filtration' value given as parameter. */ - void prune_above_filtration(Filtration_value filtration); - - /** \brief Iterator over vertices of a simplex. - * - * 'value type' must be 'Vertex_handle'.*/ - typedef unspecified Simplex_vertex_range; - - /** \brief Returns a range over vertices of a given - * simplex. */ - Simplex_vertex_range simplex_vertex_range(Simplex_handle const & simplex); - - /** \brief Iterator over the boundaries of the complex, in an arbitrary order. - * - * 'value_type' must be 'Simplex_handle'.*/ - typedef unspecified Boundary_simplex_range; - - /** \brief Returns a range over boundaries of a given simplex. */ - Boundary_simplex_range boundary_simplex_range(Simplex_handle const & simplex); - - /** \brief Return type of an insertion of a simplex - */ - typedef unspecified Insertion_result_type; -}; - -} // namespace alpha_complex - -} // namespace Gudhi - -#endif // CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ diff --git a/src/Rips_complex/concept/SimplicialComplexForRips.h b/src/Rips_complex/concept/SimplicialComplexForRips.h new file mode 100644 index 00000000..7dab0615 --- /dev/null +++ b/src/Rips_complex/concept/SimplicialComplexForRips.h @@ -0,0 +1,54 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2016 INRIA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ +#define CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ + +namespace Gudhi { + +namespace rips_complex { + +/** \brief The concept SimplicialComplexForRips describes the requirements for a type to implement a simplicial + * complex, that can be created from a `Rips_complex`. The only available model for the moment is the `Simplex_tree`. + */ +struct SimplicialComplexForRips { + /** \brief Type used to store the filtration values of the simplicial complex. */ + typedef unspecified Filtration_value; + + /** \brief Inserts a given `Gudhi::rips_complex::Rips_complex::OneSkeletonGraph` in the simplicial complex. */ + template + void insert_graph(const OneSkeletonGraph& skel_graph); + + /** \brief Expands the simplicial complex containing only its one skeleton until a given maximal dimension as + * explained in \ref ripsdefinition. */ + void expansion(int max_dim); + + /** \brief Returns the number of vertices in the simplicial complex. */ + std::size_t num_vertices(); + +}; + +} // namespace rips_complex + +} // namespace Gudhi + +#endif // CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ diff --git a/src/Rips_complex/concept/Simplicial_complex_for_rips.h b/src/Rips_complex/concept/Simplicial_complex_for_rips.h deleted file mode 100644 index 7dab0615..00000000 --- a/src/Rips_complex/concept/Simplicial_complex_for_rips.h +++ /dev/null @@ -1,54 +0,0 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ - * library for computational topology. - * - * Author(s): Vincent Rouvreau - * - * Copyright (C) 2016 INRIA - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ -#define CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ - -namespace Gudhi { - -namespace rips_complex { - -/** \brief The concept SimplicialComplexForRips describes the requirements for a type to implement a simplicial - * complex, that can be created from a `Rips_complex`. The only available model for the moment is the `Simplex_tree`. - */ -struct SimplicialComplexForRips { - /** \brief Type used to store the filtration values of the simplicial complex. */ - typedef unspecified Filtration_value; - - /** \brief Inserts a given `Gudhi::rips_complex::Rips_complex::OneSkeletonGraph` in the simplicial complex. */ - template - void insert_graph(const OneSkeletonGraph& skel_graph); - - /** \brief Expands the simplicial complex containing only its one skeleton until a given maximal dimension as - * explained in \ref ripsdefinition. */ - void expansion(int max_dim); - - /** \brief Returns the number of vertices in the simplicial complex. */ - std::size_t num_vertices(); - -}; - -} // namespace rips_complex - -} // namespace Gudhi - -#endif // CONCEPT_RIPS_COMPLEX_SIMPLICIAL_COMPLEX_FOR_RIPS_H_ diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index 60c9cd07..5e8f1dd7 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -62,7 +62,7 @@
-- cgit v1.2.3 From 6a583dcf44e801aa7045ede96dee6c0f3505f625 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 28 Feb 2017 15:04:48 +0000 Subject: csv file and not OFF git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_doc_2.0.0@2119 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e4cd541c47a9061019a3a04f47849e8c77df418a --- .../example/example_rips_complex_from_csv_distance_matrix_file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp index ef3a9d13..7ae8126f 100644 --- a/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_csv_distance_matrix_file.cpp @@ -1,5 +1,5 @@ #include -// to construct Rips_complex from a OFF file of points +// to construct Rips_complex from a csv file representing a distance matrix #include #include #include -- cgit v1.2.3 From fd510e6380ec12f3c909ccff5ee78dd7d13b8855 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 3 Mar 2017 09:52:20 +0000 Subject: Add GPL copyrights on images directories git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_doc_2.0.0@2142 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d6bdcfdefb00263199b22fcc39cdb8826f8f3dbe --- src/Alpha_complex/doc/COPYRIGHT | 19 +++++++++++++++++++ src/Bitmap_cubical_complex/doc/COPYRIGHT | 19 +++++++++++++++++++ src/Bottleneck_distance/doc/COPYRIGHT | 19 +++++++++++++++++++ src/Contraction/doc/COPYRIGHT | 18 ++++++++++++++++++ src/Persistent_cohomology/doc/COPYRIGHT | 19 +++++++++++++++++++ src/Rips_complex/doc/COPYRIGHT | 19 +++++++++++++++++++ src/Simplex_tree/doc/COPYRIGHT | 19 +++++++++++++++++++ src/Skeleton_blocker/doc/COPYRIGHT | 18 ++++++++++++++++++ src/Tangential_complex/doc/COPYRIGHT | 19 +++++++++++++++++++ src/Witness_complex/doc/COPYRIGHT | 19 +++++++++++++++++++ 10 files changed, 188 insertions(+) create mode 100644 src/Alpha_complex/doc/COPYRIGHT create mode 100644 src/Bitmap_cubical_complex/doc/COPYRIGHT create mode 100644 src/Bottleneck_distance/doc/COPYRIGHT create mode 100644 src/Contraction/doc/COPYRIGHT create mode 100644 src/Persistent_cohomology/doc/COPYRIGHT create mode 100644 src/Rips_complex/doc/COPYRIGHT create mode 100644 src/Simplex_tree/doc/COPYRIGHT create mode 100644 src/Skeleton_blocker/doc/COPYRIGHT create mode 100644 src/Tangential_complex/doc/COPYRIGHT create mode 100644 src/Witness_complex/doc/COPYRIGHT (limited to 'src/Rips_complex') diff --git a/src/Alpha_complex/doc/COPYRIGHT b/src/Alpha_complex/doc/COPYRIGHT new file mode 100644 index 00000000..dbad2380 --- /dev/null +++ b/src/Alpha_complex/doc/COPYRIGHT @@ -0,0 +1,19 @@ +The files of this directory are part of the Gudhi Library. The Gudhi library +(Geometric Understanding in Higher Dimensions) is a generic C++ library for +computational topology. + +Author(s): Vincent Rouvreau + +Copyright (C) 2015 INRIA + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . diff --git a/src/Bitmap_cubical_complex/doc/COPYRIGHT b/src/Bitmap_cubical_complex/doc/COPYRIGHT new file mode 100644 index 00000000..bcd46b23 --- /dev/null +++ b/src/Bitmap_cubical_complex/doc/COPYRIGHT @@ -0,0 +1,19 @@ +The files of this directory are part of the Gudhi Library. The Gudhi library +(Geometric Understanding in Higher Dimensions) is a generic C++ library for +computational topology. + +Author(s): Pawel Dlotko + +Copyright (C) 2015 INRIA + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . diff --git a/src/Bottleneck_distance/doc/COPYRIGHT b/src/Bottleneck_distance/doc/COPYRIGHT new file mode 100644 index 00000000..179740a6 --- /dev/null +++ b/src/Bottleneck_distance/doc/COPYRIGHT @@ -0,0 +1,19 @@ +The files of this directory are part of the Gudhi Library. The Gudhi library +(Geometric Understanding in Higher Dimensions) is a generic C++ library for +computational topology. + +Author(s): François Godi + +Copyright (C) 2015 INRIA + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . diff --git a/src/Contraction/doc/COPYRIGHT b/src/Contraction/doc/COPYRIGHT new file mode 100644 index 00000000..1de850d7 --- /dev/null +++ b/src/Contraction/doc/COPYRIGHT @@ -0,0 +1,18 @@ +The files of this directory are part of the Gudhi Library. The Gudhi library +(Geometric Understanding in Higher Dimensions) is a generic C++ library for +computational topology. + +Author(s): David Salinas +Copyright (C) 2015 INRIA + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . diff --git a/src/Persistent_cohomology/doc/COPYRIGHT b/src/Persistent_cohomology/doc/COPYRIGHT new file mode 100644 index 00000000..34345bef --- /dev/null +++ b/src/Persistent_cohomology/doc/COPYRIGHT @@ -0,0 +1,19 @@ +The files of this directory are part of the Gudhi Library. The Gudhi library +(Geometric Understanding in Higher Dimensions) is a generic C++ library for +computational topology. + +Author(s): Clément Maria + +Copyright (C) 2015 INRIA + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . diff --git a/src/Rips_complex/doc/COPYRIGHT b/src/Rips_complex/doc/COPYRIGHT new file mode 100644 index 00000000..594b7d03 --- /dev/null +++ b/src/Rips_complex/doc/COPYRIGHT @@ -0,0 +1,19 @@ +The files of this directory are part of the Gudhi Library. The Gudhi library +(Geometric Understanding in Higher Dimensions) is a generic C++ library for +computational topology. + +Author(s): Clément Maria, Pawel Dlotko, Vincent Rouvreau + +Copyright (C) 2015 INRIA + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . diff --git a/src/Simplex_tree/doc/COPYRIGHT b/src/Simplex_tree/doc/COPYRIGHT new file mode 100644 index 00000000..34345bef --- /dev/null +++ b/src/Simplex_tree/doc/COPYRIGHT @@ -0,0 +1,19 @@ +The files of this directory are part of the Gudhi Library. The Gudhi library +(Geometric Understanding in Higher Dimensions) is a generic C++ library for +computational topology. + +Author(s): Clément Maria + +Copyright (C) 2015 INRIA + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . diff --git a/src/Skeleton_blocker/doc/COPYRIGHT b/src/Skeleton_blocker/doc/COPYRIGHT new file mode 100644 index 00000000..1de850d7 --- /dev/null +++ b/src/Skeleton_blocker/doc/COPYRIGHT @@ -0,0 +1,18 @@ +The files of this directory are part of the Gudhi Library. The Gudhi library +(Geometric Understanding in Higher Dimensions) is a generic C++ library for +computational topology. + +Author(s): David Salinas +Copyright (C) 2015 INRIA + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . diff --git a/src/Tangential_complex/doc/COPYRIGHT b/src/Tangential_complex/doc/COPYRIGHT new file mode 100644 index 00000000..c4df0f64 --- /dev/null +++ b/src/Tangential_complex/doc/COPYRIGHT @@ -0,0 +1,19 @@ +The files of this directory are part of the Gudhi Library. The Gudhi library +(Geometric Understanding in Higher Dimensions) is a generic C++ library for +computational topology. + +Author(s): Clement Jamin + +Copyright (C) 2015 INRIA + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . diff --git a/src/Witness_complex/doc/COPYRIGHT b/src/Witness_complex/doc/COPYRIGHT new file mode 100644 index 00000000..7d032c87 --- /dev/null +++ b/src/Witness_complex/doc/COPYRIGHT @@ -0,0 +1,19 @@ +The files of this directory are part of the Gudhi Library. The Gudhi library +(Geometric Understanding in Higher Dimensions) is a generic C++ library for +computational topology. + +Author(s): Siargey Kachanovich + +Copyright (C) 2015 INRIA + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . -- cgit v1.2.3
- Author: Clément Maria
+ Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau
Introduced in: GUDHI 1.4.0
Copyright: GPL v3
Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau
- Introduced in: GUDHI 1.4.0
+ Introduced in: GUDHI 2.0.0
Copyright: GPL v3
@@ -118,7 +118,7 @@
Author: Clément Jamin
- Introduced in: GUDHI 1.4.0
+ Introduced in: GUDHI 2.0.0
Copyright: GPL v3
@@ -155,7 +155,7 @@
Author: François Godi
- Introduced in: GUDHI 1.4.0
+ Introduced in: GUDHI 2.0.0
Copyright: GPL v3
Requires: \ref cgal ≥ 4.8.0 and \ref eigen3