How to calculate adjacency matrix ?

조회 수: 20 (최근 30일)
muhammad ismat
muhammad ismat 2018년 3월 23일
답변: Walter Roberson 2018년 3월 24일
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
Guillaume
Guillaume 2018년 3월 23일
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 2018년 3월 24일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 3월 24일
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));

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by