Added boundary check for quadratic edges.