View source: R/max_thinning_algorithm.R
max_thinning_algorithm | R Documentation |
This function performs the core thinning algorithm used to reduce the density of points in spatial data while maintaining spatial representation. It works by iteratively removing points with the most neighbors until no points with neighbors remain. The algorithm supports multiple trials to find the optimal thinning solution.
max_thinning_algorithm(neighbor_indices, n, trials, all_trials = FALSE)
neighbor_indices |
A list of integer vectors where each element contains the indices of the neighboring points for each point in the dataset. |
n |
The number of points in the dataset. |
trials |
The number of thinning trials to run. |
all_trials |
If TRUE, returns the results of all trials; if FALSE, returns the best trial with the most points retained (default: FALSE). |
A list of logical vectors indicating which points are kept in each trial if all_trials is TRUE; otherwise, a single logical vector indicating the points kept in the best trial.
# Example usage within a larger thinning function
neighbor_indices <- list(c(2, 3), c(1, 3), c(1, 2))
n <- 3
trials <- 5
all_trials <- FALSE
keep_points <- max_thinning_algorithm(neighbor_indices, n, trials, all_trials)
print(keep_points)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.