Network visualization distance between nodes

4 views (last 30 days)
Hi, I am working on a network visualization project for my university. This important point here is to actually show when nodes are far or close to each other. I want the plot to show how far or how close a node is from each other given the weights. I created a random network just to figure out the commands, as follows:
s = [1 1 1 2 1 2 5];
t = [2 3 5 4 6 7 8];
weights = [1 2 5 20 3 5 1];
names = {'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H'};
G = graph(s,t,weights,names);
plot(G);
When I run this, no matter the numbers I put in the weights array, the image itself when I plot does not change. How can I manage to actually show in the plot that point A for example is closer to point B then from point F. The illustrative aspect is very very important.
Thank you! Felipe.
  1 Comment
Seven Eden
Seven Eden on 14 Aug 2019
Hi Felipe, did you found the answer? I'm struggling with the same.

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 14 Aug 2019
If you're using release R2018a or later, specify the 'WeightEffect' name-value pair when you plot or layout your graph or digraph plot. See the "Graph Layout Based on Edge Weight" example on the layout documentation page which shows how 'WeightEffect', 'direct' affects the graph layout.
  2 Comments
Esperanza Linares Guerrero
I tried it, but my nodes did not chage. Here is what I did:
A=[0,100,50;100,0,100;50,100,0]
node_names = {'A','B','C'};
G = graph(A,node_names);
p=plot(G,'Layout','force','EdgeLabel',G.Edges.Weight);
layout(p,'force','WeightEffect','direct')
Any idea why?

Sign in to comment.

Categories

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

Community Treasure Hunt

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

Start Hunting!