How to rename a vertices of agraphs
2 views (last 30 days)
Show older comments
Here is the code that I'm trying to rename graph nodes as a,b,c in output. But it shows error
a=[1 2 3];
b=[3 2 1];
g=graph(a,b);
p=plot(g);
c=[a b c];
p.NodeLabel=[c];
0 Comments
Accepted Answer
KSSV
on 23 Dec 2021
a=[1 2 3];
b=[3 2 1];
g=graph(a,b);
p=plot(g);
L={'a' 'b' 'c'};
p.NodeLabel=L;
0 Comments
More Answers (1)
Shanmugavelan S
on 24 Dec 2021
1 Comment
Steven Lord
on 24 Dec 2021
B = bucky;
g = graph(B(1:20, 1:20));
h = plot(g);
figure
h2 = plot(g);
h2.NodeLabel = string(2:2:40); % or
figure
h3 = plot(g);
h3.NodeLabel = "a" + (1:20);
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!