Skip to contents

Returns TRUE if tree is a spanning tree of graph: a connected acyclic subgraph that spans all vertices and uses only edges present in graph.

Usage

is_spanning_tree_of(tree, graph)

Arguments

tree

An adj object to test.

graph

An adj object representing a connected undirected graph.

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_of(t, g)
#> [1] TRUE