networkx.algorithms.tree.recognition.is_tree¶

is_tree
(G)[source]¶ Returns True if
G
is a tree.A tree is a connected graph with no undirected cycles.
For directed graphs,
G
is a tree if the underlying graph is a tree. The underlying graph is obtained by treating each directed edge as a single undirected edge in a multigraph.Parameters: G (graph) – The graph to test. Returns: b – A boolean that is True if G
is a tree.Return type: bool Notes
In another convention, a directed tree is known as a polytree and then tree corresponds to an arborescence.
See also