BUILT-IN MATHEMATICA SYMBOL

TreePlot

TreePlot[{vi1->vj1, vi2->vj2, ...}]
generates a tree plot of the graph in which vertex is connected to vertex .

TreePlot[{{vi1->vj1, lbl1}, ...}]
associates labels with edges in the graph.

TreePlot[g, pos]
places roots of trees in the plot at position pos.

TreePlot[g, pos, vk]
uses vertex as the root node in the tree plot.

Details and OptionsDetails and Options

• 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.
• By default, TreePlot places each tree root at the top. TreePlot[g, pos] places the roots at position pos. Possible positions are: Top, Bottom, Left, Right, Center.
• The vertex names and the labels can be any expressions.
• With the default setting , edges are drawn as ordinary lines. With , edges are drawn as arrows.
• 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 , vertices are displayed as points, with their names given in tooltips, so long as the number of vertices is not too large.
• Tooltip[vk, vlab] can be used to specify an alternative tooltip for a vertex. Tooltip[vi->vj, lbl] specifies a tooltip for an edge.
• Explicit settings for VertexRenderingFunction and EdgeRenderingFunction override settings for VertexLabeling, EdgeLabeling, and DirectedEdges.
• With , 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 , 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.
• The graphics primitives obtained applying EdgeRenderingFunction and VertexRenderingFunction are in effect directly spliced into the graphic generated by TreePlot. Inset can be used to insert an arbitrary expression.
• 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.
• The adjacency matrix m can be a SparseArray object.
• TreePlot returns an object of the form Graphics[Annotation[data, VertexCoordinateRules->rules]].

ExamplesExamplesopen allclose all

Basic Examples (7)Basic Examples (7)

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]=

TutorialsTutorials

New in 6
New to Mathematica? Find your learning path »
Have a question? Ask support »