GraphTheory
IsForest
test if graph is a forest
Calling Sequence
Parameters
Description
Examples
IsForest(G)
G
-
graph
The IsForest command returns true if the input graph is a forest or false otherwise. A forest is a graph whose connected components are all trees.
with⁡GraphTheory:
F≔Graph⁡1,2,3,4,5,6,1,2,2,3,5,6
F≔Graph 1: an undirected graph with 6 vertices and 3 edge(s)
IsForest⁡F
true
C≔ConnectedComponents⁡F
C≔1,2,3,4,5,6
seq⁡IsTree⁡InducedSubgraph⁡F,i,i=C
true,true,true
NumberOfVertices⁡F−NumberOfEdges⁡F−nops⁡ConnectedComponents⁡F
0
See Also
ConnectedComponents
InducedSubgraph
IsTree
Download Help Document