TransWikia.com

Bug in NearestNeighborGraph

Mathematica Asked by Rohit Namjoshi on December 21, 2020

Bug introduced in 11.3 or earlier, Fixed in 12.2.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?

2 Answers

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

Correct answer by Carl Woll on December 21, 2020

For another workaround, you can set ImageSize:

NearestNeighborGraph[
 Rasterize[Style[#, 20], ImageSize -> 10] & /@ Alphabet[], 2, 
 VertexLabels -> Automatic]

enter image description here

Answered by halmir on December 21, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP