TreeHeight - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

GraphTheory

 TreeHeight
 compute tree height

 Calling Sequence TreeHeight(T, r)

Parameters

 T - tree r - (optional) vertex

Description

 • TreeHeight returns the height of the tree T with the vertex r as root. In other words it returns the maximum distance of the vertices of T from r.
 • If the root r is omitted, TreeHeight returns the diameter of G.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $T≔\mathrm{Graph}\left(\left\{\left\{1,2\right\},\left\{2,3\right\},\left\{2,4\right\},\left\{4,5\right\}\right\}\right)$
 ${T}{≔}{\mathrm{Graph 1: an undirected graph with 5 vertices and 4 edge\left(s\right)}}$ (1)
 > $\mathrm{TreeHeight}\left(T,1\right)$
 ${3}$ (2)
 > $\mathrm{TreeHeight}\left(T,4\right)$
 ${2}$ (3)
 > $\mathrm{DrawGraph}\left(T\right)$

Compatibility

 • The GraphTheory[TreeHeight] command was updated in Maple 2021.

 See Also