Skip to content

Instantly share code, notes, and snippets.

@wanirepo
Last active August 29, 2015 14:07
Show Gist options
  • Save wanirepo/9350f5e35f0d284efb66 to your computer and use it in GitHub Desktop.
Save wanirepo/9350f5e35f0d284efb66 to your computer and use it in GitHub Desktop.
matlab function to build a adjacency matrix from a xy list
function A = build_adjacency_from_list(ij)
% function A = build_adjacency_from_list(ij)
%
% ij: row, column
A = zeros(max(max(ij)),max(max(ij)));
for i = 1:length(ij)
A(ij(i,1), ij(i,2)) = 1;
end
if ~issymmetric(A)
A = A + A';
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment