lazear / dbscan

Dependency free implementation of DBSCAN clustering in Rust
MIT License
9 stars 5 forks source link

Vectors in public interface #4

Open fegies opened 1 year ago

fegies commented 1 year ago

Hi. I was searching for a lib to cluster a large amount of data with a fairly involved comparison function.

In doing so I hit upon your lib and while it looks nice, it does feel a bit strange to have to allocate a tiny vec for every row in the matrix. Is there anything preventing the clustering algorithm from taking slices instead? e.g.

pub fn run(mut self, population: &[&[T]]) -> Vec<Classification> {

instead of

pub fn run(mut self, population: &Vec<Vec<T>>) -> Vec<Classification> {
fegies commented 1 year ago

Another issue that I hit upon is the fact that the distance measure only accepts a function pointer instead of a generic function. That means that it is not for example possible to precompute a distance matrix and refer to that in the comparison function, as fn pointers cannot close over any data.

lazear commented 1 year ago

Hi @fegies, thanks for the issues! I made this for use in a side project and didn't spend too much time optimizing the API or internals for perf. If you submit a PR, I would be happy to review and merge