SpanningForest - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


GraphTheory

  

SpanningTree

  

construct spanning tree

  

SpanningForest

  

construct spanning forest

 

Calling Sequence

Parameters

Description

Definitions

Examples

Compatibility

Calling Sequence

SpanningTree(G)

SpanningTree(G, r)

SpanningForest(G)

Parameters

G

-

undirected graph

r

-

vertex of the graph

Description

• 

SpanningTree(G) returns a spanning tree of a connected graph G.

• 

SpanningTree(G, r) returns a spanning tree of the connected component of G which contains vertex r.

• 

SpanningForest(G) returns a spanning forest of the graph G.

• 

By default, edge weights on G are ignored. To compute a minimal-weight spanning tree for a weighted graph, use MinimalSpanningTree.

Definitions

• 

A spanning tree for a graph G is a subgraph of G which contains all the vertices of G and is a tree.

• 

A spanning forest for a graph G is a subgraph of G which contains all the vertices of G and is a forest.

Examples

withGraphTheory:

withSpecialGraphs:

PPetersenGraph

PGraph 1: an undirected graph with 10 vertices and 15 edge(s)

(1)

T1SpanningTreeP

T1Graph 2: an undirected graph with 10 vertices and 9 edge(s)

(2)

IsTreeT1

true

(3)

DrawGraphP

DrawGraphT1

T2SpanningTreeP,5:

EdgesT1

1,2,1,5,1,6,2,3,2,9,4,5,5,8,6,7,6,10

(4)

EdgesT2

1,2,1,5,1,6,3,4,4,5,4,10,5,8,7,8,8,9

(5)

GGraphUnionCycleGraph1,2,3,CycleGraph4,5,6

GGraph 3: an undirected graph with 6 vertices and 6 edge(s)

(6)

IsConnectedG

false

(7)

SpanningTreeG,1

Graph 4: an undirected graph with 6 vertices and 2 edge(s)

(8)

SpanningForestG

Graph 5: an undirected graph with 6 vertices and 4 edge(s)

(9)

Compatibility

• 

The GraphTheory[SpanningForest] command was introduced in Maple 2021.

• 

For more information on Maple 2021 changes, see Updates in Maple 2021.

See Also

IsTree

MinimalSpanningTree

NumberOfSpanningTrees

TreeHeight