Advanced maths

Graph Cartesian prime factorization calculator with coordinate reconstruction

Recover arbitrary connected graph Cartesian factors and a vertex-to-coordinate bijection.

Your numbers

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

Recover arbitrary connected graph Cartesian factors and a vertex-to-coordinate bijection. Partial-cube recognition only embeds distances into binary labels; factors here may be nonbipartite, such as K3.

THE FORMULAV(G)=V(G1)×…×V(Gk); xy∈E(G) iff exactly one coordinate changes along an edge of its factor.

A worked example

The triangular prism has six vertices and nine edges. Its Cartesian prime factors are K2 and K3: two triangle layers contribute six edges, and three matching edges join corresponding coordinates.

Good to know

Connected simple undirected graph,2–12 vertices. Exact coordinate-bijection search with adjacency pruning and recursive factorization, capped at2 million search calls; complete reconstruction required. Cap failure leaves prime factorization unresolved.

Cartesian adjacency and factor coordinates

A Cartesian vertex is a tuple, with one entry from each factor. An edge changes exactly one entry, and the changed pair must be adjacent in that factor. The remaining coordinates stay fixed.

This coordinate rule explains why a product drawing can have repeated layers. In K2 square K3, the K2 coordinate selects one triangle, while the K3 coordinate selects the position within that triangle.

Graph Cartesian prime factorization calculator with coordinate reconstruction worked exampleK₂ □ K₃: six coordinate vertices000102101112Each edge changes one coordinate
Scroll across to see the full diagram.
The triangular prism has six vertices and nine edges. Its Cartesian prime factors are K2 and K3: two triangle layers contribute six edges, and three matching edges join corresponding coordinates.

Compare this with the Partial cube recognition calculator with binary distance preserving labels. Recover arbitrary connected graph Cartesian factors and a vertex-to-coordinate bijection. Partial-cube recognition only embeds distances into binary labels; factors here may be nonbipartite, such as K3.

Connectedness and uniqueness up to order

The input graph must be connected for the prime-factor interpretation used here. Its factorization is unique up to factor order and graph isomorphism, so different vertex names can describe the same mathematical answer.

A factor with one vertex contributes no new coordinate information and is omitted. Consequently, a graph declared prime is a graph with no decomposition into two connected factors both having more than one vertex. The default triangular prism separates into a three-vertex complete graph and a two-vertex edge. Labeling a prism vertex by its position in the triangle and its layer makes the rule concrete: an edge changes exactly one coordinate, following an edge in that coordinate's factor. A nonbipartite factor such as K3 is permitted, unlike a binary distance-preserving cube embedding. The returned coordinate map is therefore part of the answer, not decorative labeling. You can reconstruct each original adjacency from it and detect a factorization that has the right vertex count but the wrong edge structure.

Bounded coordinate search rather than distance heuristics

This implementation searches factor sizes and vertex coordinate assignments directly. Pairwise adjacency conditions prune an assignment as soon as it contradicts the Cartesian single-coordinate rule.

Faster recognition methods based on edge relations and compatible squares exist in the literature, but are not the algorithm promised here. A distance-only relation is also insufficient as a general prime-factor certificate.

Recovering candidate factor graphs

For a candidate factor size a dividing n, map vertices to an a by n/a coordinate grid. The first layer and first coordinate column determine the factor adjacencies; every remaining original pair must agree with them.

Construct each factor from the coordinate values and their permitted changes. A successful map must be a bijection onto the full Cartesian vertex set; missing tuples would indicate only a subgraph embedding. The implementation searches candidate factor sizes dividing the vertex count and then coordinate bijections, pruning assignments that violate Cartesian adjacency. It recursively factors a successfully reconstructed factor. This initial bounded implementation does not use the faster relation-based recognition algorithms discussed in the literature. Exhaustive completion certifies an unsplit factor as prime within this exact graph problem. A work-cap exception does not. Highly symmetric or prime examples can be expensive even at small sizes; adding vertices changes search difficulty much more than the displayed drawing suggests.

Triangular-prism worked factorization

For the triangular prism, label vertices (0,0),(0,1),(0,2),(1,0),(1,1),(1,2). Within each fixed first coordinate, all three pairs form a triangle. The three remaining edges connect equal second coordinates.

The counts check the reconstruction: 2×3=6 vertices and 2×3+3×1=9 edges. These simple totals are necessary checks, while the full pair-by-pair adjacency comparison supplies the stronger certificate.

Rebuilding and verifying every original edge

The diagram illustrates one fixed example and its coordinate directions. For a new input, inspect the returned coordinate table together with the factor edges; both are needed to audit the reconstruction.

Relabeling coordinates within a factor or swapping factor order changes the table without changing the product. Certificate comparison should therefore compare adjacency and tuple coverage rather than require one particular naming convention. A valid output should multiply its factor orders to the original order. Each original vertex must appear once in the map, every coordinate tuple must be used once and every edge must satisfy the single-coordinate rule. These checks are stronger than comparing degree sequences, which can coincide for nonisomorphic graphs.

Prime output, caps and disconnected-input limits

Prime-factor output combines two obligations: the factors must reconstruct the graph, and each factor must resist further nontrivial Cartesian decomposition. A valid composite factorization satisfies only the first obligation.

Resource limits may stop the coordinate search or recursive factorization. Such a stop leaves the answer unresolved; it must not convert a candidate partition into a verified prime factorization. Disconnected graphs need a separate componentwise convention.

A few questions, answered

How does this differ from a tensor graph product?

The tensor product changes coordinates under a different adjacency rule. This calculator uses exactly one changed coordinate.

Can a factor contain a triangle?

Yes. K3 is a prime factor of the triangular prism, so factors need not be bipartite.

Why require a connected graph?

Connectedness gives the unique prime-factor interpretation used by this page.

What proves the factors reconstruct the input?

The coordinate map covers every tuple once, and reconstructed adjacency must agree for every original vertex pair.

Find your calculator

Start typing to explore the library.