Just a little example of BMesh API: find the linked vertices, of the selected vertice:
import bpy, bmesh
bpy.ops.object.mode_set(mode='EDIT')
obj = bpy.context.object
mesh = obj.data
bm = bmesh.from_mesh(mesh)
print("Start")
# Found the linked vertices of selected vertices
for i_0, v_0 in enumerate(bm.verts):
if v_0.select and v_0.is_valid:
print("Vertice Index: ", v_0.index)
for i_1, e_0 in enumerate(v_0.link_edges):
print(" Linked verticess:", e_0.other_vert(v_0).index)
You must start the script with vertice/s alredy selected.
If you want select a vertice from the script, add (for example) the following row, before the loop:
bm.verts[2].select=True #Select the vertice with index=2