The problem
A perfect matching of a graph is a set of edges that covers every vertex exactly once — each vertex is an endpoint of one and only one edge of . We want , the number of such matchings. In general this is hard (#P-complete), but when has a linear, repetitive structure — a path, a ladder, a chain of identical blocks (diamonds, squares, triangles) — it collapses to a tiny recurrence.
Key idea: cut the chain and track a boundary state
Process the blocks of the chain from left to right, , sharing a single junction vertex between consecutive blocks. Make a vertical cut after block . Almost every vertex to the left of the cut is already matched among themselves; the only information that crosses the cut is the status of the junction vertex on the boundary:
- state — is already matched by an edge lying inside blocks ;
- state — is still free, to be matched later (i.e. inside block ).
Let be the number of partial matchings of ending in each state. The recurrence comes from asking: how can one more block be attached, given the incoming state? Because every block is identical, the same transition rule repeats, so this is exactly a transfer-matrix computation:
The entries of are read off the single block: count, for each (incoming boundary state outgoing boundary state), the number of ways to match the interior vertices of one block. The answer is the total in the accepting state after the last block (the boundary vertex of the closed end must end up matched).
How to apply it
- Decompose the graph into the repeated block and identify the shared junction vertices.
- Choose the state = the matched/free status of the current boundary vertex (sometimes a pair of boundary vertices for a ladder — then there are more states).
- Build the transition. For each incoming state, enumerate the ways to match every interior vertex of one block, recording the resulting outgoing state. This gives in terms of .
- Set base cases for the empty/first block and read off the final accepting count, or just iterate the recurrence times.
For paths and many simple chains the two states merge into a single linear recurrence — often the Fibonacci one. Example: the number of perfect matchings of the grid (ladder) satisfies with , the Fibonacci numbers, because each new column is either matched by one vertical edge (state carries over) or by two horizontals that also consume the previous column.
Mini-example: chain of diamonds
Take the structure from the konkur figure: a horizontal spine , and between and a top vertex and bottom vertex , with block being the on (both diagonals present, so the spine edge and the rung exist).
State = is the left spine vertex matched from outside this block? Per block we must cover and , plus possibly , ending by reporting whether is matched. Enumerating the legal interior choices of one block gives the transfer matrix, and letting be the number of perfect matchings of the whole chain yields the clean recurrence
because once the diamonds to the left are matched, the current diamond either reuses the spine edge to pass an already-matched forward (adding a fixed local factor) or absorbs via or . Iterating, , so the -diamond chain has perfect matchings — matching the figure with vertices and matched edges.
Exam trick: Do not try to enumerate all -edge subsets. Find the boundary state that crosses each cut (usually just "is this one vertex matched yet?"), write the per-block transition once, and ride the recurrence — most chain figures collapse to a Fibonacci-like or arithmetic formula like .