Borrar filtros
Borrar filtros

How to calculate adjacency matrix ?

10 visualizaciones (últimos 30 días)
muhammad ismat
muhammad ismat el 23 de Mzo. de 2018
Respondida: Walter Roberson el 24 de Mzo. de 2018
if i have data rearranged as follow
0 1 2 3
1 3 5 7
2 4 6 7
where this data mean that first element of first row connect with remaining element in first row and second element of second row connect with remaining element in second row so i want to calculate the adjacency matrix in the form
0 1 1 1 0 0 0 0
0 0 0 1 0 1 0 1
0 0 0 0 4 0 1 1
  2 comentarios
Guillaume
Guillaume el 23 de Mzo. de 2018
I do not understand first element of first row connect with remaining element in first row
An adjacency matrix is always square. So your output is not an adjacency matrix.
You need to give a much better explanation of what your input matrix represents and how to generate your not_an_adjacency_matrix output from it.
muhammad ismat
muhammad ismat el 24 de Mzo. de 2018
first row mean that user number 0 connect with user number 1, 2, 3 and there is a relation between user 1 and users 3, 5, 7 and so on. i want to obtain on adjacency matrix
0 1 1 1 0 0 0 0
1 0 0 1 0 1 0 1
1 0 0 0 1 0 1 1
1 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 1 1 0 0 0 0 0

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 24 de Mzo. de 2018
A = [0 1 2 3
1 3 5 7
2 4 6 7];
[r, c, s] = find(A);
adj = full(sparse(r,s+1,1));

Categorías

Más información sobre Matrices and Arrays 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