This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.

# TreePlot

 TreePlotgenerates a tree plot of the graph in which vertex is connected to vertex . TreePlotassociates labels with edges in the graph. TreePlotplaces roots of trees in the plot at position pos. TreePlotuses vertex as the root node in the tree plot.
• TreePlot 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 and the labels can be any expressions.
• TreePlot has the same options as Graphics, with the following additions and changes:
 DataRange Automatic the range of vertex coordinates to generate DirectedEdges False whether to show edges as directed arrows EdgeLabeling True whether to include labels given for edges EdgeRenderingFunction Automatic function to give explicit graphics for edges Frame False whether to draw a frame around the plot FrameTicks None what ticks to include on the frame LayerSizeFunction (1&) the height to allow for each layer MultiedgeStyle Automatic how to draw multiple edges between vertices PackingMethod Automatic method to use for packing components PlotRangePadding Automatic how much padding to include around the plot PlotStyle Automatic overall graphics directives for vertices and edges SelfLoopStyle Automatic how to draw edges linking a vertex to itself VertexLabeling Automatic whether to show vertex names as labels VertexRenderingFunction Automatic function to give explicit graphics for vertices
• With the default setting VertexLabeling, vertices are displayed as points, with their names given in tooltips, so long as the number of vertices is not too large.
• Tooltip can be used to specify an alternative tooltip for a vertex. Tooltip specifies a tooltip for an edge.
• With VertexRenderingFunction->f, each vertex is rendered with the graphics primitives given by , where is the position where the vertex is being placed, and is its name.
• With EdgeRenderingFunction->g, each edge is rendered with the graphics primitives given by , where are the beginning and ending points of the edge, are the beginning and ending vertices, and 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 generates a tree plot of the graph represented by the adjacency matrix m.
Draw a tree:
Show direction of edges:
Include vertex labels:
Show edge labels:
Drawing a tree with different orientation from the default:
Specify the root node:
If the graph is not a tree, it is laid out based on a spanning tree of this graph:
Draw a tree:
 Out[1]=

Show direction of edges:
 Out[1]=

Include vertex labels:
 Out[1]=

Show edge labels:
 Out[1]=

Drawing a tree with different orientation from the default:
 Out[1]=

Specify the root node:
 Out[1]=

If the graph is not a tree, it is laid out based on a spanning tree of this graph:
 Out[1]=
 Scope   (11)
Specify a graph using a rule list:
Specify a graph using a dense adjacency matrix:
Specify a graph using a sparse adjacency matrix:
Give labels for some edges:
Give vertex labels:
Do not show multiedges or self-loops:
Show edges as arrows:
Plot a disconnected graph using different packing methods:
For large graphs, it is sometimes better not to draw vertices at all:
Drawing a tree with different orientations:
Multiclick to move vertices in a graph:
 Options   (26)
By default, a suitable aspect ratio is calculated for good visual appearance:
If self-loops exist, an aspect ratio based on the actual coordinates shows the loops undistorted:
Show directed edges:
By default, edge labels are shown:
Displays the edge label as a tooltip:
Displays the edge label both explicitly and as a tooltip:
Change the setbacks used for arrows:
Draw self-loops as red arrows; draw other arrows gray:
Draw vertices only:
Draw a tree with the first level of height 1, the second level 2, etc.:
Plot a binary tree with random layer size:
Spread multiple edges by a specified scaled distance:
Pack disconnected components using different methods:
Use different PlotRangePadding around the graph:
Specify an overall style for the graph:
PlotStyle can be combined with VertexRenderingFunction, which has higher priority:
PlotStyle can be combined with EdgeRenderingFunction, which has higher priority:
Draw self-loops with a specified scaled diameter:
Show vertex labels:
Show vertex labels as tooltips only:
Show vertex labels as tooltips only if the graph is small:
Show vertex labels both explicitly and as tooltips:
Explicitly specify all vertex coordinates:
Show no vertices:
Render vertices using a predefined graphic:
 Applications   (8)
Define a complete binary tree of depth 3:
Use different tree layouts:
Draw a -ary tree:
Generate and plot a random tree:
Delete random connections in a binary tree:
Link a number with one that is rotated one bit right:
Link a number with one that is rotated one bit left:
Link a number with itself but with the last bit dropped:
Link a number with itself but with the first bit dropped:
Use LayeredGraphPlot for hierarchical-style drawing of a directed graph:
Use GraphPlot or GraphPlot3D for general undirected graph drawing:
Use ArrayPlot or MatrixPlot to display sparse matrices:
For nontree graphs, edges may overlap:
Use LayeredGraphPlot or GraphPlot to avoid overlapping edges:
TreePlot automatically chooses the base node to minimize tree height:
Explicitly specify a top node, which in this case is also the root node:
Complete binary trees with random layer layout sizes:
New in 6