Convert from full to sparse matrices

I have a graph adjacency weight matrix. I want to name the bellman ford algorithm for matlabbgl libaray. How to convert a matrix to a sparse format?

+3
source share
1 answer

Convert Full to Sparse

You can convert a full matrix to a sparse storage using a sparse function with a single argument.

S = sparse(A)

for instance

A = [ 0   0   0   5
      0   2   0   0
      1   3   0   0
      0   0   4   0];
S = sparse(A)

produces

S =

   (3,1)        1
   (2,2)        2
   (3,2)        3
   (4,3)        4
   (1,4)        5

S . , . , , . , A = full (S) . - . , , .

+3

All Articles