Skip to content

Commit c8efc31

Browse files
committed
dbscan(): only create clusters with non-empty core
fixes #200
1 parent c7cb345 commit c8efc31

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/dbscan.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@ function _dbscan(kdtree::KDTree, points::AbstractMatrix, radius::Real;
211211
core_selection[current_index] = true
212212
update_exploration_list!(adj_list, to_explore, visited)
213213
end
214-
cluster_size = sum(cluster_selection)
215-
min_cluster_size <= cluster_size && accept_cluster!(clusters, core_selection, cluster_selection, cluster_size)
214+
if any(core_selection) &&
215+
(cluster_size = sum(cluster_selection)) >= min_cluster_size
216+
accept_cluster!(clusters, core_selection, cluster_selection, cluster_size)
217+
end
216218
end
217219
return clusters
218220
end

0 commit comments

Comments
 (0)