2014-03-26 111 views
1

基本上,我开始学习图论,并且我想绘制一个无向图,并且在Matlab中找不到具体实现的任何地方。我有以下矩阵:Matlab - 绘制图形的顶点和边线

G = [0, 0, 1; 0, 0, 1; 1, 1, 0]; 

我怎么会因此绘制这一点,得到下面的结果?

enter image description here

回答

1

您可以使用gplot,其中只指定邻接矩阵和节点的坐标。

G = [0, 0, 1; 0, 0, 1; 1, 1, 0]; 
xy = [1 1; 0 0 ; 2 0]; 
gplot(G,xy,'-o'); 
axis([-1 3 -1 3]) % To Centre the Figure 

如果你想使它看起来爱好者,你可以用厚度和东西发挥:

hline = findobj(gcf, 'type', 'line'); 
set(hline,'LineWidth',3) 

其中给出:

enter image description here 注意:您粘贴为图形样本不符合您提供的矩阵。

+0

那么'xy'图表上的位置? – Phorce

+0

@ user1326876。对。 – Nitish

相关问题