WOLFRAM

TreeGraph[{v1,v2,},{u1,u2,}]

yields a tree where ui is the predecessor of vi.

TreeGraph[{e1,e2,}]

yields a tree with edges ej.

TreeGraph[{v1,v2,},{e1,e2,}]

yields a tree with vertices vi and edges ej.

TreeGraph[{,wi[vi,],},{,wj[ej,],}]

yields a tree with vertex and edge properties defined by the symbolic wrappers wk.

TreeGraph[{vivj,}]

uses rules vivj to specify a tree.

Details and Options

Examples

open allclose all

Basic Examples  (1)Summary of the most common use cases

A tree from pairs of children and parents:

Out[1]=1

A tree from a list of vertices and edges:

Out[2]=2

Scope  (25)Survey of the scope of standard use cases

Connectivity  (6)

Create an undirected graph using characters; enter the character as ue:

Out[1]=1

Create a directed graph using characters; enter the character as de:

Out[1]=1

Create a directed graph from a list of rules:

Out[1]=1

Create an undirected graph from a list of rules:

Out[2]=2

Use VertexList and EdgeList to get vertices and edges:

Out[1]=1

The ordering for edges is the order in which they were entered:

Out[2]=2

The ordering for vertices is the order in which they were entered in the edges:

Out[3]=3

Use an explicit vertex list to control the ordering used by VertexList:

Out[1]=1

The input vertex list controls the resulting vertex order:

Out[2]=2

Any expression can be used as vertices:

Out[1]=1
Out[2]=2

Wrappers  (5)

Use wrappers on vertices or edges:

Out[1]=1

Wrappers can be nested:

Out[1]=1

Add interactive behavior by wrappers such as Tooltip:

Out[1]=1

Any object can be used in the tooltip:

Out[2]=2

Use Button to trigger actions when clicking an edge or vertex:

Out[1]=1

Use PopupWindow to provide information drilldown:

Out[1]=1

Styling  (8)

Set the style for all vertices or edges:

Out[1]=1

Style individual vertices or edges using options:

Out[1]=1

Use wrappers for individual styling:

Out[2]=2

Adjust the size of vertices using symbolic sizes:

Out[1]=1

Or use sizes in terms of the smallest distance between vertex centers:

Out[2]=2

Use built-in collections for VertexShapeFunction:

Out[1]=1

Rounded shapes:

Out[2]=2

Concave shapes:

Out[3]=3

Draw individual vertices:

Out[1]=1

Combine with a default vertex function:

Out[2]=2

Use any Graphics, Image, or Graphics3D as a vertex shape:

Out[1]=1

Use built-in collections for EdgeShapeFunction:

Out[1]=1

Directed edges including solid arrows:

Out[2]=2

Line arrows:

Out[3]=3

Open arrows:

Out[4]=4

Specify an edge function for an individual edge:

Out[1]=1

Combine with a different default edge function:

Out[2]=2

Labeling  (6)

Label any edge or vertex:

Out[1]=1

Use any expression as a label:

Out[1]=1
Out[2]=2

Control the placement of vertex labels using Placed, including symbolic inside positions:

Out[1]=1

Symbolic outside positions:

Out[2]=2

Coordinate-based positions:

Out[3]=3

Place multiple labels using Placed in a wrapper:

Out[1]=1

Any number of labels can be used:

Out[2]=2

Place multiple labels using VertexLabels:

Out[3]=3

Use Placed with symbolic locations to control label placement along an edge:

Out[1]=1

Use explicit coordinates to place labels:

Out[2]=2

Place multiple labels using Placed in a wrapper:

Out[1]=1

Any number of labels can be used:

Out[2]=2

Place multiple labels using EdgeLabels:

Out[3]=3

Options  (82)Common values & functionality for each option

AnnotationRules  (3)

Specify an annotation for vertices:

Out[1]=1

Edges:

Out[1]=1

Graph itself:

Out[1]=1
Out[2]=2

DirectedEdges  (2)

By default, a directed tree is generated when giving a list of rules:

Out[2]=2

Use DirectedEdges->False to interpret rules as undirected edges:

Out[2]=2

Use DirectedEdge or UndirectedEdge to directly specify whether a graph is directed or not:

Out[1]=1

EdgeLabels  (7)

Label the edge 12:

Out[1]=1

Label all edges:

Out[2]=2

Use any expression as a label:

Out[1]=1

Use Placed with symbolic locations to control label placement along an edge:

Out[1]=1

Use explicit coordinates to place labels:

