TreeGraph
✖
TreeGraph
yields a tree with vertex and edge properties defined by the symbolic wrappers wk.
Details and Options

- TreeGraph generates a Graph object.
- TreeGraph supports the same vertices, edges, wrappers, and options as Graph.
- A tree is a simple connected graph with no cycles.
- A tree is a connected graph with no cycles.
- TreeGraph can only represent trees.
-
AlignmentPoint Center the default point in the graphic to align with AnnotationRules {} annotations for graph, edges and vertices AspectRatio Automatic ratio of height to width Axes False whether to draw axes AxesLabel None axes labels AxesOrigin Automatic where axes should cross AxesStyle {} style specifications for the axes Background None background color for the plot BaselinePosition Automatic how to align with a surrounding text baseline BaseStyle {} base style specifications for the graphic ContentSelectable Automatic whether to allow contents to be selected CoordinatesToolOptions Automatic detailed behavior of the coordinates tool DirectedEdges Automatic whether to interpret Rule as DirectedEdge EdgeLabels None labels and label placements for edges EdgeLabelStyle Automatic style to use for edge labels EdgeShapeFunction Automatic generate graphic shapes for edges EdgeStyle Automatic style used for edges EdgeWeight Automatic weights for edges Epilog {} primitives rendered after the main plot FormatType TraditionalForm the default format type for text Frame False whether to put a frame around the plot FrameLabel None frame labels FrameStyle {} style specifications for the frame FrameTicks Automatic frame ticks FrameTicksStyle {} style specifications for frame ticks GraphHighlight {} graph elements to highlight GraphHighlightStyle Automatic style for highlight GraphLayout Automatic how to lay out vertices and edges GridLines None grid lines to draw GridLinesStyle {} style specifications for grid lines ImageMargins 0. the margins to leave around the graphic ImagePadding All what extra padding to allow for labels etc. ImageSize Automatic the absolute size at which to render the graphic LabelStyle {} style specifications for labels Method Automatic details of graphics methods to use PerformanceGoal Automatic aspects of performance to try to optimize PlotLabel None an overall label for the plot PlotRange All range of values to include PlotRangeClipping False whether to clip at the plot range PlotRangePadding Automatic how much to pad the range of values PlotRegion Automatic the final display region to be filled PlotTheme $PlotTheme overall theme for the graph PreserveImageOptions Automatic whether to preserve image options when displaying new versions of the same graphic Prolog {} primitives rendered before the main plot RotateLabel True whether to rotate y labels on the frame Ticks Automatic axes ticks TicksStyle {} style specifications for axes ticks VertexCoordinates Automatic coordinates for vertices VertexLabels None labels and placements for vertices VertexLabelStyle Automatic style to use for vertex labels VertexShape Automatic graphic shape for vertices VertexShapeFunction Automatic generate graphic shapes for vertices VertexSize Medium size of vertices VertexStyle Automatic styles for vertices VertexWeight Automatic weights for vertices

List of all options




Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Scope (25)Survey of the scope of standard use cases
Connectivity (6)
Create an undirected graph using characters; enter the character as ue
:

https://wolfram.com/xid/0tzs368a-eyabqs

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

https://wolfram.com/xid/0tzs368a-h2znzh

Create a directed graph from a list of rules:

https://wolfram.com/xid/0tzs368a-t8xwn

Create an undirected graph from a list of rules:

https://wolfram.com/xid/0tzs368a-dwwk49

Use VertexList and EdgeList to get vertices and edges:

https://wolfram.com/xid/0tzs368a-z3ycv

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

https://wolfram.com/xid/0tzs368a-c60esi

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

https://wolfram.com/xid/0tzs368a-cs08co

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

https://wolfram.com/xid/0tzs368a-cwwd2i

The input vertex list controls the resulting vertex order:

https://wolfram.com/xid/0tzs368a-edo3i

Any expression can be used as vertices:

https://wolfram.com/xid/0tzs368a-ekr9p8


https://wolfram.com/xid/0tzs368a-ezslu6

Wrappers (5)
Use wrappers on vertices or edges:

