# Hyperloop
Hyperloop was published in Taper #16: For Good Measure, Spring 2026.
# 1 Description
A polytope is the generalized version of the sequence:
polygon (2D), polyhedron (3D), polychoron (4D), …
A measure polytope is a generalized version of the sequence:
square, cube, tesseract, …
when each has unit-length edges, providing the measure for the unit of n-dimensional content[0].
A 4D tesseract (aka hypercube) has 16 vertices, 32 edges, 24 faces (which are 2D squares), and 8 cells (which are 3D cubes). The vertices have a natural numbering in 4 bits of binary, where each bit represents position in a different dimension. Edges are present between vertices whose numbers differ by exactly one bit.
An Eulerian circuit is a closed loop through a graph visiting each edge exactly once. In the four-dimensional hypercube, each vertex has four incident edges, and because such a loop traverses each edge exactly once, each vertex is visited exactly two times in one complete circuit, with two of the edge traversals approaching the vertex and the other two departing from it.
Eulerian circuits can be constructed efficiently using Hierholzer’s algorithm[1]. However, counting distinct Eulerian circuits is hard: according to OEIS[2], there are 15,639,936 Eulerian circuits of a tesseract.
[0]: Russell Towle,
“Polytopes, Continued”,
https://www.northforktrails.com/RussellTowle/Polytopes/Chapter2/Polytopes2.html
(accessed 2025-12-18).
[1]: Wikipedia,
“Eulerian path: Hierholzer’s algorithm”,
https://en.wikipedia.org/wiki/Eulerian_path#Hierholzer's_algorithm
(accessed 2025-12-18).
[2]: The Online Encyclopedia of Integer Sequences,
“Number of Eulerian cycles in the n X n torus grid graph”,
https://oeis.org/A297385
(accessed 2025-12-18).
# 2 Implementation
There are three main parts to the code.
First and largest is an implementation of Hierholzer’s algorithm for
constructing a random Eulerian circuit in the function f().
It starts by building a list of edge adjacencies,
defining utility functions to choose items at random
and remove an edge from both edge lists that contain it.
The nested function g() joins edges end to end to form a loop,
Then the body of f() splices loops together until all edges are used.
Second is laying out the positions of all the vertices of the tesseract.
The list H contains vectors for 4 directions (and zero),
which are combined according to vertex index to give vertex positions K.
The vectors are chosen to maximize symmetry.
Third is drawing the circuit as a rainbow cycle, with an animated highlighted edge that passes along the Eulerian circuit. The circuit is drawn multiple times with translucent lines of varying widths, to create a neon glow effect. The colouring of the path also animates slowly.
Click to generate a new random circuit.
# 3 Screenshot
Static snapshot for archival purposes only:
