ArticleslgStudy

computer science

FKT algorithm

FKT algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand FKT algorithm rather than just read about it. In short: The Fisher–Kasteleyn–Temperley (FKT) algorithm, named after Michael Fisher, Pieter Kasteleyn, and Neville Temperley, counts the number of perfect matchings in a planar graph in polynomial time. This same task is #P-complete for general graphs.

FKT algorithm — main illustration
FKT algorithm — illustration

Key takeaways

  • FKT algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect FKT algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of FKT algorithm from memory before moving on to harder problems.

Reference excerpt

The Fisher–Kasteleyn–Temperley (FKT) algorithm, named after Michael Fisher, Pieter Kasteleyn, and Neville Temperley, counts the number of perfect matchings in a planar graph in polynomial time. This same task is #P-complete for general graphs. For matchings that are not required to be perfect, counting them remains #P-complete even for planar graphs. The key idea of the FKT algorithm is to convert the problem into a Pfaffian computation of a skew-symmetric matrix derived from a planar embedding of the graph. The Pfaffian of this matrix is then computed efficiently using standard determinant algorithms.

History The problem of counting planar perfect matchings has its roots in statistical mechanics and chemistry, where the original question was: If diatomic molecules are adsorbed on a surface, forming a single layer, how many ways can they be arranged? The partition function is an important quantity that encodes the statistical properties of a system at equilibrium and can be used to answer the previous question. However, trying to compute the partition function from its definition is not practical. Thus to exactly solve a physical system is to find an alternate form of the partition function for that particular physical system that is sufficiently simple to calculate exactly. In the early 1960s, the definition of exactly solvable was not rigorous. Computer science provided a rigorous definition with the introduction of polynomial time, which dates to 1965. Similarly, the notation of not exactly solvable, for a counting problem such as this one, should correspond to #P-hardness, which was defined in 1979. Another type of physical system to consider is composed of dimers, which is a polymer with two atoms. The dimer model counts the number of dimer coverings of a graph. Another physical system to consider is the bonding of H2O molecules in the form of ice. This can be modelled as a directed, 3-regular graph where the orientation of the edges at each vertex cannot all be the same. How many edge orientations does this model have? Motivated by physical systems involving dimers, in 1961, Pieter Kasteleyn and Neville Temperley and Michael Fisher independently found the number of domino tilings for the m-by-n rectangle. This is equivalent to counting the number of perfect matchings for the m-by-n lattice graph. By 1967, Kasteleyn had generalized this result to all planar graphs.

Algorithm

Explanation The main insight is that every non-zero term in the Pfaffian of the adjacency matrix of a graph G corresponds to a perfect matching. Thus, if one can find an orientation of G to align all signs of the terms in Pfaffian (no matter + or - ), then the absolute value of the Pfaffian is just the number of perfect matchings in G. The FKT algorithm does such a task for a planar graph G. The orientation it finds is called a Pfaffian orientation. Let G = (V, E) be an undirected graph with adjacency matrix A. Define PM(n) to be the set of partitions of n elements into pairs, then the number of perfect matchings in G is

PerfMatch⁡(G)=∑M∈PM(|V|)∏(i,j)∈MAij. Closely related to this is the Pfaffian for an n by n matrix A

pf⁡(A)=∑M∈PM(n)sgn⁡(M)∏(i,j)∈MAij, where sgn(M) is the sign of the permutation M. A Pfaffian orientation of G is a directed graph H with adjacency matrix B such that pf(B) = PerfMatch(G). In 1967, Kasteleyn proved that planar graphs have an efficiently computable Pfaffian orientation. Specifically, for a planar graph G, let H be a directed version of G where an odd number of edges are oriented clockwise for every face in a planar embedding of G. Then H is a Pfaffian orientation of G. Finally, for any skew-symmetric matrix A,

pf⁡(A)2=det⁡(A), where det(A) is the determinant of A. This result is due to Arthur Cayley. Since determinants are efficiently computable, so is PerfMatch(G).

High-level description

Compute a planar embedding of G. Compute a spanning tree T1 of the input graph G. Give an arbitrary orientation to each edge in G that is also in T1. Use the planar embedding to create an (undirected) graph T2 with the same vertex set as the dual graph of G. Create an edge in T2 between two vertices if their corresponding faces in G share an edge in G that is not in T1. (Note that T2 is a tree.) For each leaf v in T2 (that is not also the root): Let e be the lone edge of G in the face corresponding to v that does not yet have an orientation. Give e an orientation such that the number of edges oriented clock-wise is odd. Remove v from T2. Return the absolute value of the Pfaffian of the adjacency matrix of G, which is the square root of the determinant.

Generalizations The sum of weighted perfect matchings can also be computed by using the Tutte matrix for the adjacency matrix in the last step. Kuratowski's theorem states that

a finite graph is planar if and only if it contains no subgraph homeomorphic to K5 (complete graph on five vertices) or K3,3 (complete bipartite graph on two partitions of size three). Vijay Vazirani generalized the FKT algorithm to graphs that do not contain a subgraph homeomorphic to K3,3. More generally the complexity of counting perfect matchings has been completely characterized for families of graphs that are closed under graph minors. There exists a family of graphs, the shallow vortex grids, such that for a minor-closed family that does not include all shallow vortex grids, this counting problem is polynomially solvable. But for a minor-closed family that includes all shallow vortex grids, such as the K8-minor-free graphs, the problem of counting perfect matchings is #P-complete. Since counting the number of perfect matchings in a general graph is also #P-complete, some restriction on the input graph is required unless FP, the function version of P, is equal to #P. Counting matchings, which is known as the Hosoya index, is also #P-complete even for planar graphs.

Applications The FKT algorithm has seen extensive use in holographic algorithms on planar graphs via matchgates. For example, consider the planar version of the ice model mentioned above, which has the technical name #PL-3-NAE-SAT (where NAE stands for "not all equal"). Valiant found a polynomial time algorithm for this problem which uses matchgates.

References

External links More history, information, and examples can be found in chapter 2 and section 5.3.2 of Dmitry Kamenetsky's PhD thesis

Worked examples

Example 1 — a first encounter with FKT algorithm

Start with the simplest possible case. Write down what FKT algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to FKT algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about FKT algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of FKT algorithm

In research
FKT algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses FKT algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
FKT algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Graph algorithms, Planar graphs, so understanding it makes those chapters shorter.
In everyday life
Look for FKT algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “FKT algorithm” →

How to study FKT algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what FKT algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain FKT algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is FKT algorithm in simple terms?

The Fisher–Kasteleyn–Temperley (FKT) algorithm, named after Michael Fisher, Pieter Kasteleyn, and Neville Temperley, counts the number of perfect matchings in a planar graph in polynomial time. This same task is #P-complete for general graphs.

Why does FKT algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study FKT algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on FKT algorithm.

Tags

  • Graph algorithms
  • Planar graphs

Keep exploring