https://wolfram.com/xid/0tzs368a-kbcj08


https://wolfram.com/xid/0tzs368a-feveim

Add interactive behavior by wrappers such as Tooltip:

https://wolfram.com/xid/0tzs368a-isd8ny

Any object can be used in the tooltip:

https://wolfram.com/xid/0tzs368a-c1h5pq

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

https://wolfram.com/xid/0tzs368a-bgc3da

Use PopupWindow to provide information drilldown:

https://wolfram.com/xid/0tzs368a-nr0yak

Styling (8)
Set the style for all vertices or edges:

https://wolfram.com/xid/0tzs368a-diq4w

Style individual vertices or edges using options:

https://wolfram.com/xid/0tzs368a-jcmo8i

Use wrappers for individual styling:

https://wolfram.com/xid/0tzs368a-fumdv

Adjust the size of vertices using symbolic sizes:

https://wolfram.com/xid/0tzs368a-kij569

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

https://wolfram.com/xid/0tzs368a-du6sqj

Use built-in collections for VertexShapeFunction:

https://wolfram.com/xid/0tzs368a-bb9hnx


https://wolfram.com/xid/0tzs368a-ipopwl


https://wolfram.com/xid/0tzs368a-b93ytj


https://wolfram.com/xid/0tzs368a-cykcat

Combine with a default vertex function:

https://wolfram.com/xid/0tzs368a-6gmd9

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

https://wolfram.com/xid/0tzs368a-cfhisd

Use built-in collections for EdgeShapeFunction:

https://wolfram.com/xid/0tzs368a-bj0g84

Directed edges including solid arrows:

https://wolfram.com/xid/0tzs368a-fgaaox


https://wolfram.com/xid/0tzs368a-f8ssfa


https://wolfram.com/xid/0tzs368a-7y9i

Specify an edge function for an individual edge:

https://wolfram.com/xid/0tzs368a-927k

Combine with a different default edge function:

https://wolfram.com/xid/0tzs368a-d1bylx

Labeling (6)

https://wolfram.com/xid/0tzs368a-efut9s

Use any expression as a label:

https://wolfram.com/xid/0tzs368a-dwihyd


https://wolfram.com/xid/0tzs368a-cy6kli

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

https://wolfram.com/xid/0tzs368a-p4wj1o


https://wolfram.com/xid/0tzs368a-jzlpy


https://wolfram.com/xid/0tzs368a-dwxanf

Place multiple labels using Placed in a wrapper:

https://wolfram.com/xid/0tzs368a-jm7jll

Any number of labels can be used:

https://wolfram.com/xid/0tzs368a-g4ik4

Place multiple labels using VertexLabels:

https://wolfram.com/xid/0tzs368a-gqucwy

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

https://wolfram.com/xid/0tzs368a-e0qhjl

Use explicit coordinates to place labels:

https://wolfram.com/xid/0tzs368a-nd0sz

Place multiple labels using Placed in a wrapper:

https://wolfram.com/xid/0tzs368a-yygoa

Any number of labels can be used:

https://wolfram.com/xid/0tzs368a-bhs5vp

Place multiple labels using EdgeLabels:

https://wolfram.com/xid/0tzs368a-dyhc8j

Options (82)Common values & functionality for each option
AnnotationRules (3)
DirectedEdges (2)
By default, a directed tree is generated when giving a list of rules:

https://wolfram.com/xid/0tzs368a-iwq8nh

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

https://wolfram.com/xid/0tzs368a-hsbm48

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

https://wolfram.com/xid/0tzs368a-c4p2v7

EdgeLabels (7)

https://wolfram.com/xid/0tzs368a-z5279


https://wolfram.com/xid/0tzs368a-1t3zd

https://wolfram.com/xid/0tzs368a-hr4015

Use any expression as a label:

https://wolfram.com/xid/0tzs368a-b7zkda

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

https://wolfram.com/xid/0tzs368a-fnltmw

Use explicit coordinates to place labels:

https://wolfram.com/xid/0tzs368a-ndfa94

Vary positions within the label:

https://wolfram.com/xid/0tzs368a-bg84f5

