The chain before the lengths

Deciding that two chains are one

Two chains are the same chain when a relabelling of the links carries one to the other. Ten links admit 3,628,800 relabellings, and the census asks the question 26,335 times — so the answer is not a search but a rule that picks one labelling out of the graph itself, and asking whether the two strings match.

Assumes Right until the size nobody checked and Same links, same pins, different machines.

A kinematic chain arrives as a list of pins: link 0 to link 1, link 1 to link 2, and so on. The numbers are arbitrary. Nobody chose them for a reason, and a different draughtsman writing the same mechanism down would have produced a different list.

So the question are these two chains the same is not a comparison of lists. It is the question of whether some relabelling of one list produces the other, and for a ten-link chain there are 3,628,800 relabellings to consider.

Same links, same pins, different chains. Watt chain on the left and Stephenson chain on the right. They have the same number of links, the same number of pins and the same assortment — 4×2 + 2×3 — so no count of anything can tell them apart. What differs is where the pins go: on the left the two ternary links share a pin, on the right they do not, and that single fact makes two mechanisms with different coupler curves, different numbers of inversions and different position problems. It is the smallest case in the subject of the thing this field exists to say: the arithmetic is a filter and the graph is the answer.
Fig. 1 Two chains that are genuinely different. Establishing that takes a search over relabellings, or something better than a search.

That is the cost per pair. The census asks it far more often than once. Building the ten-link census means deciding, for each of the 3,000 candidate graphs the search reaches, whether it has been seen before — and comparing every new candidate against every stored one would be 26,335 pairwise questions on the final list alone.

Neither cost is payable, and the spectral shortcut that used to make it payable has counterexamples. What is needed is something better than an invariant.

A labelling rather than a number

The way out is to stop computing a number from the graph and start computing a labelling of it.

Pick a rule that assigns each link a number, using only what the graph says about that link and never the label it arrived with. Apply it to both chains. If the rule is deterministic and reads only the graph, then two isomorphic chains get the same labelling — up to whichever links the rule genuinely cannot distinguish — and their adjacency strings under that labelling match exactly.

That string is the canonical form. Two chains are the same chain precisely when their canonical forms are identical, and the comparison is a string equality rather than a search. There are no counterexamples by construction — unlike the spectral fingerprint of the previous rung — and the whole content of the claim is in the rule reading only the graph.

Stephenson chain: 7 pins, and nothing else. A kinematic chain drawn as what it is — a graph. Each disc is a link and carries its number; each line is a pin joining two links. There are no lengths here, no angles and no positions, and every quantity this field computes survives moving any disc anywhere: the picture is a way of reading the graph and not a picture of a machine. The fill says how many pins a link carries — 4 binary, 2 ternary — which is the coarsest thing that can tell two chains apart and the first column of every census table. The count reads two numbers off this picture and nothing else: 6 links and 7 pins give 3 × 5 − 2 × 7 = 1.
Fig. 2 The numbers on these discs are not the ones the chain arrived with. They are the canonical labelling, so a link’s number means the same thing in every drawing of this chain in this field.

Refinement does most of the work

The rule has two halves, and the first is cheap.

Colour every link by how many pins it carries. Then repeatedly recolour it with its own colour together with the multiset of its neighbours’ colours, until a pass changes nothing.

Colour by degree, recolour by neighbours' colours, stop when nothing changes. The cheap half of every isomorphism routine there is, and the half that does most of the work. Start by colouring each link with how many pins it carries. Then repeatedly recolour it with its own colour plus the multiset of its neighbours', until a pass changes nothing. On this chain the process ends with 3 classes of sizes 2, 2, 2, and two links of different colours are certainly different links — no relabelling can carry one to the other. What refinement cannot do is separate links that are alike to every local measurement, and that residue is what the backtracking search is for. It is also, exactly, why a spectral test fails: an eigenvalue is a global average over walks and has no more to say about two locally identical links than the refinement does.
Fig. 3 Refinement on Stephenson’s chain. It ends with three classes, of sizes two, two and two, and two links of different colours are certainly different links.

Two links that end in different colours cannot possibly be carried to one another by any relabelling: their colours are statements about their own neighbourhoods, then about their neighbourhoods’ neighbourhoods, and a relabelling preserves all of it. So refinement never merges links that ought to be separate, and everything it does separate is separated correctly.

On the chains in this field it does most of the job. A chain whose links carry different numbers of pins is often pinned down by that alone; adding one round of neighbours’ colours usually finishes it. Stephenson’s chain refines to three classes in two passes, and those three classes are exactly its three orbits.

