Algorithm for determining if a graph is possible?

Suppose that we have n vertices and m edges, and that the possible degrees of vertices are a or b. If a and b are nonnegative integers less than n, and the system of Diophantine equations, consisting of ax+by=2m and x+y=n, has a nonnegative solution, then does the set of conditions necessary require the existence of such a graph?