How to realize dbscan algorithm in python without using any packages?



I want to use python to perform a data analysis task which is going to use dbscan algorithm, because I prefer python than other languages or tools. However, I am not allowed to use any existing machine learning packages to do so. Is there any alternative way to perform this task? Thanks!