How can I Plot eigenvectors of a graph on the graph as bars coming out of vertices?
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Defne Odabasi
el 28 de Feb. de 2024
Comentada: Matt J
el 29 de Feb. de 2024
After finding the eigenvalue decomposition of Laplacian matrix, I found the Fourier basis and now I want to plot some of the basis vectors on the graph. How can I obtain the plot as follows:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1630861/image.png)
G = graph(weighted_adjacency);
LWidths = G.Edges.Weight/max(G.Edges.Weight);
figure;
plot(G,'XData',data(:,1),'YData' ,data(:,2),'LineWidth',LWidths);
xlabel('x');
ylabel('y');
title('Weighted Graph')
%Laplacian Matrix
%L = D - M
%Degree Matrix
degree_matrix = diag(sum(weighted_adjacency,2));
laplacian_matrix = degree_matrix - weighted_adjacency;
%Computing the eigenvalues and eigenvectors
[V, lambda] = eig(laplacian_matrix);
selected_u = [1 2 3 10 50];
fourier_basis_vectors = V(:, selected_u);
for i = 1:numel(selected_u)
basis_vector = fourier_basis_vectors(: ,i);
figure;
plot(G,'XData',data(:,1),'YData' ,data(:,2));
end
0 comentarios
Respuesta aceptada
William Rose
el 28 de Feb. de 2024
You can plot arrows representing a 2D eigenvectors, at specific locations, with quiver(X,Y,U,V), where X and Y represnt the locaiotns of the bases of the arrows, and U,V are the x- and y-lengths of the arrows. The lengths are automatically scalled to avoifd overlap. You can control the scaling, if you do not like the default.
If you attach weighted_adjacency, others may be able to run your code.
1 comentario
Matt J
el 29 de Feb. de 2024
You can also set ShowArrowHead=off to have just lines instead of arrows
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!