Mathematica 8 is now available

TreePlot

The TreePlot function.

TreePlot[g] plots the graph g as a tree. It provides greater control over layout than the LayeredDrawing and RadialDrawing methods for GraphPlot. TreePlot[g] uses the layered drawing algorithm. This algorithm starts from the root of the tree, and recursively draws sub-trees of the root such that vertices on the same level have the same  coordinate, and the horizontally closest vertices of adjacent sub-trees are of unit distance apart. The root is placed at the center of the  -coordinates of its sub-trees, and its y-coordinate is one unit above them. TreePlot[g, RootPosition->Center] uses the radial drawing algorithm. This algorithm starts from the root of the tree and draws each sub-tree inside a wedge, with the angle of the wedge proportional to the number of leaves in that sub-tree. By default, TreePlot chooses the root that gives the shortest tree, however it is possible to use any vertex  as a root with TreePlot[g, r].

This defines a k-ary tree. KaryTree[n] gives a binary tree with n levels.

In[59]:= 

This plots a binary tree with 5 levels. By default, TreePlot chooses the root that gives the shortest tree.

In[60]:= 

This plots the same tree but with vertex  as the root. This tree now has noticeably more layers.

In[62]:= 

Options for TreePlot

TreePlot accepts the following option, as well as all options for Graphics and the GraphPlot options VertexStyleFunction , EdgeStyleFunction , and PlotStyle.

Options for TreePlot.

AspectRatio

This specifies the ratio of height to width for the plot. Valid values are Automatic or a positive real machine number. The default value is Automatic, which is different from the default value of AspectRatio for Graphics.

RootPosition

This specifies the position of the root of the tree. Possible values are Automatic, Top, Bottom, Left, Right, and Center.

This is the same tree as the previous plot, but the root of the tree is in the center.

In[63]:= 

This plots the same tree with the root on the left.

In[64]:= 

This plots a more complex k-ary tree with 4 levels.

In[65]:= 

TreeSizeFunction

The value of this option is a function that specifies the height of each level of the tree plot. The default function specifies a height of one unit. The function takes the level in the tree as an argument. The first level is that between the root of the tree and its children.

This plots the previous  -ary tree with the height of each level  proportional to  .

In[66]:= 



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.