GraphTheory
IsTree
test if graph is a tree
Calling Sequence
Parameters
Description
Examples
IsTree(G)
G
-
an undirected graph
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.
with⁡GraphTheory:
T ≔ Graph⁡1,2,1,3
T≔Graph 1: an undirected graph with 3 vertices and 2 edge(s)
IsTree⁡T
true
C ≔ Graph⁡1,2,2,3,3,1
C≔Graph 2: an undirected graph with 3 vertices and 3 edge(s)
IsTree⁡C
false
See Also
IsAcyclic
IsConnected
IsForest
NumberOfEdges
NumberOfVertices
RandomGraphs[RandomTree]
SpanningTree
SpecialGraphs[CompleteBinaryTree]
TreeHeight
Download Help Document
What kind of issue would you like to report? (Optional)