implemented calcAdjacencies