Out[1]=1

Vary positions within the label:

Out[2]=2

Place multiple labels using Placed in a wrapper:

Out[1]=1

Any number of labels can be used:

Out[2]=2

Place multiple labels using EdgeLabels:

Out[3]=3

Use automatic labeling by values through Tooltip and StatusArea:

Out[1]=1
Out[2]=2

EdgeShapeFunction  (6)

Get a list of built-in settings for EdgeShapeFunction:

Out[1]=1

Undirected edges including the basic line:

Out[1]=1

Lines with different glyphs on the edges:

Out[2]=2

Directed edges including solid arrows:

Out[1]=1

Line arrows:

Out[2]=2

Open arrows:

Out[3]=3

Specify an edge function for an individual edge:

Out[1]=1

Combine with a different default edge function:

Out[2]=2

Draw edges by running a program:

Out[2]=2

EdgeShapeFunction can be combined with EdgeStyle:

Out[1]=1

EdgeShapeFunction has higher priority than EdgeStyle:

Out[2]=2

EdgeStyle  (2)

Style all edges:

Out[1]=1

Style individual edges:

Out[1]=1

EdgeWeight  (2)

Specify the weight for all edges:

Out[1]=1

Use any numeric expression as a weight:

Out[1]=1

GraphHighlight  (3)

Highlight the vertex 1:

Out[1]=1

Highlight the edge 13:

Out[1]=1

Highlight vertices and edges:

Out[1]=1

GraphHighlightStyle  (2)

Get a list of built-in settings for GraphHighlightStyle:

Out[1]=1

Use built-in settings for GraphHighlightStyle:

Out[1]=1

GraphLayout  (5)

By default, the layout is chosen automatically:

Out[1]=1

Specify layouts on special curves:

Out[1]=1

Specify layouts that satisfy optimality criteria:

Out[2]=2

VertexCoordinates overrides GraphLayout coordinates:

Out[1]=1

Use AbsoluteOptions to extract VertexCoordinates computed using a layout algorithm:

Out[1]=1
Out[2]=2

PlotTheme  (4)

Base Themes  (2)

Use a common base theme:

Out[1]=1

Use a monochrome theme:

Out[1]=1

Feature Themes  (2)

Use a large graph theme:

Out[1]=1

Use a classic diagram theme:

Out[1]=1

VertexCoordinates  (3)

By default, any vertex coordinates are computed automatically:

Out[1]=1

Extract the resulting vertex coordinates using AbsoluteOptions:

Out[2]=2

Specify a layout function along an ellipse:

Out[2]=2

Use it to generate vertex coordinates for a graph:

Out[3]=3

VertexCoordinates has higher priority than GraphLayout:

Out[1]=1

VertexLabels  (13)

Use vertex names as labels:

Out[1]=1

Label individual vertices:

Out[1]=1

Label all vertices:

Out[1]=1

Use any expression as a label:

Out[1]=1

Use Placed with symbolic locations to control label placement, including outside positions:

Out[1]=1

Symbolic outside-corner positions:

Out[2]=2

Symbolic inside positions:

Out[1]=1

Symbolic inside-corner positions:

Out[2]=2

Use explicit coordinates to place the center of labels:

Out[1]=1

Place all labels at the upper-right corner of the vertex and vary the coordinates within the label:

Out[1]=1

Place multiple labels using Placed in a wrapper:

Out[1]=1

Any number of labels can be used:

Out[2]=2

Place multiple labels using VertexLabels:

Out[3]=3

Use the argument to Placed to control formatting including Tooltip:

Out[1]=1

Or StatusArea:

Out[2]=2

Use more elaborate formatting functions:

Out[2]=2
Out[4]=4
Out[6]=6

VertexShape  (5)

Use any Graphics, Image, or Graphics3D as a vertex shape:

Out[1]=1

Specify vertex shapes for individual vertices:

Out[1]=1

VertexShape can be combined with VertexSize:

Out[1]=1

VertexShape is not affected by VertexStyle:

Out[1]=1

VertexShapeFunction has higher priority than VertexShape:

Out[1]=1

VertexShapeFunction  (10)

Get a list of built-in collections for VertexShapeFunction:

Out[1]=1

Use built-in settings for VertexShapeFunction in the "Basic" collection:

Out[1]=1

Simple basic shapes:

Out[2]=2

Common basic shapes:

Out[3]=3

Use built-in settings for VertexShapeFunction in the "Rounded" collection:

Out[1]=1
Out[2]=2

