File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,17 +171,14 @@ def dbscan(
171171 while seeds :
172172 current_point = seeds .pop ()
173173
174- if labels [current_point ] == - 1 :
175- # was noise — reassign as border point of this cluster
176- labels [current_point ] = current_cluster_id
177-
178- already_in_another = (
174+ # skip points already claimed by a different cluster
175+ if (
179176 labels [current_point ] != - 1
180177 and labels [current_point ] != current_cluster_id
181- )
182- if already_in_another :
183- continue # already in another cluster
178+ ):
179+ continue
184180
181+ # assign noise points and unvisited points to this cluster
185182 labels [current_point ] = current_cluster_id
186183 current_neighbors = get_neighbors (data , current_point , epsilon )
187184
@@ -199,4 +196,4 @@ def dbscan(
199196if __name__ == "__main__" :
200197 import doctest
201198
202- doctest .testmod (verbose = True )
199+ doctest .testmod (verbose = True )
You can’t perform that action at this time.
0 commit comments