Displaying node name in a network graph

Hello All,
I seem to have an issue in displaying the node names. My code goes as follows:
density=0.001
names = 1:295;
node_names=reshape(cellstr(num2str(names(:))),* size(names)); %%assigning node names
A = sprand( 295, 295, density );%%creating sparse random adjacency matrix
A=tril(A,-1);
A=A+A.';
G =graph(A,node_names);
ax=axesm('mercator','MapLatLimit',[40 41],'MapLonLimit',[-74 -73]);
setm(gca, 'origin',[-74.900,-73.750,-73.5340])
p=plot(ax,G);
Thanks in advance

1 Kommentar

jd net
jd net am 29 Sep. 2018
is this possible to implement......for PEG algorithm

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Mike Garrity
Mike Garrity am 14 Apr. 2016

1 Stimme

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.
labelnode(p,names,node_names)
It does get a bit "busy" though.

3 Kommentare

Mariya B
Mariya B am 14 Apr. 2016
Thanks! once again :)
Alok
Alok am 1 Jun. 2017
you can try plot(G,'NodeLabelMode','auto') as well
jd net
jd net am 29 Sep. 2018
:)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Networks finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 14 Apr. 2016

Kommentiert:

am 29 Sep. 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by