INNER CODE UNIT · Python
a
TheAlgorithms/Jupyter · machine_learning/dbscan/dbscan.py:55
a = pow((q[0] - p[0]), 2)
b = pow((q[1] - p[1]), 2)
return pow((a + b), 0.5)
def find_neighbors(db, q, eps):
"""
Finds all points in the db that
are within a distance of eps from Q
eps value should be a number
>>> find_neighbors({ (1,2):{'label':'undefined'}, (2,3):{'label':'undefined'}}, (2,5),'a')
Traceback (most recent call last):
...
ValueError: eps should be either int or float
Q must be a 2-d point as list or tuple
>>> find_neighbors({ (1,2):{'label':'undefined'}, (2,3):{'label':'undefined'}}, 2, 0.5)