implement DBSCAN algorithm