フィルターのクリア

How to remove the unconnected nodes from an adjacency matrix?

1 回表示 (過去 30 日間)
chocho
chocho 2017 年 6 月 18 日
編集済み: chocho 2017 年 6 月 18 日
Dear all,
I have an adjacency matrix(n*n) of 1's and 0's extracted from an unweighted and undirected graph, my goal is to remove all-zeros columns from this matrix and their corresponding rows which are not connected to any node from the graph (all-zeros columns).
I want to apply one algorithm by using this adjacency matrix but sadly NaN produces because of some columns in this matrix are all 0's
fid= fopen('file.txt','rt');
format = repmat('%q',[1 2]);
filee= textscan(fid,format,'Delimiter', '\t');
fclose(fid);
AA2= [filee{:, 1} , filee{:, 2}];
[nodenames, ~, id] = unique(AA2(:));
Adjacency_Matrix= accumarray(reshape(id, size(AA2)), 1, [numel(nodenames), numel(nodenames)]);
Adjoint2 = sum(Adjacency_Matrix~=0,1);

回答 (0 件)

カテゴリ

Help Center および File ExchangeUndirected Graphs についてさらに検索

Community Treasure Hunt

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

Start Hunting!