MATLAB: Changing the color of one particular node into different colors

graphgraph theoryhighlightnodecolor

function pt = plot_topology_1(filename)
newfilename = [filename, '.network'];
fileID = fopen(newfilename);
if fileID == -1
error('Author:Function:OpenFile', 'Cannot open file: %s', newfilename);
end
C = textscan(fileID,'%c %d %d %f32 %f32 %f32 %f32 \n','Delimiter',',','HeaderLines',1);
fclose(fileID);
no_of_edges = length(C{1})
final = no_of_edges;
a = C{2};
b = C{3};
edgewidth = C{5};
weights = randi([1 40],1, final);
G = graph(a,b,weights)
aa=incidence(G)
sup=supply_nodes(aa) %function of supply nodes
dem = demand_nodes(aa) %function of demand nodes
col= [0.3 8 12 5];
d=length(col)
i=0;
for i=1:d
if i==1
c='r';
elseif i==2
c='g';
elseif i==3
c='b';
else i==4
c='m';
end
p = plot(G)
highlight(p,sup, c ) % supply node color
highlight(p,dem,'NodeColor','g') %demand node color
end
end
there is only one supply node in this network and is indicated by red color. I want change the supply node color step by step in four diffrerent colors following the some given values. I made an array of 1*4 for four different color. But it shows that Matlab doesn't support the function. Please help me to figure it out.

Best Answer

What is the full and exact text of the error message you receive when you run that code? Include all the text displayed in red, exactly as it's shown in the Command Window. Don't paraphrase or summarize.
You also haven't shown us the functions supply_nodes and demand_nodes.
Finally, you probably don't want to plot the graph multiple times, once per element in your col vector. plot it once then highlight it multiple times (or highlight it with a vector of node IDs to change all those nodes at once.)
Related Question