Given a $0$-$1$ square matrix $A$, when can some of the $1$’s be changed to $-1$’s in such a way that the permanent of $A$ equals the determinant of the modified matrix? When does a real square matrix have the property that every real matrix with the same sign pattern (that is, the corresponding entries either have the same sign or are both zero) is nonsingular? When is a hypergraph with $n$ vertices and $n$ hyperedges minimally nonbipartite? When does a bipartite graph have a “Pfaffian orientation”? Given a digraph, does it have no directed circuit of even length? Given a digraph, does it have a subdivision with no even directed circuit?
It is known that all of the above problems are equivalent. We prove a structural characterization of the feasible instances, which implies a polynomial-time algorithm to solve all of the above problems. The structural characterization says, roughly speaking, that a bipartite graph has a Pfaffian orientation if and only if it can be obtained by piecing together (in a specified way) planar bipartitte graphs and one sporadic nonplanar bipartite graph.