Speed improvement by pre-computing adjacencies.