|
Thanks for the response Pekka;
Actually I want to delete any rows that share entries. For example, if the original array is this:
1 2
3 2
3 4
6 1
5 6
8 3
7 6
7 8
One of the answers is:
1 2
3 4
5 6
7 8
(That they are consecutive numbers is a coincidence)
Or:
6 1
3 4
7 8
In terms of graphs, I want to disconnect all edges by deleting some of them. What I'm using this for is to break a delaunay triangulation into nonoverlapping quadrilaterals. The example I'm using is a square broken down into 4 equal parts with a diagonal ( / ) in each. If I name the triangles like this:
5 6 7 8
1 2 3 4
The original array is a list of triangles that share an edge. Then triangle pairs 1 2 and
3 2 share a triangle, so the quadrilaterals formed by them overlap.
I took a closer look at my original code and I think it works for all cases. This might also help with the explanation:
for n = 1:size(adjtri,1)
holder = ismember(adjtri,n);
if sum(holder(:,1) + holder(:,2)) > 1
delete = max((holder(:,1) + holder(:,2)).*(1:size(adjtri,1))');
adjtri(delete,:) = [];
end
Do you have a way to do this or vectorize the above code?
Thanks.
Alex.
|