# Currect definition of edge loop

According to wikipedia https://en.wikipedia.org/wiki/Edge_loop an edge loop is:

In a stricter sense, an edge loop is defined as a set of edges where the loop follows the middle edge in every 'four way junction'.

and

The loop will end when it encounters another type of junction (three or five way for example).

In the image below we can see that the loop follows the perimeter of the n-gon and do not follows the middle edge in the four way junction. moreover in the image below we have a three way junction in which the loop doesn't stop, as wiki says. And ,not less important, we can see how blender choose arbitrarily the followed n-gon. So does a strict definition of edge loop (in terms of algorithm) exist somewhere?

thank you

I assume you're talking about what gets selected when you use AltLMB. I think it would be safe to say that the Wikipedia definition of edge loops is correct, and even though AltLMB is the "Loop Select" shortcut, it doesn't always technically select an edge loop. It selects an edge loop if one unambiguously exists, but otherwise, it tries to select something "reasonable".

I'm not aware of any precise documentation of the algorithm used by AltLMB. The code is in blender/source/blender/bmesh/intern/bmesh_walkers_impl.c, and it's complicated by lots of special cases. As far as I can see, it works as follows.

First a few definitions:

• An n-gon is a face with 5 or more edges and so excludes tris (3 edges) and quads (4 edges)
• A k-way junction is a vertex with "k" edges, so there are 3-way, 4-way, 5-way junctions, etc.
• Edges connected to certain counts of faces have special names:
• A wire edge connects to zero faces
• A boundary edge connects to exactly one face
• A manifold edge connects to exactly two faces

With these definitions, the type of selection depends on the initial edge selected by AltLMB:

• Hub selection: If the initial edge is a manifold edge, the connected face with the most edges is considered (if there's a tie, the face chosen is arbitrarily). If this face is an n-gon, then "hub selection" is performed -- edges around that face are selected by following a sequence of 3-way junctions around the face stopping at any boundary edges. This selection type is designed specifically to select the n-gon ends of cylinders and similar shapes, and I think it's also the special case you're seeing in your examples.
• Wire edge select: If it's a wire edge, all connected wire edges are selected.
• n-gon Boundary selection: If it is a boundary edge of an n-gon then neighboring boundary edges are followed along 2-way junctions, stopping at the first non-boundary edge or >2-way junction.
• Quad and tri boundary selection: If it is a boundary edge of a quad or tri, then connecting boundary edges that are also boundary edges of quads or tris are followed through 3-or-more-way junctions. The selection stops at 2-way junctions (i.e., "corners").
• Normal loop selection: Otherwise, if it is a non-wire, non-boundary edge that does not meet the requirements for hub selection, a path of neighboring manifold edges is selected through 2-way and 4-way junctions (with the usual rule for 4-way junctions of choosing the "middle" edge), stopping at the first 3-way or 5-or-more-way junction or non-manifold edge.

I think that's mostly right, though I've probably misread a few weird cases in the code.

One other complication. When AltLMB is applied to a boundary edge, it actually toggles between two selections -- "edge loop" selection, as described above, and edge boundary selection, which is simpler and just selects all the connected boundary edges.