Skip to main content

graphs and networks - Bug in NearestNeighborGraph


Update


Not fixed in 12.0.



NearestNeighborGraph generates incorrectly formatted output on rasterized input. Reported to Wolfram support CASE:4093797


$Version
(* "11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)" *)

NearestNeighborGraph[
Rasterize[Style[#, 20], "Image"] & /@ Alphabet[],
2,
VertexLabels -> "Name"
]


enter image description here


The labels are too large.


Is there a workaround?



Answer



Assuming you are asking for a workaround, you can generate the output you expect with:


v = Style[#,20]& /@ Alphabet[];
rv = Rasterize/@v;

NearestNeighborGraph[
rv,

2,
VertexLabels->Thread@Rule[rv,v]
]

enter image description here


Comments