summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Bipartite_graph_matching/example/example.cpp2
-rw-r--r--src/Bipartite_graph_matching/include/gudhi/Graph_matching.h3
-rw-r--r--src/Bipartite_graph_matching/include/gudhi/Persistence_diagrams_graph.h1
-rw-r--r--src/Bipartite_graph_matching/include/gudhi/Planar_neighbors_finder.h26
4 files changed, 25 insertions, 7 deletions
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 <iostream>
-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<int>& 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 <map>
#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<int> > pull_all_near(int u_point_index);
private:
std::pair<int,int> 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<int>(u_point.first/r);
int j0 = static_cast<int>(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<int> > Naive_pnf::pull_all_near(int u_point_index) {
+ std::unique_ptr< std::list<int> > all_pull(new std::list<int>);
+ G::Internal_point u_point = G::get_u_point(u_point_index);
+ int i0 = static_cast<int>(u_point.first/r);
+ int j0 = static_cast<int>(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