TreeForm

TreeForm[expr]

displays expr as a tree with different levels at different depths.

TreeForm[expr,n]

displays expr as a tree only down to level n.

Details and Options

Examples

open allclose all

Basic Examples  (3)

A symbolic expression formatted as a tree:

Show the tree form for the first two levels in the expression:

A graphics expression formatted as a tree:

Scope  (9)

A formatted symbolic expression with mathematical constants:

A formatted expression with symbolic, exact and inexact values:

A nested list:

An expression containing subscripted variables:

A formatted expression with a special superscript and OverBar:

A graphic object:

A Series expression:

An expression containing Hold:

Limit the levels shown:

Options  (14)

AspectRatio  (2)

By default a suitable aspect ratio is calculated for good visual appearance:

Change the aspect ratio:

DirectedEdges  (1)

Show directed edges:

EdgeRenderingFunction  (2)

Draw edges using blue arrows set back by 30%:

Draw vertices only:

LayerSizeFunction  (1)

Draw a tree with the first level of height 1, the second level 2, etc.:

PlotRangePadding  (1)

Use different PlotRangePadding around the drawing:

PlotStyle  (3)

Specify an overall style for the drawing:

PlotStyle can be combined with VertexRenderingFunction, which has higher priority:

PlotStyle can be combined with EdgeRenderingFunction, which has higher priority:

VertexLabeling  (1)

Display subtree expressions as tooltips:

VertexRenderingFunction  (2)

Show no vertices:

Render vertices using a predefined graphic:

VertexCoordinateRules  (1)

Explicitly specify all vertex coordinates:

Applications  (1)

Visualize the Wolfram Axiom for Boolean algebra as a tree:

Properties & Relations  (4)

FullForm gives a linear expression similar to TreeForm:

OutputForm of TreeForm gives a textual display of the expression:

Use TreePlot to plot a tree graph:

Use GraphPlot or GraphPlot3D for general undirected graphs:

Use LayeredGraphPlot for hierarchical-style drawing of directed graphs:

Possible Issues  (1)

Compound heads are not laid out as trees:

Neat Examples  (2)

A complete binary tree:

A complete ternary tree:

A symmetric tree:

An asymmetric tree:

Introduced in 1988
 (1.0)
 |
Updated in 2007
 (6.0)