Skip to contents

Returns TRUE if tree is a spanning tree: a connected acyclic graph with exactly n-1 edges. To additionally check that tree uses only edges from a reference graph, see is_spanning_tree_of().

Usage

is_spanning_tree(tree)

Arguments

tree

An adj object to test.

Value

A logical scalar.

Examples

g <- adj::adj(list(c(2L, 3L), c(1L, 3L), c(1L, 2L)))
t <- minimum_spanning_tree(g)
is_spanning_tree(t)
#> [1] TRUE