GraphTree
Details and Options
- In GraphTree[g], g must be a valid graph object for which TreeGraphQ gives True.
- GraphTree gives a Tree object with subtrees containing the vertices of graph.
- By default, GraphTree[g] uses the vertex with the largest VertexOutComponent as root.
- In GraphTree[g,root], the direction of edges is ignored.
- In GraphTree[g,root,h], the subtree for a vertex v is specified by h[v], which should return a pair {data,expr}. For siblings {datai,expri}, the datai give the data in the subtrees, and the siblings are sorted by the expri.
- GraphTree[TreeGraph[tree],{data,{}},Identity] is equivalent to tree, where TreeData[tree] gives data.
- GraphTree has the same options as Tree.
-
AlignmentPoint Center the default point in the graphic to align with 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 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 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 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 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
List of all options
Examples
open all close allBasic Examples (2)
Scope (4)
Transform a CompleteKaryTree graph into a tree:
CompleteKaryTree[4]GraphTree[%]GraphTree[[image], 5]Sort the siblings in reverse order:
GraphTree[[image], 5, {#, -#}&]Convert a StarGraph object into a tree:
StarGraph[6]GraphTree[%]Transform a TreeGraph object into a tree:
TreeGraph[{1 -> 2, 1 -> 3, 1 -> 4, 4 -> 5, 4 -> 6}]GraphTree[%]Options (9)
Styling Individual Tree Elements (2)
Specify the label for the generated tree element:
GraphTree[CompleteKaryTree[2], TreeElementLabel -> "?"]Specify labels and styles for subtrees by position:
GraphTree[CompleteKaryTree[3, 3],
TreeElementLabel -> {___, _ ? EvenQ} -> None, TreeElementStyle -> {___, _ ? OddQ} -> {LightRed, EdgeForm[{Red, Dashed}]}]Styling Entire Tree (4)
Specify labels and styles for all subtrees:
GraphTree[CompleteKaryTree[4, 2], TreeElementLabel -> All -> None, TreeElementStyle -> All -> EdgeForm[Red]]GraphTree[CompleteKaryTree[4, 2], BaseStyle -> LightRed]Specify the style for both the edges and the edges of the tree elements:
GraphTree[CompleteKaryTree[4, 2], BaseStyle -> {Dashed, EdgeForm[{Dashing[{}], Thick}]}]Specify the base style and styles for individual tree elements:
GraphTree[CompleteKaryTree[4, 2], BaseStyle -> {Red, EdgeForm[None]}, TreeElementStyle -> All -> Opacity[0]]Tree Layout and Graphics Options (3)
Specify the orientation for the root:
GraphTree[CompleteKaryTree[3, 2], TreeLayout -> Bottom]GraphTree[CompleteKaryTree[4, 4], TreeLayout -> "BalloonEmbedding", IconizedObject[«labels»]]Specify Graphics options:
GraphTree[TreeGraph[{1 -> 2, 1 -> 3}], Background -> LightBlue, ImageSize -> 50]Properties & Relations (3)
GraphTree can only transform TreeGraphQ objects:
GraphTree[[image]]If the graph is not TreeGraphQ, then GraphTree will fail:
GraphTree[[image]]
Use TreeGraph to convert a tree into a Graph:
TreeGraph[[image]]GraphTree[TreeGraph[tree],{data,{}},Identity] is equivalent to tree, where TreeData[tree] gives data:
TreeGraph[[image]]The root vertex is of the form {data,{}}:
VertexList[%]Reconstruct the tree, sorting siblings by their position:
GraphTree[%%, {1, {}}, Identity]Related Guides
Text
Wolfram Research (2021), GraphTree, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphTree.html (updated 2021).
CMS
Wolfram Language. 2021. "GraphTree." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/GraphTree.html.
APA
Wolfram Language. (2021). GraphTree. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphTree.html
BibTeX
@misc{reference.wolfram_2026_graphtree, author="Wolfram Research", title="{GraphTree}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/GraphTree.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_graphtree, organization={Wolfram Research}, title={GraphTree}, year={2021}, url={https://reference.wolfram.com/language/ref/GraphTree.html}, note=[Accessed: 13-June-2026]}