 GraphTheory - Maple Programming Help

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

GraphTheory

 SpanningTree

 Calling Sequence SpanningTree(G) SpanningTree(G, r)

Parameters

 G - undirected graph r - vertex of the graph

Description

 • The SpanningTree command returns a spanning tree of G, a subgraph that contains all the vertices and is a tree. Edge weights are ignored.
 • To compute a minimal-weight spanning tree for a weighted graph, use MinimalSpanningTree.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{with}\left(\mathrm{SpecialGraphs}\right):$
 > $P≔\mathrm{PetersenGraph}\left(\right)$
 ${P}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 10 vertices and 15 edge\left(s\right)}}$ (1)
 > $\mathrm{T1}≔\mathrm{SpanningTree}\left(P\right)$
 ${\mathrm{T1}}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 10 vertices and 9 edge\left(s\right)}}$ (2)
 > $\mathrm{IsTree}\left(\mathrm{T1}\right)$
 ${\mathrm{true}}$ (3)
 > $\mathrm{DrawGraph}\left(P\right)$ > $\mathrm{DrawGraph}\left(\mathrm{T1}\right)$ > $\mathrm{T2}≔\mathrm{SpanningTree}\left(P,5\right):$
 > $\mathrm{Edges}\left(\mathrm{T1}\right)$
 $\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{5}\right\}{,}\left\{{1}{,}{6}\right\}{,}\left\{{2}{,}{3}\right\}{,}\left\{{2}{,}{9}\right\}{,}\left\{{4}{,}{5}\right\}{,}\left\{{5}{,}{8}\right\}{,}\left\{{6}{,}{7}\right\}{,}\left\{{6}{,}{10}\right\}\right\}$ (4)
 > $\mathrm{Edges}\left(\mathrm{T2}\right)$
 $\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{5}\right\}{,}\left\{{1}{,}{6}\right\}{,}\left\{{3}{,}{4}\right\}{,}\left\{{4}{,}{5}\right\}{,}\left\{{4}{,}{10}\right\}{,}\left\{{5}{,}{8}\right\}{,}\left\{{7}{,}{8}\right\}{,}\left\{{8}{,}{9}\right\}\right\}$ (5)