def _triangle_neighbors(tris, npts):
 verts = tris.ravel()
 counts = np.bincount(verts, minlength=npts)
 reord = np.argsort(verts)
 tri_idx = np.unravel_index(reord, (len(tris), 3))[0]
 idx = np.cumsum(np.r_[(0, counts)])
 neighbor_tri = [np.sort(tri_idx[v1:v2]) for (v1, v2) in zip(idx[:(-1)], idx[1:])]
 return neighbor_tri

def _triangle_neighbors ( tris , npts ) : verts = tris . ravel ( ) counts = np . bincount ( verts , minlength = npts ) reord = np . argsort ( verts ) tri_idx = np . unravel_index ( reord , ( len ( tris ) , 3 ) ) [ 0 ] idx = np . cumsum ( np . r_ [ ( 0 , counts ) ] ) neighbor_tri = [ np . sort ( tri_idx [ v1 : v2 ] ) for ( v1 , v2 ) in zip ( idx [ : ( - 1 ) ] , idx [ 1 : ] ) ] return neighbor_tri
efficiently compute vertex neighboring triangles .