treeplot

Draws a tree from its parent vector.

Category: Mathematics > Sparse Matrices

Syntax

treeplot(p)

Plots the tree whose parent vector is p.

treeplot(p, nodeSpec, edgeSpec)

Sets the style of the node markers and of the edges.

Description

Nodes are placed with treelayout: the root is at the top and each level of the tree is one row lower. The format is the same one returned by etree, so treeplot(etree(A)) shows the elimination tree of a matrix.

Input arguments

p
Parent vector: p(j) is the parent of node j, 0 for a root, with p(j) < j.
nodeSpec, edgeSpec
Optional line specifications, for example 'ko' and 'r-'.

Example

A binary tree

p = [0 1 1 2 2 3 3];
treeplot(p)

Notes

treeplot returns no coordinates; use treelayout to get the node positions.

See also

treelayout etreeplot etree gplot