TreePlot

TreePlot[g]

generates a tree plot of the graph g.

TreePlot[{e1,e2,}]

generates a tree plot of the graph with edges ej.

TreePlot[{,w[ei],}]

plots ei with features defined by the symbolic wrapper w.

TreePlot[{vi 1vj 1,}]

uses rules vi 1vj 1 to specify the graph g.

TreePlot[m]

generates a tree plot of the graph represented by the adjacency matrix m.

TreePlot[,vpos]

places the root v in the plot at position pos.

Details and Options

Examples

open allclose all

Basic Examples  (5)

Plot a graph:

Plot a graph specified by edge rules:

Plot a graph specified by its adjacency matrix:

Drawing a tree with different orientation from the default:

Specify the root node:

Scope  (10)

Graph Specification  (4)

Specify a graph using a graph:

Specify a graph using a rule list:

Specify a graph using a dense adjacency matrix:

Specify a graph using a sparse adjacency matrix:

Graph Styling  (6)

Give labels for some edges:

Give vertex labels:

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:

Options  (7)

DataRange  (1)

Specify the range of vertex coordinates:

DirectedEdges  (1)

Show directed edges:

LayerSizeFunction  (2)

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

Plot a binary tree with random layer size:

PlotStyle  (3)

Specify an overall style for the graph:

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

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

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:

Properties & Relations  (4)

If the graph is not a tree, it is laid out based on a spanning tree of this graph:

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:

Possible Issues  (2)

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:

Neat Examples  (1)

Complete binary trees with random layer layout sizes:

Wolfram Research (2007), TreePlot, Wolfram Language function, https://reference.wolfram.com/language/ref/TreePlot.html (updated 2020).

Text

Wolfram Research (2007), TreePlot, Wolfram Language function, https://reference.wolfram.com/language/ref/TreePlot.html (updated 2020).

CMS

Wolfram Language. 2007. "TreePlot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/TreePlot.html.

APA

Wolfram Language. (2007). TreePlot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TreePlot.html

BibTeX

@misc{reference.wolfram_2024_treeplot, author="Wolfram Research", title="{TreePlot}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/TreePlot.html}", note=[Accessed: 11-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_treeplot, organization={Wolfram Research}, title={TreePlot}, year={2020}, url={https://reference.wolfram.com/language/ref/TreePlot.html}, note=[Accessed: 11-November-2024 ]}