funcprot(0) function [x]=degreebound1(a) [m,n] = size(a); if m~=n then error("This matrix can not be accepted!"); end; b=degree(a); [i,j]=find(a==0); for k=1:n, cols=j(k==i); if size(cols,2)==n then x=-%inf; return; end; b(k,cols)=-%inf; end; for k=1:n, cols=i(k==j); if size(cols,2)==n then x=-%inf; return; end; b(cols,k)=-%inf; end; maxb=max(b); c=maxb*ones(m,n)-b; f=hungarian(c); x=sum(b(mtlb_logical(sparse([f;1:n]',ones(1,n))))); endfunction function [x]=degreebound2(a) n=size(a,1); d=max(degree(a)); nd=n*d; nd0=n*(d-1); u=zeros(nd,nd); v=zeros(nd,nd); for i=1:nd0, u(i,i+n)=1; end; for i=1:nd0, v(i,i)=1; end; [qs,rs,es]=qr(coeff(a,d)); for j=0:d-1, f=qs'*coeff(a,j)*es; u(nd0+[1:n],j*n+[1:n])=-f(:,:); end; v(nd0+[1:n],nd0+[1:n])=rs(:,:); [alpha,beta]=spec(u,v); x=[nd,size(find(beta<>0),2)]; endfunction