GraphTheory - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Discrete Mathematics : Graph Theory : GraphTheory Package : GraphTheory/IsForest

GraphTheory

  

IsForest

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

IsForest(G)

Parameters

G

-

graph

Description

• 

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.

Examples

with(GraphTheory):

F := Graph([1,2,3,4,5,6],{{1,2},{2,3},{5,6}});

FGraph 1: an undirected unweighted graph with 6 vertices and 3 edge(s)

(1)

IsForest(F);

true

(2)

C := ConnectedComponents(F);

C1,2,3,4,5,6

(3)

seq(IsTree(InducedSubgraph(F, i)), i=C);

true,true,true

(4)

NumberOfVertices(F) - NumberOfEdges(F) - nops(ConnectedComponents(F));

0

(5)

See Also

ConnectedComponents

InducedSubgraph

IsTree