GraphTree
更多信息和选项
- 在 GraphTree[g] 中,g 必须是一个有效图对象,其 TreeGraphQ 给出 True.
- GraphTree 给出一个子树包含 graph 顶点的 Tree 对象.
- 默认情况下,GraphTree[g] 使用有最大 VertexOutComponent 的顶点作为 root.
- 在 GraphTree[g,root] 中,边的方向被忽略了.
- 在 GraphTree[g,root,h] 中,顶点 v 的子树由 h[v] 来指定,会返回一对 {data,expr}. 对于兄弟 {datai,expri},datai 在子树中给出数据,且兄弟由 expri 进行排序.
- GraphTree[TreeGraph[tree],{data,{}},Identity] 等价于 tree,其中 TreeData[tree] 给出 data.
- GraphTree 有与 Tree 相同的选项.
-
AlignmentPoint Center 在图形内对齐的缺省点 AspectRatio Automatic 高与宽的比 Axes False 是否绘制轴 AxesLabel None 坐标轴标签 AxesOrigin Automatic 坐标轴原点 AxesStyle {} 坐标轴样式指定 Background None 绘图的背景色 BaselinePosition Automatic 如何与环绕文本基线对齐 BaseStyle {} 图形的基本样式指定 ContentSelectable Automatic 是否允许进行内容选择 CoordinatesToolOptions Automatic 坐标工具的详细行为 Epilog {} 主图形之后执行的图形指令 FormatType TraditionalForm 文本的缺省样式类型 Frame False 是否在图形周围放置边框 FrameLabel None 边框标签 FrameStyle {} 边框的样式指定 FrameTicks Automatic 边框刻度 FrameTicksStyle {} 边框刻度的样式指定 GridLines None 绘制的网格线 GridLinesStyle {} 网格线的样式指定 ImageMargins 0. 图形周围的边幅 ImagePadding All 为标签等额外填充内容 ImageSize Automatic 图形的绝对尺寸 LabelStyle {} 标签的样式指定 Method Automatic 使用图形方式的细节 PlotLabel None 图形的一个整体标签 PlotRange All 图形值的范围 PlotRangeClipping False 是否在图形范围剪切 PlotRangePadding Automatic 填充图形值范围的程度 PlotRegion Automatic 填充的最后显示区域 PreserveImageOptions Automatic 当显示相同图形的新版本时,是否保存图形选项 Prolog {} 主图形之前执行的图形指令 RotateLabel True 是否在边框上旋转 y 标签 Ticks Automatic 坐标轴标记 TicksStyle {} 坐标轴标记的样式指定
所有选项的列表
范例
打开所有单元 关闭所有单元基本范例 (2)
范围 (4)
将 CompleteKaryTree 图转换为树图:
CompleteKaryTree[4]GraphTree[%]GraphTree[[image], 5]GraphTree[[image], 5, {#, -#}&]将 StarGraph 对象转换为树图:
StarGraph[6]GraphTree[%]将 TreeGraph 对象转换为树图:
TreeGraph[{1 -> 2, 1 -> 3, 1 -> 4, 4 -> 5, 4 -> 6}]GraphTree[%]选项 (9)
为单个树元素设置样式 (2)
设置整个树的样式 (4)
GraphTree[CompleteKaryTree[4, 2], TreeElementLabel -> All -> None, TreeElementStyle -> All -> EdgeForm[Red]]GraphTree[CompleteKaryTree[4, 2], BaseStyle -> LightRed]GraphTree[CompleteKaryTree[4, 2], BaseStyle -> {Dashed, EdgeForm[{Dashing[{}], Thick}]}]GraphTree[CompleteKaryTree[4, 2], BaseStyle -> {Red, EdgeForm[None]}, TreeElementStyle -> All -> Opacity[0]]树的布局和图形选项 (3)
GraphTree[CompleteKaryTree[3, 2], TreeLayout -> Bottom]GraphTree[CompleteKaryTree[4, 4], TreeLayout -> "BalloonEmbedding", IconizedObject[«labels»]]指定 Graphics 选项:
GraphTree[TreeGraph[{1 -> 2, 1 -> 3}], Background -> LightBlue, ImageSize -> 50]属性和关系 (3)
GraphTree 仅可以转换 TreeGraphQ 对象:
GraphTree[[image]]若图非 TreeGraphQ,则 GraphTree 会失败:
GraphTree[[image]]
TreeGraph[[image]]GraphTree[TreeGraph[tree],{data,{}},Identity] 等价于 tree,其中 TreeData[tree] 给出 data:
TreeGraph[[image]]VertexList[%]GraphTree[%%, {1, {}}, Identity]文本
Wolfram Research (2021),GraphTree,Wolfram 语言函数,https://reference.wolfram.com/language/ref/GraphTree.html (更新于 2021 年).
CMS
Wolfram 语言. 2021. "GraphTree." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2021. https://reference.wolfram.com/language/ref/GraphTree.html.
APA
Wolfram 语言. (2021). GraphTree. Wolfram 语言与系统参考资料中心. 追溯自 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: 04-November-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: 04-November-2026]}