How to convert sparse matrix to adjacency matrix ?
2 views (last 30 days)
Show older comments
How do you convert sparse matrix to adjacency matrix in Matlab 2015?
2 Comments
the cyclist
on 10 Feb 2016
I don't understand completely. A sparse matrix could be an adjacency matrix.
Can you please give a small example or two of the input/output you expect?
Accepted Answer
the cyclist
on 11 Feb 2016
This submission on the MATLAB File Exchange says that it will convert a *.gml file to an adjacency matrix. Maybe it will work for you.
6 Comments
the cyclist
on 12 Feb 2016
In MATLAB, curly brackets -- {} -- are not equivalent to parentheses -- (). Curly brackets are used for a special type of MATLAB object: a cell array.
More Answers (1)
Walter Roberson
on 10 Feb 2016
adjacency_matrix = logical(TheSparseMatrix);
2 Comments
Walter Roberson
on 11 Feb 2016
s = size(adjacency_matrix);
if s(1) < s(2)
adjacency_matrix(s(2),s(2)) = 0;
elseif s(1) > s(2)
adjacency_matrix(s(1),s(1)) = 0;
end
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!