Added sanity check for zero vertices.