layout.tree Function (GPL)

Syntax

layout.tree(<function>))

or

layout.tree(<algebra>, <function>)

<algebra>. Graph algebra, such as x*y. Refer to Brief Overview of GPL Algebra for an introduction to graph algebra. The algebra for network graphs is 1*1 because the position of elements is determined by the layout method and is not tied to a coordinate value (such as a value on a dimension). This algebra is implied and needs to be specified for network graphs only when faceting is needed.

<functions>. Valid functions. The from and to functions are required. The node function is optional for edges, allowing you to draw edges without a separate node data source. Also, you should use the root function when you want to ensure the correct node is used as the root node.

Description

Lays out graphic elements as a directed tree. The function is used for network graphs, which are visual representations of data that consist of nodes and relations between nodes (edges). The tree layout should be used only for directed graphs with a primary root node (compare with layout.dag). This layout produces tree-like structures from parent nodes down to leaf nodes, so the layout works well with hierarchical data. If the root node is not specified by the root function, the function picks the most likely node as the root.

Note: Network graphs that display nodes and edges require two data sources, one for the unique nodes and one for the edges. If the edge data source includes weights and the weight variable is indicated in the SOURCE statement, the weights influence the length of edges in the graph, with higher weights having shorter edges.

Examples

Figure 1. Example: Creating a tree
ELEMENT: edge(position(layout.tree(node(id), from(fromVar), to(toVar), root("A"))))
ELEMENT: point(position(layout.tree(node(id), from(fromVar), to(toVar), root("A"))), label(id))