MATLABG=(V,E,F)Warshall-FloydA=(aij)nnG=(V,E,F),vivjEaij=F(vivj),aii=0,aij=+(ij),dijvivj,rijvivj..i,j,dij=aij,rij=j.k=1.dij,rij.i,j,dik+dkjdij,dij=dik+dkj,rij=k,..dii0,vi,;k=n;k=k+1,.rij.16-4.Warshall-Floyd,MATLABn=8;A=[0281InfInfInfInf206Inf1InfInfInf8607512Inf1Inf70InfInf9InfInf15Inf03Inf8InfInf1Inf3046InfInf29Inf403InfInfInfInf8630];%MATLAB,InfD=A;%for(i=1:n)for(j=1:n)R(i,j)=j;end;end%for(k=1:n)for(i=1:n)for(j=1:n)if(D(i,k)+D(k,j)D(i,j))D(i,j)=D(i,k)+D(k,j);%dijR(i,j)=k;end;end;end%rijk%D%R%pd=0;fori=1:n%if(D(i,i)0)pd=1;break;end;end%viif(pd)break;end%,end%6-4KruskalG,T(,),q(T)=p(G)-1,T=G-1.KruskalMATLABn=8;A=[0281000020601000860751201070009001500308001030460029040300008630];k=1;%Afor(i=1:n-1)for(j=i+1:n)%Aif(A(i,j)0)x(k)=A(i,j);%xAkk=1;%for(s=1:k-1)if(x(k)==x(s))kk=0;break;end;end%k=k+kk;end;end;endk=k-1%Afor(i=1:k-1)for(j=i+1:k)%xif(x(j)x(i))xx=x(j);x(j)=x(i);x(i)=xx;end;end;endT(n,n)=0;%T0q=0;%Tfor(s=1:k)if(q==n)break;end%T,for(i=1:n-1)for(j=i+1:n)if(A(i,j)==x(s))T(i,j)=x(s);T(j,i)=x(s);%TTT=T;%Twhile(1)pd=1;%TTfor(y=1:n)kk=0;for(z=1:n)if(TT(y,z)0)kk=kk+1;zz=z;end;end%TTif(kk==1)TT(y,zz)=0;TT(zz,y)=0;pd=0;end;end%TTif(pd)break;end;end%TTpd=0;%TTfor(y=1:n-1)for(z=y+1:n)if(TT(y,z)0)pd=1;break;end;end;endif(pd)T(i,j)=0;T(j,i)=0;%TTelseq=q+1;end;end;end;end;endT%T,G(),GM,XM,M-.M-,M;M-P,PMMMM1,M1.G=(X,Y,E),X={x1,x2,,xn},Y={y1,y2,,yn}.GM(eE,M={e}).S=f,T=f,.MX\S,MG.,MuX\S,S=S{u},.N(S)={v|uS,uvE}.N(S)=T,.yN(S)\T.yM,,.xyM,S=S{x},T=T{y},.u-yM-,P,M=MP,.MP=MP\MP,.M-P,XM(M)0*,.X*,MG.X*xi,xi*,.Gxiyj(xiyjE),yj,,.xiyji.yjM,,.Myjixi,xikyk,,yts0xs,M-xsytxiyj,P={xsyt,,xiyj},MMP,.yjMxk(xkyjM),j*,.16-9G.MATLABm=5;n=5;A=[0110011011011000110000011];M(m,n)=0;for(i=1:m)for(j=1:n)if(A(i,j))M(i,j)=1;break;end;end%Mif(M(i,j))break;end;end%Mwhile(1)for(i=1:m)x(i)=0;end%X*for(i=1:n)y(i)=0;end%Y*for(i=1:m)pd=1;%XMfor(j=1:n)if(M(i,j))pd=0;end;endif(pd)x(i)=-n-1;end;end%XM0*,n+10,*pd=0;while(1)xi=0;for(i=1:m)if(x(i)0)xi=i;break;end;end%X*,X*xiif(xi==0)pd=1;break;end%X*,x(xi)=x(xi)*(-1);%xi*k=1;for(j=1:n)if(A(xi,j)&y(j)==0)y(j)=xi;yy(k)=j;k=k+1;end;end%xiyjiif(k1)k=k-1;for(j=1:k)pdd=1;for(i=1:m)if(M(i,yy(j)))x(i)=-yy(j);pdd=0;break;end;end%yjMxk(xkyjM),j*if(pdd)break;end;endif(pdd)k=1;j=yy(j);%yjMwhile(1)P(k,2)=j;P(k,1)=y(j);j=abs(x(y(j)));%Myj,if(j==n+1)break;end%X0,M-Pk=k+1;endfor(i=1:k)if(M(P(i,1),P(i,2)))M(P(i,1),P(i,2))=0;%MPelseM(P(i,1),P(i,2))=1;end;end%PMMbreak;end;end;endif(pd)break;end;end%X*,M%M,6-9G=(X,Y,E,F),L,.,,0)(},|)(max{)(YyXxyLYyxyFxL∈∈⎩⎨⎧=∈=MGL.XM,M.MuX,S={u},T=f,.NL(S)={v|uS,uvEL}.NL(S)=T,GL,..,aL=min{L(x)+L(y)-F(xy)|xS,yY\T}.H(v)=,,),(,)(,)(TvSvvLavLavLLL∈∈⎪⎩⎪⎨⎧+-L=H,GL=GH,GLM,.yNL(S)\T,yM,.,.xyM,S=S{x},T=T{y},.GLu-yM-,P,M=MP,.MATLABn=4;A=[4551224642335021];for(i=1:n)L(i,1)=0;L(i,2)=0;endfor(i=1:n)for(j=1:n)if(L(i,1)A(i,j))L(i,1)=A(i,j);end;%LM(i,j)=0;end;endfor(i=1:n)for(j=1:n)%Glif(L(i,1)+L(j,2)==A(i,j))Gl(i,j)=1;elseGl(i,j)=0;end;end;endii=0;jj=0;for(i=1:n)for(j=1:n)if(Gl(i,j))ii=i;jj=j;break;end;endif(ii)break;end;end%GlMM(ii,jj)=1;for(i=1:n)S(i)=0;T(i)=0;NlS(i)=0;endwhile(1)for(i=1:n)k=1;.for(j=1:n)if(M(i,j))k=0;break;end;endif(k)break;end;endif(k==0)break;end%M,S(1)=i;jss=1;jst=0;%S={xi},T=ϕwhile(1)jsn=0;for(i=1:jss)for(j=1:n)if(Gl(S(i),j))jsn=jsn+1;NlS(jsn)=j;%NL(S)={v|uS,uvEL}for(k=1:jsn-1)if(NlS(k)==j)jsn=jsn-1;end;end;end;end;endif(jsn==jst)pd=1;%NL(S)=T?for(j=1:jsn)if(NlS(j)~=T(j))pd=0;break;end;end;endif(jsn==jst&pd)al=Inf;%NL(S)=T,al,Inffor(i=1:jss)for(j=1:n)pd=1;for(k=1:jst)if(T(k)==j)pd=0;break;end;endif(pd&alL(S(i),1)+L(j,2)-A(S(i),j))al=L(S(i),1)+L(j,2)-A(S(i),j);end;end;endfor(i=1:jss)L(S(i),1)=L(S(i),1)-al;end%for(j=1:jst)L(T(j),2)=L(T(j),2)+al;end%for(i=1:n)for(j=1:n)%GLif(L(i,1)+L(j,2)==A(i,j))Gl(i,j)=1;elseGl(i,j)=0;endM(i,j)=0;k=0;end;endii=0;jj=0;for(i=1:n)for(j=1:n)if(Gl(i,j))ii=i;jj=j;break;end;endif(ii)break;end;end%GlMM(ii,jj)=1;breakelse%NL(S)Tfor(j=1:jsn)pd=1;%yNL(S)\Tfor(k=1:jst)if(T(k)==NlS(j))pd=0;break;end;endif(pd)jj=j;break;end;endpd=0;%yMfor(i=1:n)if(M(i,NlS(jj)))pd=1;ii=i;break;end;endif(pd)jss=jss+1;S(jss)=ii;jst=jst+1;T(jst)=NlS(jj);%S=S{x},T=T{y}else%GlM-,Mfor(k=1:jst)M(S(k),T(k))=1;M(S(k+1),T(k))=0;endif(jst==0)k=0;endM(S(k+1),NlS(jj))=1;break;end;end;end;endMaxZjpp=0;for(i=1:n)for(j=1:n)if(M(i,j))MaxZjpp=MaxZjpp+A(i,j);end;end;endM%MMaxZjpp%M,f,Ford--Fulkersonvs(+,+),ds=+.x,xy,yxE,fyx0,dy=min{fyx,dx},y(x-,dy).xyE,fxyCxy,dy=min{Cxy-fxy,dx},y(x+,dy).vt.vt,,;vt,,f.d=dvt,u=vt.u(v+,du),fvu+dfvu;u(v-,du),fvu-dfvu.v=vs,;u=v,.,S,(S,Sc),Wf=C(S,Sc).16-19.Ford--FulkersonMATLABn=8;C=[0543000000005300000003200000002000000004000000030000000500000000];%for(i=1:n)for(j=1:n)f(i,j)=0;end;end%ffor(i=1:n)No(i)=0;d(i)=0;end%No,d6-19while(1)No(1)=n+1;d(1)=Inf;%vswhile(1)pd=1;%for(i=1:n)if(No(i))%vifor(j=1:n)if(No(j)==0&f(i,j)C(i,j))%vj,vivjNo(j)=i;d(j)=C(i,j)-f(i,j);pd=0;if(d(j)d(i))d(j)=d(i);endelseif(No(j)==0&f(j,i)0)%vj,vjviNo(j)=-i;d(j)=f(j,i);pd=0;if(d(j)d(i))d(j)=d(i);end;end;end;end;endif(No(n)|pd)break;end;end%vt,if(pd)break;end%vt,f,dvt=d(n);t=n;%,dvtwhile(1)if(No(t)0)