Advanced maths

Partial cube recognition calculator with binary distance preserving labels

Recognize a partial cube and construct binary vertex coordinates whose Hamming distances equal every graph distance.

Your numbers

One edge per row, zero-based endpoint indices. Enter none for an edgeless graph where the method permits one.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Recognize a partial cube and construct binary vertex coordinates whose Hamming distances equal every graph distance.

THE FORMULAuv Θ xy iff d(u,x)+d(v,y)≠d(u,y)+d(v,x); partial cube certificate: d_G(u,v)=Hamming(b_u,b_v) for every pair.

A worked example

The default four-cycle embeds as binary labels 00, 10, 11 and 01 around its vertices. Adjacent vertices differ in one bit and opposite vertices in two, so every graph distance equals Hamming distance and dimension is 2.

Good to know

Connected simple undirected graphs with at most 30 vertices. Djoković–Winkler edge classes/cuts, binary coordinate construction and exhaustive all-pairs distance certificate. No approximate Euclidean embedding or mere subgraph-of-hypercube verdict; failed recognition is distinct from unresolved computation.

Preserve all distances in binary coordinates

A partial cube is a graph that admits an isometric embedding into a hypercube. Each vertex receives a binary string, and the number of differing bits between two strings must equal their shortest-path distance in the graph. This all-pairs condition is stronger than merely drawing the graph inside a cube or making adjacent vertices differ in one bit.

The embedding can use fewer hypercube vertices than the full cube contains. That is why a partial cube need not itself be a complete hypercube. The binary dimension counts the independent coordinate cuts needed by the representation. The calculator returns coordinates and checks their distances rather than relying on a graph drawing that looks cube-like.

Binary labels 00, 10, 11 and 01 embed the default four-cycle isometrically in a two-dimensional hypercube00101101One bit per edgeTwo bits acrossa diagonalC₄ graph distance = Hamming distance
Scroll across to see the full diagram.
Binary labels 00, 10, 11 and 01 embed the default four-cycle isometrically in a two-dimensional hypercube.

Compare this with the Bipartite graph test calculator with odd cycle. Construct or reject an isometric hypercube embedding, rather than merely check the necessary bipartite condition.

Supply a connected simple graph

Enter a connected undirected graph with at most thirty vertices and zero-based edge endpoints. Repeated edges, loops and out-of-range vertices are rejected. The input does not include edge lengths: every graph edge contributes one unit to shortest-path distance. Disconnected input is outside the page’s distance convention and is not embedded component by component silently.

A partial cube must be bipartite. An odd cycle therefore supplies an immediate obstruction. Bipartiteness alone is not sufficient, because a bipartite graph can still fail the stronger global distance requirements. The recognition pipeline retains that distinction instead of treating every two-colorable graph as a valid partial cube.

Compare edges through graph distances

For two edges uv and xy, the Djoković–Winkler relation compares the sums d(u,x)+d(v,y) and d(u,y)+d(v,x). Their inequality identifies edges associated with a common hypercube coordinate in a valid partial cube. The relation is computed from graph distances, not from a particular planar drawing or guessed coordinate labels.

The required edge classes and their associated cuts must be consistent. A relation that fails the needed class structure cannot be repaired by assigning arbitrary extra bits. The implementation checks the resulting structure within the supported graph and does not present a heuristic clustering of edge relations as a mathematical recognition certificate.

Construct one bit per coordinate cut

In a valid embedding, crossing an edge in one coordinate class flips that coordinate’s bit. Removing that class separates the corresponding two sides, and each vertex’s side determines its zero or one value. Choosing which side receives zero is arbitrary. Complementing an entire coordinate preserves every Hamming distance.

Likewise, reordering coordinates changes the displayed strings but not their distance relationships. The binary labels are therefore witnesses rather than unique vertex identifiers with physical meaning. Two implementations can return different bit strings for the same graph while agreeing perfectly after coordinate permutations and bit complements. Compare the distance certificate, not literal string equality alone.

Verify the four-cycle example

The default graph has vertices zero, one, two and three around a cycle. One valid sequence of binary labels is 00, 10, 11 and 01. Every graph edge joins strings that differ in exactly one position. Opposite vertices differ in both positions and have graph distance two. All six vertex pairs therefore satisfy the isometry condition.

There are two coordinate classes: the two opposite horizontal edges can flip one bit and the other opposite pair can flip the other. The embedding dimension is two. Changing the starting vertex or reversing the cycle order can permute or complement the bits, but it cannot change the graph’s two-coordinate distance representation.

Check every pair after constructing coordinates

The final check computes Hamming distance for every vertex pair and compares it with the independently computed graph distance. This catches a coordinate assignment that preserves edges but shortens or lengthens a nonadjacent pair. The all-pairs certificate is essential because edge-by-edge correctness alone does not prove an isometric embedding.

A failed pair identifies exactly where the candidate representation disagrees with the graph metric. A construction failure or resource limit must be reported distinctly from a completed mathematical rejection. The page’s supported size permits an explicit full comparison table, making its positive verdict reviewable rather than asking the user to trust a binary string plot.

Distinguish recognition from general embedding

A Euclidean embedding preserves or approximates distances in real coordinates and solves a different problem. A hypercube-subgraph embedding may preserve adjacency while allowing shorter Hamming paths between nonadjacent vertices, which is insufficient here. Partial-cube recognition demands equality of the graph and Hamming metrics for every pair under one shared binary labeling.

Use the output for finite graph structure and coordinate cuts. It does not claim that the graph has a unique geometry, that binary features have an application-specific interpretation or that approximate measured distances are exactly representable. The input graph supplies exact integer shortest-path distances, and the returned certificate answers that precise combinatorial question.

A few questions, answered

Is every bipartite graph a partial cube?

No. Bipartiteness is necessary, but the full isometric embedding conditions can still fail.

Are the binary labels unique?

No. Coordinates can be reordered and any coordinate can be complemented without changing distances.

Why check nonadjacent pairs?

Preserving edge differences alone does not prove that every graph distance equals Hamming distance.

Does partial mean approximate?

No. The required distance equalities are exact combinatorial conditions; the graph can occupy only part of a full hypercube.

Find your calculator

Start typing to explore the library.