GraphTree

GraphTree[g]

constructs a tree from the tree graph g.

GraphTree[g,root]

specifies what vertex to use as the root.

GraphTree[g,root,h]

applies h to each vertex to get the corresponding data and ordering of subtrees.

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 takes the same options as Tree.

Examples

open allclose all

Basic Examples  (2)

Transform a directed graph into a Tree object:

Specify an alternate root:

Convert an undirected graph into a Tree object:

Scope  (4)

Transform a CompleteKaryTree graph into a tree:

Specify the root vertex:

Sort the siblings in reverse order:

Convert a StarGraph object into a tree:

Transform a TreeGraph object into a tree:

Options  (9)

Styling Individual Tree Elements  (2)

Specify the label for the generated tree element:

Specify labels and styles for subtrees by position:

Styling Entire Tree  (4)

Specify labels and styles for all subtrees:

Specify the base style:

Specify the style for both the edges and the edges of the tree elements:

Specify the base style and styles for individual tree elements:

Tree Layout and Graphics Options  (3)

Specify the orientation for the root:

Specify a named embedding:

Specify Graphics options:

Properties & Relations  (3)

GraphTree can only transform TreeGraphQ objects:

If the graph is not TreeGraphQ, then GraphTree will fail:

Use TreeGraph to convert a tree into a Graph:

GraphTree[TreeGraph[tree],{data,{}},Identity] is equivalent to tree, where TreeData[tree] gives data:

The root vertex is of the form {data,{}}:

Reconstruct the tree, sorting siblings by their position:

Wolfram Research (2021), GraphTree, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphTree.html (updated 2021).

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_2024_graphtree, author="Wolfram Research", title="{GraphTree}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/GraphTree.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_graphtree, organization={Wolfram Research}, title={GraphTree}, year={2021}, url={https://reference.wolfram.com/language/ref/GraphTree.html}, note=[Accessed: 22-November-2024 ]}