如果要给邻接矩阵的图画为有向图,则可使用如下程序:
function y=graphy_plot(A,xy,l,p)
% Axyll=0
%l~=0,p
a=-max(abs(xy(:,1)))*1.1;b=max(abs(xy(:,1)))*1.1;
c=-max(abs(xy(:,2)))*1.1;d=max(abs(xy(:,2)))*1.1;
if l==0
gplot(A,xy),axis([a b c d]),hold on,
elseif l~=0
U=[];V=[];X=[];Y=[];
n=length(A(:,1)) ;
for i=1:n
k=find(A(i,~=0);
m=length(k);
if(m~=0)
for j=1:m
u(1)=(xy(k(j),1)-xy(i,1)); v(1)=(xy(k(j),2)-xy(i,2));
u(2)=eps; v(2)=eps; U=[u;U];V=[v;V];
X=[[xy(i,1) xy(k(j),1)];X]; Y=[[xy(i,2) xy(k(j),2)];Y];
end
text(xy(i,1),xy(i,2),['\bullet\leftarrow\fontsize{16}\it{V}',...
num2str(i)]);hold on,
end
end
gplot(A,xy),axis([a b c d]),hold on,
h=quiver(X,Y,U,V,p);set(h,'color','red');hold on,
plot(xy(:,1),xy(:,2),'k.','markersize',12),hold on,
end , hold off作者: 建模迷 时间: 2009-8-28 21:48
很复杂,你一定花了不少心思吧!!!作者: jingxingde 时间: 2010-6-13 17:27
恩 谢谢 学习了 作者: zzx6155 时间: 2014-8-30 01:20
学不会。。。以后再研究