# Topology nodes: get nearest vertex based on vertex group

I have this setup. Selected vertices are in Vertex group. I want to align vertices in the group by 2 connected points, not in the group. These in the middle works well:

But as you see, 2 side points work wrong. Why is that? Here is the node setup:

• Sorry for undeleting your post. Markus started typing an answer before you deleted and asked me to restore it so his answer would not go to waste. If you still want it removed regardless, feel free to delete again. Commented Jul 10 at 11:02

Evaluation from left to right:

- v3
- v1
- v2
- v15


First problem: there's exactly two edges with weight 0.5 connected to selected vertices. Picking two first edges by weight will pick those edges reliably, but their order may alternate - so if you want to use a factor different than 0.5 in mixing between the two directions, you might get alternating directions! Let's confirm you pick correct two edges:

Confirmed. Evaluation from left to right:

- v3 → e5 (up!)
↳ → e6 (down!)
- v1 → e0 (down)
↳ → e1 (up)
- v2 → e4 (down)
↳ → e9 (up)
- v15 → e22 (down)
↳ → e23 (up)


Alternation problem also confirmed.

Now what I would do is use "Edge Vertices" node from here, but first let's see how your corner logic works:

Corners simply copy attribute from their vertex. However now here's the probably cause of your problem:

## Docs: Corners of Edge node

The Corners of Edge node retrieves face corners connected to each edge in a mesh. The node first gathers a list of face corners which are connected to the edges. It’s important to note that the list only has one corner per face.

• Red: selected edge
• Blue: corners that get individually returned, depending on the sorting
• Purple: corners that can be retrieved by offsetting the blue corner indices using Offset Corner in Face Node

Whoops!

If you only have one corner to pick, then your weight logic is probably wrong...

Evaluation from left to right:

- v3 → e5 (up!)    → c15
↳ → e6 (down!)  → c11
- v1 → e0 (down)   → c9
↳ → e1 (up)     → c7
- v2 → e4 (down)   → c1
↳ → e9 (up)     → c40
- v15 → e22 (down) → c38
↳ → e23 (up)    → c42


Since I'm screenshotting it all from the above (where normals point), the winding is counter-clockwise:

So hopefully you can see below which corners are available to the edges directly:

[I got the colors wrong above, too much green, blue should be shifted 1 to the left, and the rightmost edges should have another color, not blue]

You deleted the post, so I'm pausing here, perhaps you got to the same conclusions before I wrote this answer. If you want I can suggest a fix.

Thanks for answer Markus, I deleted this question because I found the answer in the other one: https://blender.stackexchange.com/questions/321393/why-corners-of-edge-returns-2-elements-in-manifold-geometry (deleted it because the answer duplicates this question)

So as a solution for this, I end up making my own Vertex of Edge node (that takes in mind that Corners of edge have only one corner per face, that you pointed in answer):

Which can be used like this: