1、%function f,s=maxflow(startp,endp,c)%c%(i,j)10(j,i)0%function f,s=maxflow(startp,endp,c)n=length(c);f=zeros(size(c);l=zeros(1,n);d=zeros(1,n);examine=zeros(1,n);l(startp)=0.5;d(startp)=inf;while 1ifexam=0;ifl=0;for i=1:nif l(i)=0ifl=ifl+1;if examine(i)=1ifexam=ifexam+1;endendendif ifl=ifexambreak;en
2、dfor i=1:nif l(i)=0endendfor j=1:nif c(i,j)=0if f(i,j)0d(j)=min(d(i),f(i,j);endendendexamine(i)=1;if l(endp)=0j=endp;while 1if l(j)=0.5if l(j)0i=l(j);f(i,j)=f(i,j)+d(endp);j=i;endif l(j)0i=-l(j);f(j,i)=f(j,i)-d(endp);j=i;endelsel=zeros(1,n);break;endendl(startp)=0.5;d(startp)=inf;examine=zeros(1,n);endends=;ns=0;for i=1:nif l(i)=0ns=ns+1;s(ns)=i;endendfprintf(fn);fprintf(sn);disp(s);