Helping method to detect the least number of vertices needed to be
selected at beginning.