gets neighbors in array indeces, checks for edges