dbscan implementation in python from scratch