How can I make the weighted edges more distinct?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Deborah H.
el 20 de Mzo. de 2017
Respondida: Afiq Azaibi
el 24 de Mzo. de 2017
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
0 comentarios
Respuesta aceptada
Afiq Azaibi
el 24 de Mzo. de 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
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Graph and Network Algorithms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!