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

26 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Mike Garrity
Mike Garrity el 11 de Abr. de 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)

Más respuestas (0)

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!

Translated by