Skip to main content

is_forest

Function is_forest 

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

Returns whether graph is a forest: a DAG in which every node has in-degree at most 1, so that the edges point away from the root nodes.

The empty graph is a forest. For the undirected reading, see is_undirected_forest.

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