Is there a method to create a graph using adjacency matrix and plot the graph using custom coordinates.

36 vues (au cours des 30 derniers jours)
Hello All, There is an example where we can create a network using graph(s,t,weights) and plotting it by using plot (G,'XData',x_coordinate,'YData',y_coordinate). Has anyone tried creating a graph using a sparse adjacency matrix graph(A,omitselfloops) and then plotting it using plot (G,'XData',x_coordinate,'YData',y_coordinate). Thanks in advance

Réponse acceptée

Mike Garrity
Mike Garrity le 11 Avr 2016
The answer I gave to this MATLAB Answers question does that. In that case, I set the XData & YData after the call to plot. But you could easily rewrite it to work the way you suggested:
% Make a random MxN adjacency matrix
m = 3
n = 5
a = rand(m,n)>.25;
% Expand out to symmetric (M+N)x(M+N) matrix
big_a = [zeros(m,m), a;
a', zeros(n,n)];
g = graph(big_a);
xdata = [ones(1,m), 2+zeros(1,n)];
ydata = [linspace(0,1,m), linspace(0,1,n)];
plot(g,'XData',xdata,'YData',ydata)

Plus de réponses (0)

Catégories

En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by