MATLAB: How to set colorspace of line in special code of graph

MATLAB

G = graph(index_s,index_t,weighted);
p1 = plot(G,'XData',X1,'YData',Y1);
What I want to change is the color of lines. Have anyone can help me ?

Best Answer

There's no need to create additional lines to change the colors of lines in a GraphPlot. highlight them instead.
% Create graph
s = [1 1 1 2 2 3 3 4 5 5 6 7];
t = [2 4 8 3 7 4 6 5 6 8 7 8];
G = graph(s,t);
% Plot the graph with blue edges
h = plot(G, 'EdgeColor', 'b');
% Change the EdgeColor, LineWidth, and LineStyle properties of the edge (3, 4)
highlight(h, 3, 4, 'EdgeColor', 'r', 'LineWidth', 6, 'LineStyle', ':')
% Change the Marker and MarkerSize properties of nodes 1, 3, 5, and 7
highlight(h, 1:2:7, 'Marker', '+', 'MarkerSize', 16)