First 5 minutes of hell
A hypercube is a graph, where each vertex is an -bit string. Two vertices are connected by edge, if they differ by exactly one bit.
- - vertices 0 and 1, connected by the edge
- - vertices 00, 01, 10, 11, forms a square
- - a cube etc.
Building is by doing a Cartesian product of two and . It has a recursive structure. is composed of two , where matching vertices are connected.
Hamming distance counts how many bit positions differ between two vertices. The graph distance in equals the Hamming distance. The distance from to is exactly the number of bit switches.
- diameter is : the furthest I can go is (= flipping all bits)
- number of vertices at distance from any given vertex is equal to (just pick, which bits to flip)
- average distance is (by the symmetry of the Pascal’s triangle)
Properties:
- as there are binary strings of lenght
- (each of vertices has edges + divide by 2, because each edge is counted twice)
- is -regular, each vertex has a degree of
- it is a dense topology (since degree grows with )
- this is the price, which I have to pay for a optimal logartihmic diameter (each node needs more connections as the network grows)
- it has optimal connectivity:
- it has a largest possible bisection width: (ideal for Divide-and-Conquer algos)
- for a given pair of vertices, there exists automorphism
- one automorphism per permutation of the vertex’s binary string
Bipartiteness
- the is bipartite balanced (= same number of both colors)
- vertices with even number of 1-bits ⇒ color A
- vertices with odd number of 1-bits ⇒ color B
- if we switch one bit, we move exactly one edge and we change parity
- each color has exactly vertices (balanced)
Routing (how to get from to ):
- there exist shortest paths between two vertices in distance (each shortest path is a permuation of all bits in which and differ)
- e-cube routing is used to find the shortest paths
- walks the bits from LSB (= least significant bit) to MSB
- if the current vertex disagrees with the destination, flip that bit (by flipping the disagreeing bit, we actually move one edge closer to the destination)
- important is that the sequence is deterministic and prevents deadlocks (messages cannot take arbitrary shortest path - it could lead into cyclic deadlock)
Symmetry of
- is vertex-symmetric with different automorphisms
- if we fix one vertex, there are automorphisms
Drawbacks:
- it is dense topology, so in real-life, only smaller dimensions make sense, e.g. and each node has to have a router with 7 connections
- scalability is limited only to nodes
Today’s importance
- used in supercomputers only for smaller dimensions
- thanks to it’s density, it is able to simulate almost every other topology
- it serves as a “PRAM” model for distributed computing, if serves as a test for feasibility of parallel solutions (if the problem does not have a good solution on the hypercube model, it may be hard to be parallelized at all)
Binary hypercube
Topic: the binary hypercube , its formal definition and key graph-theoretic parameters, structural properties (recursivity, vertex symmetry, bisection, bipartiteness, hamiltonicity, vertex-disjoint paths), and standard e-cube shortest-path routing.
Definition of the binary hypercube
The n-dimensional binary hypercube is the graph with: where denotes the -bit string obtained from by flipping bit . So vertices are -bit binary addresses, and two vertices are adjacent iff they differ in exactly one bit.
Key parameters: The figure of appears as two copies of (addresses and ) joined by a perfect matching of “dimension-3” edges.
Hamming distance
The Hamming distance is the number of bit positions in which the two -bit addresses and differ. It coincides with the graph distance: This identification underlies essentially all properties of .
Properties I - recursivity, Boolean structure, connectivity, bisection, bipartiteness, hamiltonicity
$Q_n$ is regular with logarithmic diameter $\Rightarrow$ dense topology. Since grows with , is dense (not sparse). Nevertheless its is the optimal logarithmic diameter predicted by Theorem 15.
Hierarchically recursive via Cartesian product: for any . Subcubes are addressed by strings with (where is the “don’t care” symbol). These correspond exactly to terms in Boolean algebra (minterms/maxterms when all bits are fixed, more general terms with ).
Optimal connectivity: The minimum number of vertices (or edges) whose removal disconnects equals its regular degree.
Largest possible bisection width: This is the upper bound for any graph on vertices, and makes ideal for binary divide-and-conquer algorithms. Cutting into two ‘s along any single dimension removes exactly edges, because each vertex on one side has exactly one image on the other side.
Balanced bipartite graph. Parity (the XOR of all bits, or equivalently the count of 1-bits mod 2) provides a valid 2-coloring: every edge flips exactly one bit and therefore flips the parity, so adjacent vertices have opposite colors. Both color classes have size .
Hamiltonian graph. Any -bit Gray code is a Hamiltonian circuit in - e.g., the binary reflected Gray code. In fact has many Hamiltonian cycles.
Properties II - vertex symmetry (Theorem 16)
Theorem 16: is vertex-symmetric, with different automorphisms.
Proof sketch. Vertex symmetry follows from Theorem 7(1), since is trivially vertex-symmetric and . The full count comes from composing two independent families:
-
Dimension permutations. For a permutation , This preserves Hamming distance (just relabels bit positions), hence adjacency. There are such permutations. -
Translations. For any , XOR with a fixed vector preserves Hamming differences (hence adjacency) and is trivially a bijection. There are such translations.
Composing these yields automorphisms in total.
The hypercube has much more symmetry than is needed by the vertex-symmetry definition.
Properties III - automorphisms between a given pair (Corollary 17)
Corollary 17: for any , there exist automorphisms such that .
Constructive proof. Pick any permutation of the dimensions (out of choices). Compose with a translation that sends to : Substituting : Since was arbitrary out of choices, there are such automorphisms.
Properties IV - recursivity and e-cube routing
Hierarchical recursivity visually: can be drawn as a each of whose vertices is itself a .
The hypercube is a highly cyclic graph: smallest cycles are 4-cycles, then 6-cycles, 8-cycles, and so on - always even-length (because is bipartite). This cyclicity provides routing redundancy.
The standard shortest-path routing in is called e-cube routing (dimension-ordered routing):
- Bits in the -bit addresses are tested always
from the right to the left(from LSB to MSB) - At each step, if the current bit differs between the current node and the destination, traverse the edge in that dimension; otherwise skip to the next bit
Why bit-ordered routing? A routing scheme must be deadlock-free. Because is highly cyclic, routing must follow a fixed dimension order to break cycles; testing bits always in the same order (LSB to MSB, or equivalently high-to-low) prevents deadlock.
Pseudocode for e-cube routing from source to destination :
current = s
for i = 0, 1, ..., n-1:
if bit_i(current) ≠ bit_i(d):
current = neg_i(current) // traverse dimension-i edge
return current == d
The path length equals , i.e., e-cube is shortest-path. Total algorithm steps: at most .
Optimal algorithms exist for all collective communication operations on - broadcast, gather, scatter, all-to-all, reduction, prefix sum, etc. - all hitting the theoretical lower bounds.
Properties V - distance distribution (Lemmas 18, 19)
Lemma 18: the number of vertices at distance from a given vertex in is . Consequently the average distance in is approximately : Proof. The number of -bit strings differing from a given vertex in exactly bits equals the number of ways to choose bit positions out of , which is . Pascal’s triangle is symmetric, , so the distance distribution is symmetric around .
Lemma 19: between two vertices at distance in , there are exactly distinct shortest paths.
Proof. A shortest path from to with must invert exactly the bits in which they differ - once each. The order in which these bits are inverted is an arbitrary permutation of those coordinates. Hence distinct shortest paths.
Properties VI - vertex-disjoint paths (Lemma 20)
Lemma 20: if with , then there exist vertex-disjoint paths among which:
- are of length
- are of length
Construction of the short paths. Build the first path by inverting the differing bits in some fixed order. For the remaining short paths, use different rotations of the initial permutation. The key invariant: on any two different paths, the first inversions must use a different subset of dimensions out of the differing coordinates - guaranteed by rotation.
Construction of the longer paths. Pick any bit in which and do not differ. Start by inverting bit (step aside into a disjoint sub-cube), traverse the differing bits in some order (length inside that sub-cube), then invert bit again (step back). Total length . There are such “side trip” dimensions, giving longer disjoint paths.
Practical significance: has parallel routes between any pair of vertices. A large packet can be split into chunks and sent in parallel, achieving up to -fold throughput over a single-route transmission.
Drawbacks and today’s importance
Two main drawbacks of the hypercube:
Logarithmic degree: grows with system size, so a single router component can only support a fixed maximum dimension. Arbitrarily large hypercubes cannot be built from a single router type.Scalability only by powers of two: sizes .
Consequence: real supercomputers use only hypercubes of lower dimensions. Example: Salomon at IT4I (SGI) uses (routers with 7 ports), organized into “M-cells” that are 7-dimensional hypercubes.
Nevertheless, the hypercube remains the testbed for feasibility of parallel solutions in the distributed-memory model - analogous to PRAM in the shared-memory world:
If you are not able to find a good solution on a hypercube topology, it is probably difficult to solve in general in a distributed manner.
Because of its density, simulates efficiently almost any other topology.
Summary table (key formulas)
- (-regular)
- (logarithmic in , optimal for dense topology with this degree)
- (optimal connectivity)
- (maximum possible)
- Bipartite, balanced; 2-coloring = parity
- Hamiltonian (any -bit Gray code is a Hamiltonian cycle)
- Vertex-symmetric with automorphisms; automorphisms per ordered vertex pair
- Number of vertices at distance :
- Number of shortest paths between vertices at distance :
- Between any with : vertex-disjoint paths ( of length , of length )
Potential exam questions
- Give the formal definition of the -dimensional binary hypercube . Write down the vertex set, edge set, and the parameters .
- Draw and . Label all vertices with their binary addresses. Identify the two sub-’s inside and the “dimension-3” matching between them.
- Express as a Cartesian product. Use this to argue hierarchical recursivity: what is in terms of and ?
- Define the Hamming distance and explain why . What is the average distance in , and how does it follow from Pascal’s triangle symmetry?
- Prove that . Why does this make “ideal for binary divide-and-conquer algorithms”?
- Prove that is balanced bipartite. What is the natural 2-coloring, and why does every edge connect vertices of opposite color?
- Prove that is Hamiltonian. What Hamiltonian cycle is provided by an -bit Gray code?
- State and outline the proof of Theorem 16: is vertex-symmetric with automorphisms. Describe the two independent families (dimension permutations) and (translations).
- State and prove Corollary 17: for any , there are automorphisms with . Write down the explicit formula and verify it.
- Describe
e-cube routingin . Why is the bit order fixed (LSB to MSB)? Why is it deadlock-free despite the high cyclicity of ? - Prove Lemma 18: the number of vertices at distance from a given vertex is . Deduce the average distance in .
- Prove Lemma 19: there are exactly shortest paths between two vertices at Hamming distance .
- State and prove Lemma 20 (vertex-disjoint paths). Construct vertex-disjoint paths between and with : describe both the short paths (length ) and the longer ones (length ).
- What are the two main drawbacks of the hypercube? Why do real supercomputers use only low-dimensional hypercubes? Give an example of a machine that uses a hypercube topology.
- Why is the hypercube still considered the “testbed” for distributed-memory parallel algorithms? What does the lecturer’s analogy to PRAM mean?