1. 程式人生 > >如何用matlab畫出有向圖(帶箭頭)

如何用matlab畫出有向圖(帶箭頭)

close all,clear,clc;

cm =[ 

     0     10     0     18     0     0     0;

     0     0      0     0      8     0     0;

     25    0      0     0      0     9     0;

     0     0      0     0      0     0     0;

     0     0      13    0      0     0     0;

     0     0      0     30     0     0     0;

     0     0      0     0      15    12    0;

     ];

 IDS={'A','B','C','D','E','F','G'};

 bg=biograph(cm,IDS);

 set(bg.nodes,'shape','circle','color',[1,1,1],'lineColor',[0,0,0]);

 set(bg,'layoutType','radial');

 bg.showWeights='on';

 set(bg.nodes,'textColor',[0,0,0],'lineWidth',2,'fontsize',9);

 set(bg,'arrowSize',12,'edgeFontSize',9);

 get(bg.nodes,'position')

 view(bg);

 help biograph