3 mechanisms from one chain. A mechanism is a chain plus a decision about which link is bolted down, so one chain gives as many mechanisms as it has genuinely different links to bolt down. Two links are the same in that sense when some relabelling of the whole chain carries one to the other and leaves every pin where it was — an automorphism — and this chain has 4 of them. The colours are the orbits: {0, 3}, {1, 2}, {4, 5}. Grounding link 0 and grounding link 3 give the same machine drawn from a different angle; grounding a link of a different colour gives a different machine. It is the reason the sixteen eight-link chains are seventy-one eight-link mechanisms.
Fig. 4 The same three classes, drawn as what they turn out to be: the orbits of the links under the chain’s own symmetries.

What refinement cannot do is separate links that are genuinely alike to every local measurement. Watt’s chain has four binary links that refinement colours identically, and it is right to: no local test distinguishes them, because a symmetry of the whole chain carries any one of them to any other.

But refinement also stops on chains where the links are not interchangeable, and that is the case the second half exists for.

Backtracking on what is left

When refinement stops with a class of more than one link, the rule picks one link out of that class, gives it a colour of its own, and refines again — which usually cascades and splits everything.

The catch is that the rule does not know which link to pick. So it tries each of them, follows each choice to the end, and keeps whichever produces the lexicographically largest adjacency string. That choice is arbitrary and it does not matter which arbitrary rule is used; what matters is that it is the same rule every time, so that two isomorphic chains explore corresponding branches and arrive at the same string.

The search generates 3,000 candidates for 1,878 answers. How much work the enumeration does, against how much it has to show for it. The upper line is the number of complete labelled graphs the search reaches and the lower is the number of distinct graphs they turn out to be, so the vertical gap is waste — every candidate above the lower line is a graph the search had already found under a different labelling. At eight links the unpruned version of this search generated 8,494 candidates for the same 71 answers, and at ten links it did not finish at all; with the pruning it generates 3,000 for 1,878 in 442 milliseconds. The rule that does it is one line long: when two links carry the same number of pins, reject the labelling that would be lexicographically smaller if they were swapped. It cannot reject a labelling that is the largest in its class, so nothing is lost, and it is not a complete test, which is why the canonical form is still taken at the end.
Fig. 5 What the whole enumeration costs. The canonical form is taken on every one of the 3,000 candidates the ten-link search reaches, and the census finishes in about half a second.

The cost is the number of branches, and on chains this size refinement leaves very few. It is worth being honest that this is not a general result: individualisation-and-refinement is exponential in the worst case, and the worst cases are highly regular graphs — which is exactly what makes the ten-vertex chains here comfortable, since a chain with a triangle in it is not a chain at all and the graphs are sparse and irregular.

This is a tool and not a subject. The routine is written to the size of the problem and not to the state of the art; what is claimed here is a census of mechanisms, never anything about isomorphism testing in general, which is algorithms-data-structures.com’s ground.

What falls out for free: the symmetries

The same search, run without the maximising, produces something the census needs anyway.

An automorphism is a relabelling of a chain that leaves it unchanged — every pin still between the same two links. Finding them all is the same backtracking with a different acceptance test: extend a partial map only to a link of the same degree whose adjacencies to the already-mapped links agree exactly, and record every complete map.

Symmetry is what a chain pays for its mechanisms in. Every 8-link chain placed by how symmetric it is against how many mechanisms it gives. The relation is not a formula — the orbit count is not determined by the group's size — but the direction is unambiguous and the extremes are exact: the chain with 16 automorphisms gives 2 mechanisms, and the chain with none but the identity gives 8, one for every link it has. Orbit counting is the whole argument: a symmetry that carries link 3 to link 5 says the two mechanisms you would get by grounding them are the same machine drawn twice.
Fig. 6 Every eight-link chain placed by how symmetric it is against how many mechanisms it gives. The chain with sixteen automorphisms gives two mechanisms; the ones with none give eight.

That matters because a chain is not a mechanism until a link is held still, and two links give the same mechanism exactly when an automorphism carries one to the other. So the number of genuinely different mechanisms a chain gives is the number of orbits — and that is where the classical counts come from. Two six-link chains, five orbits, five six-bars. Sixteen eight-link chains, seventy-one orbits, seventy-one eight-link mechanisms.

It is a nice economy that the expensive machinery a census needs for deduplication turns out to be the machinery it needs for counting driven mechanisms. Neither was built for the other.

