Skip to content

Commit f16f717

Browse files
committed
dbscan(): add metric= kwarg
1 parent a1bc906 commit f16f717

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
@@ -136,7 +136,7 @@ end
136136

137137
"""
138138
dbscan(points::AbstractMatrix, radius::Real;
139-
[min_neighbors], [min_cluster_size],
139+
[metric], [min_neighbors], [min_cluster_size],
140140
[nntree_kwargs...]) -> Vector{DbscanCluster}
141141
142142
Cluster `points` using the DBSCAN (density-based spatial clustering of
@@ -148,6 +148,7 @@ applications with noise) algorithm.
148148
- `radius::Real`: query radius
149149
150150
Optional keyword arguments to control the algorithm:
151+
- `metric` (defaults to `Euclidean`): the points distance metric to use
151152
- `min_neighbors::Integer` (defaults to 1): the minimum number of a *core* point
152153
neighbors
153154
- `min_cluster_size::Integer` (defaults to 1): the minimum number of points in
@@ -172,9 +173,10 @@ clusters = dbscan(points, 0.05, min_neighbors = 3, min_cluster_size = 20)
172173
Vol.42(3)3, pp. 1--21, https://doi.org/10.1145/3068335
173174
"""
174175
function dbscan(points::AbstractMatrix, radius::Real;
176+
metric = Euclidean(),
175177
min_neighbors::Integer = 1, min_cluster_size::Integer = 1,
176178
nntree_kwargs...)
177-
kdtree = KDTree(points; nntree_kwargs...)
179+
kdtree = KDTree(points, metric; nntree_kwargs...)
178180
return _dbscan(kdtree, points, radius;
179181
min_neighbors=min_neighbors,
180182
min_cluster_size=min_cluster_size)

0 commit comments

Comments
 (0)