Given a graph G=(V,E) and for each vertex v∈V a subset B(v) of the
set {0,1,…,dG(v)}, where dG(v) denotes the degree of vertex v
in the graph G, a B-factor of G is any set F⊆E such that
dF(v)∈B(v) for each vertex v, where dF(v) denotes the number of
edges of F incident to v. The general factor problem asks the existence of
a B-factor in a given graph. A set B(v) is said to have a {\em gap of
length} p if there exists a natural number k∈B(v) such that k+1,…,k+p∈/B(v) and k+p+1∈B(v). Without any restrictions the
general factor 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-factor, if
it exists. In this paper we consider a weighted version of the general factor
problem, in which each edge has a nonnegative weight and we are interested in
finding a B-factor of maximum (or minimum) weight. In particular, this
version comprises the minimum/maximum cardinality variant of the general factor
problem, where we want to find a B-factor having a minimum/maximum number of
edges.
We present an algorithm for the maximum/minimum weight B-factor for the
case when no set B(v) contains a gap of length greater than 1. This also
yields the first polynomial time algorithm for the maximum/minimum cardinality
B-factor for this case