Given a pattern of points on a linear network,
this function finds the nearest neighbour of each point
(i.e. for each point it identifies the nearest other point)
measuring distance by the shortest path in the network.
If method="C"
the task is performed using
code in the C language. If method="interpreted"
then the
computation is performed using interpreted R code. The R code is
much slower, but is provided for checking purposes.
The result is NA
if the k
th nearest neighbour
does not exist. This can occur
if there are fewer than k+1
points in the dataset, or if
the linear network is not connected.