From 8194773c116763e538b6a542fccbd92ec1537372 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 23 Jun 2017 15:07:18 +0000 Subject: First version of expansion with blocker oracle git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2562 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 755af58e3688d00b43edd9616fd903cce1eca704 --- src/Simplex_tree/example/CMakeLists.txt | 24 ----------- src/Simplex_tree/include/gudhi/Simplex_tree.h | 59 ++++++++++++++++++++------- 2 files changed, 44 insertions(+), 39 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index cfac0da6..d05bb187 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -36,27 +36,3 @@ if(GMP_FOUND AND CGAL_FOUND) install(TARGETS Simplex_tree_example_alpha_shapes_3_from_off DESTINATION bin) endif() - - -add_executable(rips_step_by_step rips_step_by_step.cpp) -target_link_libraries(rips_step_by_step ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) -if (TBB_FOUND) - target_link_libraries(rips_step_by_step ${TBB_LIBRARIES}) -endif() - -add_executable(cgal_rips_step_by_step cgal_rips_step_by_step.cpp) -target_link_libraries(cgal_rips_step_by_step ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) -if (TBB_FOUND) - target_link_libraries(cgal_rips_step_by_step ${TBB_LIBRARIES}) -endif() - -add_executable(cgal_euclidean_distance cgal_euclidean_distance.cpp) -if (TBB_FOUND) - target_link_libraries(cgal_euclidean_distance ${TBB_LIBRARIES}) -endif() - -add_executable(subsamp_rips_step_by_step subsamp_rips_step_by_step.cpp) -target_link_libraries(subsamp_rips_step_by_step ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) -if (TBB_FOUND) - target_link_libraries(subsamp_rips_step_by_step ${TBB_LIBRARIES}) -endif() diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 317bce23..a83623a5 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1007,11 +1007,35 @@ class Simplex_tree { * The Simplex_tree must contain no simplex of dimension bigger than * 1 when calling the method. */ void expansion(int max_dim) { + expansion_with_blockers(max_dim, + [](Simplex_handle origin_sh, + Simplex_handle dict1_sh, + Simplex_handle dict2_sh) { + // Default blocker is always insert with the maximal filtration value between + // origin, dict1 and dict2 + return std::make_pair(true, (std::max)({origin_sh->second.filtration(), + dict1_sh->second.filtration(), + dict2_sh->second.filtration()})); }); + } + + /** \brief Expands the Simplex_tree containing only its one skeleton + * until dimension max_dim. + * + * The expanded simplicial complex until dimension \f$d\f$ + * attached to a graph \f$G\f$ is the maximal simplicial complex of + * dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. + * The filtration value assigned to a simplex is the maximal filtration + * value of one of its edges. + * + * The Simplex_tree must contain no simplex of dimension bigger than + * 1 when calling the method. */ + template< typename Blocker > + void expansion_with_blockers(int max_dim, Blocker blocker_expansion_function) { dimension_ = max_dim; for (Dictionary_it root_it = root_.members_.begin(); root_it != root_.members_.end(); ++root_it) { if (has_children(root_it)) { - siblings_expansion(root_it->second.children(), max_dim - 1); + siblings_expansion_with_blockers(root_it->second.children(), max_dim - 1, blocker_expansion_function); } } dimension_ = max_dim - dimension_; @@ -1019,8 +1043,9 @@ class Simplex_tree { private: /** \brief Recursive expansion of the simplex tree.*/ - void siblings_expansion(Siblings * siblings, // must contain elements - int k) { + template< typename Blocker > + void siblings_expansion_with_blockers(Siblings * siblings, // must contain elements + int k, Blocker blocker_expansion_function) { if (dimension_ > k) { dimension_ = k; } @@ -1034,20 +1059,21 @@ class Simplex_tree { s_h != siblings->members().end(); ++s_h, ++next) { Simplex_handle root_sh = find_vertex(s_h->first); if (has_children(root_sh)) { - intersection( - inter, // output intersection - next, // begin - siblings->members().end(), // end - root_sh->second.children()->members().begin(), - root_sh->second.children()->members().end(), - s_h->second.filtration()); + intersection_with_blockers( + inter, // output intersection + next, // begin + siblings->members().end(), // end + root_sh->second.children()->members().begin(), + root_sh->second.children()->members().end(), + s_h, blocker_expansion_function); if (inter.size() != 0) { Siblings * new_sib = new Siblings(siblings, // oncles s_h->first, // parent inter); // boost::container::ordered_unique_range_t + // As siblings_expansion_with_blockers is recusively called, inter must be cleared before inter.clear(); s_h->second.assign_children(new_sib); - siblings_expansion(new_sib, k - 1); + siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); } else { // ensure the children property s_h->second.assign_children(siblings); @@ -1059,16 +1085,19 @@ class Simplex_tree { /** \brief Intersects Dictionary 1 [begin1;end1) with Dictionary 2 [begin2,end2) * and assigns the maximal possible Filtration_value to the Nodes. */ - static void intersection(std::vector >& intersection, + template< typename Blocker > + static void intersection_with_blockers(std::vector >& intersection, Dictionary_it begin1, Dictionary_it end1, Dictionary_it begin2, Dictionary_it end2, - Filtration_value filtration_) { + Dictionary_it origin_sh, + Blocker blocker_expansion_function) { if (begin1 == end1 || begin2 == end2) return; // ----->> while (true) { if (begin1->first == begin2->first) { - Filtration_value filt = (std::max)({begin1->second.filtration(), begin2->second.filtration(), filtration_}); - intersection.emplace_back(begin1->first, Node(nullptr, filt)); + std::pair blocker_result = blocker_expansion_function(origin_sh, begin1, begin2); + if (blocker_result.first) + intersection.emplace_back(begin1->first, Node(nullptr, blocker_result.second)); if (++begin1 == end1 || ++begin2 == end2) return; // ----->> } else if (begin1->first < begin2->first) { -- cgit v1.2.3 From 5c4d2b4a40ca149702253a2412cb7a63a182ff92 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 26 Jun 2017 15:17:28 +0000 Subject: A test of Cech complex with oracle blocker git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2563 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6c4325dd1ca53a92f4f3de3ed32323c8b6505f5d --- src/Simplex_tree/example/CMakeLists.txt | 9 + .../example/cech_complex_step_by_step.cpp | 240 +++++++++++++++++++++ src/Simplex_tree/include/gudhi/Simplex_tree.h | 11 +- src/common/include/gudhi/Points_off_io.h | 2 +- 4 files changed, 257 insertions(+), 5 deletions(-) create mode 100644 src/Simplex_tree/example/cech_complex_step_by_step.cpp (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index d05bb187..5dbbfcc0 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -36,3 +36,12 @@ if(GMP_FOUND AND CGAL_FOUND) install(TARGETS Simplex_tree_example_alpha_shapes_3_from_off DESTINATION bin) endif() + +add_executable ( Simplex_tree_example_cech_complex_step_by_step cech_complex_step_by_step.cpp) +target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${Boost_PROGRAM_OPTIONS_LIBRARY}) +if (TBB_FOUND) + target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${TBB_LIBRARIES}) +endif() +add_test(NAME Simplex_tree_example_cech_complex_step_by_step COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "-r" "12." "-d" "3") +install(TARGETS Simplex_tree_example_cech_complex_step_by_step DESTINATION bin) diff --git a/src/Simplex_tree/example/cech_complex_step_by_step.cpp b/src/Simplex_tree/example/cech_complex_step_by_step.cpp new file mode 100644 index 00000000..b5cda443 --- /dev/null +++ b/src/Simplex_tree/example/cech_complex_step_by_step.cpp @@ -0,0 +1,240 @@ +/* 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 + +#include + +#include +#include +#include // infinity +#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; +using Simplex_handle = Simplex_tree::Simplex_handle; +using Filtration_value = Simplex_tree::Filtration_value; +using Siblings = Simplex_tree::Siblings; +using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS +, boost::property < vertex_filtration_t, Filtration_value > +, boost::property < edge_filtration_t, Filtration_value > +>; +using Edge_t = std::pair< Vertex_handle, Vertex_handle >; + +// using Kernel = CGAL::Epick_d< CGAL::Dimension_tag<2> >;// CGAL::Dynamic_dimension_tag >; +typedef CGAL::Cartesian_d Kernel; +typedef CGAL::Optimisation_d_traits_d Traits; +typedef CGAL::Min_sphere_d Min_sphere; + +using Point = Kernel::Point_d; +using Points_off_reader = Gudhi::Points_off_reader; +// using Min_sphere = CGAL::Min_sphere_d; + +class Cech_blocker { + public: + std::pair operator()(Simplex_handle origin_sh, Simplex_handle dict1_sh, Simplex_handle dict2_sh, Siblings* siblings) { + //std::vector path = {dict1_sh->first, origin_sh->first}; + Siblings* sib_path = siblings; + std::vector sphere_points = {point_cloud_[dict1_sh->first], point_cloud_[origin_sh->first]}; + do { + //path.push_back(sib_path->parent()); + sphere_points.push_back(point_cloud_[sib_path->parent()]); + sib_path = sib_path->oncles(); + } while (sib_path->oncles() != nullptr); + /*std::cout << square_threshold_ << "-"; + for (auto vh : path) { + std::cout << vh << " "; + } + std::cout << std::endl;*/ + Min_sphere min_sphere(sphere_points.begin(), sphere_points.end()); + //std::cout << min_sphere.squared_radius() << std::endl; + Filtration_value squared_diameter = min_sphere.squared_radius() * 4.; + // Default blocker is always insert with the maximal filtration value between + // origin, dict1 and dict2 + return std::make_pair(squared_diameter < square_threshold_, + squared_diameter); + } + Cech_blocker(Filtration_value threshold, const std::vector& point_cloud) + : square_threshold_(threshold * threshold), + point_cloud_(point_cloud) { } + private: + Filtration_value square_threshold_; + std::vector point_cloud_; +}; + +template< typename InputPointRange> +Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold); + +void program_options(int argc, char * argv[] + , std::string & off_file_points + , Filtration_value & threshold + , int & dim_max); + +int main(int argc, char * argv[]) { + std::string off_file_points; + Filtration_value threshold; + int dim_max; + + program_options(argc, argv, off_file_points, threshold, dim_max); + + // Extract the points from the file filepoints + Points_off_reader off_reader(off_file_points); + + // Compute the proximity graph of the points + Graph_t prox_graph = compute_proximity_graph(off_reader.get_point_cloud(), threshold); + + //Min_sphere sph1(off_reader.get_point_cloud()[0], off_reader.get_point_cloud()[1], off_reader.get_point_cloud()[2]); + // Construct the Rips complex in a Simplex Tree + Simplex_tree st; + // insert the proximity graph in the simplex tree + st.insert_graph(prox_graph); + // expand the graph until dimension dim_max + st.expansion_with_blockers(dim_max, Cech_blocker(threshold, off_reader.get_point_cloud())); + + std::cout << "The complex contains " << st.num_simplices() << " simplices \n"; + std::cout << " and has dimension " << st.dimension() << " \n"; + + // Sort the simplices in the order of the filtration + st.initialize_filtration(); + + std::cout << "********************************************************************\n"; + // Display the Simplex_tree - Can not be done in the middle of 2 inserts + std::cout << "* The complex contains " << st.num_simplices() << " simplices\n"; + std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : st.filtration_simplex_range()) { + std::cout << " " << "[" << st.filtration(f_simplex) << "] "; + for (auto vertex : st.simplex_vertex_range(f_simplex)) { + std::cout << static_cast(vertex) << " "; + } + std::cout << std::endl; + } + + return 0; +} + +void program_options(int argc, char * argv[] + , std::string & off_file_points + , Filtration_value & threshold + , int & dim_max) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options() + ("input-file", po::value(&off_file_points), + "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") + ("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."); + + 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 << "Construct a Cech complex defined on a set of input points.\n \n"; + + std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} + +/** 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> +Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold) { + std::vector< Edge_t > edges; + std::vector< Filtration_value > edges_fil; + + Kernel k; + Filtration_value square_threshold = threshold * threshold; + + 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 = k.squared_distance_d_object()(*it_u, *it_v); + if (fil <= square_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; +} diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index a83623a5..dbed47b8 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1010,7 +1010,8 @@ class Simplex_tree { expansion_with_blockers(max_dim, [](Simplex_handle origin_sh, Simplex_handle dict1_sh, - Simplex_handle dict2_sh) { + Simplex_handle dict2_sh, + Siblings* siblings) { // Default blocker is always insert with the maximal filtration value between // origin, dict1 and dict2 return std::make_pair(true, (std::max)({origin_sh->second.filtration(), @@ -1044,7 +1045,7 @@ class Simplex_tree { private: /** \brief Recursive expansion of the simplex tree.*/ template< typename Blocker > - void siblings_expansion_with_blockers(Siblings * siblings, // must contain elements + void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements int k, Blocker blocker_expansion_function) { if (dimension_ > k) { dimension_ = k; @@ -1065,7 +1066,8 @@ class Simplex_tree { siblings->members().end(), // end root_sh->second.children()->members().begin(), root_sh->second.children()->members().end(), - s_h, blocker_expansion_function); + s_h, siblings, + blocker_expansion_function); if (inter.size() != 0) { Siblings * new_sib = new Siblings(siblings, // oncles s_h->first, // parent @@ -1090,12 +1092,13 @@ class Simplex_tree { Dictionary_it begin1, Dictionary_it end1, Dictionary_it begin2, Dictionary_it end2, Dictionary_it origin_sh, + Siblings* siblings, Blocker blocker_expansion_function) { if (begin1 == end1 || begin2 == end2) return; // ----->> while (true) { if (begin1->first == begin2->first) { - std::pair blocker_result = blocker_expansion_function(origin_sh, begin1, begin2); + std::pair blocker_result = blocker_expansion_function(origin_sh, begin1, begin2, siblings); if (blocker_result.first) intersection.emplace_back(begin1->first, Node(nullptr, blocker_result.second)); if (++begin1 == end1 || ++begin2 == end2) diff --git a/src/common/include/gudhi/Points_off_io.h b/src/common/include/gudhi/Points_off_io.h index 29af8a8a..2104b411 100644 --- a/src/common/include/gudhi/Points_off_io.h +++ b/src/common/include/gudhi/Points_off_io.h @@ -85,7 +85,7 @@ class Points_off_visitor_reader { std::cout << std::endl; #endif // DEBUG_TRACES // Fill the point cloud - point_cloud.push_back(Point_d(point.begin(), point.end())); + point_cloud.push_back(Point_d(point.end() - point.begin(), point.begin(), point.end())); } // Off_reader visitor maximal_face implementation - Only points are read -- cgit v1.2.3 From 0423b7024dee787659b76fff4b4f659546a40aea Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 29 Jun 2017 15:57:04 +0000 Subject: First working version of expansion insertion (different from rips expansion). git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2570 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6a6bb4052c3111e783e9e138619f1e945c856708 --- src/Simplex_tree/example/CMakeLists.txt | 17 +++ src/Simplex_tree/example/block.cpp | 82 +++++++++++ src/Simplex_tree/example/simple_simplex_tree.cpp | 35 ++++- src/Simplex_tree/include/gudhi/Simplex_tree.h | 167 ++++++++++++++++------- 4 files changed, 251 insertions(+), 50 deletions(-) create mode 100644 src/Simplex_tree/example/block.cpp (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index 5dbbfcc0..d5f512b3 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -45,3 +45,20 @@ endif() add_test(NAME Simplex_tree_example_cech_complex_step_by_step COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "-r" "12." "-d" "3") install(TARGETS Simplex_tree_example_cech_complex_step_by_step DESTINATION bin) + + +# +# TO BE REMOVED !! +# + +#add_executable ( rips_step_by_step rips_step_by_step.cpp) +#target_link_libraries(rips_step_by_step ${Boost_PROGRAM_OPTIONS_LIBRARY}) +#if (TBB_FOUND) +# target_link_libraries(rips_step_by_step ${TBB_LIBRARIES}) +#endif() + + +add_executable ( block block.cpp ) +if (TBB_FOUND) + target_link_libraries(block ${TBB_LIBRARIES}) +endif() diff --git a/src/Simplex_tree/example/block.cpp b/src/Simplex_tree/example/block.cpp new file mode 100644 index 00000000..07ec3921 --- /dev/null +++ b/src/Simplex_tree/example/block.cpp @@ -0,0 +1,82 @@ +/* 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) 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 + * 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 // for pair +#include + +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[]) { + + // Construct the Simplex Tree + Simplex_tree simplexTree; + + simplexTree.insert_simplex({0, 1}); + simplexTree.insert_simplex({0, 2}); + simplexTree.insert_simplex({0, 3}); + simplexTree.insert_simplex({1, 2}); + simplexTree.insert_simplex({1, 3}); + simplexTree.insert_simplex({2, 3}); + simplexTree.insert_simplex({2, 4}); + simplexTree.insert_simplex({3, 6}); + simplexTree.insert_simplex({4, 5}); + simplexTree.insert_simplex({4, 6}); + simplexTree.insert_simplex({5, 6}); + simplexTree.insert_simplex({6}); + + std::cout << "********************************************************************\n"; + // Display the Simplex_tree - Can not be done in the middle of 2 inserts + std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplexTree.filtration_simplex_range()) { + std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; + for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + simplexTree.expansion_with_blockers(3, [](){return true;}); + + simplexTree.initialize_filtration(); + std::cout << "********************************************************************\n"; + // Display the Simplex_tree - Can not be done in the middle of 2 inserts + std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplexTree.filtration_simplex_range()) { + std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; + for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + return 0; +} diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index 60f9a35e..f27d7ab8 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -195,9 +195,8 @@ int main(int argc, char * const argv[]) { std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; for (auto f_simplex : simplexTree.filtration_simplex_range()) { std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; - for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) { - std::cout << static_cast(vertex) << " "; - } + for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; std::cout << std::endl; } // [0.1] 0 @@ -250,5 +249,35 @@ int main(int argc, char * const argv[]) { std::cout << "***+ YES IT IS!\n"; else std::cout << "***- NO IT ISN'T\n"; + + invSimplexVector = { 0, 1 }; + simplexFound = simplexTree.find({ 0, 1 }); + std::cout << "**************IS THE SIMPLEX {0,1} IN THE SIMPLEX TREE ?\n"; + if (simplexFound != simplexTree.null_simplex()) + std::cout << "***+ YES IT IS!\n"; + else + std::cout << "***- NO IT ISN'T\n"; + + std::cout << "**************COFACES OF {0,1} IN CODIMENSION 1 ARE\n"; + for (auto& simplex : simplexTree.cofaces_simplex_range(simplexTree.find({0,1}), 1)) { + for (auto vertex : simplexTree.simplex_vertex_range(simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + std::cout << "**************STARS OF {0,1} ARE\n"; + for (auto& simplex : simplexTree.star_simplex_range(simplexTree.find({0,1}))) { + for (auto vertex : simplexTree.simplex_vertex_range(simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + std::cout << "**************BOUNDARIES OF {0,1,2} ARE\n"; + for (auto& simplex : simplexTree.boundary_simplex_range(simplexTree.find({0,1,2}))) { + for (auto vertex : simplexTree.simplex_vertex_range(simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + return 0; } diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index dbed47b8..ff31fd89 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1007,36 +1007,11 @@ class Simplex_tree { * The Simplex_tree must contain no simplex of dimension bigger than * 1 when calling the method. */ void expansion(int max_dim) { - expansion_with_blockers(max_dim, - [](Simplex_handle origin_sh, - Simplex_handle dict1_sh, - Simplex_handle dict2_sh, - Siblings* siblings) { - // Default blocker is always insert with the maximal filtration value between - // origin, dict1 and dict2 - return std::make_pair(true, (std::max)({origin_sh->second.filtration(), - dict1_sh->second.filtration(), - dict2_sh->second.filtration()})); }); - } - - /** \brief Expands the Simplex_tree containing only its one skeleton - * until dimension max_dim. - * - * The expanded simplicial complex until dimension \f$d\f$ - * attached to a graph \f$G\f$ is the maximal simplicial complex of - * dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. - * The filtration value assigned to a simplex is the maximal filtration - * value of one of its edges. - * - * The Simplex_tree must contain no simplex of dimension bigger than - * 1 when calling the method. */ - template< typename Blocker > - void expansion_with_blockers(int max_dim, Blocker blocker_expansion_function) { dimension_ = max_dim; for (Dictionary_it root_it = root_.members_.begin(); root_it != root_.members_.end(); ++root_it) { if (has_children(root_it)) { - siblings_expansion_with_blockers(root_it->second.children(), max_dim - 1, blocker_expansion_function); + siblings_expansion(root_it->second.children(), max_dim - 1); } } dimension_ = max_dim - dimension_; @@ -1044,9 +1019,8 @@ class Simplex_tree { private: /** \brief Recursive expansion of the simplex tree.*/ - template< typename Blocker > - void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements - int k, Blocker blocker_expansion_function) { + void siblings_expansion(Siblings * siblings, // must contain elements + int k) { if (dimension_ > k) { dimension_ = k; } @@ -1060,22 +1034,20 @@ class Simplex_tree { s_h != siblings->members().end(); ++s_h, ++next) { Simplex_handle root_sh = find_vertex(s_h->first); if (has_children(root_sh)) { - intersection_with_blockers( - inter, // output intersection - next, // begin - siblings->members().end(), // end - root_sh->second.children()->members().begin(), - root_sh->second.children()->members().end(), - s_h, siblings, - blocker_expansion_function); + intersection( + inter, // output intersection + next, // begin + siblings->members().end(), // end + root_sh->second.children()->members().begin(), + root_sh->second.children()->members().end(), + s_h->second.filtration()); if (inter.size() != 0) { Siblings * new_sib = new Siblings(siblings, // oncles s_h->first, // parent inter); // boost::container::ordered_unique_range_t - // As siblings_expansion_with_blockers is recusively called, inter must be cleared before inter.clear(); s_h->second.assign_children(new_sib); - siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); + siblings_expansion(new_sib, k - 1); } else { // ensure the children property s_h->second.assign_children(siblings); @@ -1087,20 +1059,16 @@ class Simplex_tree { /** \brief Intersects Dictionary 1 [begin1;end1) with Dictionary 2 [begin2,end2) * and assigns the maximal possible Filtration_value to the Nodes. */ - template< typename Blocker > - static void intersection_with_blockers(std::vector >& intersection, + static void intersection(std::vector >& intersection, Dictionary_it begin1, Dictionary_it end1, Dictionary_it begin2, Dictionary_it end2, - Dictionary_it origin_sh, - Siblings* siblings, - Blocker blocker_expansion_function) { + Filtration_value filtration_) { if (begin1 == end1 || begin2 == end2) return; // ----->> while (true) { if (begin1->first == begin2->first) { - std::pair blocker_result = blocker_expansion_function(origin_sh, begin1, begin2, siblings); - if (blocker_result.first) - intersection.emplace_back(begin1->first, Node(nullptr, blocker_result.second)); + Filtration_value filt = (std::max)({begin1->second.filtration(), begin2->second.filtration(), filtration_}); + intersection.emplace_back(begin1->first, Node(nullptr, filt)); if (++begin1 == end1 || ++begin2 == end2) return; // ----->> } else if (begin1->first < begin2->first) { @@ -1113,6 +1081,111 @@ class Simplex_tree { } } + + + /*-------------------------------------------------------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------------------------------------------------------*/ + + public: + /** \brief Expands the Simplex_tree containing only its one skeleton + * until dimension max_dim. + * + * The expanded simplicial complex until dimension \f$d\f$ + * attached to a graph \f$G\f$ is the maximal simplicial complex of + * dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. + * The filtration value assigned to a simplex is the maximal filtration + * value of one of its edges. + * + * The Simplex_tree must contain no simplex of dimension bigger than + * 1 when calling the method. */ + template< typename Blocker > + void expansion_with_blockers(int max_dim, Blocker blocker_expansion_function) { + dimension_ = max_dim; + // Loop must be from the end to the beginning, as higher dimension simplex are always on the left part of the tree + for (auto& simplex : boost::adaptors::reverse(root_.members())) { + if (has_children(&simplex)) { + std::cout << " *** root on " << static_cast(simplex.first) << std::endl; + siblings_expansion_with_blockers(simplex.second.children(), max_dim - 1, blocker_expansion_function); + } + } + dimension_ = max_dim - dimension_; + } + + private: + /** \brief Recursive expansion of the simplex tree.*/ + template< typename Blocker > + void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements + int k, Blocker blocker_expansion_function) { + if (dimension_ > k) { + dimension_ = k; + } + if (k == 0) + return; + // No need to go deeper + if (siblings->members().size() < 2) + return; + // Reverse loop starting before the last one for 'next' to be the last one + for (auto simplex = siblings->members().rbegin() + 1; simplex != siblings->members().rend(); simplex++) { + auto next = siblings->members().rbegin(); + std::vector > intersection; + while(next != simplex) { + bool to_be_inserted = true; + std::cout << "to_be_inserted = " << to_be_inserted << " dim = " << k << " simplex = " << simplex->first << " - next = " << next->first << std::endl; + + for (auto& border : boundary_simplex_range(simplex)) { + to_be_inserted = to_be_inserted && find_child(border, next->first); + + for (auto vertex : simplex_vertex_range(border)) { + std::cout << "(" << vertex << ")"; + } + std::cout << " | "; + } + std::cout << std::endl; + if (to_be_inserted) { + std::cout << next->first << " to be inserted." << std::endl; + intersection.emplace_back(next->first, Node(nullptr, 0.0)); + } + + // loop until simplex is reached + next++; + } + if (intersection.size() != 0) { + // Reverse the order to insert + std::reverse(std::begin(intersection), std::end(intersection)); + Siblings * new_sib = new Siblings(siblings, // oncles + simplex->first, // parent + intersection); // boost::container::ordered_unique_range_t + // intersection must be cleared before the function to be called recursively + intersection.clear(); + simplex->second.assign_children(new_sib); + siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); + } else { + // ensure the children property + simplex->second.assign_children(siblings); + intersection.clear(); + } + + } + + } + + /** \private Returns true if vh is a member of sh*/ + bool find_child(Simplex_handle sh, Vertex_handle vh) { + std::vector child = {vh}; + std::cout << "+" << vh; + for (auto vertex : simplex_vertex_range(sh)) { + std::cout << "+" << vertex; + child.push_back(vertex); + } + std::cout << " => " << (find(child) != null_simplex()) << "___ "; + return find(child) != null_simplex(); + } + + /*-------------------------------------------------------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------------------------------------------------------*/ + public: /** \brief Write the hasse diagram of the simplicial complex in os. * -- cgit v1.2.3 From 7c205b2cb36b9d8b04556cc81afb4940f27743fc Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Sat, 1 Jul 2017 21:57:42 +0000 Subject: Example of blocker and Cech Complex implementation git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2573 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 88a98ef49630989833a09b59d9b1e4713b409c0b --- src/Simplex_tree/example/CMakeLists.txt | 32 +++++------ src/Simplex_tree/example/block.cpp | 42 ++++++++------- .../example/cech_complex_step_by_step.cpp | 62 +++++++++------------- 3 files changed, 63 insertions(+), 73 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index d5f512b3..7a30979f 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -35,30 +35,26 @@ if(GMP_FOUND AND CGAL_FOUND) install(TARGETS Simplex_tree_example_alpha_shapes_3_from_off DESTINATION bin) -endif() + # + # TO BE REMOVED !! + # -add_executable ( Simplex_tree_example_cech_complex_step_by_step cech_complex_step_by_step.cpp) -target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${Boost_PROGRAM_OPTIONS_LIBRARY}) -if (TBB_FOUND) - target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${TBB_LIBRARIES}) -endif() -add_test(NAME Simplex_tree_example_cech_complex_step_by_step COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "-r" "12." "-d" "3") -install(TARGETS Simplex_tree_example_cech_complex_step_by_step DESTINATION bin) + add_executable ( Simplex_tree_example_cech_complex_step_by_step cech_complex_step_by_step.cpp ) + target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${GMP_LIBRARIES} ${CGAL_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) + if (TBB_FOUND) + target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${TBB_LIBRARIES}) + endif() + add_test(NAME Simplex_tree_example_cech_complex_step_by_step COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "-d" "3" "-r" "6.0") +endif() # # TO BE REMOVED !! # -#add_executable ( rips_step_by_step rips_step_by_step.cpp) -#target_link_libraries(rips_step_by_step ${Boost_PROGRAM_OPTIONS_LIBRARY}) -#if (TBB_FOUND) -# target_link_libraries(rips_step_by_step ${TBB_LIBRARIES}) -#endif() - - -add_executable ( block block.cpp ) +add_executable ( Simplex_tree_example_block block.cpp ) if (TBB_FOUND) - target_link_libraries(block ${TBB_LIBRARIES}) + target_link_libraries(Simplex_tree_example_block ${TBB_LIBRARIES}) endif() +add_test(NAME Simplex_tree_example_block COMMAND $) diff --git a/src/Simplex_tree/example/block.cpp b/src/Simplex_tree/example/block.cpp index 07ec3921..75b8d1ea 100644 --- a/src/Simplex_tree/example/block.cpp +++ b/src/Simplex_tree/example/block.cpp @@ -28,31 +28,27 @@ #include 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 >; +using Simplex_handle = Simplex_tree::Simplex_handle; int main(int argc, char * const argv[]) { // Construct the Simplex Tree Simplex_tree simplexTree; - simplexTree.insert_simplex({0, 1}); - simplexTree.insert_simplex({0, 2}); - simplexTree.insert_simplex({0, 3}); - simplexTree.insert_simplex({1, 2}); - simplexTree.insert_simplex({1, 3}); - simplexTree.insert_simplex({2, 3}); - simplexTree.insert_simplex({2, 4}); - simplexTree.insert_simplex({3, 6}); - simplexTree.insert_simplex({4, 5}); - simplexTree.insert_simplex({4, 6}); - simplexTree.insert_simplex({5, 6}); - simplexTree.insert_simplex({6}); + simplexTree.insert_simplex({0, 1}, 0.); + simplexTree.insert_simplex({0, 2}, 1.); + simplexTree.insert_simplex({0, 3}, 2.); + simplexTree.insert_simplex({1, 2}, 3.); + simplexTree.insert_simplex({1, 3}, 4.); + simplexTree.insert_simplex({2, 3}, 5.); + simplexTree.insert_simplex({2, 4}, 6.); + simplexTree.insert_simplex({3, 6}, 7.); + simplexTree.insert_simplex({4, 5}, 8.); + simplexTree.insert_simplex({4, 6}, 9.); + simplexTree.insert_simplex({5, 6}, 10.); + simplexTree.insert_simplex({6}, 11.); std::cout << "********************************************************************\n"; - // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; @@ -63,11 +59,19 @@ int main(int argc, char * const argv[]) { std::cout << std::endl; } - simplexTree.expansion_with_blockers(3, [](){return true;}); + simplexTree.expansion_with_blockers(3, [&](Simplex_handle sh){ + bool result = false; + for (auto vertex : simplexTree.simplex_vertex_range(sh)) { + if (vertex == 6) + result = true; + std::cout << "#(" << vertex << ")#"; + } + std::cout << std::endl; + return result; + }); simplexTree.initialize_filtration(); std::cout << "********************************************************************\n"; - // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; diff --git a/src/Simplex_tree/example/cech_complex_step_by_step.cpp b/src/Simplex_tree/example/cech_complex_step_by_step.cpp index b5cda443..1805c792 100644 --- a/src/Simplex_tree/example/cech_complex_step_by_step.cpp +++ b/src/Simplex_tree/example/cech_complex_step_by_step.cpp @@ -28,9 +28,9 @@ // #include // #include // #include -#include -#include -#include +#include +#include +#include #include @@ -59,44 +59,34 @@ using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirec >; using Edge_t = std::pair< Vertex_handle, Vertex_handle >; -// using Kernel = CGAL::Epick_d< CGAL::Dimension_tag<2> >;// CGAL::Dynamic_dimension_tag >; -typedef CGAL::Cartesian_d Kernel; -typedef CGAL::Optimisation_d_traits_d Traits; -typedef CGAL::Min_sphere_d Min_sphere; - +using Kernel = CGAL::Epick_d< CGAL::Dimension_tag<2> >;// CGAL::Dynamic_dimension_tag >; using Point = Kernel::Point_d; +using Traits = CGAL::Min_sphere_of_points_d_traits_d; +using Min_sphere = CGAL::Min_sphere_of_spheres_d; + using Points_off_reader = Gudhi::Points_off_reader; -// using Min_sphere = CGAL::Min_sphere_d; class Cech_blocker { public: - std::pair operator()(Simplex_handle origin_sh, Simplex_handle dict1_sh, Simplex_handle dict2_sh, Siblings* siblings) { - //std::vector path = {dict1_sh->first, origin_sh->first}; - Siblings* sib_path = siblings; - std::vector sphere_points = {point_cloud_[dict1_sh->first], point_cloud_[origin_sh->first]}; - do { - //path.push_back(sib_path->parent()); - sphere_points.push_back(point_cloud_[sib_path->parent()]); - sib_path = sib_path->oncles(); - } while (sib_path->oncles() != nullptr); - /*std::cout << square_threshold_ << "-"; - for (auto vh : path) { - std::cout << vh << " "; + bool operator()(Simplex_handle sh) { + std::vector points; + for (auto vertex : simplex_tree_.simplex_vertex_range(sh)) { + points.push_back(point_cloud_[vertex]); + std::cout << "#(" << vertex << ")#"; } - std::cout << std::endl;*/ - Min_sphere min_sphere(sphere_points.begin(), sphere_points.end()); - //std::cout << min_sphere.squared_radius() << std::endl; - Filtration_value squared_diameter = min_sphere.squared_radius() * 4.; - // Default blocker is always insert with the maximal filtration value between - // origin, dict1 and dict2 - return std::make_pair(squared_diameter < square_threshold_, - squared_diameter); + Min_sphere ms(points.begin(),points.end()); + Filtration_value radius = ms.radius(); + std::cout << "radius = " << radius << " - " << (radius > threshold_) << std::endl; + simplex_tree_.assign_filtration(sh, radius); + return (radius > threshold_); } - Cech_blocker(Filtration_value threshold, const std::vector& point_cloud) - : square_threshold_(threshold * threshold), + Cech_blocker(Simplex_tree& simplex_tree, Filtration_value threshold, const std::vector& point_cloud) + : simplex_tree_(simplex_tree), + threshold_(threshold), point_cloud_(point_cloud) { } private: - Filtration_value square_threshold_; + Simplex_tree simplex_tree_; + Filtration_value threshold_; std::vector point_cloud_; }; @@ -127,7 +117,7 @@ int main(int argc, char * argv[]) { // insert the proximity graph in the simplex tree st.insert_graph(prox_graph); // expand the graph until dimension dim_max - st.expansion_with_blockers(dim_max, Cech_blocker(threshold, off_reader.get_point_cloud())); + st.expansion_with_blockers(dim_max, Cech_blocker(st, threshold, off_reader.get_point_cloud())); std::cout << "The complex contains " << st.num_simplices() << " simplices \n"; std::cout << " and has dimension " << st.dimension() << " \n"; @@ -206,8 +196,6 @@ Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value thresh std::vector< Filtration_value > edges_fil; Kernel k; - Filtration_value square_threshold = threshold * threshold; - Vertex_handle idx_u, idx_v; Filtration_value fil; idx_u = 0; @@ -215,7 +203,9 @@ Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value thresh idx_v = idx_u + 1; for (auto it_v = it_u + 1; it_v != points.end(); ++it_v, ++idx_v) { fil = k.squared_distance_d_object()(*it_u, *it_v); - if (fil <= square_threshold) { + // For Cech Complex, threshold is a radius (distance /2) + fil = std::sqrt(fil) / 2.; + if (fil <= threshold) { edges.emplace_back(idx_u, idx_v); edges_fil.push_back(fil); } -- cgit v1.2.3 From 093866604f986dded2db6a96d7dbc4b6d1f7194a Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 5 Jul 2017 15:03:57 +0000 Subject: Fix default filtration value given by the graph_expansion method with blocker git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2585 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 38586e3c9a622c74c6b6658bdc0a6776c5ea5d5a --- src/Simplex_tree/example/CMakeLists.txt | 17 -- src/Simplex_tree/example/block.cpp | 30 ++- .../example/cech_complex_step_by_step.cpp | 230 --------------------- src/Simplex_tree/include/gudhi/Simplex_tree.h | 93 +++++---- 4 files changed, 61 insertions(+), 309 deletions(-) delete mode 100644 src/Simplex_tree/example/cech_complex_step_by_step.cpp (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index 7a30979f..4557deb3 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -34,25 +34,8 @@ if(GMP_FOUND AND CGAL_FOUND) "${CMAKE_SOURCE_DIR}/data/points/bunny_5000.off") install(TARGETS Simplex_tree_example_alpha_shapes_3_from_off DESTINATION bin) - - # - # TO BE REMOVED !! - # - - add_executable ( Simplex_tree_example_cech_complex_step_by_step cech_complex_step_by_step.cpp ) - target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${GMP_LIBRARIES} ${CGAL_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) - if (TBB_FOUND) - target_link_libraries(Simplex_tree_example_cech_complex_step_by_step ${TBB_LIBRARIES}) - endif() - add_test(NAME Simplex_tree_example_cech_complex_step_by_step COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "-d" "3" "-r" "6.0") - endif() -# -# TO BE REMOVED !! -# - add_executable ( Simplex_tree_example_block block.cpp ) if (TBB_FOUND) target_link_libraries(Simplex_tree_example_block ${TBB_LIBRARIES}) diff --git a/src/Simplex_tree/example/block.cpp b/src/Simplex_tree/example/block.cpp index 75b8d1ea..67697b89 100644 --- a/src/Simplex_tree/example/block.cpp +++ b/src/Simplex_tree/example/block.cpp @@ -24,15 +24,13 @@ #include #include -#include // for pair -#include using Simplex_tree = Gudhi::Simplex_tree<>; using Simplex_handle = Simplex_tree::Simplex_handle; int main(int argc, char * const argv[]) { - // Construct the Simplex Tree + // Construct the Simplex Tree with a 1-skeleton graph example Simplex_tree simplexTree; simplexTree.insert_simplex({0, 1}, 0.); @@ -46,31 +44,27 @@ int main(int argc, char * const argv[]) { simplexTree.insert_simplex({4, 5}, 8.); simplexTree.insert_simplex({4, 6}, 9.); simplexTree.insert_simplex({5, 6}, 10.); - simplexTree.insert_simplex({6}, 11.); - - std::cout << "********************************************************************\n"; - std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; - std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; - std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; - for (auto f_simplex : simplexTree.filtration_simplex_range()) { - std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; - for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) - std::cout << "(" << vertex << ")"; - std::cout << std::endl; - } + simplexTree.insert_simplex({6}, 10.); simplexTree.expansion_with_blockers(3, [&](Simplex_handle sh){ bool result = false; + std::cout << "Blocker on ["; + // User can loop on the vertices from the given simplex_handle i.e. for (auto vertex : simplexTree.simplex_vertex_range(sh)) { + // We block the expansion, if the vertex '6' is in the given list of vertices if (vertex == 6) result = true; - std::cout << "#(" << vertex << ")#"; + std::cout << vertex << ", "; } - std::cout << std::endl; + std::cout << "] ( " << simplexTree.filtration(sh); + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + simplexTree.assign_filtration(sh, simplexTree.filtration(sh) + 1.); + + std::cout << " + 1. ) = " << result << std::endl; + return result; }); - simplexTree.initialize_filtration(); std::cout << "********************************************************************\n"; std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; diff --git a/src/Simplex_tree/example/cech_complex_step_by_step.cpp b/src/Simplex_tree/example/cech_complex_step_by_step.cpp deleted file mode 100644 index 1805c792..00000000 --- a/src/Simplex_tree/example/cech_complex_step_by_step.cpp +++ /dev/null @@ -1,230 +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 - -#include - -#include -#include -#include // infinity -#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; -using Simplex_handle = Simplex_tree::Simplex_handle; -using Filtration_value = Simplex_tree::Filtration_value; -using Siblings = Simplex_tree::Siblings; -using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS -, boost::property < vertex_filtration_t, Filtration_value > -, boost::property < edge_filtration_t, Filtration_value > ->; -using Edge_t = std::pair< Vertex_handle, Vertex_handle >; - -using Kernel = CGAL::Epick_d< CGAL::Dimension_tag<2> >;// CGAL::Dynamic_dimension_tag >; -using Point = Kernel::Point_d; -using Traits = CGAL::Min_sphere_of_points_d_traits_d; -using Min_sphere = CGAL::Min_sphere_of_spheres_d; - -using Points_off_reader = Gudhi::Points_off_reader; - -class Cech_blocker { - public: - bool operator()(Simplex_handle sh) { - std::vector points; - for (auto vertex : simplex_tree_.simplex_vertex_range(sh)) { - points.push_back(point_cloud_[vertex]); - std::cout << "#(" << vertex << ")#"; - } - Min_sphere ms(points.begin(),points.end()); - Filtration_value radius = ms.radius(); - std::cout << "radius = " << radius << " - " << (radius > threshold_) << std::endl; - simplex_tree_.assign_filtration(sh, radius); - return (radius > threshold_); - } - Cech_blocker(Simplex_tree& simplex_tree, Filtration_value threshold, const std::vector& point_cloud) - : simplex_tree_(simplex_tree), - threshold_(threshold), - point_cloud_(point_cloud) { } - private: - Simplex_tree simplex_tree_; - Filtration_value threshold_; - std::vector point_cloud_; -}; - -template< typename InputPointRange> -Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold); - -void program_options(int argc, char * argv[] - , std::string & off_file_points - , Filtration_value & threshold - , int & dim_max); - -int main(int argc, char * argv[]) { - std::string off_file_points; - Filtration_value threshold; - int dim_max; - - program_options(argc, argv, off_file_points, threshold, dim_max); - - // Extract the points from the file filepoints - Points_off_reader off_reader(off_file_points); - - // Compute the proximity graph of the points - Graph_t prox_graph = compute_proximity_graph(off_reader.get_point_cloud(), threshold); - - //Min_sphere sph1(off_reader.get_point_cloud()[0], off_reader.get_point_cloud()[1], off_reader.get_point_cloud()[2]); - // Construct the Rips complex in a Simplex Tree - Simplex_tree st; - // insert the proximity graph in the simplex tree - st.insert_graph(prox_graph); - // expand the graph until dimension dim_max - st.expansion_with_blockers(dim_max, Cech_blocker(st, threshold, off_reader.get_point_cloud())); - - std::cout << "The complex contains " << st.num_simplices() << " simplices \n"; - std::cout << " and has dimension " << st.dimension() << " \n"; - - // Sort the simplices in the order of the filtration - st.initialize_filtration(); - - std::cout << "********************************************************************\n"; - // Display the Simplex_tree - Can not be done in the middle of 2 inserts - std::cout << "* The complex contains " << st.num_simplices() << " simplices\n"; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << "\n"; - std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; - for (auto f_simplex : st.filtration_simplex_range()) { - std::cout << " " << "[" << st.filtration(f_simplex) << "] "; - for (auto vertex : st.simplex_vertex_range(f_simplex)) { - std::cout << static_cast(vertex) << " "; - } - std::cout << std::endl; - } - - return 0; -} - -void program_options(int argc, char * argv[] - , std::string & off_file_points - , Filtration_value & threshold - , int & dim_max) { - namespace po = boost::program_options; - po::options_description hidden("Hidden options"); - hidden.add_options() - ("input-file", po::value(&off_file_points), - "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") - ("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."); - - 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 << "Construct a Cech complex defined on a set of input points.\n \n"; - - std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; - std::cout << visible << std::endl; - std::abort(); - } -} - -/** 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> -Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold) { - std::vector< Edge_t > edges; - std::vector< Filtration_value > edges_fil; - - Kernel k; - 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 = k.squared_distance_d_object()(*it_u, *it_v); - // For Cech Complex, threshold is a radius (distance /2) - fil = std::sqrt(fil) / 2.; - 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; -} diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index ff31fd89..72cb9401 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1081,31 +1081,23 @@ class Simplex_tree { } } - - - /*-------------------------------------------------------------------------------------------------------------------------*/ - /*-------------------------------------------------------------------------------------------------------------------------*/ - /*-------------------------------------------------------------------------------------------------------------------------*/ - public: - /** \brief Expands the Simplex_tree containing only its one skeleton - * until dimension max_dim. + /** \brief Expands the Simplex_tree containing only its one skeleton until dimension max_dim according with a user + * given blocker expansion oracle * - * The expanded simplicial complex until dimension \f$d\f$ - * attached to a graph \f$G\f$ is the maximal simplicial complex of - * dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. - * The filtration value assigned to a simplex is the maximal filtration - * value of one of its edges. + * The expanded simplicial complex until dimension \f$d\f$ attached to a graph \f$G\f$ is the maximal simplicial + * complex of dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. + * The filtration value assigned to a simplex is the maximal filtration value of one of its edges. + * The blocker expansion oracle shall answer true on a Simplex_handle if this Simplex_handle has to be removed, + * false otherwise. The blocker expansion oracle can re-assign the filtration value. * - * The Simplex_tree must contain no simplex of dimension bigger than - * 1 when calling the method. */ + * The Simplex_tree must contain no simplex of dimension bigger than 1 when calling the method. */ template< typename Blocker > void expansion_with_blockers(int max_dim, Blocker blocker_expansion_function) { dimension_ = max_dim; // Loop must be from the end to the beginning, as higher dimension simplex are always on the left part of the tree for (auto& simplex : boost::adaptors::reverse(root_.members())) { if (has_children(&simplex)) { - std::cout << " *** root on " << static_cast(simplex.first) << std::endl; siblings_expansion_with_blockers(simplex.second.children(), max_dim - 1, blocker_expansion_function); } } @@ -1113,7 +1105,7 @@ class Simplex_tree { } private: - /** \brief Recursive expansion of the simplex tree.*/ + /** \brief Recursive expansion with blockers of the simplex tree.*/ template< typename Blocker > void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements int k, Blocker blocker_expansion_function) { @@ -1131,22 +1123,16 @@ class Simplex_tree { std::vector > intersection; while(next != simplex) { bool to_be_inserted = true; - std::cout << "to_be_inserted = " << to_be_inserted << " dim = " << k << " simplex = " << simplex->first << " - next = " << next->first << std::endl; - + Filtration_value filt = simplex->second.filtration(); + // If all the boundaries are present, 'next' needs to be inserted for (auto& border : boundary_simplex_range(simplex)) { - to_be_inserted = to_be_inserted && find_child(border, next->first); - - for (auto vertex : simplex_vertex_range(border)) { - std::cout << "(" << vertex << ")"; - } - std::cout << " | "; + Simplex_handle border_child = find_child(border, next->first); + to_be_inserted = to_be_inserted && (border_child != null_simplex()); + filt = std::max(filt, filtration(border_child)); } - std::cout << std::endl; if (to_be_inserted) { - std::cout << next->first << " to be inserted." << std::endl; - intersection.emplace_back(next->first, Node(nullptr, 0.0)); + intersection.emplace_back(next->first, Node(nullptr, filt)); } - // loop until simplex is reached next++; } @@ -1158,34 +1144,50 @@ class Simplex_tree { intersection); // boost::container::ordered_unique_range_t // intersection must be cleared before the function to be called recursively intersection.clear(); - simplex->second.assign_children(new_sib); - siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); + + std::vector blocked_new_sib_list; + // As all intersections are inserted, we can call the blocker function on all new_sib members + for (auto new_sib_member = new_sib->members().begin(); + new_sib_member != new_sib->members().end(); + new_sib_member++) { + bool blocker_result = blocker_expansion_function(new_sib_member); + // new_sib member has been blocked by the blocker function + // add it to the list to be removed - do not perform it while looping on it + if (blocker_result) + blocked_new_sib_list.push_back(new_sib_member); + } + bool removed = false; + for (auto& blocked_new_sib_member : blocked_new_sib_list){ + removed = removed || remove_maximal_simplex(blocked_new_sib_member); + } + if (removed) { + // ensure the children property + simplex->second.assign_children(siblings); + } else { + // ensure recursive call + simplex->second.assign_children(new_sib); + siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); + } } else { // ensure the children property simplex->second.assign_children(siblings); intersection.clear(); } - } - } - /** \private Returns true if vh is a member of sh*/ - bool find_child(Simplex_handle sh, Vertex_handle vh) { + /* \private Returns the Simplex_handle composed of the vertex list (from the Simplex_handle), plus the given + * Vertex_handle. + * Returns null_simplex() if it does not exist + */ + Simplex_handle find_child(Simplex_handle sh, Vertex_handle vh) { std::vector child = {vh}; - std::cout << "+" << vh; for (auto vertex : simplex_vertex_range(sh)) { - std::cout << "+" << vertex; child.push_back(vertex); } - std::cout << " => " << (find(child) != null_simplex()) << "___ "; - return find(child) != null_simplex(); + return find(child); } - /*-------------------------------------------------------------------------------------------------------------------------*/ - /*-------------------------------------------------------------------------------------------------------------------------*/ - /*-------------------------------------------------------------------------------------------------------------------------*/ - public: /** \brief Write the hasse diagram of the simplicial complex in os. * @@ -1295,11 +1297,12 @@ class Simplex_tree { public: /** \brief Remove a maximal simplex. * @param[in] sh Simplex handle on the maximal simplex to remove. + * @return true if siblings was deleted, false otherwise. * \pre Please check the simplex has no coface before removing it. * \exception std::invalid_argument In debug mode, if sh has children. * \post Be aware that removing is shifting data in a flat_map (initialize_filtration to be done). */ - void remove_maximal_simplex(Simplex_handle sh) { + bool remove_maximal_simplex(Simplex_handle sh) { // Guarantee the simplex has no children GUDHI_CHECK(!has_children(sh), std::invalid_argument("Simplex_tree::remove_maximal_simplex - argument has children")); @@ -1315,7 +1318,9 @@ class Simplex_tree { // Sibling is emptied : must be deleted, and its parent must point on his own Sibling child->oncles()->members().at(child->parent()).assign_children(child->oncles()); delete child; + return true; } + return false; } private: -- cgit v1.2.3 From 40aaa716132bb2f6a6110e229d91345618bf1088 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 5 Jul 2017 17:50:45 +0000 Subject: Checkin tests and fixes git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2586 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0f9cbe3d6b94e939e151dea989ae99f7e4f3bffa --- src/Simplex_tree/example/CMakeLists.txt | 8 +- src/Simplex_tree/example/block.cpp | 80 ------- .../example/graph_expansion_with_blocker.cpp | 79 +++++++ src/Simplex_tree/test/CMakeLists.txt | 8 + .../simplex_tree_graph_expansion_unit_test.cpp | 235 +++++++++++++++++++++ src/common/include/gudhi/Points_off_io.h | 2 +- 6 files changed, 328 insertions(+), 84 deletions(-) delete mode 100644 src/Simplex_tree/example/block.cpp create mode 100644 src/Simplex_tree/example/graph_expansion_with_blocker.cpp create mode 100644 src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index 4557deb3..c414c019 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -36,8 +36,10 @@ if(GMP_FOUND AND CGAL_FOUND) install(TARGETS Simplex_tree_example_alpha_shapes_3_from_off DESTINATION bin) endif() -add_executable ( Simplex_tree_example_block block.cpp ) +add_executable ( Simplex_tree_example_graph_expansion_with_blocker graph_expansion_with_blocker.cpp ) if (TBB_FOUND) - target_link_libraries(Simplex_tree_example_block ${TBB_LIBRARIES}) + target_link_libraries(Simplex_tree_example_graph_expansion_with_blocker ${TBB_LIBRARIES}) endif() -add_test(NAME Simplex_tree_example_block COMMAND $) +add_test(NAME Simplex_tree_example_graph_expansion_with_blocker COMMAND $) + +install(TARGETS Simplex_tree_example_graph_expansion_with_blocker DESTINATION bin) diff --git a/src/Simplex_tree/example/block.cpp b/src/Simplex_tree/example/block.cpp deleted file mode 100644 index 67697b89..00000000 --- a/src/Simplex_tree/example/block.cpp +++ /dev/null @@ -1,80 +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) 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 - * 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 - -using Simplex_tree = Gudhi::Simplex_tree<>; -using Simplex_handle = Simplex_tree::Simplex_handle; - -int main(int argc, char * const argv[]) { - - // Construct the Simplex Tree with a 1-skeleton graph example - Simplex_tree simplexTree; - - simplexTree.insert_simplex({0, 1}, 0.); - simplexTree.insert_simplex({0, 2}, 1.); - simplexTree.insert_simplex({0, 3}, 2.); - simplexTree.insert_simplex({1, 2}, 3.); - simplexTree.insert_simplex({1, 3}, 4.); - simplexTree.insert_simplex({2, 3}, 5.); - simplexTree.insert_simplex({2, 4}, 6.); - simplexTree.insert_simplex({3, 6}, 7.); - simplexTree.insert_simplex({4, 5}, 8.); - simplexTree.insert_simplex({4, 6}, 9.); - simplexTree.insert_simplex({5, 6}, 10.); - simplexTree.insert_simplex({6}, 10.); - - simplexTree.expansion_with_blockers(3, [&](Simplex_handle sh){ - bool result = false; - std::cout << "Blocker on ["; - // User can loop on the vertices from the given simplex_handle i.e. - for (auto vertex : simplexTree.simplex_vertex_range(sh)) { - // We block the expansion, if the vertex '6' is in the given list of vertices - if (vertex == 6) - result = true; - std::cout << vertex << ", "; - } - std::cout << "] ( " << simplexTree.filtration(sh); - // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) - simplexTree.assign_filtration(sh, simplexTree.filtration(sh) + 1.); - - std::cout << " + 1. ) = " << result << std::endl; - - return result; - }); - - std::cout << "********************************************************************\n"; - std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; - std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; - std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; - for (auto f_simplex : simplexTree.filtration_simplex_range()) { - std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; - for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) - std::cout << "(" << vertex << ")"; - std::cout << std::endl; - } - - return 0; -} diff --git a/src/Simplex_tree/example/graph_expansion_with_blocker.cpp b/src/Simplex_tree/example/graph_expansion_with_blocker.cpp new file mode 100644 index 00000000..d0d3f038 --- /dev/null +++ b/src/Simplex_tree/example/graph_expansion_with_blocker.cpp @@ -0,0 +1,79 @@ +/* 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) 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 + * 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 + +using Simplex_tree = Gudhi::Simplex_tree<>; +using Simplex_handle = Simplex_tree::Simplex_handle; + +int main(int argc, char * const argv[]) { + + // Construct the Simplex Tree with a 1-skeleton graph example + Simplex_tree simplexTree; + + simplexTree.insert_simplex({0, 1}, 0.); + simplexTree.insert_simplex({0, 2}, 1.); + simplexTree.insert_simplex({0, 3}, 2.); + simplexTree.insert_simplex({1, 2}, 3.); + simplexTree.insert_simplex({1, 3}, 4.); + simplexTree.insert_simplex({2, 3}, 5.); + simplexTree.insert_simplex({2, 4}, 6.); + simplexTree.insert_simplex({3, 6}, 7.); + simplexTree.insert_simplex({4, 5}, 8.); + simplexTree.insert_simplex({4, 6}, 9.); + simplexTree.insert_simplex({5, 6}, 10.); + simplexTree.insert_simplex({6}, 10.); + + simplexTree.expansion_with_blockers(3, [&](Simplex_handle sh){ + bool result = false; + std::cout << "Blocker on ["; + // User can loop on the vertices from the given simplex_handle i.e. + for (auto vertex : simplexTree.simplex_vertex_range(sh)) { + // We block the expansion, if the vertex '6' is in the given list of vertices + if (vertex == 6) + result = true; + std::cout << vertex << ", "; + } + std::cout << "] ( " << simplexTree.filtration(sh); + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + simplexTree.assign_filtration(sh, simplexTree.filtration(sh) + 1.); + + std::cout << " + 1. ) = " << result << std::endl; + + return result; + }); + + std::cout << "********************************************************************\n"; + std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplexTree.filtration_simplex_range()) { + std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; + for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + return 0; +} diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt index 17b0f2c2..2408d937 100644 --- a/src/Simplex_tree/test/CMakeLists.txt +++ b/src/Simplex_tree/test/CMakeLists.txt @@ -13,3 +13,11 @@ endif() file(COPY "simplex_tree_for_unit_test.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) gudhi_add_coverage_test(Simplex_tree_test_unit) + +add_executable ( Simplex_tree_test_unit_graph_expansion simplex_tree_graph_expansion_unit_test.cpp ) +target_link_libraries(Simplex_tree_test_unit_graph_expansion ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +if (TBB_FOUND) + target_link_libraries(Simplex_tree_test_unit_graph_expansion ${TBB_LIBRARIES}) +endif() + +gudhi_add_coverage_test(Simplex_tree_test_unit_graph_expansion) diff --git a/src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp new file mode 100644 index 00000000..bef82275 --- /dev/null +++ b/src/Simplex_tree/test/simplex_tree_graph_expansion_unit_test.cpp @@ -0,0 +1,235 @@ +#include +#include +#include +#include +#include // std::pair, std::make_pair +#include // float comparison +#include +#include // greater + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "simplex_tree" +#include +#include + +// ^ +// /!\ Nothing else from Simplex_tree shall be included to test includes are well defined. +#include "gudhi/Simplex_tree.h" + +using namespace Gudhi; + +typedef boost::mpl::list, Simplex_tree> list_of_tested_variants; + + +bool AreAlmostTheSame(float a, float b) { + return std::fabs(a - b) < std::numeric_limits::epsilon(); +} + +BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_expansion_with_blockers_3, typeST, list_of_tested_variants) { + using Simplex_handle = typename typeST::Simplex_handle; + // Construct the Simplex Tree with a 1-skeleton graph example + typeST simplex_tree; + + simplex_tree.insert_simplex({0, 1}, 0.); + simplex_tree.insert_simplex({0, 2}, 1.); + simplex_tree.insert_simplex({0, 3}, 2.); + simplex_tree.insert_simplex({1, 2}, 3.); + simplex_tree.insert_simplex({1, 3}, 4.); + simplex_tree.insert_simplex({2, 3}, 5.); + simplex_tree.insert_simplex({2, 4}, 6.); + simplex_tree.insert_simplex({3, 6}, 7.); + simplex_tree.insert_simplex({4, 5}, 8.); + simplex_tree.insert_simplex({4, 6}, 9.); + simplex_tree.insert_simplex({5, 6}, 10.); + simplex_tree.insert_simplex({6}, 10.); + + simplex_tree.expansion_with_blockers(3, [&](Simplex_handle sh){ + bool result = false; + std::cout << "Blocker on ["; + // User can loop on the vertices from the given simplex_handle i.e. + for (auto vertex : simplex_tree.simplex_vertex_range(sh)) { + // We block the expansion, if the vertex '6' is in the given list of vertices + if (vertex == 6) + result = true; + std::cout << vertex << ", "; + } + std::cout << "] ( " << simplex_tree.filtration(sh); + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + simplex_tree.assign_filtration(sh, simplex_tree.filtration(sh) + 1.); + + std::cout << " + 1. ) = " << result << std::endl; + + return result; + }); + + std::cout << "********************************************************************\n"; + std::cout << "simplex_tree_expansion_with_blockers_3\n"; + std::cout << "********************************************************************\n"; + std::cout << "* The complex contains " << simplex_tree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplex_tree.dimension() << " - filtration " << simplex_tree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplex_tree.filtration_simplex_range()) { + std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; + for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + BOOST_CHECK(simplex_tree.num_simplices() == 23); + BOOST_CHECK(simplex_tree.dimension() == 3); + // {4, 5, 6} shall be blocked + BOOST_CHECK(simplex_tree.find({4, 5, 6}) == simplex_tree.null_simplex()); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2})), 4.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,3})), 5.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,2,3})), 6.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({1,2,3})), 6.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2,3})), 7.)); + +} + +BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_expansion_with_blockers_2, typeST, list_of_tested_variants) { + using Simplex_handle = typename typeST::Simplex_handle; + // Construct the Simplex Tree with a 1-skeleton graph example + typeST simplex_tree; + + simplex_tree.insert_simplex({0, 1}, 0.); + simplex_tree.insert_simplex({0, 2}, 1.); + simplex_tree.insert_simplex({0, 3}, 2.); + simplex_tree.insert_simplex({1, 2}, 3.); + simplex_tree.insert_simplex({1, 3}, 4.); + simplex_tree.insert_simplex({2, 3}, 5.); + simplex_tree.insert_simplex({2, 4}, 6.); + simplex_tree.insert_simplex({3, 6}, 7.); + simplex_tree.insert_simplex({4, 5}, 8.); + simplex_tree.insert_simplex({4, 6}, 9.); + simplex_tree.insert_simplex({5, 6}, 10.); + simplex_tree.insert_simplex({6}, 10.); + + simplex_tree.expansion_with_blockers(2, [&](Simplex_handle sh){ + bool result = false; + std::cout << "Blocker on ["; + // User can loop on the vertices from the given simplex_handle i.e. + for (auto vertex : simplex_tree.simplex_vertex_range(sh)) { + // We block the expansion, if the vertex '6' is in the given list of vertices + if (vertex == 6) + result = true; + std::cout << vertex << ", "; + } + std::cout << "] ( " << simplex_tree.filtration(sh); + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + simplex_tree.assign_filtration(sh, simplex_tree.filtration(sh) + 1.); + + std::cout << " + 1. ) = " << result << std::endl; + + return result; + }); + + std::cout << "********************************************************************\n"; + std::cout << "simplex_tree_expansion_with_blockers_2\n"; + std::cout << "********************************************************************\n"; + std::cout << "* The complex contains " << simplex_tree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplex_tree.dimension() << " - filtration " << simplex_tree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplex_tree.filtration_simplex_range()) { + std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; + for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + BOOST_CHECK(simplex_tree.num_simplices() == 22); + BOOST_CHECK(simplex_tree.dimension() == 2); + // {4, 5, 6} shall be blocked + BOOST_CHECK(simplex_tree.find({4, 5, 6}) == simplex_tree.null_simplex()); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2})), 4.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,3})), 5.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,2,3})), 6.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({1,2,3})), 6.)); + BOOST_CHECK(simplex_tree.find({0,1,2,3}) == simplex_tree.null_simplex()); +} + +BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_expansion, typeST, list_of_tested_variants) { + // Construct the Simplex Tree with a 1-skeleton graph example + typeST simplex_tree; + + simplex_tree.insert_simplex({0, 1}, 0.); + simplex_tree.insert_simplex({0, 2}, 1.); + simplex_tree.insert_simplex({0, 3}, 2.); + simplex_tree.insert_simplex({1, 2}, 3.); + simplex_tree.insert_simplex({1, 3}, 4.); + simplex_tree.insert_simplex({2, 3}, 5.); + simplex_tree.insert_simplex({2, 4}, 6.); + simplex_tree.insert_simplex({3, 6}, 7.); + simplex_tree.insert_simplex({4, 5}, 8.); + simplex_tree.insert_simplex({4, 6}, 9.); + simplex_tree.insert_simplex({5, 6}, 10.); + simplex_tree.insert_simplex({6}, 10.); + + simplex_tree.expansion(3); + std::cout << "********************************************************************\n"; + std::cout << "simplex_tree_expansion_3\n"; + std::cout << "********************************************************************\n"; + std::cout << "* The complex contains " << simplex_tree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplex_tree.dimension() << " - filtration " << simplex_tree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplex_tree.filtration_simplex_range()) { + std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; + for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + BOOST_CHECK(simplex_tree.num_simplices() == 24); + BOOST_CHECK(simplex_tree.dimension() == 3); + + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({4,5,6})), 10.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2})), 3.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,3})), 4.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,2,3})), 5.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({1,2,3})), 5.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2,3})), 5.)); + +} + +BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_expansion_2, typeST, list_of_tested_variants) { + // Construct the Simplex Tree with a 1-skeleton graph example + typeST simplex_tree; + + simplex_tree.insert_simplex({0, 1}, 0.); + simplex_tree.insert_simplex({0, 2}, 1.); + simplex_tree.insert_simplex({0, 3}, 2.); + simplex_tree.insert_simplex({1, 2}, 3.); + simplex_tree.insert_simplex({1, 3}, 4.); + simplex_tree.insert_simplex({2, 3}, 5.); + simplex_tree.insert_simplex({2, 4}, 6.); + simplex_tree.insert_simplex({3, 6}, 7.); + simplex_tree.insert_simplex({4, 5}, 8.); + simplex_tree.insert_simplex({4, 6}, 9.); + simplex_tree.insert_simplex({5, 6}, 10.); + simplex_tree.insert_simplex({6}, 10.); + + simplex_tree.expansion(2); + + std::cout << "********************************************************************\n"; + std::cout << "simplex_tree_expansion_2\n"; + std::cout << "********************************************************************\n"; + std::cout << "* The complex contains " << simplex_tree.num_simplices() << " simplices\n"; + std::cout << " - dimension " << simplex_tree.dimension() << " - filtration " << simplex_tree.filtration() << "\n"; + std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; + for (auto f_simplex : simplex_tree.filtration_simplex_range()) { + std::cout << " " << "[" << simplex_tree.filtration(f_simplex) << "] "; + for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) + std::cout << "(" << vertex << ")"; + std::cout << std::endl; + } + + BOOST_CHECK(simplex_tree.num_simplices() == 23); + BOOST_CHECK(simplex_tree.dimension() == 2); + + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({4,5,6})), 10.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,2})), 3.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,1,3})), 4.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({0,2,3})), 5.)); + BOOST_CHECK(AreAlmostTheSame(simplex_tree.filtration(simplex_tree.find({1,2,3})), 5.)); + BOOST_CHECK(simplex_tree.find({0,1,2,3}) == simplex_tree.null_simplex()); +} diff --git a/src/common/include/gudhi/Points_off_io.h b/src/common/include/gudhi/Points_off_io.h index 2104b411..29af8a8a 100644 --- a/src/common/include/gudhi/Points_off_io.h +++ b/src/common/include/gudhi/Points_off_io.h @@ -85,7 +85,7 @@ class Points_off_visitor_reader { std::cout << std::endl; #endif // DEBUG_TRACES // Fill the point cloud - point_cloud.push_back(Point_d(point.end() - point.begin(), point.begin(), point.end())); + point_cloud.push_back(Point_d(point.begin(), point.end())); } // Off_reader visitor maximal_face implementation - Only points are read -- cgit v1.2.3 From 73c3f473fa9d4dc6965607edd1ad748d26cfb86b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 6 Jul 2017 07:10:41 +0000 Subject: Doc example addition git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2587 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: eec20e1b4242460fbe97a9622d69ad35bfdca8b7 --- src/Simplex_tree/doc/Intro_simplex_tree.h | 9 ++++++--- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- src/common/doc/main_page.h | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/doc/Intro_simplex_tree.h b/src/Simplex_tree/doc/Intro_simplex_tree.h index f5b72ff6..769491d9 100644 --- a/src/Simplex_tree/doc/Intro_simplex_tree.h +++ b/src/Simplex_tree/doc/Intro_simplex_tree.h @@ -67,10 +67,13 @@ Information of the Simplex Tree: Number of vertices = 10 Number of simplices = 98 \endcode * * \li - * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp - Simplex tree is computed and displayed from a 3D alpha - * complex (Requires CGAL, GMP and GMPXX to be installed) - * + * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp - Simplex tree is computed and displayed + * from a 3D alpha complex (Requires CGAL, GMP and GMPXX to be installed). * + * \li + * Simplex_tree/graph_expansion_with_blocker.cpp - Simple simplex tree construction from a one-skeleton graph with + * a simple blocker expansion method. + * * \subsection filteredcomplexeshassecomplex Hasse complex * The second one is the Hasse_complex. The Hasse complex is a data structure representing explicitly all co-dimension * 1 incidence relations in a complex. It is consequently faster when accessing the boundary of a simplex, but is less diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 72cb9401..b7ec2c1c 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1089,7 +1089,7 @@ class Simplex_tree { * complex of dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. * The filtration value assigned to a simplex is the maximal filtration value of one of its edges. * The blocker expansion oracle shall answer true on a Simplex_handle if this Simplex_handle has to be removed, - * false otherwise. The blocker expansion oracle can re-assign the filtration value. + * false otherwise. The blocker expansion oracle can re-assign the filtration value if needed. * * The Simplex_tree must contain no simplex of dimension bigger than 1 when calling the method. */ template< typename Blocker > diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index bd4615f5..7219bcfa 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -364,6 +364,8 @@ make doxygen * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp * \li * Simplex_tree/simplex_tree_from_cliques_of_graph.cpp + * \li + * Simplex_tree/graph_expansion_with_blocker.cpp * \li * Persistent_cohomology/alpha_complex_3d_persistence.cpp * \li @@ -450,6 +452,7 @@ make doxygen * @example Simplex_tree/simple_simplex_tree.cpp * @example Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp * @example Simplex_tree/simplex_tree_from_cliques_of_graph.cpp + * @example Simplex_tree/graph_expansion_with_blocker.cpp * @example Skeleton_blocker/Skeleton_blocker_from_simplices.cpp * @example Skeleton_blocker/Skeleton_blocker_iteration.cpp * @example Skeleton_blocker/Skeleton_blocker_link.cpp -- cgit v1.2.3 From deb3ac325f84a6e023923da4cc8e2886d98c3132 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 6 Jul 2017 07:35:16 +0000 Subject: Uused variable git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2589 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: eb0f479d8bdd70010918c80e2902eed9a25806c4 --- src/Simplex_tree/example/simple_simplex_tree.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index f27d7ab8..33face2a 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -250,7 +250,6 @@ int main(int argc, char * const argv[]) { else std::cout << "***- NO IT ISN'T\n"; - invSimplexVector = { 0, 1 }; simplexFound = simplexTree.find({ 0, 1 }); std::cout << "**************IS THE SIMPLEX {0,1} IN THE SIMPLEX TREE ?\n"; if (simplexFound != simplexTree.null_simplex()) -- cgit v1.2.3 From 4be27acc9ad9d1c1d8f67c0c3839022b910b8b75 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Aug 2017 08:13:28 +0000 Subject: Code review : use boost::adaptors::reverse(intersection) instead of std::reverse Doc review : siblings make no sense to a user git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2630 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0c9f2b3159294687241ad994e0c7fa7098d31285 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index b7ec2c1c..7815b95d 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1138,10 +1138,10 @@ class Simplex_tree { } if (intersection.size() != 0) { // Reverse the order to insert - std::reverse(std::begin(intersection), std::end(intersection)); + //std::reverse(std::begin(intersection), std::end(intersection)); Siblings * new_sib = new Siblings(siblings, // oncles simplex->first, // parent - intersection); // boost::container::ordered_unique_range_t + boost::adaptors::reverse(intersection)); // boost::container::ordered_unique_range_t // intersection must be cleared before the function to be called recursively intersection.clear(); @@ -1297,7 +1297,7 @@ class Simplex_tree { public: /** \brief Remove a maximal simplex. * @param[in] sh Simplex handle on the maximal simplex to remove. - * @return true if siblings was deleted, false otherwise. + * @return true if simplex was deleted, false otherwise. * \pre Please check the simplex has no coface before removing it. * \exception std::invalid_argument In debug mode, if sh has children. * \post Be aware that removing is shifting data in a flat_map (initialize_filtration to be done). -- cgit v1.2.3 From 3d2b438a5d6c08b84df3aefe4a0753f4f0c3e49c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Aug 2017 09:56:37 +0000 Subject: Doc review : expansion_with_blockers doc Code review : blocker_expansion_function reamed block_simplex. Add of concept in doc. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2631 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5746beb589e80e329cc7233c5cb54d733256f793 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 34 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 7815b95d..88092b3d 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1082,23 +1082,31 @@ class Simplex_tree { } public: - /** \brief Expands the Simplex_tree containing only its one skeleton until dimension max_dim according with a user - * given blocker expansion oracle + /** \brief Expands a simplex tree containing only a graph. Simplices corresponding to cliques in the graph are added + * incrementally, faces before cofaces, unless the simplex has dimension larger than `max_dim` or `block_simplex` + * returns true for this simplex. * - * The expanded simplicial complex until dimension \f$d\f$ attached to a graph \f$G\f$ is the maximal simplicial - * complex of dimension at most \f$d\f$ admitting the graph \f$G\f$ as \f$1\f$-skeleton. - * The filtration value assigned to a simplex is the maximal filtration value of one of its edges. - * The blocker expansion oracle shall answer true on a Simplex_handle if this Simplex_handle has to be removed, - * false otherwise. The blocker expansion oracle can re-assign the filtration value if needed. + * @param[in] max_dim Expansion maximal dimension value. + * @param[in] block_simplex Blocker oracle. Its concept is bool block_simplex(Simplex_handle sh) * - * The Simplex_tree must contain no simplex of dimension bigger than 1 when calling the method. */ + * The function identifies a candidate simplex whose faces are all already in the complex, inserts + * it with a filtration value corresponding to the maximum of the filtration values of the faces, then calls + * `block_simplex` on a `Simplex_handle` for this new simplex. If `block_simplex` returns true, the simplex is + * removed, otherwise it is kept. Note that the evaluation of `block_simplex` is a good time to update the + * filtration value of the simplex if you want a customized value. The algorithm then proceeds with the next + * candidate. + * + * @warning several candidates of the same dimension may be inserted simultaneously before calling `block_simplex`, + * so if you examine the complex in `block_simplex`, you may hit a few simplices that have not been vetted by + * `block_simplex` yet. + */ template< typename Blocker > - void expansion_with_blockers(int max_dim, Blocker blocker_expansion_function) { + void expansion_with_blockers(int max_dim, Blocker block_simplex) { dimension_ = max_dim; // Loop must be from the end to the beginning, as higher dimension simplex are always on the left part of the tree for (auto& simplex : boost::adaptors::reverse(root_.members())) { if (has_children(&simplex)) { - siblings_expansion_with_blockers(simplex.second.children(), max_dim - 1, blocker_expansion_function); + siblings_expansion_with_blockers(simplex.second.children(), max_dim - 1, block_simplex); } } dimension_ = max_dim - dimension_; @@ -1108,7 +1116,7 @@ class Simplex_tree { /** \brief Recursive expansion with blockers of the simplex tree.*/ template< typename Blocker > void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements - int k, Blocker blocker_expansion_function) { + int k, Blocker block_simplex) { if (dimension_ > k) { dimension_ = k; } @@ -1150,7 +1158,7 @@ class Simplex_tree { for (auto new_sib_member = new_sib->members().begin(); new_sib_member != new_sib->members().end(); new_sib_member++) { - bool blocker_result = blocker_expansion_function(new_sib_member); + bool blocker_result = block_simplex(new_sib_member); // new_sib member has been blocked by the blocker function // add it to the list to be removed - do not perform it while looping on it if (blocker_result) @@ -1166,7 +1174,7 @@ class Simplex_tree { } else { // ensure recursive call simplex->second.assign_children(new_sib); - siblings_expansion_with_blockers(new_sib, k - 1, blocker_expansion_function); + siblings_expansion_with_blockers(new_sib, k - 1, block_simplex); } } else { // ensure the children property -- cgit v1.2.3 From fa0388bc3896f881b35fa6c333ceb0116d3e7fdb Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Aug 2017 13:36:42 +0000 Subject: Code review : find_child implementation improvement git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2632 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c4024b5a56b64dd168a5de1422a857ccebd606fb --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 88092b3d..aa097a38 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1189,11 +1189,16 @@ class Simplex_tree { * Returns null_simplex() if it does not exist */ Simplex_handle find_child(Simplex_handle sh, Vertex_handle vh) { - std::vector child = {vh}; - for (auto vertex : simplex_vertex_range(sh)) { - child.push_back(vertex); - } - return find(child); + if (!has_children(sh)) + return null_simplex(); + + Simplex_handle child = sh->second.children()->find(vh); + // Specific case of boost::flat_map does not find, returns boost::flat_map::end() + // in simplex tree we want a null_simplex() + if (child == sh->second.children()->members().end()) + return null_simplex(); + + return child; } public: -- cgit v1.2.3 From eead3066ec52bdc1eaedf5d6bbd3957ce711b036 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Aug 2017 14:37:50 +0000 Subject: Code review : no need to clear intersection git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2633 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9a59d20c5786b012229cc5db45181ba165af8f8a --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index aa097a38..b1767f63 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1146,13 +1146,9 @@ class Simplex_tree { } if (intersection.size() != 0) { // Reverse the order to insert - //std::reverse(std::begin(intersection), std::end(intersection)); Siblings * new_sib = new Siblings(siblings, // oncles simplex->first, // parent boost::adaptors::reverse(intersection)); // boost::container::ordered_unique_range_t - // intersection must be cleared before the function to be called recursively - intersection.clear(); - std::vector blocked_new_sib_list; // As all intersections are inserted, we can call the blocker function on all new_sib members for (auto new_sib_member = new_sib->members().begin(); @@ -1179,7 +1175,6 @@ class Simplex_tree { } else { // ensure the children property simplex->second.assign_children(siblings); - intersection.clear(); } } } -- cgit v1.2.3 From 3e9006eeb1c731e63fce5aa71802997284abe461 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 25 Aug 2017 15:33:05 +0000 Subject: Code review : dimension_ is now set on the fly git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2634 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 12974878db3242c442c09268437de4d56e704593 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index b1767f63..ee173c70 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1102,23 +1102,20 @@ class Simplex_tree { */ template< typename Blocker > void expansion_with_blockers(int max_dim, Blocker block_simplex) { - dimension_ = max_dim; // Loop must be from the end to the beginning, as higher dimension simplex are always on the left part of the tree for (auto& simplex : boost::adaptors::reverse(root_.members())) { if (has_children(&simplex)) { - siblings_expansion_with_blockers(simplex.second.children(), max_dim - 1, block_simplex); + siblings_expansion_with_blockers(simplex.second.children(), max_dim, max_dim - 1, block_simplex); } } - dimension_ = max_dim - dimension_; } private: /** \brief Recursive expansion with blockers of the simplex tree.*/ template< typename Blocker > - void siblings_expansion_with_blockers(Siblings* siblings, // must contain elements - int k, Blocker block_simplex) { - if (dimension_ > k) { - dimension_ = k; + void siblings_expansion_with_blockers(Siblings* siblings, int max_dim, int k, Blocker block_simplex) { + if (dimension_ < max_dim - k) { + dimension_ = max_dim - k; } if (k == 0) return; @@ -1170,7 +1167,7 @@ class Simplex_tree { } else { // ensure recursive call simplex->second.assign_children(new_sib); - siblings_expansion_with_blockers(new_sib, k - 1, block_simplex); + siblings_expansion_with_blockers(new_sib, max_dim, k - 1, block_simplex); } } else { // ensure the children property -- cgit v1.2.3 From 5fb66b3c664b2343776b97327c4bde9eb6c69351 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 30 Aug 2017 09:18:40 +0000 Subject: Code review better use a break to end loop when we know it is not needed to be inserted. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2640 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2f5fe60856598f0b45c86fd91beda407bcf6938d --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index ee173c70..f7df277c 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1132,7 +1132,10 @@ class Simplex_tree { // If all the boundaries are present, 'next' needs to be inserted for (auto& border : boundary_simplex_range(simplex)) { Simplex_handle border_child = find_child(border, next->first); - to_be_inserted = to_be_inserted && (border_child != null_simplex()); + if (border_child == null_simplex()) { + to_be_inserted=false; + break; + } filt = std::max(filt, filtration(border_child)); } if (to_be_inserted) { -- cgit v1.2.3 From b9ca395bdade623ccfc58e92a98e90bf7eae6f17 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 11 Sep 2017 19:40:56 +0000 Subject: Code review: constify find_child and for instead of while loop git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2657 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e136c1a8b6d5bbc213383f1e6a2e00a875424ad1 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index f7df277c..f48dd048 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1124,9 +1124,8 @@ class Simplex_tree { return; // Reverse loop starting before the last one for 'next' to be the last one for (auto simplex = siblings->members().rbegin() + 1; simplex != siblings->members().rend(); simplex++) { - auto next = siblings->members().rbegin(); std::vector > intersection; - while(next != simplex) { + for(auto next = siblings->members().rbegin(); next != simplex; next++) { bool to_be_inserted = true; Filtration_value filt = simplex->second.filtration(); // If all the boundaries are present, 'next' needs to be inserted @@ -1141,8 +1140,6 @@ class Simplex_tree { if (to_be_inserted) { intersection.emplace_back(next->first, Node(nullptr, filt)); } - // loop until simplex is reached - next++; } if (intersection.size() != 0) { // Reverse the order to insert @@ -1183,7 +1180,7 @@ class Simplex_tree { * Vertex_handle. * Returns null_simplex() if it does not exist */ - Simplex_handle find_child(Simplex_handle sh, Vertex_handle vh) { + Simplex_handle find_child(Simplex_handle sh, Vertex_handle vh) const { if (!has_children(sh)) return null_simplex(); -- cgit v1.2.3 From fb41612243f07ee6faaca02f70d09d4501c24bb1 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 11 Sep 2017 19:49:36 +0000 Subject: Code review: remove reference and explicit type (instead of auto) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2658 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3ba33efc13a3a650f2c2d20bb803aca3b475603a --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index f48dd048..ff6ffa67 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1129,7 +1129,7 @@ class Simplex_tree { bool to_be_inserted = true; Filtration_value filt = simplex->second.filtration(); // If all the boundaries are present, 'next' needs to be inserted - for (auto& border : boundary_simplex_range(simplex)) { + for (Simplex_handle border : boundary_simplex_range(simplex)) { Simplex_handle border_child = find_child(border, next->first); if (border_child == null_simplex()) { to_be_inserted=false; -- cgit v1.2.3 From f25099a09b2c0c4a6a317f2c869bc819462d7edf Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 11 Sep 2017 19:53:33 +0000 Subject: Doc review: rephrase git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2659 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b8a04218fa043e2bd273f77233d794e2c9522060 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index ff6ffa67..5cb13053 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1097,8 +1097,8 @@ class Simplex_tree { * candidate. * * @warning several candidates of the same dimension may be inserted simultaneously before calling `block_simplex`, - * so if you examine the complex in `block_simplex`, you may hit a few simplices that have not been vetted by - * `block_simplex` yet. + * so if you examine the complex in `block_simplex`, you may hit a few simplices of the same dimension that have not + * been vetted by `block_simplex` yet, or have already been rejected but not yet removed. */ template< typename Blocker > void expansion_with_blockers(int max_dim, Blocker block_simplex) { -- cgit v1.2.3 From de09c3d3a8c86b1538f66c674f6f9819abec16cc Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 11 Sep 2017 20:08:29 +0000 Subject: Doc review: bad doc review fix git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2660 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a024a1570e282c5ebd1c675d687372ee3dab0ed0 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 5cb13053..730b552f 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1302,7 +1302,7 @@ class Simplex_tree { public: /** \brief Remove a maximal simplex. * @param[in] sh Simplex handle on the maximal simplex to remove. - * @return true if simplex was deleted, false otherwise. + * @return true if the leaf's branch has no other leaves (branch's children has been re-assigned), false otherwise. * \pre Please check the simplex has no coface before removing it. * \exception std::invalid_argument In debug mode, if sh has children. * \post Be aware that removing is shifting data in a flat_map (initialize_filtration to be done). -- cgit v1.2.3 From 3534c24fd805f8cf0ed8f1d5faea183513966b9f Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 22 Sep 2017 06:59:33 +0000 Subject: Remove global filtration attribute of te simplex tree (including getter and setter) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_remove_useless_global_filtration@2705 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a6c179ae47e61d1ca12d1f54c4ae1fc0e3c1fde2 --- src/Hasse_complex/include/gudhi/Hasse_complex.h | 10 +--------- .../example/alpha_complex_3d_persistence.cpp | 2 -- .../example/exact_alpha_complex_3d_persistence.cpp | 2 -- .../periodic_alpha_complex_3d_persistence.cpp | 2 -- .../example/persistence_from_file.cpp | 3 +-- .../persistence_from_simple_simplex_tree.cpp | 3 +-- .../weighted_alpha_complex_3d_persistence.cpp | 2 -- .../test/persistent_cohomology_unit_test.cpp | 3 +-- ...persistent_cohomology_unit_test_multi_field.cpp | 3 +-- src/Simplex_tree/example/simple_simplex_tree.cpp | 3 +-- src/Simplex_tree/include/gudhi/Simplex_tree.h | 22 ---------------------- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 22 ++++------------------ src/cython/cython/simplex_tree.pyx | 10 ---------- src/cython/example/simplex_tree_example.py | 1 - src/cython/test/test_simplex_tree.py | 1 - 15 files changed, 10 insertions(+), 79 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Hasse_complex/include/gudhi/Hasse_complex.h b/src/Hasse_complex/include/gudhi/Hasse_complex.h index 8b06b771..834201a5 100644 --- a/src/Hasse_complex/include/gudhi/Hasse_complex.h +++ b/src/Hasse_complex/include/gudhi/Hasse_complex.h @@ -104,7 +104,6 @@ class Hasse_complex { Hasse_complex(Complex_ds & cpx) : complex_(cpx.num_simplices()) , vertices_() - , threshold_(cpx.filtration()) , num_vertices_() , dim_max_(cpx.dimension()) { int size = complex_.size(); @@ -125,7 +124,6 @@ class Hasse_complex { Hasse_complex() : complex_() , vertices_() - , threshold_(0) , num_vertices_(0) , dim_max_(-1) { } @@ -157,15 +155,11 @@ class Hasse_complex { Filtration_value filtration(Simplex_handle sh) { if (sh == null_simplex()) { - return filtration(); + return INFINITY; } return complex_[sh].filtration_; } - Filtration_value filtration() { - return threshold_; - } - int dimension(Simplex_handle sh) { if (complex_[sh].boundary_.empty()) return 0; return complex_[sh].boundary_.size() - 1; @@ -206,7 +200,6 @@ class Hasse_complex { std::vector< Hasse_simp, Gudhi::no_init_allocator > complex_; std::vector vertices_; - Filtration_value threshold_; size_t num_vertices_; int dim_max_; }; @@ -245,7 +238,6 @@ std::istream& operator>>(std::istream & is } hcpx.dim_max_ = max_dim; - hcpx.threshold_ = max_fil; return is; } diff --git a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp index fd227b82..53e50a69 100644 --- a/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/alpha_complex_3d_persistence.cpp @@ -202,7 +202,6 @@ int main(int argc, char * const argv[]) { else std::cout << "This shall not happen" << std::endl; } - simplex_tree.set_filtration(filtration_max); simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES @@ -216,7 +215,6 @@ int main(int argc, char * const argv[]) { std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; std::cout << " Dimension = " << simplex_tree.dimension() << " "; - std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl; #endif // DEBUG_TRACES #ifdef DEBUG_TRACES diff --git a/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp index 8a335075..acb34bcb 100644 --- a/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/exact_alpha_complex_3d_persistence.cpp @@ -204,7 +204,6 @@ int main(int argc, char * const argv[]) { else std::cout << "This shall not happen" << std::endl; } - simplex_tree.set_filtration(filtration_max); simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES @@ -218,7 +217,6 @@ int main(int argc, char * const argv[]) { std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; std::cout << " Dimension = " << simplex_tree.dimension() << " "; - std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl; #endif // DEBUG_TRACES #ifdef DEBUG_TRACES 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 8928cfc2..f731d349 100644 --- a/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/periodic_alpha_complex_3d_persistence.cpp @@ -221,7 +221,6 @@ int main(int argc, char * const argv[]) { else std::cout << "This shall not happen" << std::endl; } - simplex_tree.set_filtration(filtration_max); simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES @@ -235,7 +234,6 @@ int main(int argc, char * const argv[]) { std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; std::cout << " Dimension = " << simplex_tree.dimension() << " "; - std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl; #endif // DEBUG_TRACES #ifdef DEBUG_TRACES diff --git a/src/Persistent_cohomology/example/persistence_from_file.cpp b/src/Persistent_cohomology/example/persistence_from_file.cpp index 67235467..eafa3fd5 100644 --- a/src/Persistent_cohomology/example/persistence_from_file.cpp +++ b/src/Persistent_cohomology/example/persistence_from_file.cpp @@ -61,8 +61,7 @@ int main(int argc, char * argv[]) { simplex_tree_stream >> simplex_tree; std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices" << std::endl; - std::cout << " - dimension " << simplex_tree.dimension() << " - filtration " << simplex_tree.filtration() - << std::endl; + std::cout << " - dimension " << simplex_tree.dimension() << std::endl; /* std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; 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 7ca9410a..8214d66a 100644 --- a/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp +++ b/src/Persistent_cohomology/example/persistence_from_simple_simplex_tree.cpp @@ -143,11 +143,10 @@ int main(int argc, char * const argv[]) { /* An edge [10,12,2] */ st.set_dimension(2); - st.set_filtration(0.4); std::cout << "The complex contains " << st.num_simplices() << " simplices - " << st.num_vertices() << " vertices " << std::endl; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; + std::cout << " - dimension " << st.dimension() << std::endl; std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; std::cout << "**************************************************************" << std::endl; diff --git a/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp b/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp index 34b90933..9728f22d 100644 --- a/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp +++ b/src/Persistent_cohomology/example/weighted_alpha_complex_3d_persistence.cpp @@ -222,7 +222,6 @@ int main(int argc, char * const argv[]) { else std::cout << "This shall not happen" << std::endl; } - simplex_tree.set_filtration(filtration_max); simplex_tree.set_dimension(dim_max); #ifdef DEBUG_TRACES @@ -236,7 +235,6 @@ int main(int argc, char * const argv[]) { std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; std::cout << " Dimension = " << simplex_tree.dimension() << " "; - std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl; #endif // DEBUG_TRACES #ifdef DEBUG_TRACES diff --git a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp index f8174020..f53987b6 100644 --- a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp +++ b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp @@ -31,12 +31,11 @@ std::string test_rips_persistence(int coefficient, int min_persistence) { // Display the Simplex_tree std::cout << "The complex contains " << st.num_simplices() << " simplices" << " - dimension= " << st.dimension() - << " - filtration= " << st.filtration() << std::endl; + << std::endl; // Check BOOST_CHECK(st.num_simplices() == 98); BOOST_CHECK(st.dimension() == 3); - BOOST_CHECK(st.filtration() == 1.89); // Sort the simplices in the order of the filtration st.initialize_filtration(); 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 3537cfa4..9e767943 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 @@ -31,12 +31,11 @@ std::string test_rips_persistence(int min_coefficient, int max_coefficient, doub // Display the Simplex_tree std::cout << "The complex contains " << st.num_simplices() << " simplices" << " - dimension= " << st.dimension() - << " - filtration= " << st.filtration() << std::endl; + << std::endl; // Check BOOST_CHECK(st.num_simplices() == 58); BOOST_CHECK(st.dimension() == 3); - BOOST_CHECK(st.filtration() == 0.4); // Sort the simplices in the order of the filtration st.initialize_filtration(); diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index 60f9a35e..d8318f03 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -185,13 +185,12 @@ int main(int argc, char * const argv[]) { } // ++ GENERAL VARIABLE SET - simplexTree.set_filtration(FOURTH_FILTRATION_VALUE); // Max filtration value simplexTree.set_dimension(2); // Max dimension = 2 -> (2,1,0) std::cout << "********************************************************************\n"; // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n"; - std::cout << " - dimension " << simplexTree.dimension() << " - filtration " << simplexTree.filtration() << "\n"; + std::cout << " - dimension " << simplexTree.dimension() << "\n"; std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; for (auto f_simplex : simplexTree.filtration_simplex_range()) { std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 317bce23..8c91cc67 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -289,7 +289,6 @@ class Simplex_tree { /** \brief Constructs an empty simplex tree. */ Simplex_tree() : null_vertex_(-1), - threshold_(0), root_(nullptr, null_vertex_), filtration_vect_(), dimension_(-1) { } @@ -297,7 +296,6 @@ class Simplex_tree { /** \brief User-defined copy constructor reproduces the whole tree structure. */ Simplex_tree(const Simplex_tree& simplex_source) : null_vertex_(simplex_source.null_vertex_), - threshold_(simplex_source.threshold_), root_(nullptr, null_vertex_ , simplex_source.root_.members_), filtration_vect_(), dimension_(simplex_source.dimension_) { @@ -323,12 +321,10 @@ class Simplex_tree { /** \brief User-defined move constructor moves the whole tree structure. */ Simplex_tree(Simplex_tree && old) : null_vertex_(std::move(old.null_vertex_)), - threshold_(std::move(old.threshold_)), root_(std::move(old.root_)), filtration_vect_(std::move(old.filtration_vect_)), dimension_(std::move(old.dimension_)) { old.dimension_ = -1; - old.threshold_ = 0; old.root_ = Siblings(nullptr, null_vertex_); } @@ -356,7 +352,6 @@ class Simplex_tree { /** \brief Checks if two simplex trees are equal. */ bool operator==(Simplex_tree& st2) { if ((null_vertex_ != st2.null_vertex_) || - (threshold_ != st2.threshold_) || (dimension_ != st2.dimension_)) return false; return rec_equal(&root_, &st2.root_); @@ -427,11 +422,6 @@ class Simplex_tree { sh->second.assign_filtration(fv); } - /** \brief Returns an upper bound of the filtration values of the simplices. */ - Filtration_value filtration() const { - return threshold_; - } - /** \brief Returns a Simplex_handle different from all Simplex_handles * associated to the simplices in the simplicial complex. * @@ -757,11 +747,6 @@ class Simplex_tree { return &root_; } - /** Set an upper bound for the filtration values. */ - void set_filtration(Filtration_value fil) { - threshold_ = fil; - } - /** Set a dimension for the simplicial complex. */ void set_dimension(int dimension) { dimension_ = dimension; @@ -1215,8 +1200,6 @@ class Simplex_tree { private: Vertex_handle null_vertex_; - /** \brief Upper bound on the filtration values of the simplices.*/ - Filtration_value threshold_; /** \brief Total number of simplices in the complex, without the empty simplex.*/ /** \brief Set of simplex tree Nodes representing the vertices.*/ Siblings root_; @@ -1244,7 +1227,6 @@ std::istream& operator>>(std::istream & is, Simplex_tree & st) { typedef Simplex_tree ST; std::vector simplex; typename ST::Filtration_value fil; - typename ST::Filtration_value max_fil = 0; int max_dim = -1; while (read_simplex(is, simplex, fil)) { // read all simplices in the file as a list of vertices @@ -1253,15 +1235,11 @@ std::istream& operator>>(std::istream & is, Simplex_tree & st) { if (max_dim < dim) { max_dim = dim; } - if (max_fil < fil) { - max_fil = fil; - } // insert every simplex in the simplex tree st.insert_simplex(simplex, fil); simplex.clear(); } st.set_dimension(max_dim); - st.set_filtration(max_fil); return is; } diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index b06d7ec9..17ddc605 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -26,7 +26,6 @@ void test_empty_simplex_tree(typeST& tst) { 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(); @@ -98,12 +97,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_from_file, typeST, list_of_tested_var // Display the Simplex_tree std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; + std::cout << " - dimension " << st.dimension() << std::endl; // Check BOOST_CHECK(st.num_simplices() == 143353); BOOST_CHECK(st.dimension() == 3); - BOOST_CHECK(AreAlmostTheSame(st.filtration(), 0.4)); int previous_size = 0; for (auto f_simplex : st.filtration_simplex_range()) { @@ -147,7 +145,6 @@ void test_simplex_tree_insert_returns_true(const typePairSimplexBool& returnValu } // Global variables -double max_fil = 0.0; int dim_max = -1; template @@ -158,15 +155,8 @@ void set_and_test_simplex_tree_dim_fil(typeST& simplexTree, int vectorSize, cons std::cout << " set_and_test_simplex_tree_dim_fil - dim_max=" << dim_max << std::endl; } - if (fil > max_fil) { - max_fil = fil; - simplexTree.set_filtration(max_fil); - std::cout << " set_and_test_simplex_tree_dim_fil - max_fil=" << max_fil - << std::endl; - } BOOST_CHECK(simplexTree.dimension() == dim_max); - BOOST_CHECK(AreAlmostTheSame(simplexTree.filtration(), max_fil)); // Another way to count simplices: size_t num_simp = 0; @@ -190,7 +180,6 @@ 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 = 0.0; // TEST OF INSERTION std::cout << "********************************************************************" << std::endl; @@ -310,7 +299,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr)); BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !! BOOST_CHECK(st.dimension() == dim_max); - BOOST_CHECK(AreAlmostTheSame(st.filtration(), max_fil)); // ++ ELEVENTH std::cout << " - INSERT (2,1,0) (already inserted)" << std::endl; @@ -325,7 +313,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var BOOST_CHECK(shReturned == typename typeST::Simplex_handle(nullptr)); BOOST_CHECK(st.num_vertices() == (size_t) 4); // Not incremented !! BOOST_CHECK(st.dimension() == dim_max); - BOOST_CHECK(AreAlmostTheSame(st.filtration(), max_fil)); /* Inserted simplex: */ /* 1 */ @@ -365,7 +352,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insertion, typeST, list_of_tested_var // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; + std::cout << " - dimension " << st.dimension() << std::endl; std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; for (auto f_simplex : st.filtration_simplex_range()) { std::cout << " " << "[" << st.filtration(f_simplex) << "] "; @@ -575,7 +562,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(NSimplexAndSubfaces_tree_insertion, typeST, list_o // Display the Simplex_tree - Can not be done in the middle of 2 inserts std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; - std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl; + std::cout << " - dimension " << st.dimension() << std::endl; std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl; for (auto f_simplex : st.filtration_simplex_range()) { std::cout << " " << "[" << st.filtration(f_simplex) << "] "; @@ -756,7 +743,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(copy_move_on_simplex_tree, typeST, list_of_tested_ typeST st_empty; // Check st has been emptied by the move BOOST_CHECK(st == st_empty); - BOOST_CHECK(st.filtration() == 0); BOOST_CHECK(st.dimension() == -1); BOOST_CHECK(st.num_simplices() == 0); BOOST_CHECK(st.num_vertices() == (size_t)0); @@ -1149,4 +1135,4 @@ BOOST_AUTO_TEST_CASE(mini_prune_above_filtration) { // Display the Simplex_tree std::cout << "The complex contains " << st.num_simplices() << " simplices" << std::endl; -} \ No newline at end of file +} diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx index 47aa5311..45487158 100644 --- a/src/cython/cython/simplex_tree.pyx +++ b/src/cython/cython/simplex_tree.pyx @@ -36,9 +36,7 @@ cdef extern from "Simplex_tree_interface.h" namespace "Gudhi": cdef cppclass Simplex_tree_interface_full_featured "Gudhi::Simplex_tree_interface": Simplex_tree() - double filtration() double simplex_filtration(vector[int] simplex) - void set_filtration(double filtration) void initialize_filtration() int num_vertices() int num_simplices() @@ -115,14 +113,6 @@ cdef class SimplexTree: """ return self.thisptr.simplex_filtration(simplex) - def set_filtration(self, filtration): - """This function sets the main simplicial complex filtration value. - - :param filtration: The filtration value. - :type filtration: float. - """ - self.thisptr.set_filtration( filtration) - def initialize_filtration(self): """This function initializes and sorts the simplicial complex filtration vector. diff --git a/src/cython/example/simplex_tree_example.py b/src/cython/example/simplex_tree_example.py index 3af20fcf..831d9da8 100755 --- a/src/cython/example/simplex_tree_example.py +++ b/src/cython/example/simplex_tree_example.py @@ -52,7 +52,6 @@ else: st.set_dimension(3) print("dimension=", st.dimension()) -st.set_filtration(4.0) st.initialize_filtration() print("filtration=", st.get_filtration()) print("filtration[1, 2]=", st.filtration([1, 2])) diff --git a/src/cython/test/test_simplex_tree.py b/src/cython/test/test_simplex_tree.py index 3ae537e3..4d452d7d 100755 --- a/src/cython/test/test_simplex_tree.py +++ b/src/cython/test/test_simplex_tree.py @@ -53,7 +53,6 @@ def test_insertion(): assert st.find([2, 3]) == False # filtration test - st.set_filtration(5.0) st.initialize_filtration() assert st.filtration([0, 1, 2]) == 4.0 assert st.filtration([0, 2]) == 4.0 -- cgit v1.2.3 From 697884f4193c32723922aa5edfef37d09d198fac Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 26 Sep 2017 19:57:06 +0000 Subject: Doc review : Simplex tree remove maximal simplex is an implementatino detail that is not needed by the developper git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2717 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d096485bf30e50c804cf349f040f57764770136f --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 730b552f..fe1e87b4 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1302,10 +1302,11 @@ class Simplex_tree { public: /** \brief Remove a maximal simplex. * @param[in] sh Simplex handle on the maximal simplex to remove. - * @return true if the leaf's branch has no other leaves (branch's children has been re-assigned), false otherwise. + * @return a boolean value that is an implementation detail, and that the user is supposed to ignore * \pre Please check the simplex has no coface before removing it. * \exception std::invalid_argument In debug mode, if sh has children. * \post Be aware that removing is shifting data in a flat_map (initialize_filtration to be done). + * \internal @return true if the leaf's branch has no other leaves (branch's children has been re-assigned), false otherwise. */ bool remove_maximal_simplex(Simplex_handle sh) { // Guarantee the simplex has no children -- cgit v1.2.3 From 914398be0187ab7d21ef1100533ed7a3c7983c76 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 27 Sep 2017 20:10:05 +0000 Subject: Replace INFINITY with std::numeric_limits::infinity() git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_remove_useless_global_filtration@2719 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b24d3381da60cd634142e3024d5f5ed53294f8e8 --- src/Hasse_complex/include/gudhi/Hasse_complex.h | 3 ++- src/Simplex_tree/include/gudhi/Simplex_tree.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Hasse_complex/include/gudhi/Hasse_complex.h b/src/Hasse_complex/include/gudhi/Hasse_complex.h index 834201a5..e67f7609 100644 --- a/src/Hasse_complex/include/gudhi/Hasse_complex.h +++ b/src/Hasse_complex/include/gudhi/Hasse_complex.h @@ -30,6 +30,7 @@ #include #include // for pair #include +#include // for infinity value #ifdef GUDHI_USE_TBB #include @@ -155,7 +156,7 @@ class Hasse_complex { Filtration_value filtration(Simplex_handle sh) { if (sh == null_simplex()) { - return INFINITY; + return std::numeric_limits::infinity(); } return complex_[sh].filtration_; } diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 8c91cc67..37b3ea97 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -402,14 +402,14 @@ class Simplex_tree { /** \brief Returns the filtration value of a simplex. * - * Called on the null_simplex, returns INFINITY. + * Called on the null_simplex, it returns infinity. * If SimplexTreeOptions::store_filtration is false, returns 0. */ static Filtration_value filtration(Simplex_handle sh) { if (sh != null_simplex()) { return sh->second.filtration(); } else { - return INFINITY; + return std::numeric_limits::infinity(); } } -- cgit v1.2.3 From b9d4c8c0073fbd8c0b0bf999ae6ee7d3de60501d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 5 Oct 2017 17:16:48 +0000 Subject: Doc review : fix find_child explanation git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/graph_expansion_with_blocker_oracle@2758 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 30759214110b29a525cbbf2d97ff84b92b4eace2 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index fe1e87b4..a8c01f84 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1177,7 +1177,7 @@ class Simplex_tree { } /* \private Returns the Simplex_handle composed of the vertex list (from the Simplex_handle), plus the given - * Vertex_handle. + * Vertex_handle if the Vertex_handle is found in the Simplex_handle children list. * Returns null_simplex() if it does not exist */ Simplex_handle find_child(Simplex_handle sh, Vertex_handle vh) const { -- cgit v1.2.3