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 allBasic Examples (2)
Scope (4)
Transform a CompleteKaryTree graph into a tree:
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)
Styling Entire Tree (4)
Tree Layout and Graphics Options (3)
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:
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