TreeGraphQ
TreeGraphQ[g] yields True if graph g is a tree (connected and acyclic) and False otherwise.
Examples
Test for tree:
TreeGraphQ[TreeGraph[{1 -> 2, 1 -> 3, 2 -> 4}]]
(* True *)
TreeGraphQ[CycleGraph[4]]
(* False - has cycle *)
TreeGraphQ[Graph[{1 <-> 2, 3 <-> 4}]]
(* False - not connected *)Please visit the official Wolfram Language Reference for more details.