13
$\begingroup$

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?

$\endgroup$
0

2 Answers 2

10
$\begingroup$

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

$\endgroup$
0
3
$\begingroup$

For another workaround, you can set ImageSize:

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

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.