Place multiple labels using Placed in a wrapper:

https://wolfram.com/xid/0tzs368a-cj2dt

Any number of labels can be used:

https://wolfram.com/xid/0tzs368a-dy5run

Place multiple labels using EdgeLabels:

https://wolfram.com/xid/0tzs368a-33q72

Use automatic labeling by values through Tooltip and StatusArea:

https://wolfram.com/xid/0tzs368a-dhn5kr


https://wolfram.com/xid/0tzs368a-bd54a9

EdgeShapeFunction (6)
Get a list of built-in settings for EdgeShapeFunction:

https://wolfram.com/xid/0tzs368a-hfmhqu

Undirected edges including the basic line:

https://wolfram.com/xid/0tzs368a-fjhml

Lines with different glyphs on the edges:

https://wolfram.com/xid/0tzs368a-lxjrsx

Directed edges including solid arrows:

https://wolfram.com/xid/0tzs368a-lvr0ss


https://wolfram.com/xid/0tzs368a-qslbt


https://wolfram.com/xid/0tzs368a-f6ch7m

Specify an edge function for an individual edge:

https://wolfram.com/xid/0tzs368a-eczrhp

Combine with a different default edge function:

https://wolfram.com/xid/0tzs368a-jwjk2c

Draw edges by running a program:

https://wolfram.com/xid/0tzs368a-j0dznf

https://wolfram.com/xid/0tzs368a-lsgwlp

EdgeShapeFunction can be combined with EdgeStyle:

https://wolfram.com/xid/0tzs368a-gt52v9

EdgeShapeFunction has higher priority than EdgeStyle:

https://wolfram.com/xid/0tzs368a-cfn5oz

EdgeStyle (2)
EdgeWeight (2)
GraphHighlight (3)
GraphHighlightStyle (2)
Get a list of built-in settings for GraphHighlightStyle:

https://wolfram.com/xid/0tzs368a-lu7p68

Use built-in settings for GraphHighlightStyle:

https://wolfram.com/xid/0tzs368a-qwjuvn

GraphLayout (5)
By default, the layout is chosen automatically:

https://wolfram.com/xid/0tzs368a-igrugb

Specify layouts on special curves:

https://wolfram.com/xid/0tzs368a-d70vy1

Specify layouts that satisfy optimality criteria:

https://wolfram.com/xid/0tzs368a-f5io18

https://wolfram.com/xid/0tzs368a-eilzf

VertexCoordinates overrides GraphLayout coordinates:

https://wolfram.com/xid/0tzs368a-eibt82

Use AbsoluteOptions to extract VertexCoordinates computed using a layout algorithm:

https://wolfram.com/xid/0tzs368a-p76zf


https://wolfram.com/xid/0tzs368a-cxtvu4

PlotTheme (4)
Base Themes (2)
VertexCoordinates (3)
By default, any vertex coordinates are computed automatically:

https://wolfram.com/xid/0tzs368a-5spor

Extract the resulting vertex coordinates using AbsoluteOptions:

https://wolfram.com/xid/0tzs368a-2whoh

Specify a layout function along an ellipse:

https://wolfram.com/xid/0tzs368a-mwyuvu

https://wolfram.com/xid/0tzs368a-cvx31k

Use it to generate vertex coordinates for a graph:

https://wolfram.com/xid/0tzs368a-uukkr

VertexCoordinates has higher priority than GraphLayout:

https://wolfram.com/xid/0tzs368a-hdij4u

VertexLabels (13)

https://wolfram.com/xid/0tzs368a-c9ka50


https://wolfram.com/xid/0tzs368a-i40mcj


https://wolfram.com/xid/0tzs368a-whkpg

Use any expression as a label:

https://wolfram.com/xid/0tzs368a-kokbex

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

https://wolfram.com/xid/0tzs368a-ies878

Symbolic outside-corner positions:

https://wolfram.com/xid/0tzs368a-cdmwvl

https://wolfram.com/xid/0tzs368a-ocwty6


https://wolfram.com/xid/0tzs368a-fg0pin

Symbolic inside-corner positions:

https://wolfram.com/xid/0tzs368a-kfrv7

