Borrar filtros
Borrar filtros

how to obtain adjacency matrix?

1 visualización (últimos 30 días)
muhammad ismat
muhammad ismat el 7 de Abr. de 2018
Comentada: muhammad ismat el 7 de Abr. de 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

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Abr. de 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 comentario
muhammad ismat
muhammad ismat el 7 de Abr. de 2018
Thank you very much Walter Roberson for your advance

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical 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