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.
withGraphTheory:
F≔Graph1,2,3,4,5,6,1,2,2,3,5,6
F≔Graph 1: an undirected graph with 6 vertices and 3 edge(s)
IsForestF
true
C≔ConnectedComponentsF
C≔1,2,3,4,5,6
seqIsTreeInducedSubgraphF,i,i=C
true,true,true
NumberOfVerticesF−NumberOfEdgesF−nopsConnectedComponentsF
0
See Also
ConnectedComponents
InducedSubgraph
IsTree
Download Help Document