Visualize a tree: Difference between revisions
Content deleted Content added
m →Opener view: drop heading level |
m →Tree graph: ditto; remove empty lines |
||
Line 380: | Line 380: | ||
== Tree graph == |
=== Tree graph === |
||
Make a tree graph. In Mathematica, '''\[DirectedEdge]''' will appear as an arrow. |
Make a tree graph. In Mathematica, '''\[DirectedEdge]''' will appear as an arrow. |
||
⚫ | |||
<lang Mathematica> |
|||
⚫ | |||
3 \[DirectedEdge] 6, 4 \[DirectedEdge] 7}; |
3 \[DirectedEdge] 6, 4 \[DirectedEdge] 7}; |
||
t = TreeGraph[edges, GraphStyle -> "VintageDiagram"]</lang> |
|||
</lang> |
|||
[[File:Tree.jpg]] |
[[File:Tree.jpg]] |
||
Line 395: | Line 391: | ||
Show the syntactical structure of the above code. '''Defer''' is added to impede '''TreeGraph''' from becoming a graphical object. |
Show the syntactical structure of the above code. '''Defer''' is added to impede '''TreeGraph''' from becoming a graphical object. |
||
<lang Mathematica> |
<lang Mathematica>TreeForm[Defer@ |
||
TreeForm[Defer@ |
|||
TreeGraph[{1 \[DirectedEdge] 2, 1 \[DirectedEdge] 3, 2 \[DirectedEdge] 4, 2 \[DirectedEdge] 5, |
TreeGraph[{1 \[DirectedEdge] 2, 1 \[DirectedEdge] 3, 2 \[DirectedEdge] 4, 2 \[DirectedEdge] 5, |
||
3 \[DirectedEdge] 6, 4 \[DirectedEdge] 7}, VertexLabels -> "Name"]] |
3 \[DirectedEdge] 6, 4 \[DirectedEdge] 7}, VertexLabels -> "Name"]]</lang> |
||
</lang> |
|||
[[File:syntax.jpg]] |
[[File:syntax.jpg]] |
||
Line 408: | Line 402: | ||
Here's another way to display a tree. The triangles open/close when clicked on. |
Here's another way to display a tree. The triangles open/close when clicked on. |
||
⚫ | |||
<lang Mathematica> |
|||
⚫ | |||
OpenerView[{3, OpenerView[{TraditionalForm[Cos[x]], Plot[Cos[x], {x, 0, 10}, ImageSize -> 150]}, |
OpenerView[{3, OpenerView[{TraditionalForm[Cos[x]], Plot[Cos[x], {x, 0, 10}, ImageSize -> 150]}, |
||
True]}, True]}}, True] |
True]}, True]}}, True]</lang> |
||
</lang> |
|||
[[File:opener.jpg]] |
[[File:opener.jpg]] |