Filter löschen
Filter löschen

how to obtain adjacency matrix?

1 Ansicht (letzte 30 Tage)
muhammad ismat
muhammad ismat am 7 Apr. 2018
Kommentiert: muhammad ismat am 7 Apr. 2018
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 7 Apr. 2018
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 Kommentar
muhammad ismat
muhammad ismat am 7 Apr. 2018
Thank you very much Walter Roberson for your advance

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by