IsTree - Maple Help

GraphTheory

 IsTree
 test if graph is a tree

 Calling Sequence IsTree(G)

Parameters

 G - an undirected graph

Description

 • An undirected graph G on $n$ vertices is a tree if it is connected and has exactly $n-1$ edges.
 • The IsTree command returns true if the input graph is a tree, and false otherwise.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $T≔\mathrm{Graph}\left(\left\{\left\{1,2\right\},\left\{1,3\right\}\right\}\right)$
 ${T}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 3 vertices and 2 edge\left(s\right)}}$ (1)
 > $\mathrm{IsTree}\left(T\right)$
 ${\mathrm{true}}$ (2)
 > $C≔\mathrm{Graph}\left(\left\{\left\{1,2\right\},\left\{1,3\right\},\left\{2,3\right\}\right\}\right)$
 ${C}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 3 vertices and 3 edge\left(s\right)}}$ (3)
 > $\mathrm{IsTree}\left(C\right)$
 ${\mathrm{false}}$ (4)