GraphTheory[SpecialGraphs] - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

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

GraphTheory[SpecialGraphs]

 HypercubeGraph
 construct hypercube graph

 Calling Sequence HypercubeGraph(n)

Parameters

 n - positive integer

Description

 • The HypercubeGraph(n) command creates the hypercube graph of dimension n on ${2}^{n}$ vertices. The vertex labels are strings of binary vectors of length n, and two vertices are joined by an edge if and only if they differ in exactly one coordinate. Note, the hypercube graph for n=2 is a square and for n=3 it is a cube.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{with}\left(\mathrm{SpecialGraphs}\right):$
 > $H≔\mathrm{HypercubeGraph}\left(3\right)$
 ${H}{:=}{\mathrm{Graph 1: an undirected unweighted graph with 8 vertices and 12 edge\left(s\right)}}$ (1)
 > $\mathrm{Vertices}\left(H\right)$
 $\left[{"000"}{,}{"001"}{,}{"010"}{,}{"011"}{,}{"100"}{,}{"101"}{,}{"110"}{,}{"111"}\right]$ (2)
 > $\mathrm{Neighbors}\left(H,"010"\right)$
 $\left[{"000"}{,}{"011"}{,}{"110"}\right]$ (3)
 > $\mathrm{DrawGraph}\left(H\right)$

Hypercube graphs have Hamiltonian cycles.

 > $\mathrm{IsHamiltonian}\left(H,'C'\right)$
 ${\mathrm{true}}$ (4)
 > $C$
 $\left[{"000"}{,}{"100"}{,}{"110"}{,}{"010"}{,}{"011"}{,}{"111"}{,}{"101"}{,}{"001"}{,}{"000"}\right]$ (5)
 > $\mathrm{HighlightTrail}\left(H,C,\mathrm{red}\right)$
 > $\mathrm{DrawGraph}\left(H\right)$

 See Also

## Was this information helpful?

 Please add your Comment (Optional) E-mail Address (Optional) What is ? This question helps us to combat spam