function tri = trigon(H9)

# Usage: tri = trigon(H9)
# find the triangles in plane graph H9

[i,j,v]= find(H9);
# Inzidenzmatrix aus Adjazenz berechnen
trii = sparse(1:sum(i<j),i(i<j),1,sum(sum(i<j)),size(H9)(1));
trii += sparse(1:sum(i<j),j(i<j),1,sum(sum(i<j)),size(H9)(1));
# H9 == trii'*trii -diag(diag(trii'*trii))
tri0 = trii*trii' -diag(diag(trii*trii'));
[i,j] = find((tri0*trii)==2);
# j (i==220) ergibt die beiden Dreiecke zu find(trii(220,:))
[k,l]=find(trii);
[y1,i1,j1] =unique(k,"first");
[y2,i2,j2] =unique(k,"last");
# [l(i1),l(i2)]
# [j,l(i1)(i),l(i2)(i)](i==220,:)
tri = unique(sort([j,l(i1)(i),l(i2)(i)]')',"rows");
# all(sortrows(sort(tri)')==tmp)
endfunction
