Wolfram Language & System 10.3 (2015)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

NearestNeighborGraph

NearestNeighborGraph[{elem1,elem2,}]
gives a graph with vertices and edges connecting each to its nearest neighbors.

NearestNeighborGraph[{elem1,elem2,},k]
gives a graph connecting each to its k nearest neighbors.

NearestNeighborGraph[{elem1,elem2,},{k,r}]
gives a graph connecting each to at most k nearest vertices within radius r of .

NearestNeighborGraph[{elem1,elem2,},{All,r}]
gives a graph connecting each to all vertices within radius r of .

Details and OptionsDetails and Options

  • The nearest neighbor graph is also known as k-nearest neighbor graph (k-NNG).
  • An element is a nearest neighbor of an element whenever the distance from to is no larger than the distance from to any other element.
  • An element is a k-nearest neighbor of an element whenever the distance from to is among the k^(th) smallest distances from to any other element.
  • NearestNeighborGraph works for a variety of data, including numerical, geospatial, textual, and visual.
  • NearestNeighborGraph has the same options as Graph, with the following additions and changes:
  • DirectedEdgesAutomaticwhether edges should be taken to be directed
    DistanceFunctionAutomaticthe distance metric or dissimilarity to use
    WorkingPrecisionAutomaticprecision to use for numeric data
  • NearestNeighborGraph takes the same DistanceFunction as Nearest.
Introduced in 2015
(10.2)