GraphTheory
SpanningTree
construct spanning tree
SpanningForest
construct spanning forest
Calling Sequence
Parameters
Description
Definitions
Examples
Compatibility
SpanningTree(G)
SpanningTree(G, r)
SpanningForest(G)
G
-
undirected graph
r
vertex of the graph
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.
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.
with⁡GraphTheory:
with⁡SpecialGraphs:
P ≔ PetersenGraph⁡
P≔Graph 1: an undirected graph with 10 vertices and 15 edge(s)
T1 ≔ SpanningTree⁡P
T1≔Graph 2: an undirected graph with 10 vertices and 9 edge(s)
IsTree⁡T1
true
DrawGraph⁡P
DrawGraph⁡T1
T2 ≔ SpanningTree⁡P,5:
Edges⁡T1
1,2,1,5,1,6,2,3,2,9,4,5,5,8,6,7,6,10
Edges⁡T2
1,2,1,5,1,6,3,4,4,5,4,10,5,8,7,8,8,9
G ≔ GraphUnion⁡CycleGraph⁡1,2,3,CycleGraph⁡4,5,6
G≔Graph 3: an undirected graph with 6 vertices and 6 edge(s)
IsConnected⁡G
false
SpanningTree⁡G,1
Graph 4: an undirected graph with 6 vertices and 2 edge(s)
SpanningForest⁡G
Graph 5: an undirected graph with 6 vertices and 4 edge(s)
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
Download Help Document
What kind of issue would you like to report? (Optional)