# Is this a correct interpretation of k nearest neighbours?

Given this dataset :

name1,name2,distance
a,b,1
a,c,5
b,c,8


If k=1 is the following correct :

a,b nearest neighbour is b,c
a,c nearest neighbour is b,c
b,c nearest neighbour is a,c


or

"a" nearest neighbor is b since distance(a,b) is 1
"b" nearest neighbor is a since distance(a,b) is 1
"c" nearest neighbor is a since distance(a,c) is 5

• Pedantry alert: If your measure is symmetric, i.e., $d(a, b) = d(b, a)$ then your measure violates the triangle inequality, since $6 = d(b,a) + d(a,c) < d(b, c) = 8$, and isn't actually a valid distance, which can cause problems.
– alto
Commented May 15, 2014 at 21:01

The distance between $a$ and $b$ is 1, the distance between $a$ and $c$ is 5. Thus the nearest neighbor to $a$ is $b$.
Similarly, the nearest neighbor to $b$ is $a$ since the distance between $b$ and $c$ is 8.
The nearest neighbor to $c$ is $a$ since the distance between $c$ and $a$ is 5 which is less than the distance between $c$ and $b$ which is 8.