summaryrefslogtreecommitdiff
path: root/src/Cech_complex/example
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-02-22 23:16:55 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-02-22 23:16:55 +0000
commit3cd1e01f0b0d4fdb46f49ec640c389374ca2fe70 (patch)
treeafe2bec947f098942d021e62d62546d56b9acabd /src/Cech_complex/example
parentd57e3dfbf15f8aaa3afa097a4e3ed49cd23d26ea (diff)
Fix Cech with radius distance
Add a meta generation script for off_file_generator git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3256 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fb13baa124ddc97c0dc61835ab0c72595d666155
Diffstat (limited to 'src/Cech_complex/example')
-rw-r--r--src/Cech_complex/example/cech_complex_example_from_points.cpp43
-rw-r--r--src/Cech_complex/example/cech_complex_step_by_step.cpp32
2 files changed, 25 insertions, 50 deletions
diff --git a/src/Cech_complex/example/cech_complex_example_from_points.cpp b/src/Cech_complex/example/cech_complex_example_from_points.cpp
index 882849c3..97327e69 100644
--- a/src/Cech_complex/example/cech_complex_example_from_points.cpp
+++ b/src/Cech_complex/example/cech_complex_example_from_points.cpp
@@ -1,25 +1,3 @@
-/* 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) 2018 Inria
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
#include <gudhi/Cech_complex.h>
#include <gudhi/Simplex_tree.h>
#include <gudhi/distance_functions.h>
@@ -37,23 +15,22 @@ int main() {
using Cech_complex = Gudhi::cech_complex::Cech_complex<Simplex_tree, Point_cloud>;
Point_cloud points;
- points.push_back({1.0, 1.0});
- points.push_back({7.0, 0.0});
- points.push_back({4.0, 6.0});
- points.push_back({9.0, 6.0});
- points.push_back({0.0, 14.0});
- points.push_back({2.0, 19.0});
- points.push_back({9.0, 17.0});
+ points.push_back({0., 0.});
+ points.push_back({0., 2.});
+ points.push_back({std::sqrt(3.), 1.});
+ points.push_back({1., 0.});
+ points.push_back({1., 2.});
+ points.push_back({1. - std::sqrt(3.), 1.});
// ----------------------------------------------------------------------------
// Init of a Cech complex from points
// ----------------------------------------------------------------------------
- // 7.1 is a magic number to force one blocker, and one non-blocker
- Filtration_value threshold = 7.1;
- Cech_complex cech_complex_from_points(points, threshold, Gudhi::Euclidean_distance());
+ // 5. is a magic number to force one blocker, and one non-blocker
+ Filtration_value max_radius = 12.;
+ Cech_complex cech_complex_from_points(points, max_radius);
Simplex_tree stree;
- cech_complex_from_points.create_complex(stree, 2);
+ cech_complex_from_points.create_complex(stree, -1);
// ----------------------------------------------------------------------------
// Display information about the one skeleton Cech complex
// ----------------------------------------------------------------------------
diff --git a/src/Cech_complex/example/cech_complex_step_by_step.cpp b/src/Cech_complex/example/cech_complex_step_by_step.cpp
index e71086b6..8705a3e5 100644
--- a/src/Cech_complex/example/cech_complex_step_by_step.cpp
+++ b/src/Cech_complex/example/cech_complex_step_by_step.cpp
@@ -65,23 +65,22 @@ class Cech_blocker {
std::cout << "#(" << vertex << ")#";
#endif // DEBUG_TRACES
}
- Min_sphere ms(dimension_, points.begin(),points.end());
- Filtration_value radius = std::sqrt(ms.squared_radius());
+ Filtration_value radius = Gudhi::Radius_distance()(points);
#ifdef DEBUG_TRACES
- std::cout << "radius = " << radius << " - " << (radius > threshold_) << std::endl;
+ std::cout << "radius = " << radius << " - " << (radius > max_radius_) << std::endl;
#endif // DEBUG_TRACES
simplex_tree_.assign_filtration(sh, radius);
- return (radius > threshold_);
+ return (radius > max_radius_);
}
- Cech_blocker(Simplex_tree& simplex_tree, Filtration_value threshold, const std::vector<Point>& point_cloud)
+ Cech_blocker(Simplex_tree& simplex_tree, Filtration_value max_radius, const std::vector<Point>& point_cloud)
: simplex_tree_(simplex_tree),
- threshold_(threshold),
+ max_radius_(max_radius),
point_cloud_(point_cloud) {
dimension_ = point_cloud_[0].size();
}
private:
Simplex_tree simplex_tree_;
- Filtration_value threshold_;
+ Filtration_value max_radius_;
std::vector<Point> point_cloud_;
int dimension_;
};
@@ -89,31 +88,31 @@ class Cech_blocker {
void program_options(int argc, char * argv[]
, std::string & off_file_points
- , Filtration_value & threshold
+ , Filtration_value & max_radius
, int & dim_max);
int main(int argc, char * argv[]) {
std::string off_file_points;
- Filtration_value threshold;
+ Filtration_value max_radius;
int dim_max;
- program_options(argc, argv, off_file_points, threshold, dim_max);
+ program_options(argc, argv, off_file_points, max_radius, dim_max);
// Extract the points from the file filepoints
Points_off_reader off_reader(off_file_points);
// Compute the proximity graph of the points
Proximity_graph prox_graph = Gudhi::compute_proximity_graph<Simplex_tree>(off_reader.get_point_cloud(),
- threshold,
- Gudhi::Euclidean_distance());
+ max_radius,
+ Gudhi::Radius_distance());
// 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()));
+ st.expansion_with_blockers(dim_max, Cech_blocker(st, max_radius, off_reader.get_point_cloud()));
std::cout << "The complex contains " << st.num_simplices() << " simplices \n";
std::cout << " and has dimension " << st.dimension() << " \n";
@@ -123,7 +122,6 @@ int main(int argc, char * argv[]) {
#if DEBUG_TRACES
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 - dimension=" << st.dimension() << "\n";
std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n";
for (auto f_simplex : st.filtration_simplex_range()) {
@@ -140,7 +138,7 @@ int main(int argc, char * argv[]) {
void program_options(int argc, char * argv[]
, std::string & off_file_points
- , Filtration_value & threshold
+ , Filtration_value & max_radius
, int & dim_max) {
namespace po = boost::program_options;
po::options_description hidden("Hidden options");
@@ -151,8 +149,8 @@ void program_options(int argc, char * argv[]
po::options_description visible("Allowed options", 100);
visible.add_options()
("help,h", "produce help message")
- ("max-edge-length,r",
- po::value<Filtration_value>(&threshold)->default_value(std::numeric_limits<Filtration_value>::infinity()),
+ ("max-radius,r",
+ po::value<Filtration_value>(&max_radius)->default_value(std::numeric_limits<Filtration_value>::infinity()),
"Maximal length of an edge for the Rips complex construction.")
("cpx-dimension,d", po::value<int>(&dim_max)->default_value(1),
"Maximal dimension of the Rips complex we want to compute.");