## Drawing a directed graph

### Deepa Maheshvare (view profile)

on 12 Dec 2018
Latest activity Answered by Steven Lord

### Steven Lord (view profile)

on 12 Dec 2018
I have the following graph,
function Digraph()
Edges = [1 2;2 3;3 4; 3 5;4 5;4 6;5 6;6 7]
t= Edges(:,1)
h = Edges(:,2)
G = graph(t,h)
NNodes = height(G.Nodes);
NNode = string(1:NNodes)';
G.Nodes.Name = cellstr(NNode);
values = 100*rand(7,1);
G.Nodes.Values = values;
tValues = values(t);
hValues = values(h);
Diff =(tValues-hValues);
G.Edges.Weight = Diff;
plot(G,'EdgeLabel',G.Edges.Weight)
end
Values are assigned to the nodes.The edge weights are assigned based on the difference in values between two nodes.I wish to draw the direction of flow from node 1 to node 7.
For instance, edge weight of the edge connecting node 1 to node 2 is positive so I wish to draw the arrowhead pointing towards 2.Edge weight of the edge connecting
node 3 to 5 is negative,so I want the arrowhead to point towards 3.
I'd like to ask for suggestions on how this can be done.