separates graph into proper groups when elements are deleted