Is there a method to create a graph using adjacency matrix and plot the graph using custom coordinates.
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mariya B
am 11 Apr. 2016
Kommentiert: Mariya B
am 11 Apr. 2016
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
0 Kommentare
Akzeptierte Antwort
Mike Garrity
am 11 Apr. 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)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!