Manuscript Offprint
arXiv:2610.29817Pfaffian Recognition is in coRP
Abstract
A graph is called Pfaffian if it admits a Pfaffian orientation. The Pfaffian recognition problem asks whether a given graph is Pfaffian. In 1989, Vazirani and Yannakakis showed that this problem is polynomial time equivalent to testing whether a prescribed orientation is Pfaffian, and that the problem belongs to coNP. The complexity of the problem for general graphs has remained open since then. For bipartite graphs, polynomial time recognition algorithms were obtained by Robertson, Seymour, and Thomas in 1999, and independently by McCuaig in 2004. We show that testing whether a given orientation is Pfaffian can be reduced to polynomial identity testing. This gives a randomized polynomial time algorithm for Pfaffian recognition on general graphs, placing the problem in coRP.
1 Introduction
Counting perfect matchings is a central problem in combinatorics and the theory of counting problems [6, 8]. A perfect matching of a graph is a set of pairwise disjoint edges that covers every vertex exactly once. Although the existence of a perfect matching can be decided in polynomial time [3], counting the number of perfect matchings is much harder. Valiant proved that the problem is #P-complete, even for bipartite graphs [17].
All graphs considered in this paper are finite and simple. For a graph , we write and for its vertex and edge sets, and for its set of perfect matchings. Let have vertices, and assign a variable to each edge . The perfect matching polynomial of is
Setting all variables gives the number of perfect matchings of G.
A classical algebraic approach to counting perfect matchings uses Pfaffian orientations. An orientation of is a choice of direction for each edge. Fix an ordering of the vertices of . If , we write and interchangeably for the corresponding edge variable. The weighted skew adjacency matrix of with respect to , denoted by , is the matrix whose -entry is
Let be a perfect matching of , and suppose that in the orientation , the tail and the head of are and , respectively. The permutation of in , denoted by , is
The sign of M with respect to D, denoted by , is the sign of . This value is independent of the order in which the edges of M are enumerated. The Pfaffian of is
It contains exactly the same monomials as PerfMatch(G), with signs determined by the orientation. If all perfect matchings have the same sign with respect to D, then
Such an orientation is called a Pfaffian orientation, and a graph admitting one is called Pfaffian. Once a Pfaffian orientation is known, the number of perfect matchings can be computed in polynomial time using Cayley's identity [1],
which holds for every skew symmetric matrix A of even order.
Pfaffian orientations originate in Kasteleyn's work on the dimer problem. In 1967, Kasteleyn showed that every planar graph admits a Pfaffian orientation and gave a polynomial time algorithm for finding one, yielding a polynomial time algorithm for counting perfect matchings in planar graphs [6]. In 1975, Little [7] proved that a bipartite graph with a perfect matching is Pfaffian if and only if it contains no even subdivision of whose deletion leaves a graph with a perfect matching. In 1999, Robertson, Seymour, and Thomas [14], and independently McCuaig in 2004 [10], obtained structural characterizations which lead to polynomial time algorithms for deciding whether a bipartite graph is Pfaffian.
Considerable progress has also been made for some nonbipartite graph classes. Fischer and Little [4] characterized Pfaffian near-bipartite graphs, which are nonbipartite matching-covered graphs that become bipartite and remain matching covered after deleting two specific edges. Miranda and Lucchesi [11] later gave a polynomial time Pfaffian recognition algorithm for weakly near-bipartite graphs, a larger class that includes near-bipartite graphs. Carvalho, Lucchesi, and Murty [2] extended Little's characterization to solid matching-covered graphs, a class that includes bipartite matching-covered graphs.
For general graphs, however, the problem has proved much more difficult. Norine and Thomas [13] constructed an infinite family of minimal non-Pfaffian graphs with respect to matching minors, showing that the forbidden obstruction characterization for bipartite graphs does not extend directly to general graphs. Despite the progress on special graph classes, the existence of a polynomial time algorithm for recognizing general Pfaffian graphs remained open; see [16, 9].
A major insight into the Pfaffian recognition problem came from Vazirani and Yannakakis in 1989 [18]. Given a graph G, they construct in polynomial time an orientation such that G admits a Pfaffian orientation if and only if is Pfaffian. Thus, the recognition problem reduces to testing whether this one prescribed orientation is Pfaffian. Using this reduction, they also showed that Pfaffian graph recognition belongs to coNP. Recall that a decision problem is in coNP if every no instance has a polynomial-size certificate that can be verified in polynomial time. If two perfect matchings have different signs with respect to a given orientation, they certify that the orientation is not Pfaffian. Such a pair can be checked in polynomial time. Hence, when G is not Pfaffian, two perfect matchings of different signs in give such a certificate.
However, testing whether a given orientation is Pfaffian is not straightforward, since a graph may have exponentially many perfect matchings. In this paper, we give a randomized polynomial time algorithm for this problem using an algebraic approach, establishing the following result.
Theorem 1.1. Pfaffian graph recognition is in coRP.
Recall that a decision problem belongs to coRP if there is a randomized polynomial time algorithm that always accepts yes instances and rejects no instances with probability at least 1/2. For Pfaffian recognition, given a graph G, we first use the reduction of Vazirani and Yannakakis to construct the orientation . We then run our randomized test on . If G is Pfaffian, then is Pfaffian and our test always accepts. If G is not Pfaffian, then is non-Pfaffian and our test rejects with probability at least 1/2. Repeating the test independently reduces the probability of error exponentially.
The proof reduces testing a prescribed orientation to polynomial identity testing. Given G and an orientation D, we define a polynomial such that
The polynomial records the perfect matchings whose sign is opposite to that of a fixed perfect matching. We show how to evaluate in polynomial time using determinants of principal submatrices of the Tutte matrix. We further show that one randomized trial for testing a given orientation can be implemented using field operations.
The rest of the paper is organized as follows. In Section 2 we study the signs of perfect matchings and define the polynomial used in the algorithm. In Section 3 we use this polynomial to test whether an orientation is Pfaffian and thus obtain the recognition algorithm. In Section 4 we give a faster way to evaluate the polynomial and obtain a randomized test for a given orientation using field operations.
2.1 Signs of perfect matchings
We use to record parity, with 0 representing even parity and 1 representing odd parity. For an edge , with , say that is backward in if it is oriented from to . For a perfect matching , let be the parity of the number of backward edges in .
Two vertex disjoint edges and , written with and , cross if their endpoints alternate, that is, if or . For a perfect matching , let be the parity of the number of crossing pairs in . The following sign formula also appears in Norine [12].
Lemma 2.1. For every perfect matching M,
Proof. For each edge of , write its endpoints as with , and order the edges so that . Consider the permutation
Fix . Since , the only possible inversions involving the endpoints of the two edges and come from . If , there are no such inversions. If , there is exactly one inversion, while if , there are two. Thus the number of inversions contributed by this pair of edges is odd exactly when
which is exactly when the two edges cross. Therefore the parity of the total number of inversions of is , and hence
To obtain the oriented order defining , we swap the two endpoints of each backward edge. Each such swap changes the sign by a factor of -1. Therefore
2.2 The wrong sign polynomial
Assume that has a perfect matching, and fix one such matching . Put . By Lemma 2.1, a perfect matching has sign opposite to exactly when
Let , where the are variables over a finite field of characteristic two. Define
The polynomial depends on the choice of F. Since we fix F throughout, we write without mentioning F explicitly.
Proposition 2.2. The orientation D is Pfaffian if and only if .
Proof. The monomials of are in one to one correspondence with the perfect matchings whose sign differs from that of . Since is itself a perfect matching, is identically zero exactly when every perfect matching has the same sign as , which is exactly when is Pfaffian.
To obtain an efficient expression for , we use the Tutte matrix. The Tutte matrix of , denoted by , is the skew symmetric matrix defined by
Write . For an edge , let denote the principal submatrix obtained by deleting rows and columns . For two vertex disjoint edges and , let denote the principal submatrix obtained by deleting rows and columns .
Let be the set of backward edges of , and let be the set of unordered pairs of vertex disjoint edges which cross in the fixed vertex ordering. The next identity expresses in terms of principal minors of the Tutte matrix.
Lemma 2.3. Over every field of characteristic two,
Proof. In characteristic two, , so all terms in the Pfaffian expansion have positive signs. Thus
In characteristic two, squaring both sides gives
By Cayley's identity, , and hence
The same argument applies to principal submatrices. Let , and let denote the graph obtained by deleting the vertices and . Since is the Tutte matrix of ,
Every perfect matching of extends uniquely to a perfect matching of containing , so
Likewise, for two vertex disjoint edges and ,
Fix a perfect matching and consider the coefficient of on the right hand side of (1). The term det contributes . The second sum contributes once for each backward edge in , and the third once for each crossing pair in . Its coefficient is therefore
By Lemma 2.1, this equals 1 exactly when , and equals 0 otherwise. This is precisely the coefficient of the same monomial in .
3 Randomized Pfaffian recognition
In this section, we use the determinant identity to evaluate in polynomial time and, together with polynomial identity testing, obtain a randomized test for a prescribed orientation.
3.1 Testing Pfaffianness of an orientation
We use the following standard form of the Schwartz-Zippel lemma [15, 19].
Lemma 3.1 (Schwartz-Zippel). Let be a nonzero polynomial of total degree at most , and let be finite. If are chosen independently and uniformly from , then
Theorem 3.2. There is a randomized polynomial time algorithm which, given a graph G and an orientation D, always accepts if D is Pfaffian and rejects with probability at least 1/2 if D is non-Pfaffian.
Proof. First check whether has a perfect matching. If it has none, then is trivially Pfaffian, so we accept. Otherwise, find a perfect matching and consider the polynomial defined above.
Choose a field of characteristic two, where is the smallest power of 2 satisfying . Then , and since , the basic field operations in can be carried out in polynomial time. The randomized algorithm proceeds as follows.
-
For each edge , choose independently and uniformly at random.
-
Evaluate using Lemma 2.3.
-
Reject if , and accept otherwise.
If is Pfaffian, then by Proposition 2.2, so the algorithm always accepts. If is non-Pfaffian, then is a nonzero polynomial of degree . By Lemma 3.1,
A non-Pfaffian orientation is therefore rejected with probability at least 1/2. By Lemma 2.3, evaluating requires only polynomially many determinant computations on matrices of order at most 2n, so the algorithm runs in polynomial time.
Repeating the test independently r times reduces the error probability exponentially. If D is Pfaffian, every trial accepts, so the repeated test always accepts. If D is non-Pfaffian, each trial accepts with probability at most 1/2. Therefore the probability that all r independent trials accept is at most . Thus, by repeating the test, the probability of incorrectly accepting a non-Pfaffian orientation can be made arbitrarily small.
3.2 Pfaffian graph recognition
We use the reduction of Vazirani and Yannakakis [18, Theorem 3.1]. Given a graph G with a perfect matching, their reduction constructs in polynomial time an orientation such that G admits a Pfaffian orientation if and only if is Pfaffian.
Proof of Theorem 1.1. If has no perfect matching, then is trivially Pfaffian. Otherwise, construct using the reduction of Vazirani and Yannakakis and apply Theorem 3.2. If admits a Pfaffian orientation, then is Pfaffian, so the algorithm always accepts. If does not admit a Pfaffian orientation, then is non-Pfaffian and is rejected with probability at least 1/2.
4 Efficient evaluation of the wrong sign polynomial
We now show that whenever is invertible, can be evaluated using field operations. The main idea is to compute the required principal minors from a single matrix inverse.
We use Jacobi's complementary minor identity [5]. For an invertible matrix indexed by and a subset ,
where denotes the principal submatrix of A with rows and columns indexed by X.
Let be a point over a field of characteristic two, and write . Set whenever . Suppose that is invertible, and write .
We first note that both and its inverse are alternating. Over a field of characteristic two, an alternating matrix is a symmetric matrix with zero diagonal. For any alternating matrix and any vector , we have
since and . By definition, is alternating. In characteristic two, symmetric and skew-symmetric matrices are the same, so . Hence . Thus is also symmetric. To see that has zero diagonal, let be the vector of length with 1 in position and 0 elsewhere. Then
where the last equality follows since is alternating. Hence has zero diagonal and is therefore alternating. For an edge , Jacobi's identity gives
Similarly, for two vertex disjoint edges and , Jacobi's identity gives
The last equality follows since the determinant of an alternating matrix of even order is the square of its Pfaffian. Define
Lemma 4.1. If is invertible, then .
Proof. Substituting (2) and (3) into (1), we obtain
Taking common gives
Since squaring distributes over sums in characteristic two and , the expression in parentheses is exactly by (4). Therefore, .
Lemma 4.2. If is invertible, then can be evaluated using field operations.
Proof. The determinant and inverse of can be computed by Gaussian elimination using field operations. By Lemma 4.1, it is enough to show that can be computed within the same bound. The constant term and the sum over take only operations. The only nontrivial part is the sum over crossing pairs,
Every pair of crossing edges can be written uniquely as , where . A direct computation of would therefore use four nested loops, one for each of , and would take operations. We show how to avoid the loop over . Using the order , we can rewrite as
For fixed , the factors which do not depend on can be taken outside the innermost sum. Hence
For fixed j, the inner sums can be updated efficiently as k increases. Set S = 0. For each j, perform the following steps.
-
Set for every vertex .
-
Process in increasing order. For each such :
(a) For each , set
(b) After all have been processed, set for every vertex .
We now show that the above procedure computes exactly S. Before processing a given k, the value is
Thus , , and are exactly the three inner sums appearing in the expression for . Therefore the update of adds the contribution of all choices for the fixed . After processing , the update adds the new term corresponding to . Hence the same identity for holds for the next value of . So, as , , and run through all possible choices, we add exactly all terms with . These are exactly the terms in the sum defining . Hence the procedure computes .
We now count the number of field operations. For each fixed pair , the loop over takes field operations. Updating for all vertices also takes field operations. Since there are choices of , the total number of field operations is
Thus , and hence , can be computed using field operations. By Lemma 4.1, the same bound holds for evaluating .
Corollary 4.3. Let G be a graph with a perfect matching, and let D be an orientation of G. There is a randomized test for whether D is Pfaffian using field operations per trial. The test always accepts if D is Pfaffian and rejects with probability at least 1/2 otherwise.
Proof. Let , and let be the smallest power of two satisfying . Choose uniformly at random. We use the following test.
-
If is singular, accept.
-
Otherwise, compute . Reject if , and accept otherwise.
If is Pfaffian, then for every . If , the test accepts. Otherwise, is invertible, and by Lemma 4.1,
Since , we have , so the test also accepts in this case. Hence the test always accepts when is Pfaffian.
Now suppose that is non-Pfaffian. Then is a nonzero polynomial of degree . Since has a perfect matching, is also a nonzero polynomial of degree . The test can accept only if or . By the Schwartz-Zippel lemma and the union bound,
Thus, with probability at least , is invertible and . By Lemma 4.1, this implies , and the test detects that is non-Pfaffian.
Testing whether is singular takes field operations. If it is invertible, its inverse and can also be computed within the same bound by the proof of Lemma 4.2. Hence each trial uses field operations.
5 Concluding remarks
We have shown that Pfaffian graph recognition belongs to coRP. For a prescribed orientation, the randomized test can moreover be implemented using field operations. The main remaining question is whether Pfaffian graph recognition can be solved in deterministic polynomial time. A related question is whether the polynomial viewpoint can be used directly at the level of the graph, without first passing through the orientation constructed by Vazirani and Yannakakis. Finally, since coRP coNP, a coNP-completeness result for Pfaffian graph recognition would imply coNP = coRP and hence NP = RP. Thus, unless NP = RP, Pfaffian graph recognition is not coNP-complete.
AI Disclosure
We obtained the mathematical results independently. ChatGPT (OpenAI) was used for minor language and grammar editing of the manuscript. We take full responsibility for the content.
References
[1] Arthur Cayley. Sur les déterminants gauches. (suite du mémoire t. xxxii. p. 119). Journal für die reine und angewandte Mathematik, 38:93–96, 1849. doi:10.1515/crll.1849.38.93.
[2] Marcelo H. de Carvalho, Cláudio L. Lucchesi, and U. S. R. Murty. A generalization of Little's theorem on Pfaffian orientations. Journal of Combinatorial Theory, Series B, 102(6):1241–1266, 2012. doi:10.1016/j.jctb.2012.07.004.
[3] Jack Edmonds. Paths, trees, and flowers. Canadian Journal of Mathematics, 17:449–467, 1965. doi:10.4153/CJM-1965-045-4.
[4] Ilse Fischer and Charles H. C. Little. A characterisation of Pfaffian near bipartite graphs. Journal of Combinatorial Theory, Series B, 82(2):175–222, 2001. doi:10.1006/jctb.2000.2025.
[5] Roger A. Horn and Charles R. Johnson. Matrix Analysis. Cambridge University Press, Cambridge, 2nd edition, 2013. doi:10.1017/CB09781139020411.
[6] P. W. Kasteleyn. Graph theory and crystal physics. In Frank Harary, editor, Graph Theory and Theoretical Physics, pages 43–110. Academic Press, London, 1967.
[7] C. H. C. Little. A characterization of convertible (0,1)-matrices. Journal of Combinatorial Theory, Series B, 18(3):187–208, 1975. doi:10.1016/0095-8956(75)90048-9.
[8] László Lovász and Michael D. Plummer. Matching Theory, volume 121 of North-Holland Mathematics Studies. North-Holland, Amsterdam, 1986.
[9] Cláudio L. Lucchesi and U. S. R. Murty. Perfect Matchings: A Theory of Matching Covered Graphs, volume 31 of Algorithms and Computation in Mathematics. Springer, Cham, 2024. doi:10.1007/978-3-031-47504-7.
[10] William McCuaig. Pólya's permanent problem. The Electronic Journal of Combinatorics, 11(1):R79, 2004. doi:10.37236/1832.
[11] Alberto Alexandre Assis Miranda and Cláudio Leonardo Lucchesi. Recognizing near-bipartite Pfaffian graphs in polynomial time. Discrete Applied Mathematics, 158(12):1275–1278, 2010. doi:10.1016/j.dam.2009.01.008.
[12] Serguei Norine. Pfaffian graphs, T-joins and crossing numbers. Combinatorica, 28(1):89–98, 2008. doi:10.1007/s00493-008-2150-2.
[13] Serguei Norine and Robin Thomas. Minimally non-Pfaffian graphs. Journal of Combinatorial Theory, Series B, 98(5):1038–1055, 2008. doi:10.1016/j.jctb.2007.12.005.
[14] Neil Robertson, Paul D. Seymour, and Robin Thomas. Permanents, Pfaffian orientations, and even directed circuits. Annals of Mathematics, 150(3):929–975, 1999. doi:10.2307/121059.
[15] Jacob T. Schwartz. Fast probabilistic algorithms for verification of polynomial identities. Journal of the ACM, 27(4):701–717, 1980. doi:10.1145/322217.322225.
[16] Robin Thomas. A survey of Pfaffian orientations of graphs. In Marta Sanz-Solé, Javier Soria, Juan Luis Varona, and Joan Verdera, editors, Proceedings of the International Congress of Mathematicians, Madrid 2006, Volume III, pages 963–984, Zürich, 2006. European Mathematical Society. doi:10.4171/022-3/47.
[17] Leslie G. Valiant. The complexity of computing the permanent. Theoretical Computer Science, 8(2):189–201, 1979. doi:10.1016/0304-3975(79)90044-6.
[18] Vijay V. Vazirani and Mihalis Yannakakis. Pfaffian orientations, 0–1 permanents, and even cycles in directed graphs. Discrete Applied Mathematics, 25(1–2):179–190, 1989. doi:10.1016/0166-218X(89)90053-X.
[19] Richard E. Zippel. Probabilistic algorithms for sparse polynomials. In Edward W. Ng, editor, Symbolic and Algebraic Computation: EUROSAM '79, volume 72 of Lecture Notes in Computer Science, pages 216–226, Berlin, Heidelberg, 1979. Springer. doi:10.1007/3-540-09519-5_73.