Use built-in settings for VertexShapeFunction in the "Concave" collection:

Out[1]=1
Out[2]=2

Draw individual vertices:

Out[1]=1

Combine with a default vertex function:

Out[2]=2

Draw vertices using a predefined graphic:

Out[1]=1

Draw vertices by running a program:

Out[2]=2

VertexShapeFunction can be combined with VertexStyle:

Out[2]=2

VertexShapeFunction has higher priority than VertexStyle:

Out[4]=4

VertexShapeFunction can be combined with VertexSize:

Out[1]=1

VertexShapeFunction has higher priority than VertexShape:

Out[1]=1

VertexSize  (8)

By default, the size of vertices is computed automatically:

Out[1]=1

Specify the size of all vertices using symbolic vertex size:

Out[1]=1

Use a fraction of the minimum distance between vertex coordinates:

Out[1]=1

Use a fraction of the overall diagonal for all vertex coordinates:

Out[1]=1

Specify size in both the and directions:

Out[1]=1

Specify the sizes for individual vertices:

Out[1]=1

VertexSize can be combined with VertexShapeFunction:

Out[1]=1

VertexSize can be combined with VertexShape:

Out[1]=1

VertexStyle  (5)

Style all vertices:

Out[1]=1

Style individual vertices:

Out[1]=1

VertexShapeFunction can be combined with VertexStyle:

Out[2]=2

VertexShapeFunction has higher priority than VertexStyle:

Out[4]=4

VertexStyle can be combined with BaseStyle:

Out[1]=1

VertexStyle has higher priority than BaseStyle:

Out[2]=2

VertexShape is not affected by VertexStyle:

Out[1]=1

VertexWeight  (2)

Set the weight for all vertices:

Out[1]=1
Out[2]=2

Use any numeric expression as a weight:

Out[1]=1
Out[2]=2

Applications  (4)Sample problems that can be solved with this function

Generate a random tree:

Out[1]=1

Highlight the GraphCenter and GraphPeriphery:

Out[2]=2

The VertexEccentricity:

Out[2]=2

Highlight the vertex eccentricity path:

Out[4]=4

The GraphRadius:

Out[2]=2

Highlight the radius path:

Out[4]=4

The GraphDiameter:

Out[2]=2

Highlight the diameter path:

Out[4]=4

Properties & Relations  (9)Properties of the function, and connections to other functions

Use VertexCount and EdgeCount to count vertices and edges:

Out[1]=1
Out[2]=2

Use VertexList and EdgeList to enumerate vertices and edges in standard order:

Out[2]=2

Edges and vertices are given in the order they are input:

Out[4]=4

Compute the AdjacencyMatrix from a graph:

Out[1]=1

A tree graph is connected:

Out[1]=1
Out[2]=2

A tree graph does not have any loops or cycles:

Out[1]=1
Out[2]=2

A tree graph with vertices has edges:

Out[1]=1
Out[2]=2

A tree graph is a bipartite graph:

Out[1]=1
Out[2]=2

A tree graph with vertices with has at least two and at most vertices of degree 1:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

A star graph is a tree graph:

Out[1]=1
Out[2]=2
Wolfram Research (2010), TreeGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/TreeGraph.html (updated 2015).
Wolfram Research (2010), TreeGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/TreeGraph.html (updated 2015).

Text

Wolfram Research (2010), TreeGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/TreeGraph.html (updated 2015).

Wolfram Research (2010), TreeGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/TreeGraph.html (updated 2015).

CMS

Wolfram Language. 2010. "TreeGraph." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/TreeGraph.html.

Wolfram Language. 2010. "TreeGraph." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/TreeGraph.html.

APA

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

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

BibTeX

@misc{reference.wolfram_2025_treegraph, author="Wolfram Research", title="{TreeGraph}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/TreeGraph.html}", note=[Accessed: 02-June-2025 ]}

@misc{reference.wolfram_2025_treegraph, author="Wolfram Research", title="{TreeGraph}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/TreeGraph.html}", note=[Accessed: 02-June-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_treegraph, organization={Wolfram Research}, title={TreeGraph}, year={2015}, url={https://reference.wolfram.com/language/ref/TreeGraph.html}, note=[Accessed: 02-June-2025 ]}

@online{reference.wolfram_2025_treegraph, organization={Wolfram Research}, title={TreeGraph}, year={2015}, url={https://reference.wolfram.com/language/ref/TreeGraph.html}, note=[Accessed: 02-June-2025 ]}