From 42a123c74255be2e2471eb35fd9226ceea5a011c Mon Sep 17 00:00:00 2001 From: fgodi Date: Fri, 3 Jul 2015 18:03:02 +0000 Subject: envelope tree git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bottleneckDistance@675 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7a66384ac0aaa5678d87d2a0b1eb59a45cbaf8ee --- src/Bipartite_graph_matching/example/example.cpp | 2 +- .../include/gudhi/Graph_matching.h | 3 +-- .../include/gudhi/Persistence_diagrams_graph.h | 1 + .../include/gudhi/Planar_neighbors_finder.h | 26 ++++++++++++++++++---- 4 files changed, 25 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Bipartite_graph_matching/example/example.cpp b/src/Bipartite_graph_matching/example/example.cpp index 683f7723..d190ab48 100644 --- a/src/Bipartite_graph_matching/example/example.cpp +++ b/src/Bipartite_graph_matching/example/example.cpp @@ -23,7 +23,7 @@ #include "../include/gudhi/Graph_matching.h" #include -using namespace Gudhi::bottleneck; +using namespace Gudhi::bipartite_graph_matching; int main() { diff --git a/src/Bipartite_graph_matching/include/gudhi/Graph_matching.h b/src/Bipartite_graph_matching/include/gudhi/Graph_matching.h index 5133646d..a2754333 100644 --- a/src/Bipartite_graph_matching/include/gudhi/Graph_matching.h +++ b/src/Bipartite_graph_matching/include/gudhi/Graph_matching.h @@ -176,8 +176,7 @@ inline void Graph_matching::update(std::deque& path) { for (auto it = path.cbegin(); it != path.cend(); ++it) { // Be careful, the iterator is incremented twice each time int tmp = *it; - ++it; - v_to_u[*it] = tmp; + v_to_u[*(++it)] = tmp; } } diff --git a/src/Bipartite_graph_matching/include/gudhi/Persistence_diagrams_graph.h b/src/Bipartite_graph_matching/include/gudhi/Persistence_diagrams_graph.h index a1fe9285..1f8e83e7 100644 --- a/src/Bipartite_graph_matching/include/gudhi/Persistence_diagrams_graph.h +++ b/src/Bipartite_graph_matching/include/gudhi/Persistence_diagrams_graph.h @@ -71,6 +71,7 @@ private: static Internal_point get_v_point(int v_point_index); friend class Naive_pnf; + friend class Upper_envelope_tree; }; /** \internal \typedef \brief Shorter alias */ diff --git a/src/Bipartite_graph_matching/include/gudhi/Planar_neighbors_finder.h b/src/Bipartite_graph_matching/include/gudhi/Planar_neighbors_finder.h index 50829be6..32155b91 100644 --- a/src/Bipartite_graph_matching/include/gudhi/Planar_neighbors_finder.h +++ b/src/Bipartite_graph_matching/include/gudhi/Planar_neighbors_finder.h @@ -27,7 +27,7 @@ #include #include "Persistence_diagrams_graph.h" -#include "Grid_cell.h" +#include "Envelope_tree.h" namespace Gudhi { @@ -76,6 +76,8 @@ public: bool contains(int v_point_index) const; /** \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. */ int pull_near(int u_point_index); + /** \internal \brief Provide and remove all the V points near to the U point given as parameter. */ + virtual std::unique_ptr< std::list > pull_all_near(int u_point_index); private: std::pair get_v_key(int v_point_index) const; @@ -135,9 +137,9 @@ inline int Naive_pnf::pull_near(int u_point_index) { G::Internal_point u_point = G::get_u_point(u_point_index); int i0 = static_cast(u_point.first/r); int j0 = static_cast(u_point.second/r); - for(int i = i0 -1; i<= i0 + 1; i++) - for(int j = j0 -1; j<= j0 + 1; j++) - for(auto it = grid.find(std::make_pair(i,j)); it!=grid.end(); it++) + 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); @@ -146,6 +148,22 @@ inline int Naive_pnf::pull_near(int u_point_index) { return null_point_index(); } +inline std::unique_ptr< std::list > Naive_pnf::pull_all_near(int u_point_index) { + std::unique_ptr< std::list > all_pull(new std::list); + G::Internal_point u_point = G::get_u_point(u_point_index); + int i0 = static_cast(u_point.first/r); + int j0 = static_cast(u_point.second/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); + all_pull->emplace_back(tmp); + } + return all_pull; +} + } // namespace bipartite_graph_matching } // namespace Gudhi -- cgit v1.2.3