matlab - Calculating the degree matrix having the sparse representation of the adjacency matrix -



matlab - Calculating the degree matrix having the sparse representation of the adjacency matrix -

i trying calculate laplacian matrix of graph. ve calculated sparse representation of adjacency matrix stored in text file dimension nx3. n size of nodes (ith-node jth node weight). open in matlab file adj = spconvert(adj);. next step calculate grade matrix of sparse matrix in order perform operation l = d - adj. how possible calculate grade matrix having input sparse adjacency matrix of graph? in order calculate grade matrix calculate grade every node:

for i=1:n % size of node degree(i) = length(find(adj(:,1) == & adj(:,3) == 1)); end

however, how can perform subtraction of d , a?

use spdiags function convert grade vector sparse diagonal matrix. subtract adjacency matrix diagonal matrix laplacian. illustration using code:

adj = spconvert(adj); i=1:size(adj, 1) degree(i) = calcdegree(adj, i) end d = spdiags(degree, 0, size(adj, 1), size(adj, 2)); l = d - adj;

by way, code calculating node grade may incorrect.

matlab sparse-matrix adjacency-matrix

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -