Nearest Neighbor Graph Connections

This Demonstration expands on a graphical study of nearest neighbors to look at the statistics of the number of connections. (The original Demonstration, "Nearest Neighbor Networks", looked at a process of connecting nearest neighbors and successively more removed neighbors on an assortment of points in 2D.) The parameter settings specify the number of connections to make from each point to its nearest neighbors and possibly to further neighbors. The first control is for the number of points. The second control is for the neighbor connections in the dot and stick visualization, while the third slider specifies the maximum of a range of neighbor connections over which to explore in the bottom plots. Note that while the parameter set specifies connections from each point to a certain number of neighbors, the result is more complex, with some points connected multiply as back-and-forth connections accumulate, so that clusters of connections form.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


The two graphs at the top, from the original Demonstration, show an arrangement of points and connections for the number of neighbors specified and one number beyond.
The bottom-left plot shows ranked plots over the range of neighbors chosen (up to the maximum). That is, for each value for nearest or next neighbors, the ranked graph shows how well the points are connected. As the number of specified neighbors increases, the number of realized connections increases as well. And there is a skew to the result, as a few dots have many connections and many dots are in the tail with fewer connections. Connections are concentrated as a purely probabilistic phenomenon.
The contour plot at the lower right shows the statistics for the number of connections, a PDF in terms of counting the occurrences of different values for resulting connections. It uses the same results as in the ranked plot, but counts the occurrence of each value of connection. A ridge appears, representing the maximum count of connections for each nearest neighbor number. This ridge is more diffuse for larger values of connections as there is statistical variation in the clustering, with the larger reaches from successively farther neighbor connections. Finally both plots reach a maximum plateau at connections. When enough neighbors are connected the points become connected to every other point.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2017 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+