TreeGraphQ

TreeGraphQ[g]
yields True if the graph g is a tree and False otherwise.

DetailsDetails

  • A tree is a connected graph with no cycles.

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Test whether a graph is a tree:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
In[5]:=
Click for copyable input
Out[5]=
In[6]:=
Click for copyable input
Out[6]=

A graph with cycles is not a tree:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Introduced in 2010
(8.0)
Translate this page: