GraphTheory
TreeHeight
compute tree height
Calling Sequence
Parameters
Description
Examples
Compatibility
TreeHeight(T, r)
T
-
tree
r
(optional) vertex
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.
with⁡GraphTheory:
T≔Graph⁡1,2,2,3,2,4,4,5
T≔Graph 1: an undirected graph with 5 vertices and 4 edge(s)
TreeHeight⁡T,1
3
TreeHeight⁡T,4
2
DrawGraph⁡T
The GraphTheory[TreeHeight] command was updated in Maple 2021.
See Also
Diameter
IsTree
SpanningTree
Download Help Document