4
$\begingroup$

In regards to the new tree functionality in Mathematica 12.3, apparently the display is collapsed/summarized when an element has more than 10 sub-elements, so what I was expecting to be displayed as 11 is replaced by a <<1>>:

RulesTree[1 -> Range[11]]

tree

is there an way of preventing this to display the full tree?

UPDATE: I have found that there is a symbol Trees`$VisualizationMaxChildren which is protected. It can be unprotected and changed to avoid the truncation. I'll leave the question open as this is kind of a hack, but it works.

$\endgroup$
4
$\begingroup$

There's a protected, internal parameter you can tweak:

Unprotect[Trees`$VisualizationMaxChildren];
Trees`$VisualizationMaxChildren = 12;
Protect[Trees`$VisualizationMaxChildren];
RulesTree[1 -> Range[12]]
Unprotect[Trees`$VisualizationMaxChildren];
Trees`$VisualizationMaxChildren = 10;
Protect[Trees`$VisualizationMaxChildren];

enter image description here

The value is used at the time MakeBoxes[] is called, so if you change the value of $VisualizationMaxChildren back to 10 within a code before the tree is returned and converted to boxes, it won't work.

Does not work:

Block[{Trees`$VisualizationMaxChildren = 12},
 RulesTree[1 -> Range[12]]
 ]

Works:

Block[{Trees`$VisualizationMaxChildren = 12},
 With[{expr = RulesTree[1 -> Range[12]]}, 
  MakeBoxes[expr, StandardForm] // RawBoxes]
 ]
$\endgroup$
2
  • $\begingroup$ Oh, well, I was lazy. I answered the Q before reading it completely.... :) $\endgroup$
    – Michael E2
    Jul 9 at 21:33
  • $\begingroup$ Thanks, you added much more detail to my update in the question. $\endgroup$ Jul 12 at 13:31
3
$\begingroup$

Trees are still being considered as Experimental in 12.3, and there are no visualization options yet (source).

I think you will have to rely on TreePlot:

TreePlot[Flatten@Table[{1 -> i}, {i, 2, 12}], VertexLabeling -> True]

TreePlot

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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