coloring node and edge of a graph

I have a graph with values assigned to nodes and edges,
t = 1:4;
h = 2:5;
g = graph(t,h);
plot(g)
g.Edges.value = [10; 20; 20; 100];
g.Nodes.value = [0.3; 0.564; 12; 1; 0.005];
I would like to know whether there is an option of coloring the nodes and edges based on the values.

 Accepted Answer

Cris LaPierre
Cris LaPierre on 24 Dec 2018
The highlight function is one way to do this. Check out the examples on this page.

1 Comment

You could try this page as well. Here's a quick mock up
t = 1:4;
h = 2:5;
g = graph(t,h);
p = plot(g);
g.Edges.value = [10; 20; 20; 100];
g.Nodes.value = [0.3; 0.564; 12; 1; 0.005];
g.Nodes.NodeColors = g.Nodes.value;
g.Edges.EdgeColors = g.Edges.value;
p.NodeCData = g.Nodes.NodeColors;
p.EdgeCData = g.Edges.EdgeColors;
colorbar

Sign in to comment.

More Answers (1)

madhan ravi
madhan ravi on 24 Dec 2018
Easy way create a handle to the graph and just use dot indexing and assign the color for instance red , green .. blabla

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Products

Tags

Community Treasure Hunt

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

Start Hunting!