GraphTheory - Maple Programming Help

Home : Support : Online Help : Mathematics : Discrete Mathematics : Graph Theory : GraphTheory Package : GraphTheory/TreeHeight

GraphTheory

 TreeHeight

 Calling Sequence TreeHeight(T, r)

Parameters

 T - a tree r - a 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.

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 unweighted 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)$