Created function neighborIndex2offset(3)