Discover how graph theory transforms the Rubik’s Cube into a massive mathematical network—and how computers can find solutions in just 20 moves or fewer.

When most people look at a scrambled Rubik’s Cube, they see a puzzle with colored stickers.
Mathematicians can see something very different: a graph containing an enormous number of connected states.
Imagine that every possible arrangement of a 3×3×3 Rubik’s Cube is represented by a dot. That dot is a vertex, or node, in a graph.
Now imagine connecting two dots whenever one legal twist of a cube face can transform one configuration into the other.
The result is the Rubik’s Cube graph.
This idea turns the physical puzzle into a mathematical problem involving graph theory, permutations, search algorithms and group theory.
The scale of the problem is difficult to comprehend.
A standard 3×3×3 Rubik’s Cube has exactly:
43,252,003,274,489,856,000
reachable configurations—roughly 43 quintillion.
For comparison, the smaller 2×2×2 cube has only around 3.7 million reachable positions, making it much more manageable for exhaustive computational studies. Carnegie Mellon University researchers have also used the smaller cube as a way to explore the mathematical structure behind these enormous state spaces.
But the important point is that computers don't simply store and examine all 43 quintillion configurations one by one.
That would be enormously inefficient.
Instead, mathematicians use the structure of the graph to reduce the problem.
Each node represents one cube configuration.
An edge represents a legal move.
A face of a standard cube can be rotated:
There are six faces, producing:
6 × 3 = 18 possible face-turn moves
under the half-turn metric.
Therefore, each cube position has 18 immediate neighbors in the corresponding graph representation.
The graph is also undirected.
Why?
Because every move can be reversed.
If turning the front face clockwise takes configuration A to configuration B, turning that face counter-clockwise takes B back to A.
So the same connection can be traveled in either direction.
Now comes the interesting part.
Consider the solved Rubik’s Cube as a special node in the graph.
A scrambled cube is another node somewhere among the 43 quintillion configurations.
Solving the cube means finding a path from the scrambled node to the solved node.
If the path contains:
Scramble → Move 1 → Move 2 → Move 3 → Solvedthen the cube has been solved in three moves.
But if another route requires 15 moves, the three-move path is obviously preferable.
This creates a classic shortest-path problem.
The challenge is that the graph is unbelievably large.
A naïve search could potentially explore an enormous portion of the state space before discovering the shortest solution.
That's where algorithms and mathematical shortcuts become essential.
One of the most famous results in the mathematics of the Rubik’s Cube is God’s Number.
It represents the maximum number of moves required to solve any possible 3×3×3 position when using the optimal solution and counting any face twist—including a 180° turn—as one move.
That value is:
In other words, no matter how badly a standard Rubik’s Cube is scrambled, an optimal solution requires no more than 20 moves under the half-turn metric.
The number 20 was not simply estimated by a computer.
It was mathematically established through an enormous computational proof.
Researchers divided the problem into manageable sets, exploited symmetry and used distributed computing to establish that every position could be solved within 20 moves. The computation involved roughly 35 CPU-years of processing time.
There are different ways to measure moves.
The two important metrics are the half-turn metric and quarter-turn metric.
A 90° rotation counts as one move.
A 180° rotation also counts as one move.
Under this metric:
God’s Number = 20
A 90° rotation counts as one move, but a 180° rotation counts as two.
Under this measurement:
God’s Number = 26.
So the number isn't contradictory—the answer depends on how a "move" is defined.
At first glance, solving a 43-quintillion-node graph seems impossible.
The key is that computer solvers don't necessarily need to construct and examine the entire graph.
They use mathematical structure to dramatically reduce the search.
One important technique is a heuristic—an estimate of how far a particular configuration is from the solution.
Instead of blindly exploring every possible move, a solver can prioritize states that appear more promising.
Algorithms such as IDA and two-phase search methods can combine these ideas with precomputed tables known as pattern databases* or pruning tables.
These tables provide information about how difficult certain partial configurations are to solve.
The result is similar to having a map that doesn't show every road in a city but tells you which directions are likely to lead toward your destination.
Graph theory explains the cube's network structure, but another branch of mathematics explains why that network has such powerful structure:
group theory.
Every cube move can be understood as a permutation of pieces.
When several moves are performed one after another, they can be treated as mathematical operations.
For example:
Move A → Move B → Move Ccreates a new transformation of the cube.
These transformations form a mathematical group known as the Rubik’s Cube group.
This perspective allows researchers to divide the enormous state space into mathematically meaningful subsets.
The original proof of God's Number used cosets, symmetry and set-covering techniques to reduce the amount of computation required.
This is one of the reasons the Rubik’s Cube is so important mathematically: its apparent chaos contains a remarkable amount of structure.
The cube also contains enormous amounts of symmetry.
If you rotate the entire cube in your hands, you haven't fundamentally created a new puzzle difficulty.
The mathematical problem is essentially the same.
Researchers can exploit these symmetries so that they don't need to separately analyze configurations that are equivalent under rotation or reflection.
The God's Number computation used these ideas to reduce the number of large sets requiring direct computation from billions of possibilities to a much smaller collection of representative cases.
This is a general computational strategy:
Don't solve the same mathematical problem repeatedly when symmetry lets you solve it once.
If every position can be solved in 20 moves or fewer, are there actually positions that require all 20?
Yes.
The famous superflip configuration was the first position proven to require 20 moves under the half-turn metric.
Interestingly, such positions are extremely rare compared with the entire state space.
The cube20 project has continued documenting known distance-20 positions; its published data includes more than 100 million known positions at distance 20 as of July 2025.
So "20 moves" represents the maximum optimal distance—not the typical number of moves required for a random scramble.
The Rubik’s Cube provides a surprisingly useful demonstration of several computer science concepts.
Each configuration is a state, and each move creates another state.
This same idea appears in:
The cube demonstrates concepts such as:
Instead of searching blindly, algorithms estimate which states are more promising.
The proof of God's Number demonstrates how a problem that is far too large for straightforward exhaustive computation can be divided among many machines and solved through carefully designed mathematical reductions.
The Rubik’s Cube looks simple because its physical mechanism is simple.
There are only six faces and a relatively small number of possible moves.
Yet those moves generate a state space containing approximately 43 quintillion configurations.
That contrast is what makes the puzzle so fascinating.
A small set of rules can generate an extraordinarily complex system.
Graph theory provides the map.
Group theory explains the transformations.
Search algorithms find paths.
Heuristics reduce the work.
And computing brings all of these ideas together.
The result is one of the most famous examples of mathematics hiding inside an everyday puzzle.
The next time you pick up a Rubik’s Cube, you're not just holding a puzzle—you are holding a physical representation of an enormous mathematical graph.
Every twist moves you from one vertex to another. Every sequence of moves creates a path. And the challenge of solving the cube is essentially the challenge of finding a sufficiently short path back to the solved state.
What appears to be a colorful toy is actually a remarkable laboratory for graph theory, group theory, algorithms, optimization and computational mathematics.