Partly revert to keep DBSCAN fast
cimport cython
from libcpp.vector cimport vector
-from libcpp.set cimport set as cset
cimport numpy as np
import numpy as np
@@ -23,7 +22,6 @@ def dbscan_inner(np.ndarray[np.uint8_t, ndim=1, mode='c'] is_core,
cdef np.npy_intp i, label_num = 0, v
cdef np.ndarray[np.npy_intp, ndim=1] neighb
cdef vector[np.npy_intp] stack
- cdef cset[np.npy_intp] seen
for i in range(labels.shape[0]):
if labels[i] != -1 or not is_core[i]:
@@ -40,8 +38,7 @@ def dbscan_inner(np.ndarray[np.uint8_t, ndim=1, mode='c'] is_core,
neighb = neighborhoods[i]
for i in range(neighb.shape[0]):
v = neighb[i]
- if labels[v] == -1 and seen.count(v) == 0:
- seen.insert(v)
+ if labels[v] == -1:
push(stack, v)
if stack.size() == 0:
@@ -49,6 +46,4 @@ def dbscan_inner(np.ndarray[np.uint8_t, ndim=1, mode='c'] is_core,
i = stack.back()
stack.pop_back()
- seen.clear()
-
label_num += 1
