How to remove an edge from a half edge structure?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Removing an edge from a half-edge structure is not just a delete operation. It changes topology, so the real task is to relink neighboring half-edges, update face and vertex references, and decide exactly what "remove" means in your mesh editing model.
First decide what removal means
In a half-edge mesh, "remove an edge" can mean several different things:
- delete an interior edge and merge two adjacent faces
- collapse an edge and merge its two vertices
- remove a boundary edge from an open mesh
Those are different operations. The simplest case to explain is removing an interior edge that separates two faces and merging those faces into one.
The half-edge objects involved
For one edge, you usually have two half-edges:
- '
he' - '
he.twin'
Each half-edge also has:
- '
next' - '
prev' - '
vertex' - '
face'
Removing the edge means bypassing both half-edges in their face loops and then fixing any face or vertex references that still point to them.
A merge-faces style removal
Here is pseudocode for the topological part of removing an interior edge:
That reconnects the surrounding cycle so the two half-edges are no longer part of the boundary traversal.
Updating face references
Once the loops are reconnected, you usually keep one face and discard the other. Every half-edge that used to belong to the discarded face must now point to the surviving face:
Then call:
If either face object stored a representative half-edge that is about to be deleted, update that pointer too.
Updating vertex references
Vertices often store one outgoing half-edge as an entry point into local traversal. If a vertex points at he or twin, redirect it to another valid outgoing half-edge nearby.
This step is easy to forget, but it matters. Without it, the mesh may still look fine until later code asks a vertex for one of its incident half-edges and receives a deleted reference.
Validity checks matter
Not every edge should be removed blindly. Before removing one, check conditions such as:
- the edge is not on the boundary if your code assumes two faces
- removing it will not create a non-manifold configuration
- the surrounding faces are compatible with your mesh rules
Topology code fails less often in the removal step itself than in the assumptions made before it.
Common Pitfalls
- Treating edge removal like a simple delete instead of a topological update.
- Forgetting that
heandhe.twinmust both be removed consistently. - Updating
nextandprevpointers but forgetting face or vertex representative references. - Applying an interior-edge algorithm to a boundary edge or non-manifold case.
Summary
- In a half-edge mesh, removing an edge means relinking topology, not just deleting two objects.
- You must decide whether the operation is edge deletion, face merge, or edge collapse.
- For an interior face-merge removal, bypass both half-edges and reassign the surviving face references.
- Always update vertex and face representatives so later traversals remain valid.

