TreeOutline

TreeOutline[tree]

gives an outline of the data in tree as a nested OpenerView.

TreeOutline[tree,pos]

gives an outline of the data in tree initially opened to the subtree at the position specified by pos.

TreeOutline[tree,{pos1,pos2,}]

opens the outline to several positions.

Details

  • TreeOutline gives an outline view of a Tree object where each subtree can be interactively opened and closed to display and hide its children. The outline is initially opened to the subtrees at the specified positions, with all other subtrees closed.
  • TreeOutline[Tree[data,{child1,child2,}]] displays as OpenerView[{data,openers},False], where openers is a column of the TreeOutline[childi].
  • TreeOutline[tree,pos] uses OpenerView[,True] if tree has a proper subtree at position pos and OpenerView[,False] otherwise. »
  • TreeOutline[tree,{i,j,}] gives an outline opened to the position {i,j,}.
  • TreeOutline can use the position specifications returned by TreePosition as well as extended forms as used in functions such as TreeExtract and TreeInsert.
  • An individual position specification pos can be given as {part1,part2,}, where part specifications parti include:
  • ithe i^(th) child
    -ithe i^(th) child from the end
    {i1,i2,}the list of children with part numbers i1, i2,
    patternthe children with part number matching patt
    "key"the child whose key is "key"
    Key[k]the child with an arbitrary key k
  • Patterns can include constructs such as __, representing position specifications of variable lengths.
  • In TreeOutline[tree,{p1,p2,}], {p1,p2,} is interpreted as a list of individual position specifications if all the pi are lists. Otherwise, {p1,p2,} will be taken to be an individual position specification.
  • TreeOutline works on trees containing an Association of subtrees, using the same specification for keys as in Part. »
  • TreeOutline[tree] uses certain options specified in tree.
  • Options affecting individual tree elements or nodes include:
  • TreeElementLabellabels for subtree elements
    TreeElementLabelStylestyles for subtree element labels
    TreeElementLabelFunctiongenerate labels for subtree elements
  • Options affecting individual edges include:
  • ParentEdgeLabellabels for edges
    ParentEdgeLabelStylestyles for edge labels
    ParentEdgeLabelFunctiongenerate labels for edges
  • Options affecting elision of nodes include:
  • MaxDisplayedChildrenmaximum number of children to display

Examples

open allclose all

Basic Examples  (2)

Get an outline of a tree:

Open the first level of the tree:

Open all levels of the tree:

Open to a list of positions:

Scope  (4)

Associations  (4)

Open an outline of a tree containing an association by key:

If the key is a string, the Key wrapper is optional:

Open an outline of a tree containing an association by key:

Open an outline of a tree containing an association by position:

Open a nested subtree of a tree containing an association:

Open several nested subtrees of a tree containing an association:

Options  (5)

Styling Individual Tree Elements  (2)

Specify the label for the tree element:

Specify labels and label styles for subtrees by position:

Styling Individual Parent Edges  (2)

Specify the label for the parent edge:

Specify labels and label styles for parent edges by position:

Elision  (1)

Display all children of the root node:

Display five children:

Applications  (6)

Import XML as symbolic XML:

Create an outline from the hierarchy of tags, attributes and elements:

Import JSON as symbolic JSON:

Create an outline from the hierarchy of names and values:

Create an outline from a tree of life:

Create an outline from a tree of descendants:

Create an outline from the hierarchy of subdirectories and files in a directory:

Create an outline from the hierarchy of properties and text:

Properties & Relations  (7)

Leaves do not have openers:

TreeOutline[tree,pos] opens all subtrees that contain a proper subtree at positions specified by pos:

If the positions specified by pos do not exist, then the outline is left closed:

A pattern p that is not explicitly a list matches against the immediate children:

In that case, p is equivalent to {p}:

TreeOutline can use the lists of positions returned by TreePosition:

TreeOutline[tree,i] is equivalent to TreeOutline[tree,j] if the i^(th) and j^(th) children both exist:

This is similar if both children do not exist:

TreeOutline[tree] is equivalent to TreeOutline[tree,{}]:

Possible Issues  (2)

Opening to the root does not open any subtrees:

To open the root subtree, specify a position at level 1:

Negative integers are not supported in patterns:

Negative integers can be used in explicit positions:

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

Text

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

CMS

Wolfram Language. 2021. "TreeOutline." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/TreeOutline.html.

APA

Wolfram Language. (2021). TreeOutline. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TreeOutline.html

BibTeX

@misc{reference.wolfram_2023_treeoutline, author="Wolfram Research", title="{TreeOutline}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/TreeOutline.html}", note=[Accessed: 01-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_treeoutline, organization={Wolfram Research}, title={TreeOutline}, year={2022}, url={https://reference.wolfram.com/language/ref/TreeOutline.html}, note=[Accessed: 01-March-2024 ]}