MATLAB Answers


Displaying node name in a network graph

Asked by Mariya B on 14 Apr 2016
Latest activity Commented on by jd net
on 29 Sep 2018
Hello All,
I seem to have an issue in displaying the node names. My code goes as follows:
names = 1:295;
node_names=reshape(cellstr(num2str(names(:))),* size(names)); %%assigning node names
A = sprand( 295, 295, density );%%creating sparse random adjacency matrix
G =graph(A,node_names);
ax=axesm('mercator','MapLatLimit',[40 41],'MapLonLimit',[-74 -73]);
setm(gca, 'origin',[-74.900,-73.750,-73.5340])
Thanks in advance

  1 Comment

is this possible to implement......for PEG algorithm

Sign in to comment.

1 Answer

Answer by Mike Garrity
on 14 Apr 2016
 Accepted Answer

I think that it doesn't label them by default when the number of nodes gets bigger than some number. You can tell it that you really do want them by using the labelnode function.
It does get a bit "busy" though.


Thanks! once again :)
you can try plot(G,'NodeLabelMode','auto') as well

Sign in to comment.