Question: Checking if a sequence is graphical?

If I have a list, how can I write a program to see is that list is graphical? So far I have

graphicalseq := proc (L::list)

local i::integer, N;

N := convert(L, `+`);


if type(N, odd) then print("Sequence is not graphical")


else if numelems(L)-1 < L[1] then print("Sequence is not graphical")
end if;


end if;

end proc;

I know I still have to keep going to determine whether the sequence is graphical, but I'm not sure how.

 I was thinking of trying to somehow use Havel-Hakimi's theorem, but again I'm not sure how. Any hints would be appreciated.  I can't use the is Graph Sequence function

Please Wait...