Simple graph

In this case, no I don't think so. Sets are unordered, so you don't know the order in which you'll get each element. If you were using a list (or an OrderedSet! http://code.activestate.com/recipes/576694/) you could do this by iterating backwards so that removing an element only affects the indices of elements through which you've already iterated.