WLJS LogoWLJS Notebook

AcyclicGraphQ

AcyclicGraphQ[g] yields True if graph g has no cycles and False otherwise.

Examples

Test for cycles:

AcyclicGraphQ[TreeGraph[{1 -> 2, 1 -> 3}]]
(* True *)

AcyclicGraphQ[CycleGraph[5]]
(* False *)

Path is acyclic:

AcyclicGraphQ[PathGraph[Range[5]]]
(* True *)

Please visit the official Wolfram Language Reference for more details.

On this page