Improved performance of hasEdge method.