This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

TreePlot

TreePlot[{vi1->vj1, vi2->vj2, ...}]
generates a tree plot of the graph in which vertex vik is connected to vertex vjk.
TreePlot[{{vi1->vj1, lbl1}, ...}]
associates labels lblk with edges in the graph.
TreePlot[g, pos]
places roots of trees in the plot at position pos.
TreePlot[g, pos, vk]
uses vertex vk as the root node in the tree plot.
  • TreePlot[g, ...] lays out the vertices of g in a tree of successive layers, or a collection of trees.
  • If the graph g is not a tree, TreePlot lays out its vertices on the basis of a spanning tree of each component of the graph.
  • TreePlot[g] attempts to choose the root so as to make trees have as few layers as possible.
  • The vertex names vk and the labels lblk can be any expressions.
  • TreePlot has the same options as Graphics, with the following additions and changes:
DataRangeAutomaticthe range of vertex coordinates to generate
DirectedEdgesFalsewhether to show edges as directed arrows
EdgeLabelingTruewhether to include labels given for edges
EdgeRenderingFunctionAutomaticfunction to give explicit graphics for edges
FrameFalsewhether to draw a frame around the plot
FrameTicksNonewhat ticks to include on the frame
LayerSizeFunction(1&)the height to allow for each layer
MultiedgeStyleAutomatichow to draw multiple edges between vertices
PackingMethodAutomaticmethod to use for packing components
PlotRangePaddingAutomatichow much padding to include around the plot
PlotStyleAutomaticoverall graphics directives for vertices and edges
SelfLoopStyleAutomatichow to draw edges linking a vertex to itself
VertexLabelingAutomaticwhether to show vertex names as labels
VertexRenderingFunctionAutomaticfunction to give explicit graphics for vertices
  • With the default setting VertexLabeling->Automatic, vertices are displayed as points, with their names vk given in tooltips.
  • Tooltip[vk, vlab] can be used to specify an alternative tooltip for a vertex. Tooltip[vi->vj, lbl] specifies a tooltip for an edge.
  • With VertexRenderingFunction->f, each vertex is rendered with the graphics primitives given by f[rk, vk], where rk is the position where the vertex is being placed, and vk is its name.
  • With EdgeRenderingFunction->g, each edge is rendered with the graphics primitives given by g[{ri, rj}, {vi, vj}, lblij], where ri, rj are the beginning and ending points of the edge, vi, vj are the beginning and ending vertices, and lblij is any label specified for the edge.
  • In the graphics generated by TreePlot, edges are effectively drawn first, and vertices afterwards.
  • The graph does not need to be connected. Disconnected components are typically arranged so as to fill the area roughly uniformly.
  • TreePlot[m, ...] generates a tree plot of the graph represented by the adjacency matrix m.
Draw a tree:
In[1]:=
Click for copyable input
Out[1]=
 
Show direction of edges:
In[1]:=
Click for copyable input
Out[1]=
 
Include vertex labels:
In[1]:=
Click for copyable input
Out[1]=
 
Show edge labels:
In[1]:=
Click for copyable input
Out[1]=
 
Drawing a tree with different orientation from the default:
In[1]:=
Click for copyable input
Out[1]=
 
Specify the root node:
In[1]:=
Click for copyable input
Out[1]=
 
If the graph is not a tree, it is laid out based on a spanning tree of this graph:
In[1]:=
Click for copyable input
Out[1]=
New in 6