-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ng. DBSCAN, OPTICS, CURE optimization.
- Loading branch information
Showing
19 changed files
with
501 additions
and
599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,53 @@ | ||
/** | ||
* | ||
* @authors Andrei Novikov ([email protected]) | ||
* @date 2014-2020 | ||
* @copyright GNU Public License | ||
* | ||
* GNU_PUBLIC_LICENSE | ||
* pyclustering 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. | ||
* | ||
* pyclustering 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 <http://www.gnu.org/licenses/>. | ||
* | ||
/*! | ||
@authors Andrei Novikov ([email protected]) | ||
@date 2014-2020 | ||
@copyright GNU Public License | ||
@cond GNU_PUBLIC_LICENSE | ||
pyclustering 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. | ||
pyclustering 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 <http://www.gnu.org/licenses/>. | ||
@endcond | ||
*/ | ||
|
||
|
||
#pragma once | ||
|
||
|
||
#include <functional> | ||
#include <memory> | ||
#include <vector> | ||
|
||
#include <pyclustering/definitions.hpp> | ||
|
||
|
||
namespace pyclustering { | ||
|
||
namespace container { | ||
|
||
/** | ||
* | ||
* @brief Node of KD Tree. | ||
* | ||
*/ | ||
class kdnode { | ||
/*! | ||
friend class kdtree; | ||
@brief Node of KD Tree. | ||
*/ | ||
class kdnode : public std::enable_shared_from_this<kdnode> { | ||
public: | ||
using ptr = std::shared_ptr<kdnode>; | ||
using ptr = std::shared_ptr<kdnode>; | ||
|
||
private: | ||
using weak_ptr = std::weak_ptr<kdnode>; | ||
using weak_ptr = std::weak_ptr<kdnode>; | ||
using search_node_rule = std::function< bool(const kdnode&) >; | ||
|
||
private: | ||
std::vector<double> m_data = { }; | ||
|
@@ -68,13 +70,17 @@ friend class kdtree; | |
|
||
virtual ~kdnode() = default; | ||
|
||
private: | ||
public: | ||
void set_left(const kdnode::ptr & p_node); | ||
|
||
void set_right(const kdnode::ptr & p_node); | ||
|
||
void set_parent(const kdnode::ptr & p_node); | ||
|
||
void set_data(const point & p_data); | ||
|
||
void set_payload(void * p_payload); | ||
|
||
void set_discriminator(const std::size_t disc); | ||
|
||
public: | ||
|
@@ -84,7 +90,32 @@ friend class kdtree; | |
|
||
kdnode::ptr get_parent() const; | ||
|
||
void * get_payload(); | ||
void * get_payload() const; | ||
|
||
/*! | ||
@brief Find node in KD-tree using current node as a root of a subtree, the first founded node with | ||
specified coordinates is returned. | ||
@param[in] p_point: coordinates of searched node. | ||
@return Pointer to found node in the sub-tree. | ||
*/ | ||
kdnode::ptr find_node(const point & p_point); | ||
|
||
/*! | ||
@brief Find node using specified rule, it returns the first node that satisfy search rule. | ||
@param[in] p_point: coordinates of searched node. | ||
@param[in] p_cur_node: node from which search is performed. | ||
@param[in] p_rule: rule that should be satisfied by searched node. | ||
@return Return the smallest node in specified subtree in line with discriminator. | ||
*/ | ||
kdnode::ptr find_node(const point & p_point, const search_node_rule & p_rule); | ||
|
||
const std::vector<double> & get_data() const; | ||
|
||
|
Oops, something went wrong.