Skip to content

HypercubeGraph ​

The nn-dimensional hypercube graph — 2n2^n vertices (bit strings), edges between strings differing in one bit.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageHypercubeGraph✓
HypercubeGraph(n)vertex ii (1-based) labels the bit pattern i−1i - 1; edges join patterns at Hamming distance 1.
SageMathenumeratio_graph(graphs.CubeGraph(n))
Typed signatures
TypePackageApplies
(integer) -> valuecombinatoricsalways

Domain: Collections

Examples

Basic #

Q3Q_3: 8 vertices, 3⋅22=123 \cdot 2^2 = 12 edges

live ↗
In[VertexCount(HypercubeGraph(3)),EdgeCount(HypercubeGraph(3))]\bigl\lbrack\mathrm{VertexCount}(\mathrm{HypercubeGraph}(3)), \mathrm{EdgeCount}(\mathrm{HypercubeGraph}(3))\bigr\rbrackOut[8,12]\bigl\lbrack8, 12\bigr\rbrack
Scope #

The cube graph: 88 vertices, joined when their binary labels differ in one bit

live ↗
InHypercubeGraph(3)\mathrm{HypercubeGraph}(3)OutGraph([1,2,3,4,5,6,7,8],[UndirectedEdge(1,2),UndirectedEdge(1,3),UndirectedEdge(1,5),UndirectedEdge(2,4),UndirectedEdge(2,6),UndirectedEdge(3,4),UndirectedEdge(3,7),UndirectedEdge(4,8),UndirectedEdge(5,6),UndirectedEdge(5,7),UndirectedEdge(6,8),UndirectedEdge(7,8)])\mathrm{Graph}(\bigl\lbrack1, 2, 3, 4, 5, 6, 7, 8\bigr\rbrack, \bigl\lbrack\mathrm{UndirectedEdge}(1, 2), \mathrm{UndirectedEdge}(1, 3), \mathrm{UndirectedEdge}(1, 5), \mathrm{UndirectedEdge}(2, 4), \mathrm{UndirectedEdge}(2, 6), \mathrm{UndirectedEdge}(3, 4), \mathrm{UndirectedEdge}(3, 7), \mathrm{UndirectedEdge}(4, 8), \mathrm{UndirectedEdge}(5, 6), \mathrm{UndirectedEdge}(5, 7), \mathrm{UndirectedEdge}(6, 8), \mathrm{UndirectedEdge}(7, 8)\bigr\rbrack)
Applications #

Every vertex is at distance 33 from its antipode, so all eccentricities are equal

live ↗
InMap(_1⁡↦VertexEccentricity(HypercubeGraph(3),_1⁡),VertexList(HypercubeGraph(3)))\mathrm{Map}(\operatorname{\_1}↦\mathrm{VertexEccentricity}(\mathrm{HypercubeGraph}(3), \operatorname{\_1}), \mathrm{VertexList}(\mathrm{HypercubeGraph}(3)))Out[3,3,3,3,3,3,3,3]\bigl\lbrack3, 3, 3, 3, 3, 3, 3, 3\bigr\rbrack
Properties #

Split by parity of the bit count

live ↗
InIsBipartiteGraph(HypercubeGraph(3))\mathrm{IsBipartiteGraph}(\mathrm{HypercubeGraph}(3))OutTrue\mathrm{True}

The 22-cube is the 44-cycle

live ↗
InHypercubeGraph(2)\mathrm{HypercubeGraph}(2)OutGraph([1,2,3,4],[UndirectedEdge(1,2),UndirectedEdge(1,3),UndirectedEdge(2,4),UndirectedEdge(3,4)])\mathrm{Graph}(\bigl\lbrack1, 2, 3, 4\bigr\rbrack, \bigl\lbrack\mathrm{UndirectedEdge}(1, 2), \mathrm{UndirectedEdge}(1, 3), \mathrm{UndirectedEdge}(2, 4), \mathrm{UndirectedEdge}(3, 4)\bigr\rbrack)
live ↗
InSort(Eigenvalues(AdjacencyMatrix(HypercubeGraph(4))))\mathrm{Sort}(\mathrm{Eigenvalues}(\mathrm{AdjacencyMatrix}(\mathrm{HypercubeGraph}(4))))Out[−4,−2,−2,−2,−2,0,0,0,0,0,0,2,2,2,2,4]\bigl\lbrack-4, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 4\bigr\rbrack
About
Examples6
Checked againstWolfram Language 6 agreeSageMath 2 agree2 differ
CrosswalkWolfram LanguageSageMath

Implementation

mappedsagepackages/oracle/src/mappings.ts

See also: GridGraph, CompleteGraph