First, I assume that the graph is undirected, edges are going both ways, but you might want to change that maybe.
A = zeros(13, 13);
link(1,:)=[1 2];
link(2,:)=[1 3];
link(3,:)=[1 4];
link(4,:)=[2 6];
link(5,:)=[3 6];
link(6,:)=[3 7];
link(7,:)=[4 8];
link(8,:)=[4 9];
link(9,:)=[6 10];
link(10,:)=[7 10];
link(11,:)=[8 11];
link(12,:)=[8 12];
link(13,:)=[9 12];
link(14,:)=[9 13];
link(15,:)=[1 5];
link(16,:)=[5 13];
nlinks = length(link);
inds = sub2ind(size(A), link(:,1), link(:,2))
A(inds) = 1;
A = triu(A, 1);
A = A + A';
theta = linspace(0, 2*pi, nlinks);
x = cos(theta);
y = sin(theta);
gplot(A, [x' y'], 'o-')
hold on
scale = 1.07;
for i = 1:size(A,1)
if sum(A(i,:)) > 0
text(scale*x(i), scale*y(i), num2str(i), 'fontsize', 16,...
'HorizontalAlignment', 'center')
end
end
axis([-1.1,1.1,-1.1,1.1])
So, I first create a adjacency matrix from the links you provided. Then I give gplot the coordinates to the node positions using a circle, that just seemed to work in this case. If you wish to place the nodes in another position you can give other coordinates to x and y.
I also added text at the node positions so you can easily check that it is correct.
Best Answer