Network visualization distance between nodes

3 次查看(过去 30 天)
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 个)

Steven Lord
Steven Lord 2019-8-14
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 个评论
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?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by