sys.path.append("../db_scan")
from dbscan import DBscan
from point import Point

#################################################################################
# Compute DBSCAN
#################################################################################
xx = X.tolist()
point_array = []
for x in xx:
    pt = Point(x[0], x[1])
    point_array.append(pt)
# db = DBscan(point_array=parr, start_point_index= 0, cluster_map=clustmap, epsilon=EPS, min_neighbour=MIN_SAMPLES)
db = DBscan()
clusters = db.start(points=point_array, eps=EPS, minPts=MIN_SAMPLES)

#################################################################################
# Plot result
#################################################################################
plt.subplot(212)
colors = plt.cm.Spectral(np.linspace(0, 1, len(clusters)))

for p in point_array:
    if p.get_clusterID() == Point.NOISE:
        col = 'k'
    elif p.get_clusterID == Point.UNCLASSIFIED:
        col = 'g'
    else:
        col = colors[p.get_clusterID() - 1]