Why the string is compared and not the matrix

A small point of practice, because it is where an implementation of this usually goes wrong.

The canonical form here is the upper-triangle bit string of the adjacency matrix under the canonical labelling, read row by row — for a ten-link chain, forty-five characters. It is not the matrix, not the edge list, and not a hash of either.

The string form matters for three reasons. It is comparable with a single equality, so a census can store it as a map key and deduplicate in constant time rather than by pairwise testing. It is orderable, which is what lets the backtracking maximise over branches: “lexicographically largest” needs a total order, and a matrix has none. And it is exact — no floating point anywhere, so two chains either are the same or are not, with no tolerance to choose and nothing to be near.

That last property is unusual on this site and worth marking. Almost every other field’s central quantity is a real number arrived at by a solve, with a tolerance that is a check rather than a stopping rule and a decision somewhere about where a spectrum stops being signal — which is what the count that does not move is about. Here there is no such decision. The census is a set of strings, and a chain is in it or is not.

What it costs to be sure

It is worth putting a number on the whole apparatus, because the argument for it is partly economic.

Building the ten-link census means: enumerating eleven degree sequences; walking a pruned search that reaches 3,000 complete labelled graphs; canonicalising each of them; deduplicating into 1,878 distinct graphs; running a subset scan over each to reject the 1,648 that hide a structure; and computing the automorphism group of each of the 230 survivors to count its mechanisms. That is about half a second.

For comparison: the spectral shortcut this replaces would have taken a few milliseconds and would have returned 228 chains, with two of them silently absent and two others silently doubled. The saving is real and the error is permanent, which is roughly the worst exchange rate available.

The one place the cost does bite is the next row. Twelve links means 4,096 subsets to scan per graph, a search space larger by about the factor the last three steps were, and a canonical form on twelve vertices rather than ten. That is the subject of its own rung, and the honest answer there is that this routine does not reach it.

Why the drawings depend on it

There is a second use, and it is the one that decides whether this field’s figures can be trusted at all.

A graph has no geometry. Where the discs go on a page is a choice, and an arbitrary choice would make two drawings of the same chain look like different chains — which is the single worst thing a figure in this field could do, because are these two the same is the field’s central question and a reader’s first instrument is their eye.

The same chain twice: as connections, and as parts. On the left the chain as a graph — a disc per link, a line per pin. On the right the same chain as a mechanism somebody could hold: every pin is a point of the plane, and every link is the bar or plate through the pins it carries. The right-hand picture has dimensions and the chain does not. The pins were placed first and the links read off them, so the assembly is exact — each pin is one point and both its links pass through it, with a closure residual of nought by construction rather than to a tolerance — but the particular lengths are a representative and nothing in this field depends on them. Move any pin and the picture changes, the mechanism changes, and every count on this page stays where it was. positioned by solving, not by drawing.
Fig. 7 The left-hand picture is a choice and the right-hand one is a further choice. Neither is a property of the chain, and both have to be reproducible from it.

So the layout is defined as a function of the canonical form and of nothing else. Links start on a circle in canonical order, relax under a fixed number of spring-and-repulsion steps with a fixed schedule, and the result is rotated so its longest principal axis is horizontal and reflected so the first canonical link is on the left. No random seed, no hand-placement, no per-chain adjustment.

The consequence is checkable, and it is checked: a chain relabelled forty times at random produces forty different edge lists and one drawing. The assertion compares the closest pair of links in the picture and requires it to be unchanged to 10910^{-9}.

That is the same discipline the rest of the site applies to positions — nothing is drawn that was not solved — carried over to the one thing in this field with no solve behind it. It is worth stating as a rule because the alternative is so easy and so quietly wrong: hand-placing the discs of sixteen chains until each looks tidy produces sixteen good pictures and destroys the only comparison the reader can make.

The rule that makes the census finish

The canonical form decides whether two graphs are the same. It does not, on its own, make a census affordable, and the reason is that a search generating labelled graphs produces every labelling of every chain.

At eight links the unpruned search reaches 8,494 complete graphs and returns 71. At ten links it does not finish at all.

What fixes it is one rule, and it is a weak relative of the canonical form. When two links carry the same number of pins, swapping them gives a relabelling of the same partial graph; if that swap would make the adjacency string lexicographically larger, the current labelling is not the largest in its class and can be abandoned. The largest one is generated by some other branch, so nothing is lost.

