Currently depsgraph code assumes that any dependency cycle is an
error, and it is reasonable to provide no behavior guarantees.
However, in the case of physics collision, cycles are actually
supported in a limited way by the underlying system via using
the saved collision data from the previous frame. It is also
reasonable for the user to want multiple cloth objects to collide
with one another, and it worked that way safely in 2.79.
In order to allow using this behavior, dependency graph should
know which relations are collisions, and prefer deleting them if
possible when a cycle is detected; it should also avoid excessive
This adds a new relation flag that marks collision relations.
When resolving a cycle, collision relations going backward in
the alphabetic order of object names are chosen as primary
candidates for removal; this predictably resolves all cycles
between multiple objects all colliding with each other.
The depth first search cycle detection algorithm had to be
enchanced to unwind the stack to the relation being removed;
otherwise it cannot correctly detect all cycles. This would
already been a problem with the godmode flag, but it's not
that obvious there, as that flag is rare.