https://wolfram.com/xid/0tzs368a-dr87wv

Use explicit coordinates to place the center of labels:

https://wolfram.com/xid/0tzs368a-cqfi4r

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

https://wolfram.com/xid/0tzs368a-20sv

Place multiple labels using Placed in a wrapper:

https://wolfram.com/xid/0tzs368a-eazh7z

Any number of labels can be used:

https://wolfram.com/xid/0tzs368a-ftgvi6

Place multiple labels using VertexLabels:

https://wolfram.com/xid/0tzs368a-kusfg3

Use the argument to Placed to control formatting including Tooltip:

https://wolfram.com/xid/0tzs368a-cxzeiw

Or StatusArea:

https://wolfram.com/xid/0tzs368a-nddwmk

Use more elaborate formatting functions:

https://wolfram.com/xid/0tzs368a-bd9m40

https://wolfram.com/xid/0tzs368a-cggp96


https://wolfram.com/xid/0tzs368a-l3s7yb

https://wolfram.com/xid/0tzs368a-cljxny


https://wolfram.com/xid/0tzs368a-cqkdbb

https://wolfram.com/xid/0tzs368a-bjoam1

VertexShape (5)
Use any Graphics, Image, or Graphics3D as a vertex shape:

https://wolfram.com/xid/0tzs368a-dvz661

Specify vertex shapes for individual vertices:

https://wolfram.com/xid/0tzs368a-i1s9c7

VertexShape can be combined with VertexSize:

https://wolfram.com/xid/0tzs368a-jqe83v

VertexShape is not affected by VertexStyle:

https://wolfram.com/xid/0tzs368a-3ef8f

VertexShapeFunction has higher priority than VertexShape:

https://wolfram.com/xid/0tzs368a-budnxj

VertexShapeFunction (10)
Get a list of built-in collections for VertexShapeFunction:

https://wolfram.com/xid/0tzs368a-cc7w4d

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

https://wolfram.com/xid/0tzs368a-kqz1mq


https://wolfram.com/xid/0tzs368a-hshluc


https://wolfram.com/xid/0tzs368a-wm2s7

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

https://wolfram.com/xid/0tzs368a-je3pt2


https://wolfram.com/xid/0tzs368a-cj5ftp

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

https://wolfram.com/xid/0tzs368a-f4ea1p


https://wolfram.com/xid/0tzs368a-bfhgv4


https://wolfram.com/xid/0tzs368a-fhb0zi

Combine with a default vertex function:

https://wolfram.com/xid/0tzs368a-fmawhn

Draw vertices using a predefined graphic:

https://wolfram.com/xid/0tzs368a-6fiu

Draw vertices by running a program:

https://wolfram.com/xid/0tzs368a-oroxkx

https://wolfram.com/xid/0tzs368a-lt54lp

VertexShapeFunction can be combined with VertexStyle:

https://wolfram.com/xid/0tzs368a-c5uihz

https://wolfram.com/xid/0tzs368a-djz15m

VertexShapeFunction has higher priority than VertexStyle:

https://wolfram.com/xid/0tzs368a-h9wrh2

https://wolfram.com/xid/0tzs368a-ir0ry

VertexShapeFunction can be combined with VertexSize:

https://wolfram.com/xid/0tzs368a-e414xo

VertexShapeFunction has higher priority than VertexShape:

https://wolfram.com/xid/0tzs368a-lnnzsy

VertexSize (8)
By default, the size of vertices is computed automatically:

https://wolfram.com/xid/0tzs368a-dsy1ve

Specify the size of all vertices using symbolic vertex size:

https://wolfram.com/xid/0tzs368a-lskxsr

Use a fraction of the minimum distance between vertex coordinates:

https://wolfram.com/xid/0tzs368a-g5f1xn

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

https://wolfram.com/xid/0tzs368a-my5omo

Specify size in both the and
directions:

https://wolfram.com/xid/0tzs368a-c7twgs

Specify the sizes for individual vertices:

https://wolfram.com/xid/0tzs368a-h6r4ja

VertexSize can be combined with VertexShapeFunction:

https://wolfram.com/xid/0tzs368a-b3jw4t

VertexSize can be combined with VertexShape:

https://wolfram.com/xid/0tzs368a-dego1v

VertexStyle (5)

https://wolfram.com/xid/0tzs368a-ehbi7i


https://wolfram.com/xid/0tzs368a-dtkst6

VertexShapeFunction can be combined with VertexStyle:

https://wolfram.com/xid/0tzs368a-om30z

https://wolfram.com/xid/0tzs368a-nnfnwx

VertexShapeFunction has higher priority than VertexStyle:

https://wolfram.com/xid/0tzs368a-kfv4n

https://wolfram.com/xid/0tzs368a-cldcke

VertexStyle can be combined with BaseStyle:

https://wolfram.com/xid/0tzs368a-bby1h9

VertexStyle has higher priority than BaseStyle:

https://wolfram.com/xid/0tzs368a-d0df6

VertexShape is not affected by VertexStyle:

https://wolfram.com/xid/0tzs368a-3rqw0

VertexWeight (2)
Set the weight for all vertices:

https://wolfram.com/xid/0tzs368a-coy9ti


https://wolfram.com/xid/0tzs368a-jjkrix

Use any numeric expression as a weight:

https://wolfram.com/xid/0tzs368a-lxjpz1


https://wolfram.com/xid/0tzs368a-gbkkry

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

https://wolfram.com/xid/0tzs368a-hz916a

Highlight the GraphCenter and GraphPeriphery:

https://wolfram.com/xid/0tzs368a-jumrf

The VertexEccentricity:

https://wolfram.com/xid/0tzs368a-bosckn

https://wolfram.com/xid/0tzs368a-j85hrw

Highlight the vertex eccentricity path:

https://wolfram.com/xid/0tzs368a-dsdipl

https://wolfram.com/xid/0tzs368a-bqnfgg

The GraphRadius:

https://wolfram.com/xid/0tzs368a-dasegx

https://wolfram.com/xid/0tzs368a-bsaw7


https://wolfram.com/xid/0tzs368a-lyxd43

https://wolfram.com/xid/0tzs368a-i7o2zk

The GraphDiameter:

https://wolfram.com/xid/0tzs368a-bhpt

https://wolfram.com/xid/0tzs368a-dckbk


https://wolfram.com/xid/0tzs368a-h2qy47

https://wolfram.com/xid/0tzs368a-ct72bn

Properties & Relations (9)Properties of the function, and connections to other functions
Use VertexCount and EdgeCount to count vertices and edges:

https://wolfram.com/xid/0tzs368a-ewldet


https://wolfram.com/xid/0tzs368a-buy2ca

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

https://wolfram.com/xid/0tzs368a-l0u8q

https://wolfram.com/xid/0tzs368a-l06m

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

https://wolfram.com/xid/0tzs368a-chydq0

https://wolfram.com/xid/0tzs368a-f3ry1t

Compute the AdjacencyMatrix from a graph:

https://wolfram.com/xid/0tzs368a-bil8h7


https://wolfram.com/xid/0tzs368a-cewi3i


https://wolfram.com/xid/0tzs368a-blpefu


https://wolfram.com/xid/0tzs368a-fg25f1

A tree graph does not have any loops or cycles:

https://wolfram.com/xid/0tzs368a-o1vuao


https://wolfram.com/xid/0tzs368a-vvnmc

A tree graph with vertices has
edges:

https://wolfram.com/xid/0tzs368a-kbnjnt


https://wolfram.com/xid/0tzs368a-b355iq

A tree graph is a bipartite graph:

https://wolfram.com/xid/0tzs368a-dl65aj


https://wolfram.com/xid/0tzs368a-l864ep

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

https://wolfram.com/xid/0tzs368a-s8wsg


https://wolfram.com/xid/0tzs368a-gz1flg


https://wolfram.com/xid/0tzs368a-c6r1bh


https://wolfram.com/xid/0tzs368a-cr4r74


https://wolfram.com/xid/0tzs368a-etxrcr


https://wolfram.com/xid/0tzs368a-e4alil

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