How this calculation works
Find a shortest diagonal-flip sequence between two triangulations of the same labeled convex polygon.
d(T,U)=minimum number of legal quadrilateral diagonal flips taking T to U.A worked example
The two triangulations of a labeled quadrilateral contain diagonals (0,2) and (1,3). Replacing that diagonal takes exactly one flip.
Good to know
Strictly convex labeled polygon with 4–11 vertices, two validated sets of n−3 noncrossing diagonals. Complete bidirectional BFS on triangulations with explicit state cap and replayable shortest witness. No arbitrary point-set flip distance, greedy optimum or comparison of unrelated boundaries.
Reference: Primary method or official documentation (opens in a new tab) ↗
Distance in the graph of triangulations
A triangulation divides a convex polygon into triangles using noncrossing internal diagonals. One flip replaces a diagonal shared by two triangles with the other diagonal of their quadrilateral. The flip distance is the smallest number of these moves needed to transform one complete triangulation into another, while retaining the same labeled polygon vertices.
This is a combinatorial distance, not a physical length. Stretching a convex polygon without changing its cyclic vertex order leaves the problem unchanged. The calculator returns both a minimum count and a replayable sequence, so the answer can be inspected as a series of valid intermediate triangulations rather than accepted as an unexplained integer.
Compare this with the Concave polygon triangulation calculator from vertices. Find the fewest legal diagonal flips between two supplied triangulations, rather than construct one triangulation of a boundary.
Using a consistent labeling convention
Enter the vertex count and the two sets of diagonals. Labels run from zero to n minus one around the boundary. A triangulation of an n-vertex polygon must contain exactly n minus three distinct internal diagonals. Boundary edges are already part of the polygon and should not be entered as if they were diagonals.
Both inputs must describe the same strictly convex labeled boundary. A reversed or rotated labeling can make geometrically similar drawings appear different combinatorially. If the second drawing uses different labels, relabel it deliberately before comparing. The solver does not search all vertex permutations or decide whether two unrelated point sets should be regarded as the same polygon.
Validating the two triangulations
Every diagonal must connect two different valid vertices, and neither endpoint pair may be a polygon side. Two diagonals cross when their endpoints interleave in the cyclic ordering and they do not share an endpoint. Checking this rule avoids needing approximate screen coordinates for the strictly convex input model.
A valid collection of n minus three noncrossing internal diagonals triangulates the convex polygon. Repeated entries cannot be used to reach that count, and an invalid set should be rejected before the distance search begins. Those checks ensure that the initial and target states both belong to the same finite triangulation graph whose shortest paths are being searched.
Why breadth-first search gives a minimum
All flips have equal cost one. Searching the triangulation graph in increasing distance therefore establishes a shortest path once the relevant layers meet. A bidirectional search can reduce the number of visited states by exploring from both supplied triangulations, while preserving the same exact count when complete distance layers and meeting conditions are handled correctly.
Each state has a canonical sorted representation of its diagonal set. This avoids revisiting the same triangulation under different input orders. Parent records preserve the witness sequence. A search cap limits the computation, but reaching that cap is an unresolved result, not permission to call a currently known route the shortest possible route.
The quadrilateral worked example
A quadrilateral has two triangulations: one uses diagonal (0,2), and the other uses diagonal (1,3). Removing the first diagonal exposes the whole quadrilateral, and inserting the other completes the flip. The default distance is consequently one, with no intermediate triangulation beyond the starting and target states.
If both entries use (0,2), the distance is zero. This simple pair of tests checks identity handling and the basic move rule independently of a large search. For a larger polygon, a returned witness can be verified by confirming that exactly one diagonal is removed and one inserted at every step, and that their endpoints form the same quadrilateral.
Checking a returned shortest witness
Replay the sequence from the first input. At every move, verify that the removed diagonal is present and that the inserted diagonal is the legal alternative in its adjacent pair of triangles. The last state must match the second input exactly. This proves that the reported count is an achievable route, while the completed search establishes minimality.
Distance is symmetric, so swapping the inputs should preserve the count and allow the witness to be reversed. The number of diagonals that differ gives a simple lower bound because one move can introduce at most one missing target diagonal. A longer witness is plausible only when temporary moves are needed; a count below this lower bound is necessarily incorrect.
Scope beyond the convex case
For a nonconvex polygon, a proposed replacement diagonal may leave the interior. For a general point set, additional geometric constraints appear, and not every triangulation graph behaves like the convex-polygon case. Those are separate tasks and are not covered by accepting arbitrary coordinates under this calculator's convex labeling convention.
The result also does not optimize triangle quality, total edge length or a mesh-smoothing objective. A shortest transformation may pass through triangulations that are undesirable for another application. Use flip distance to answer the stated transformation-count question, and retain the explicit unresolved status whenever the bounded search cannot finish its minimum-distance certificate.
A few questions, answered
Do I need polygon coordinates?
No. Strict convexity and cyclic labels determine crossing and legal-flip relationships for this problem.
Can I include the boundary edges?
No. Enter only the n minus three internal diagonals of each triangulation.
Does a found route prove it is shortest?
Only when the breadth-first search completes the required distance-layer certificate. A cap-limited route is not automatically optimal.
Why is the count unchanged when I stretch the polygon?
The problem depends on cyclic order and convexity, not on lengths or angles.