Obtaining adjacency matrix from vertex connection information

3 ビュー (過去 30 日間)
Hayden
Hayden 2012 年 10 月 6 日
I am given a list of XYZ vertices (mx3 matrix) and a list of vertex connections (nx2 matrix, X and Y are a pairing of connected vertices.) I ultimately need to be able to plot a projection on the X-Y plane from this information, and while I've found a way on this site to do this using gplot and the adjacency matrix, I can't find anything on how to use MATLAB to take the list of vertex connections and convert it to an adjacency matrix. Obviously this can be achieved manually, and I've done so for a small cube to ensure the rest of the program works, but it needs to be done automatically for any lists that could be loaded.
I have absolutely no idea where to start, and would appreciate some guidance.

採用された回答

Walter Roberson
Walter Roberson 2012 年 10 月 6 日
adjmatrix = zeros(m,m);
for K = 1 : n
p1 = vertices(K,1);
p2 = vertices(K,2);
adjmatrix(p1,p2) = 1;
adjmatrix(p2,p1) = 1;
end
  1 件のコメント
Hayden
Hayden 2012 年 10 月 6 日
Once an understanding of the code was achieved it worked perfectly. Likely something I should have been able to arrive at myself with more familiarity in Matlab, but I clearly was not there.
Thank you sincerely.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by