フィルターのクリア

how to obtain adjacency matrix?

1 回表示 (過去 30 日間)
muhammad ismat
muhammad ismat 2018 年 4 月 7 日
コメント済み: muhammad ismat 2018 年 4 月 7 日
if i have data
1 2 3 4
2 3 5 6
3 5 6 7
in first row the element 1 has a connection with elements 2,3,4. And so on in remaining rows, so i want the adjacency matrix as
0 1 1 1 0 0 0
1 0 1 0 1 1 0
1 1 0 0 1 1 1
1 0 0 0 0 0 0
0 1 1 0 0 0 0
0 1 1 0 0 0 0
0 0 1 0 0 0 0

採用された回答

Walter Roberson
Walter Roberson 2018 年 4 月 7 日
Same basic technique as in https://www.mathworks.com/matlabcentral/answers/390250-how-to-calculate-adjacency-matrix#answer_311752 which is waiting for a response from you.
A = [1 2 3 4
2 3 5 6
3 5 6 7];
[r, c, s] = find(A(:,2:end));
adj = full(sparse([r,s],[s,r],1));
  1 件のコメント
muhammad ismat
muhammad ismat 2018 年 4 月 7 日
Thank you very much Walter Roberson for your advance

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by