summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-05-31 14:15:46 +0000
committerfgodi <fgodi@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-05-31 14:15:46 +0000
commit8f455abec0d349949960eaefdd0aedd8dff8e7ca (patch)
treeb1e4ba36e1aa415545b06ebfe5b2ea140b117ea0
parent8c2cc1f42a779a5774b8330d5630b91c5258fac4 (diff)
works
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bottleneckDistance@1227 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6b7d024adef25ef52ac48a2a0ead692be798a708
-rw-r--r--src/Bipartite_graphs_matching/example/basic.cpp1
-rw-r--r--src/Bipartite_graphs_matching/include/gudhi/Internal_point.h2
-rw-r--r--src/Bipartite_graphs_matching/include/gudhi/Neighbors_finder.h2
-rw-r--r--src/Bipartite_graphs_matching/include/gudhi/Planar_neighbors_finder.h30
4 files changed, 22 insertions, 13 deletions
diff --git a/src/Bipartite_graphs_matching/example/basic.cpp b/src/Bipartite_graphs_matching/example/basic.cpp
index 09530f9a..f1c9d36e 100644
--- a/src/Bipartite_graphs_matching/example/basic.cpp
+++ b/src/Bipartite_graphs_matching/example/basic.cpp
@@ -36,6 +36,7 @@ int main(){
objetfichier.open("results.csv", std::ios::out);
for(int n =50; n<=1000; n+=100){
+std::cout << n << "\n";
std::uniform_real_distribution<double> unif1(0.,upper_bound);
std::uniform_real_distribution<double> unif2(upper_bound/1000.,upper_bound/100.);
std::default_random_engine re;
diff --git a/src/Bipartite_graphs_matching/include/gudhi/Internal_point.h b/src/Bipartite_graphs_matching/include/gudhi/Internal_point.h
index 6c9389b7..3dc37962 100644
--- a/src/Bipartite_graphs_matching/include/gudhi/Internal_point.h
+++ b/src/Bipartite_graphs_matching/include/gudhi/Internal_point.h
@@ -42,7 +42,7 @@ struct Internal_point {
double& y() { return vec[ 1 ]; }
bool operator==(const Internal_point& p) const
{
- return (x() == p.x()) && (y() == p.y()) && (point_index==p.point_index);
+ return point_index==p.point_index;
}
bool operator!=(const Internal_point& p) const { return ! (*this == p); }
/*
diff --git a/src/Bipartite_graphs_matching/include/gudhi/Neighbors_finder.h b/src/Bipartite_graphs_matching/include/gudhi/Neighbors_finder.h
index 7fa9453d..f346c62f 100644
--- a/src/Bipartite_graphs_matching/include/gudhi/Neighbors_finder.h
+++ b/src/Bipartite_graphs_matching/include/gudhi/Neighbors_finder.h
@@ -106,7 +106,7 @@ inline int Neighbors_finder::pull_near(int u_point_index) {
int tmp;
int c = G::corresponding_point_in_v(u_point_index);
if (G::on_the_u_diagonal(u_point_index) && !projections_f.empty())
- //All projections are at distance 0
+ //Any pair of projection is at distance 0
tmp = *projections_f.cbegin();
else if (contains(c) && (G::distance(u_point_index, c) <= r))
//Is the query point near to its projection ?
diff --git a/src/Bipartite_graphs_matching/include/gudhi/Planar_neighbors_finder.h b/src/Bipartite_graphs_matching/include/gudhi/Planar_neighbors_finder.h
index ec5c6f91..3d6d0084 100644
--- a/src/Bipartite_graphs_matching/include/gudhi/Planar_neighbors_finder.h
+++ b/src/Bipartite_graphs_matching/include/gudhi/Planar_neighbors_finder.h
@@ -94,7 +94,7 @@ private:
};
/** \internal \typedef \brief Planar_neighbors_finder is the used implementation. */
-typedef Cgal_pnf Planar_neighbors_finder;
+typedef Naive_pnf Planar_neighbors_finder;
inline Naive_pnf::Naive_pnf(double r_) :
r(r_), grid() { }
@@ -110,12 +110,12 @@ inline void Naive_pnf::add(int v_point_index) {
}
inline void Naive_pnf::remove(int v_point_index) {
- if(!contains(v_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;
- }
+ 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 {
@@ -136,6 +136,7 @@ inline int Naive_pnf::pull_near(int u_point_index) {
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();
@@ -165,18 +166,24 @@ inline Cgal_pnf::Cgal_pnf(double r_)
/** \internal \brief A point added will be possibly pulled. */
inline void Cgal_pnf::add(int v_point_index){
+ if(v_point_index == null_point_index())
+ return;
contents.insert(v_point_index);
kd_t.insert(G::get_v_point(v_point_index));
}
/** \internal \brief A point manually removed will no longer be possibly pulled. */
inline void Cgal_pnf::remove(int v_point_index){
- contents.erase(v_point_index);
- kd_t.remove(G::get_v_point(v_point_index));
+ if(contains(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{
+ if(v_point_index == null_point_index())
+ return false;
return contents.count(v_point_index)>0;
}
@@ -188,7 +195,9 @@ inline int Cgal_pnf::pull_near(int u_point_index){
auto it = search.begin();
if(it==search.end() || G::distance(u_point_index, it->first.point_index) > r)
return null_point_index();
- return it->first.point_index;
+ int tmp = it->first.point_index;
+ remove(tmp);
+ return tmp;
}
inline std::shared_ptr< std::list<int> > Cgal_pnf::pull_all_near(int u_point_index) {
@@ -196,7 +205,6 @@ inline std::shared_ptr< std::list<int> > Cgal_pnf::pull_all_near(int u_point_ind
int last_pull = pull_near(u_point_index);
while (last_pull != null_point_index()) {
all_pull->emplace_back(last_pull);
- remove(last_pull);
last_pull = pull_near(u_point_index);
}
return all_pull;