optimization of dbscan with data structure