How can I make the weighted edges more distinct?

1 view (last 30 days)
I am trying to create a graph from an adjacency matrix with weighted edges. Right now the weighted values are between -.7 and .7. Is this too small?
This is the code I am using: G = graph(A,'lower'); PlotOfG = plot(G); layout (PlotOfG,'circle')
This is the plot that is generated:
It looks really cool but isn't useful like this. Please help! -Deborah

Accepted Answer

Afiq Azaibi
Afiq Azaibi on 24 Mar 2017
While you are right that is a cool looking graph it appears to be extremely dense which is why it is hard to read any of the values. The fact that it is hard to read is independent of the edge weights. Try running the following code:
s = [1 1 1 2 2 3 3 4 5 5 6 7];
t = [2 4 8 3 7 4 6 5 6 8 7 8];
weights = [0 1000 1 1 1 -1000 1 1 2 1 1 1];
names = {'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H'};
G = graph(s,t,weights,names);
plot(G,'EdgeLabel',G.Edges.Weight,'layout', 'circle')
You will generate a graph like the following:
Notice how the edge weights of 1000 and -1000 do not affect the visibility of the edges relative to the much lower weights of 1 and 2.
To see your issue on a slightly smaller scale, I have generated a similar graph with the following code (without edge weights) with 26 points.
A = ceil(rand(26));
preName= 'abcdefghijklmnopqrstuvwxyz';
names = cell(1,length(preName));
for i = 1:length(preName)
names{i} = preName(i);
end
G = graph(A,names,'upper','OmitSelfLoops');
p = plot(G, 'layout', 'circle');
This will generate the following graph:
You can see that this graph with almost half the points is still hard to read. Due to the density of the data, it will be difficult to clearly show edge weights as well as the connection between all 47 points. Leaving it in adjacency matrix form may be the best way to extract the most details but there are a number of other ways in which you can graphically represent the data. You can refer to the following for more ideas:
https://www.mathworks.com/help/matlab/math/graph-plotting-and-customization.html

More Answers (0)

Community Treasure Hunt

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

Start Hunting!