summaryrefslogtreecommitdiff
path: root/src/Bottleneck_distance/include
diff options
context:
space:
mode:
authorfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-11-25 13:17:50 +0000
committerfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-11-25 13:17:50 +0000
commite15d7f55c337596e988cd84425bbfc4815913074 (patch)
treeeb8b476b96893008c771618134daed19ef300d54 /src/Bottleneck_distance/include
parent5bd04a9433462965aecf000e5044e70405e968ff (diff)
copyrigths
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bottleneck_integration@1783 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c045f59d4f2810aa2193add84ac97a2632888dc4
Diffstat (limited to 'src/Bottleneck_distance/include')
-rw-r--r--src/Bottleneck_distance/include/gudhi/Bottleneck.h6
-rw-r--r--src/Bottleneck_distance/include/gudhi/Construct_coord_iterator.h4
-rw-r--r--src/Bottleneck_distance/include/gudhi/Graph_matching.h4
-rw-r--r--src/Bottleneck_distance/include/gudhi/Internal_point.h4
-rw-r--r--src/Bottleneck_distance/include/gudhi/Neighbors_finder.h4
-rw-r--r--src/Bottleneck_distance/include/gudhi/Persistence_diagrams_graph.h7
-rw-r--r--src/Bottleneck_distance/include/gudhi/Planar_neighbors_finder.h89
7 files changed, 26 insertions, 92 deletions
diff --git a/src/Bottleneck_distance/include/gudhi/Bottleneck.h b/src/Bottleneck_distance/include/gudhi/Bottleneck.h
index 71845e25..bb0a13d2 100644
--- a/src/Bottleneck_distance/include/gudhi/Bottleneck.h
+++ b/src/Bottleneck_distance/include/gudhi/Bottleneck.h
@@ -2,9 +2,9 @@
* (Geometric Understanding in Higher Dimensions) is a generic C++
* library for computational topology.
*
- * Author(s): Francois Godi
+ * Author: Francois Godi
*
- * Copyright (C) 2015 INRIA Sophia-Antipolis (France)
+ * Copyright (C) 2015 INRIA (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
@@ -65,7 +65,7 @@ double compute(const Persistence_diagram1 &diag1, const Persistence_diagram2 &di
if(e == 0.)
return compute_exactly(diag1, diag2);
G::initialize(diag1, diag2, e);
- int in = G::diameter()/e;
+ int in = G::diameter()/e + 1;
int idmin = 0;
int idmax = in;
// alpha can be modified, this will change the complexity
diff --git a/src/Bottleneck_distance/include/gudhi/Construct_coord_iterator.h b/src/Bottleneck_distance/include/gudhi/Construct_coord_iterator.h
index 278b7955..0959dd03 100644
--- a/src/Bottleneck_distance/include/gudhi/Construct_coord_iterator.h
+++ b/src/Bottleneck_distance/include/gudhi/Construct_coord_iterator.h
@@ -2,9 +2,9 @@
* (Geometric Understanding in Higher Dimensions) is a generic C++
* library for computational topology.
*
- * Author(s): Francois Godi
+ * Author: Francois Godi
*
- * Copyright (C) 2015 INRIA Sophia-Antipolis (France)
+ * Copyright (C) 2015 INRIA (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
diff --git a/src/Bottleneck_distance/include/gudhi/Graph_matching.h b/src/Bottleneck_distance/include/gudhi/Graph_matching.h
index c50c3a9e..fa20b2a2 100644
--- a/src/Bottleneck_distance/include/gudhi/Graph_matching.h
+++ b/src/Bottleneck_distance/include/gudhi/Graph_matching.h
@@ -2,9 +2,9 @@
* (Geometric Understanding in Higher Dimensions) is a generic C++
* library for computational topology.
*
- * Author(s): Francois Godi
+ * Author: Francois Godi
*
- * Copyright (C) 2015 INRIA Sophia-Antipolis (France)
+ * Copyright (C) 2015 INRIA (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
diff --git a/src/Bottleneck_distance/include/gudhi/Internal_point.h b/src/Bottleneck_distance/include/gudhi/Internal_point.h
index 90b5dd14..78aad470 100644
--- a/src/Bottleneck_distance/include/gudhi/Internal_point.h
+++ b/src/Bottleneck_distance/include/gudhi/Internal_point.h
@@ -2,9 +2,9 @@
* (Geometric Understanding in Higher Dimensions) is a generic C++
* library for computational topology.
*
- * Author(s): Francois Godi
+ * Author: Francois Godi
*
- * Copyright (C) 2015 INRIA Sophia-Antipolis (France)
+ * Copyright (C) 2015 INRIA (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
diff --git a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h
index e8560559..20b47d0b 100644
--- a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h
+++ b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h
@@ -2,9 +2,9 @@
* (Geometric Understanding in Higher Dimensions) is a generic C++
* library for computational topology.
*
- * Author(s): Francois Godi
+ * Author: Francois Godi
*
- * Copyright (C) 2015 INRIA Sophia-Antipolis (France)
+ * Copyright (C) 2015 INRIA (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
diff --git a/src/Bottleneck_distance/include/gudhi/Persistence_diagrams_graph.h b/src/Bottleneck_distance/include/gudhi/Persistence_diagrams_graph.h
index 7d37b9e0..8242ce2b 100644
--- a/src/Bottleneck_distance/include/gudhi/Persistence_diagrams_graph.h
+++ b/src/Bottleneck_distance/include/gudhi/Persistence_diagrams_graph.h
@@ -2,9 +2,9 @@
* (Geometric Understanding in Higher Dimensions) is a generic C++
* library for computational topology.
*
- * Author(s): Francois Godi
+ * Author: Francois Godi
*
- * Copyright (C) 2015 INRIA Sophia-Antipolis (France)
+ * Copyright (C) 2015 INRIA (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
@@ -65,8 +65,7 @@ private:
static Internal_point get_u_point(int u_point_index);
static Internal_point get_v_point(int v_point_index);
- friend class Naive_pnf;
- friend class Cgal_pnf;
+ friend class Planar_neighbors_finder;
};
/** \internal \typedef \brief Shorter alias */
diff --git a/src/Bottleneck_distance/include/gudhi/Planar_neighbors_finder.h b/src/Bottleneck_distance/include/gudhi/Planar_neighbors_finder.h
index f574231e..c1f4d908 100644
--- a/src/Bottleneck_distance/include/gudhi/Planar_neighbors_finder.h
+++ b/src/Bottleneck_distance/include/gudhi/Planar_neighbors_finder.h
@@ -2,9 +2,9 @@
* (Geometric Understanding in Higher Dimensions) is a generic C++
* library for computational topology.
*
- * Author(s): Francois Godi
+ * Author: Francois Godi
*
- * Copyright (C) 2015 INRIA Sophia-Antipolis (France)
+ * Copyright (C) 2015 INRIA (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
@@ -67,7 +67,7 @@ private:
std::multimap<std::pair<int,int>,int> grid;
};
-class Cgal_pnf {
+class Planar_neighbors_finder {
typedef CGAL::Dimension_tag<2> D;
typedef CGAL::Search_traits<double, Internal_point, const double*, CGAL::Construct_coord_iterator, D> Traits;
@@ -78,7 +78,7 @@ class Cgal_pnf {
public:
/** \internal \brief Constructor taking the near distance definition as parameter. */
- Cgal_pnf(double r_);
+ Planar_neighbors_finder(double r_);
/** \internal \brief A point added will be possibly pulled. */
void add(int v_point_index);
/** \internal \brief A point manually removed will no longer be possibly pulled. */
@@ -96,79 +96,14 @@ private:
Kd_tree kd_t;
};
-/** \internal \typedef \brief Planar_neighbors_finder is the used implementation. */
-typedef Cgal_pnf Planar_neighbors_finder;
-
-inline Naive_pnf::Naive_pnf(double r_) :
- r(r_), grid() { }
-
-
-inline std::pair<int,int> Naive_pnf::get_v_key(int v_point_index) const{
- Internal_point v_point = G::get_v_point(v_point_index);
- return std::make_pair(static_cast<int>(v_point.x()/r), static_cast<int>(v_point.y()/r));
-}
-
-inline void Naive_pnf::add(int v_point_index) {
- grid.emplace(get_v_key(v_point_index),v_point_index);
-}
-
-inline void Naive_pnf::remove(int v_point_index) {
- if(v_point_index != null_point_index())
- for(auto it = grid.find(get_v_key(v_point_index)); it!=grid.end(); it++)
- if(it->second==v_point_index){
- grid.erase(it);
- return;
- }
-}
-
-inline bool Naive_pnf::contains(int v_point_index) const {
- if(v_point_index == null_point_index())
- return false;
- for(auto it = grid.find(get_v_key(v_point_index)); it!=grid.end(); it++)
- if(it->second==v_point_index)
- return true;
- return false;
-}
-
-inline int Naive_pnf::pull_near(int u_point_index) {
- Internal_point u_point = G::get_u_point(u_point_index);
- int i0 = static_cast<int>(u_point.x()/r);
- int j0 = static_cast<int>(u_point.y()/r);
- for(int i = 1; i<= 3; i++)
- for(int j = 1; j<= 3; j++)
- for(auto it = grid.find(std::make_pair(i0 +(i%3)-1, j0+(j%3)-1)); it!=grid.end(); it++)
- if (G::distance(u_point_index, it->second) <= r) {
- int tmp = it->second;
- grid.erase(it);
- return tmp;
- }
- return null_point_index();
-}
-
-inline std::vector<int> Naive_pnf::pull_all_near(int u_point_index) {
- std::vector<int> all_pull;
- Internal_point u_point = G::get_u_point(u_point_index);
- int i0 = static_cast<int>(u_point.x()/r);
- int j0 = static_cast<int>(u_point.y()/r);
- for(int i = 1; i<= 3; i++)
- for(int j = 1; j<= 3; j++)
- for(auto it = grid.find(std::make_pair(i0 +(i%3)-1, j0+(j%3)-1)); it!=grid.end();)
- if (G::distance(u_point_index, it->second) <= r) {
- all_pull.emplace_back(it->second);
- it = grid.erase(it);
- }
- else it++;
- return all_pull;
-}
-
/** \internal \brief Constructor taking the near distance definition as parameter. */
-inline Cgal_pnf::Cgal_pnf(double r_)
+inline Planar_neighbors_finder::Planar_neighbors_finder(double r_)
: r(r_), contents(), kd_t() {}
/** \internal \brief A point added will be possibly pulled. */
-inline void Cgal_pnf::add(int v_point_index){
+inline void Planar_neighbors_finder::add(int v_point_index){
if(v_point_index == null_point_index())
return;
contents.insert(v_point_index);
@@ -176,22 +111,20 @@ inline void Cgal_pnf::add(int v_point_index){
}
/** \internal \brief A point manually removed will no longer be possibly pulled. */
-inline void Cgal_pnf::remove(int v_point_index){
- if(contains(v_point_index)){
+inline void Planar_neighbors_finder::remove(int v_point_index){
contents.erase(v_point_index);
kd_t.remove(G::get_v_point(v_point_index));
- }
}
/** \internal \brief Can the point given as parameter be returned ? */
-inline bool Cgal_pnf::contains(int v_point_index) const{
+inline bool Planar_neighbors_finder::contains(int v_point_index) const{
if(v_point_index == null_point_index())
return false;
return contents.count(v_point_index)>0;
}
/** \internal \brief Provide and remove a V point near to the U point given as parameter, null_point_index() if there isn't such a point. */
-inline int Cgal_pnf::pull_near(int u_point_index){
+inline int Planar_neighbors_finder::pull_near(int u_point_index){
Internal_point u_point = G::get_u_point(u_point_index);
std::vector<double> w = {1., 1.};
K_neighbor_search search(kd_t, u_point, 0., true, Distance(0, 2, w));
@@ -199,11 +132,13 @@ inline int Cgal_pnf::pull_near(int u_point_index){
if(it==search.end() || G::distance(u_point_index, it->first.point_index) > r)
return null_point_index();
int tmp = it->first.point_index;
+ if(!contains(tmp))
+ std::cout << "!! A kd_tree returns a point (Point_index:" << tmp << ") previously removed !!" << std::endl;
remove(tmp);
return tmp;
}
-inline std::vector<int> Cgal_pnf::pull_all_near(int u_point_index) {
+inline std::vector<int> Planar_neighbors_finder::pull_all_near(int u_point_index) {
std::vector<int> all_pull;
int last_pull = pull_near(u_point_index);
while (last_pull != null_point_index()) {