Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change kdTree code to choose the number of leaves #962

Merged
merged 3 commits into from
Sep 5, 2023

Conversation

MohamedKISSI
Copy link
Contributor

Thanks for contributing to TTK!

Before submitting your pull request, please:

  • Review our Contributor Guidelines, in particular regarding code formatting (with clang-format) and continuous integration.

  • Please provide a quick description of your contributions below:

Your description here

Copy link
Collaborator

@julien-tierny julien-tierny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot Mohamed!
Could you please take my remarks into account?
Thanks!

@@ -64,14 +64,18 @@ namespace ttk {
const int &ptNumber,
const int &dimension,
const std::vector<std::vector<dataType>> &weights = {},
const int weight_number = 1);
const int weight_number = 1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend to take the habit to use references for function parameters (unless pointers are necessary), even for integers.
const int weight_number = 1 -> const int &weightNumber = 1
(also, we usually don't use underscores for names in TTK, but a camel wording)

@@ -64,14 +64,18 @@ namespace ttk {
const int &ptNumber,
const int &dimension,
const std::vector<std::vector<dataType>> &weights = {},
const int weight_number = 1);
const int weight_number = 1,
int nodeNumber = -1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int &nodeNumber = -1 --> const int &nodeNumber = -1 (unless it is not read only)


void buildRecursive(dataType *data,
std::vector<int> &idx_side,
const int &ptNumber,
const int &dimension,
KDTree<dataType, Container> *parent,
KDTreeMap &correspondence_map,
const int nodeNumber,
const int maximumLevel,
int &createdNumberNode,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above const (if indeed read only)

@@ -146,15 +150,67 @@ typename ttk::KDTree<dataType, Container>::KDTreeMap
const int &ptNumber,
const int &dimension,
const std::vector<std::vector<dataType>> &weights,
const int weight_number) {
const int weight_number,
int nodeNumber) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same remark as above const int &nodeNumber

@@ -146,15 +150,67 @@ typename ttk::KDTree<dataType, Container>::KDTreeMap
const int &ptNumber,
const int &dimension,
const std::vector<std::vector<dataType>> &weights,
const int weight_number) {
const int weight_number,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same remark as above const int &weightNumber.

@@ -225,23 +291,35 @@ void ttk::KDTree<dataType, Container>::buildRecursive(
const int &dimension,
KDTree<dataType, Container> *parent,
KDTreeMap &correspondence_map,
const int nodeNumber,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const int &nodeNumber

@@ -225,23 +291,35 @@ void ttk::KDTree<dataType, Container>::buildRecursive(
const int &dimension,
KDTree<dataType, Container> *parent,
KDTreeMap &correspondence_map,
const int nodeNumber,
const int maximumLevel,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const int &maximumLevel

@@ -225,23 +291,35 @@ void ttk::KDTree<dataType, Container>::buildRecursive(
const int &dimension,
KDTree<dataType, Container> *parent,
KDTreeMap &correspondence_map,
const int nodeNumber,
const int maximumLevel,
int &createdNumberNode,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const int &createdNumberNode (unless not read-only)

@@ -288,10 +368,13 @@ void ttk::KDTree<dataType, Container>::buildRecursive(
this->left_
= std::make_unique<KDTree>(this, (coords_number_ + 1) % dimension, true);
this->left_->buildRecursive(data, idx_left, ptNumber, dimension, this,
correspondence_map, weights, weight_number);
correspondence_map, nodeNumber, maximumLevel,
createdNumberNode, weights, weight_number);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weightNumber

@@ -300,7 +383,8 @@ void ttk::KDTree<dataType, Container>::buildRecursive(
this->right_
= std::make_unique<KDTree>(this, (coords_number_ + 1) % dimension, false);
this->right_->buildRecursive(data, idx_right, ptNumber, dimension, this,
correspondence_map, weights, weight_number);
correspondence_map, nodeNumber, maximumLevel,
createdNumberNode, weights, weight_number);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weightNumber

@julien-tierny
Copy link
Collaborator

thanks a lot, let's go!

@julien-tierny julien-tierny merged commit 66e3ddd into topology-tool-kit:dev Sep 5, 2023
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants