From de45f2d9bb77f0256c1ae36b3c1f99afebd3ec2d Mon Sep 17 00:00:00 2001 From: fgodi Date: Tue, 30 Jun 2015 16:35:20 +0000 Subject: rm Grid_Cell (this sub-algorithm doesn't work) :( git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bottleneckDistance@669 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: ae3e4c7bf16676fd2335c2813dbc1d1e939eecd8 --- .../include/gudhi/Grid_cell.h | 210 --------------------- 1 file changed, 210 deletions(-) delete mode 100644 src/Bipartite_graph_matching/include/gudhi/Grid_cell.h (limited to 'src') diff --git a/src/Bipartite_graph_matching/include/gudhi/Grid_cell.h b/src/Bipartite_graph_matching/include/gudhi/Grid_cell.h deleted file mode 100644 index f0b09b52..00000000 --- a/src/Bipartite_graph_matching/include/gudhi/Grid_cell.h +++ /dev/null @@ -1,210 +0,0 @@ -/* 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): Francois Godi - * - * Copyright (C) 2015 INRIA Sophia-Antipolis (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 - * 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 . - */ - -#ifndef SRC_BOTTLENECK_INCLUDE_GUDHI_GRID_CELL_H_ -#define SRC_BOTTLENECK_INCLUDE_GUDHI_GRID_CELL_H_ - -#include -#include -#include - -#include "Persistence_diagrams_graph.h" - -namespace Gudhi { - -namespace bipartite_graph_matching { - - -class Grid_cell { -public: - Grid_cell(double r); - void add(int v_point_index); - void remove(int v_point_index); - bool contains(int v_point_index) const; - int pull_center(); - int pull_xi(int u_point_index); - int pull_xd(int u_point_index); - int pull_yi(int u_point_index); - int pull_yd(int u_point_index); - int pull_xi_yi(int u_point_index); - int pull_xi_yd(int u_point_index); - int pull_xd_yi(int u_point_index); - int pull_xd_yd(int u_point_index); - -private: - double r; - std::set xi_order; - std::set yi_order; - struct Hidden_points_tree{int point; std::list hidden;}; - typedef std::map, G::Compare_x> Corner_tree; - Corner_tree xi_yi_order; - Corner_tree xi_yd_order; - Corner_tree xd_yi_order; - Corner_tree xd_yd_order; - void remove_aux(Corner_tree t, int v_point_index); - template - int pull_contiguous_aux(Contiguous_tree t, bool reverse, int u_point_index); - //int pull_corner_aux(Corner_tree t, bool reverse, int u_point_index); -}; - - -inline Grid_cell::Grid_cell(double r) - : r(r), xi_order(G::Compare_x(r)), yi_order(G::Compare_y(r)), xi_yi_order(G::Compare_x(r)), - xi_yd_order(G::Compare_x(r)), xd_yi_order(G::Compare_x(r)), xd_yd_order(G::Compare_x(r)) {} - -inline void Grid_cell::add(int v_point_index){ - xi_order.emplace(v_point_index); -} - -inline bool Grid_cell::contains(int v_point_index) const{ - return (xi_order.count(v_point_index) > 0); -} - -inline void Grid_cell::remove_aux(Corner_tree t, int v_point_index){ - if(t.empty()) - return; - std::list hidden_points = t.at(v_point_index); - t.erase(v_point_index); - for(auto it = hidden_points.begin(); it != hidden_points.end(); ++it) - t.emplace(it->point,it->hidden); - -} - -inline void Grid_cell::remove(int v_point_index){ - xi_order.erase(v_point_index); - yi_order.erase(v_point_index); - remove_aux(xi_yi_order,v_point_index); - remove_aux(xi_yd_order,v_point_index); - remove_aux(xd_yi_order,v_point_index); - remove_aux(xd_yd_order,v_point_index); -} - -template -inline int Grid_cell::pull_contiguous_aux(Contiguous_tree t, bool reverse, int u_point_index){ - if(xi_order.empty()) - return null_point_index(); - if(t.empty()) - for(auto it = xi_order.begin(); it!= xi_order.end(); ++it) - t.emplace(*it); - int v_point_index = reverse ? *(t.rbegin()) : *(t.begin()); - if(G::distance(u_point_index,v_point_index)<=r){ - remove(v_point_index); - return v_point_index; - } - return null_point_index(); -} - -inline int Grid_cell::pull_center(){ - if(xi_order.empty()) - return null_point_index(); - int v_point_index = *(xi_order.begin()); - remove(v_point_index); - return v_point_index; -} - -inline int Grid_cell::pull_xi(int u_point_index){ - return pull_contiguous_aux(xi_order, false, u_point_index); -} - -inline int Grid_cell::pull_xd(int u_point_index){ - return pull_contiguous_aux(xi_order, true, u_point_index); -} - -inline int Grid_cell::pull_yi(int u_point_index){ - return pull_contiguous_aux(yi_order, false, u_point_index); -} - -inline int Grid_cell::pull_yd(int u_point_index){ - return pull_contiguous_aux(yi_order, true, u_point_index); -} - -inline int Grid_cell::pull_corner_aux(Corner_tree t, bool reverse, int u_point_index){ - if(xi_order.empty()) - return null_point_index(); - if(t.empty()) - build_corner(t); - auto it = t.upper_bound(u_point_index+G::size()); - if(it == (reverse ? t.end() : t.begin())) - return null_point_index(); - if(!reverse) - it--; - int v_point_index = it->first; - for(auto it2=it->second.begin();it2!=it->second.end();it2++) - t.emplace(it2->point,it2->hidden); - if(G::distance(u_point_index,v_point_index)<=r){ - remove(v_point_index); - return v_point_index; - } - return null_point_index(); -} - -inline int Grid_cell::pull_xi_yi(int u_point_index){ - for(auto it = xi_order.begin(); it!=xi_order.end(); ++it) - if(G::distance(u_point_index,*it)<=r){ - int tmp = *it; - remove(tmp); - return tmp; - } - return(null_point_index()); - //return pull_corner_aux(xi_yi_order, false, u_point_index); -} - -inline int Grid_cell::pull_xi_yd(int u_point_index){ - for(auto it = xi_order.begin(); it!=xi_order.end(); ++it) - if(G::distance(u_point_index,*it)<=r){ - int tmp = *it; - remove(tmp); - return tmp; - } - return(null_point_index()); - //return pull_corner_aux(xi_yd_order, false, u_point_index); -} - -inline int Grid_cell::pull_xd_yi(int u_point_index){ - for(auto it = xi_order.rbegin(); it!=xi_order.rend(); ++it) - if(G::distance(u_point_index,*it)<=r){ - int tmp = *it; - remove(tmp); - return tmp; - } - return(null_point_index()); - //return pull_corner_aux(xd_yi_order, true, u_point_index); -} - -inline int Grid_cell::pull_xd_yd(int u_point_index){ - for(auto it = xi_order.begin(); it!=xi_order.end(); ++it) - if(G::distance(u_point_index,*it)<=r){ - int tmp = *it; - remove(tmp); - return tmp; - } - return(null_point_index()); - //return pull_corner_aux(xd_yd_order, true, u_point_index); -} - - -} // namespace bipartite_graph_matching - -} // namespace Gudhi - -#endif // SRC_BOTTLENECK_INCLUDE_GUDHI_GRID_CELL_H_ - -- cgit v1.2.3