Network visualization distance between nodes

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 Kommentar

Seven Eden
Seven Eden am 14 Aug. 2019
Hi Felipe, did you found the answer? I'm struggling with the same.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Steven Lord
Steven Lord am 14 Aug. 2019

0 Stimmen

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 Kommentare

Seven Eden
Seven Eden am 15 Aug. 2019
Thanks!
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?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graph and Network Algorithms finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by