This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

AcyclicGraphQ

AcyclicGraphQ[g]
yields True if the graph g is an acyclic graph and False otherwise.
  • A graph has a cycle if there is a path that starts and ends in the same vertex.
Test whether a graph is acyclic:
A cycle graph is not acyclic:
Test whether a graph is acyclic:
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]=
 
A cycle graph is not acyclic:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Test undirected or directed graphs:
AcyclicGraphQ gives False for anything that is not an acyclic graph:
Test large graphs:
New in 8