Bmesh module add edge if doesn't exist

Hi,

Is there a way to test if edge already exists between two verts.
Something like:

for all verts in my beautiful bmesh object:
....if there is an edge between vi and vi+1 :
....     pass 
.... else:
....     add a new edge between vi and vi+1

thank you !

you should just be able to compare the edge indices of v1.edges and v2.edges. if they have entirely unique edges (the two verts are not connected by an edge), there’s already an edge between them.

Hi

something like this ?

    bm = bmesh.new()
    bm.from_mesh(bm_obj.data)
    bm.verts.ensure_lookup_table()
    bm.edges.ensure_lookup_table()
    vertices = [vertex for vertex in bm.verts]
    for i in range(len(vertices)-1):
        if not(set(vertices[i].link_edges) & set(vertices[i+1].link_edges)) :
            bm.edges.new((bm.verts[i],bm.verts[i+1]))

what do you think ?

PS: freely inspired from here

thank you