Look at vertices with minimum degree 0 first instead of starting with those with minimum degree 1 (fix courtesy of Roman Dementiev)