% given a list of triangles, find the adjacency matrix

function M=find_adj_mat(tri)

N=size(tri,1); % number of triangles
M=sparse(N,N);
for k=1:N-1
for j=k+1:N
if length(intersect(tri(k,:),tri(j,:)))==2
M(k,j)=1;
M(j,k)=1;
end % if
end % for j
end % for k

return