Extracting data from a graph(directed graph.)

5 visualizaciones (últimos 30 días)
Anurag Gupta
Anurag Gupta el 1 de Feb. de 2021
Respondida: Steven Lord el 1 de Feb. de 2021
Hi Everyone,
I have a digraph(directed graph) plotted and I want to extract the data of the nodes from it.
It would be great if anyone can help me with it. I tried get function but it always returns an empty matrix.
Any help is highly appreciated.
Regards,
Anurag Gupta

Respuestas (1)

Steven Lord
Steven Lord el 1 de Feb. de 2021
What "data of the nodes" do you want to retrieve? Do you want the coordinates of the plotted points?
B = graph(bucky);
h = plot(B);
X = h.XData;
Y = h.YData;
fprintf("Node 1 is located at (%f, %f)\n", X(1), Y(1))
Node 1 is located at (0.103347, -1.803899)
% Turn on the axes ticks so you can check the coordinates
ax = ancestor(h, 'axes');
ax.XTickMode = 'auto';
ax.YTickMode = 'auto';
xticks(-5:5)
% Draw lines -- X marks the spot
xline(X(1), 'r')
yline(Y(1), 'r')

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by