# How to find a mesh loops and rings

I'm trying to find a clear, safe, simple explanation to the ring and loop madness. I select an edge:

Then I run this script:

import bpy
import bmesh

# Walk rings from currently selected edges.
# Run this in edit mode!

def find_edge_loops(loop,max_loops=1000):
i=0
first_loop=loop
while i<max_loops:
# Jump to adjacent face and walk two edges forward
loop.edge.select = True
i += 1
# If radial loop links back here, we're boundary, thus done
if loop == first_loop:
break

bm = bmesh.from_edit_mesh(bpy.context.object.data)
selected_edges = [ e for e in bm.edges if e.select ]

for edge in selected_edges:
# Get rings from "forward" loop
# Get rings from "backward" loop

bm.select_flush_mode()
bpy.context.object.data.update()

(It's equivalent to select edge loops in select menu) And I get, correctly:

Then, again, I select the starting edge, and I run this other script:

import bpy
import bmesh

# Walk rings from currently selected edges.
# Run this in edit mode!

def find_edge_rings(loop,max_loops=1000):
i=0
first_loop=loop
while i<max_loops:
# Jump to adjacent face and walk two edges forward
loop.edge.select = True
i += 1
# If radial loop links back here, we're boundary, thus done
if loop == first_loop:
break

bm = bmesh.from_edit_mesh(bpy.context.object.data)
selected_edges = [ e for e in bm.edges if e.select ]

for edge in selected_edges:
# Get rings from "forward" loop
# Get rings from "backward" loop

bm.select_flush_mode()
bpy.context.object.data.update()

(It's equivalent to select edge rings in select menu) and I get:

I summarized those scripts from sources here and there, and I see they work. But, for the life of me, I can't understand the precise relation which stems from:

Can someone clarify the way loops and rings are traversed, possibly with a picture? The api is obscure, I didn't find any official code examples, and I'd like to have a much clearer idea of what's suggested in the vague bmesh design documents