Treeおよび関連関数のオプションで,部分木要素を描画するためのプリミティブを生成する関数を指定する.
TreeElementShapeFunction
Treeおよび関連関数のオプションで,部分木要素を描画するためのプリミティブを生成する関数を指定する.
詳細
- TreeElementShapeFunctionを使うと木の根のノードの形状およびパターンにマッチする位置にある任意の部分木の形状を生成する関数が指定できる.
- 次は,使用可能なオプション設定である.
-
Automatic 自動形状を使う None ノードは描画しない "name" 名前付きのノード形状関数 » func 一般的なノード形状関数 Allfunc すべてのノードに形状関数 func を使う » TreeCases[pattern]func データが pattern と一致するノードに func を使う » "Leaves"func 葉に func を使う » "NonLeaves"func 葉以外に func を使う » {pos1func1,pos2func2,…} funciを相対位置 posiのノードに使う » {patt1func1,patt2func2,…} パターン pattiにマッチする位置のノードに funciを使う » - 部分木要素のスタイル指定は,事実上,TreeElementStyle,TreeElementStyleFunction,TreeElementShapeFunctionの順に適用され,後の指定が先の指定をオーバーライドする.
- TreeElementShapeFunctionfunc は func[{x,y},data,{w,h}]が与えるプリミティブで根ノードを描画するように指定する.ここで,{x,y}は中心, data は根のデータ,{w,h}は幅と高さである.
- 部分木要素関数 func はレイアウトアルゴリズムで自動計算された境界ボックス{{x-w,x+w},{y-h,y+h}}内に部分木要素のプリミティブを描画しなければならない.
例題
すべて開く すべて閉じる例 (4)
Tree[1, {2, 3}, TreeElementShapeFunction -> "Square", TreeElementSize -> All -> Large]Tree[1, {2, 3}, TreeElementShapeFunction -> {{} -> None, {1} -> "Square", {2} -> "Star"}, TreeElementSize -> All -> Large]Tree[1, {2, 3}, TreeElementShapeFunction -> All -> None]Tree[1, {2, 3}, TreeElementShapeFunction -> {"Leaves" -> "Square", "NonLeaves" -> "Star"}, TreeElementSize -> All -> Large]スコープ (6)
TreeElementShapeFunctionギャラリー (4)
VertexShapeFunctionの組込みコレクションのリストを得る:
ResourceData["VertexShapeFunction"]"Basic"コレクションの中のTreeElementShapeFunctionの組込み設定を使う:
ResourceData["VertexShapeFunction", "Basic"]Table[Tree[1, {2, 3}, TreeElementShapeFunction -> vf, TreeElementSize -> 0.2, PlotLabel -> vf], {vf, {"Triangle", "Square", "Rectangle", "Pentagon", "Hexagon", "Octagon"}}]Table[Tree[1, {2, 3}, TreeElementShapeFunction -> vf, TreeElementSize -> 0.2, PlotLabel -> vf], {vf, {"DownTrapezoid", "UpTrapezoid", "Parallelogram", "FiveDown", "Circle", "Diamond", "Star", "Capsule"}}]"Rounded"コレクションの中のTreeElementShapeFunctionの組込み設定を使う:
ResourceData["VertexShapeFunction", "Rounded"]Table[Tree[1, {2, 3}, TreeElementShapeFunction -> vf, TreeElementSize -> 0.2, PlotLabel -> Style[vf, 9]], {vf, ResourceData["VertexShapeFunction", "Rounded"]}]"Concave"コレクションの中のTreeElementShapeFunctionの組込み設定を使う:
ResourceData["VertexShapeFunction", "Concave"]Table[Tree[1, {2, 3}, TreeElementShapeFunction -> vf, TreeElementSize -> 0.2, PlotLabel -> Style[vf, 9]], {vf, ResourceData["VertexShapeFunction", "Concave"]}]位置指定 (2)
Tree[1, {[image], [image], [image]}, TreeElementShapeFunction -> {{} -> None, {___, 1} -> "Square", {2} -> "Star"}, TreeElementSize -> All -> Large]Tree[1, {[image], [image], [image]}, TreeElementShapeFunction -> {TreeCases[1] -> None, TreeCases[_ ? EvenQ] -> "Square", TreeCases[_ ? OddQ] -> "Star"}, TreeElementSize -> All -> Large]特性と関係 (4)
Tree[1, {Tree[2, {4, 5}], Tree[3, {6, 7}]}, TreeElementShapeFunction -> {{} -> None, {___, 1} -> "Square", {2} -> "Star"}, TreeElementSize -> All -> Large]部分木によって指定された形状はその祖先によって指定された形状よりも優先順位が高い:
Tree[2, {3}, TreeElementShapeFunction -> Automatic]Tree[1, {%}, TreeElementShapeFunction -> All -> None]部分木内の位置{i,j,…}は相対位置{i,j,…}にあるその部分木を参照する:
Tree[1, {Tree[2, {3, 4}, TreeElementShapeFunction -> {{2} -> None}]}]位置{1}における相対位置{2}は大域的な位置{1,2}を参照する:
Tree[1, {Tree[2, {3, 4}]}, TreeElementShapeFunction -> {{1, 2} -> None}]一般に,パターン patt は patt にマッチする大域的な位置{i,j,…}にある部分木に適用される:
Tree[1, {Tree[2, {3, 4}, TreeElementShapeFunction -> {pos_ /; Total[pos] === 2 -> None}]}]パターンのリスト{patt1,patt2,…}は pattiにマッチする相対位置{i,j,…}に適用される:
Tree[1, {Tree[2, {3, 4}, TreeElementShapeFunction -> {{1} -> None}]}]考えられる問題 (1)
Insetを使ってグラフィックスまたは画像を描画する:
Tree[1, {2, 3}, TreeElementShapeFunction -> All -> (Inset[[image], #, Center, 2 * #3]&), TreeElementSize -> All -> Large]TreeElementShapeはノードに使われるグラフィックスまたは画像を取る:
Tree[1, {2, 3}, TreeElementShape -> All -> [image], TreeElementSize -> All -> Large]関連するガイド
-
▪
- 木構造の可視化
テキスト
Wolfram Research (2022), TreeElementShapeFunction, Wolfram言語関数, https://reference.wolfram.com/language/ref/TreeElementShapeFunction.html.
CMS
Wolfram Language. 2022. "TreeElementShapeFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TreeElementShapeFunction.html.
APA
Wolfram Language. (2022). TreeElementShapeFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TreeElementShapeFunction.html
BibTeX
@misc{reference.wolfram_2026_treeelementshapefunction, author="Wolfram Research", title="{TreeElementShapeFunction}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/TreeElementShapeFunction.html}", note=[Accessed: 01-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_treeelementshapefunction, organization={Wolfram Research}, title={TreeElementShapeFunction}, year={2022}, url={https://reference.wolfram.com/language/ref/TreeElementShapeFunction.html}, note=[Accessed: 01-November-2026]}