Optimal General Matchings
Given a graph $G=(V,E)$ and for each vertex $v \in V$ a subset $B(v)$ of the set $\{0,1,\ldots, d_G(v)\}$ a $B$-matching of $G$ is any set $F \subseteq E$ such that $d_F(v) \in B(v)$ for each vertex $v$. The general matching problem asks the existence of a $B$-matching in a given graph. A set $B(v)$ is said to have a {\em gap of length} $p$ if there exists a number $k \in B(v)$ such that $k+1, \ldots, k+p \notin B(v)$ and $k+p+1 \in B(v)$. Without any restrictions the general matching problem is NP-complete. However, if no set $B(v)$ contains a gap of length greater than $1$, then the problem can be solved in polynomial time and Cornuejols \cite{Cor} presented an algorithm for finding a $B$-matching, if it exists. In this paper we consider a version of the general matching problem, in which we are interested in finding a $B$-matching having a maximum (or minimum) number of edges. We present the first polynomial time algorithm for the maximum weight $B$-matching for the case when no set $B(v)$ contains a gap of length greater than $1$.