import sys
sys.path.append('../')
import Figure.rcParams
Figure.rcParams.a()
import numpy as np
from sklearn.neighbors import NearestNeighbors
import matplotlib.pyplot as plt
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
nbrs = NearestNeighbors(n_neighbors=3, algorithm='ball_tree').fit(X)
print nbrs
distances, indices = nbrs.kneighbors(X)
print distances, indices
print nbrs.kneighbors_graph(X).toarray()
plt.ylim((-3,3))
ax=plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.spines['bottom'].set_position(('data', 0))
ax.spines['left'].set_position(('data', 0))
plt.scatter([-1, -2, -3, 1, 2, 3], [-1, -1, -2, 1, 1, 2], c='r', marker='*')
from matplotlib.patches import Circle
cir1 = Circle(xy = (1, 1), radius=2.23606798, alpha=0.5,color='y')
ax.add_patch(cir1)
plt.show()