It is a partial test — adjacent swaps generate all the relabellings within a degree class but checking them one at a time does not decide maximality — which is why the full canonical form is still taken at the end. That combination is the ordinary shape of an enumeration: a cheap partial rule that removes almost everything during the search, and an exact rule that finishes the job on what survives.

A canonical form is a name, and names have to be versioned

The canonical form is used above for deduplication and for drawing, and it has a third use that is worth stating because it is the one that outlives any particular run.

A canonical form is a name. It is a short string, it is computed from the chain and from nothing else, and two people who have never spoken produce the same string for the same chain. So a chain can be stored under it, looked up by it, and referred to in a table without anybody agreeing on a numbering first — which is exactly what a census needs if its rows are to be compared against a census somebody else built, or against the same census rebuilt a year later after the enumerator has been rewritten.

That is a genuinely useful property and it comes with a trap that is easy to walk into. The string is stable against relabelling and not against the rule. It is stable against relabelling by construction, which is the whole point and is what the scramble test checks. It is not stable against a change to the refinement rule, the tie-breaking order, or the direction the upper triangle is read in — change any of those and every chain in the census gets a different name, all of them still correct, none of them matching what was stored yesterday.

So a stored canonical form is only a name in the presence of the rule that produced it, and a census that records the strings without recording the rule has recorded something that will silently stop matching. The remedy is dull and complete: keep the rule’s identity beside the strings, and treat a mismatch as a question about which rule was used rather than as a discovery about chains.

The failure this prevents is a particular one and it is worse than a broken lookup. Two censuses with different rules produce two sets of strings with no overlap at all, so a comparison between them reports that every chain in one is absent from the other — which reads exactly like a genuine disagreement about what the census contains, and is a disagreement about spelling. The first thing to check when two enumerations disagree completely is therefore not the enumeration.

None of that argues against the string form, which is the right representation for all three uses. It argues for one line of metadata, and it is the same discipline the site applies to a figure’s own numbers: a value is only a value with the thing that produced it attached.

The thing that has to be got right

One property carries the whole census and it is worth stating on its own: the rule must read the graph and never the labels.

Every failure mode here is a leak of the arrival order into the answer. A refinement that broke ties by link number would give two isomorphic chains different canonical forms. A backtracking search that tried the branches in the order the links happened to be listed, and stopped at the first complete labelling instead of maximising, would do the same. In both cases the census would silently over-count — the same chain stored twice under different strings — and there is no gate anywhere that would notice, because every graph in it would still be a perfectly good chain.

The check for it is the relabelling test above, and it is the only check that would catch it: take a chain, scramble its labels, and require the canonical form and the drawing to be unchanged. Comparing against published counts helps too — the census reproduces 1, 2, 16 and 230, and separately reproduces the number of unlabelled trees on up to ten vertices, which is a sequence from an entirely different subject — but agreement with a published number is weaker evidence than it looks. It confirms the total and says nothing about which objects are in it.

The chains that never close, counted by the same routine. An open chain has one joint fewer than it has links, so its graph is a tree and its mobility is the joint count rather than one. Feeding the same enumerator that produced the closed-chain census — with the minimum-degree condition relaxed to one, because an arm's base and its end each carry a single joint — gives 1, 2, 3, 6, 11, 23, 47, 106 for three links up to ten. That is the number of unlabelled trees, a sequence anybody can look up, and reproducing it is the strongest check the enumerator gets: it was written for a different problem, tested against three mechanism counts, and asked here for a number from a different subject entirely.
Fig. 8 The enumerator asked for something it was not written for: the number of distinct open chains, which is the number of unlabelled trees, 1, 2, 3, 6, 11, 23, 47, 106.

A related point about what the string can and cannot be compared against. Two canonical forms produced by the same rule are equal exactly when the chains are the same, so equality is a complete test and inequality is a complete test. What the strings do not support is anything in between: they cannot be ordered meaningfully, the distance between two of them says nothing about how similar the chains are, and a near-match is not a near-miss. That is worth knowing before anybody tries to index the census by string prefix or to cluster chains by how much of the string they share, both of which look reasonable and measure the labelling rule rather than the graphs.

What this makes readable

Essays that name this one as a prerequisite.

About the same objects

Not linked from either essay — found by the objects both name.

What links here

Essays that link to this one from their own argument.

The objects this essay names

Each one links to every other essay that touches it.

AutomorphismCanonical formDegenerate chainGraph isomorphismInversionKinematic chainLink assortmentOrbitRefinementType synthesis