Graphes du voisin le plus proche
Générez le graphe du plus proche voisin d'une collection de données arbitraires à l'aide de la nouvelle fonction NearestNeighborGraph de la version 11.
Construisez le graphe du plus proche voisin pour les pays d'Amérique du Sud.
In[1]:=
![Click for copyable input](assets.fr/nearest-neighbor-graphs/In_9.png)
locs = CountryData["SouthAmerica"];
coords = EntityValue[locs, "Position"][[All, 1, {2, 1}]];
In[2]:=
![Click for copyable input](assets.fr/nearest-neighbor-graphs/In_10.png)
g = NearestNeighborGraph[locs, VertexCoordinates -> coords]
Out[2]=
![](assets.fr/nearest-neighbor-graphs/O_8.png)
Stylisez le réseau au-dessus du continent.
Afficher l'entrée complète de Wolfram Language
In[4]:=
![Click for copyable input](assets.fr/nearest-neighbor-graphs/In_12.png)
Graph[g, opts]
Out[4]=
![](assets.fr/nearest-neighbor-graphs/O_9.png)
Affichez le graphe des 3 voisins les plus proches pour une collection de couleurs aléatoires.
In[5]:=
![Click for copyable input](assets.fr/nearest-neighbor-graphs/In_13.png)
colors = RandomColor[50]
Out[5]=
![](assets.fr/nearest-neighbor-graphs/O_10.png)
In[6]:=
![Click for copyable input](assets.fr/nearest-neighbor-graphs/In_14.png)
NearestNeighborGraph[colors, 3, VertexShapeFunction -> "Name"]
Out[6]=
![](assets.fr/nearest-neighbor-graphs/O_11.png)