# Geometry nodes, how to select the top edges of faces

how to select the top edges of faces, using Geometry nodes?

I tried using this post, but I couldn't get result. Delete edges on the top of geometry in geometry nodes

First, let's define what is a "top edge"...

### Edge, which position is the highest

Here's one way to implement it, and you can see this is not the same result as in your screenshot:

### Edge, which highest vertex is the highest

Here we have a problem, because edges share the highest vertex and so the following result is correct based on the definition in the header:

The vertical edges are picked, because they happen to be first in the "Less Than" comparison. Since their highest vertex position is the same as the actual edge we wanted to pick, it's $$z$$ isn't Less Than the same vertex of the other edge compared, and so this first edge position is picked in the switch.

So what are we missing here... We have a tie, two edges of a face are ex æquo winners in the highest $$z$$ discipline. We need a different tie-breaker than just quasi-random edge ordering… How about edge position (the position of the center of the edge)?

### First Edge sorted by two criteria: 1st: highest vertex; 2nd: highest center

Let's add an additional check: if the top vertices $$z$$ are equal, use edge $$z$$ instead:

I think this setup could be simpler working with the insight that it's all about the highest vertex… But I didn't take the time to simplify it, because…

So, what happened here…? See, a very, very short almost vertical edge, will have its center above a very very long almost horizontal edge:

The definition of the problem is still incorrect! How about we take the direction from this top vertex to the other vertex of the edge, normalize the direction, move there and use that position's $$z$$ as sorting Weight?

### Edge, for which, the position obtained by moving 1 meter from its higher vertex towards (and potentially through and past) the lower vertex, is the highest

Why 1 meter? Because that's the default for normalization. If it's too much, and has to be adjusted, then it's a problem because it become arbitrary, subjective…

It seems it works!

Keep in mind I assumed the edge of interest is still an edge with the highest vertex of the face, which could be a wrong assumption for some weird ngons:

But for your purposes it's probably fine...