GraphTheory[SpecialGraphs] - Maple Programming Help

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

GraphTheory[SpecialGraphs]

 CompleteBinaryTree
 construct complete binary tree
 CompleteKaryTree
 construct complete k-ary tree

 Calling Sequence CompleteBinaryTree(n) CompleteKaryTree(k,n)

Parameters

 k - positive integer indicating the degree of the root n - positive integer indicating the depth of the tree

Description

 • The CompleteBinaryTree(n) command constructs the complete binary tree with depth n.
 • The CompleteKaryTree(k,n) command constructs the complete k-ary tree with depth n for a given k.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{with}\left(\mathrm{SpecialGraphs}\right):$
 > $G≔\mathrm{CompleteBinaryTree}\left(2\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 7 vertices and 6 edge\left(s\right)}}$ (1)
 > $\mathrm{Edges}\left(G\right)$
 $\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{5}\right\}{,}\left\{{2}{,}{3}\right\}{,}\left\{{2}{,}{4}\right\}{,}\left\{{5}{,}{6}\right\}{,}\left\{{5}{,}{7}\right\}\right\}$ (2)
 > $\mathrm{DrawGraph}\left(G\right)$
 > $H≔\mathrm{CompleteKaryTree}\left(3,2\right)$
 ${H}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 13 vertices and 12 edge\left(s\right)}}$ (3)
 > $\mathrm{Edges}\left(H\right)$
 $\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{6}\right\}{,}\left\{{1}{,}{10}\right\}{,}\left\{{2}{,}{3}\right\}{,}\left\{{2}{,}{4}\right\}{,}\left\{{2}{,}{5}\right\}{,}\left\{{6}{,}{7}\right\}{,}\left\{{6}{,}{8}\right\}{,}\left\{{6}{,}{9}\right\}{,}\left\{{10}{,}{11}\right\}{,}\left\{{10}{,}{12}\right\}{,}\left\{{10}{,}{13}\right\}\right\}$ (4)
 > $\mathrm{DrawGraph}\left(H\right)$