Skip to main content

is_tree

Function is_tree 

Source
pub fn is_tree(graph: &Graph) -> bool
Expand description

Returns whether graph is a tree: a forest with at most one root node.

The edges of a tree point away from its root. For a tree whose edges point toward the root, check the transposed graph, which is BiAdjacentGraph::of(&graph).transposed(). For the undirected reading, see is_undirected_tree. The empty graph is a tree.

Time: O(node_count + edge_count). Memory: 8 x node_count bytes while it runs.